调色架构1
This commit is contained in:
@@ -10,7 +10,7 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -30,35 +30,49 @@ public final class GlobalCrashActivity extends Activity implements MenuItem.OnMe
|
||||
private static final int MENUITEM_RESTART = 1;
|
||||
|
||||
String mLog;
|
||||
|
||||
int colorPrimary;
|
||||
int colorPrimaryDark;
|
||||
int colorAccent;
|
||||
int colorText;
|
||||
|
||||
public static final String TAG = "GlobalCrashActivity";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
CrashHandler.AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext());
|
||||
|
||||
|
||||
mLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_INFO);
|
||||
setTheme(android.R.style.Theme_DeviceDefault_NoActionBar);
|
||||
|
||||
//setTheme(android.R.style.Theme_Holo_Light_NoActionBar);
|
||||
setTheme(R.style.APPBaseTheme);
|
||||
setContentView(R.layout.activity_globalcrash);
|
||||
|
||||
TypedArray a = obtainStyledAttributes(R.attr.globalCrashActivity, R.styleable.GlobalCrashActivity);
|
||||
colorPrimary = a.getColor(R.styleable.GlobalCrashActivity_attrPrimary, Color.WHITE);
|
||||
colorPrimaryDark = a.getColor(R.styleable.GlobalCrashActivity_attrPrimaryDark, Color.BLACK);
|
||||
colorAccent = a.getColor(R.styleable.GlobalCrashActivity_attrAccent, Color.RED);
|
||||
colorText = a.getColor(R.styleable.GlobalCrashActivity_attrText, Color.RED);
|
||||
// 返回一个绑定资源结束的信号给资源
|
||||
a.recycle();
|
||||
|
||||
LinearLayout llMain = findViewById(R.id.activityglobalcrashLinearLayout1);
|
||||
llMain.setBackgroundColor(Color.GRAY);
|
||||
llMain.setBackgroundColor(colorPrimaryDark);
|
||||
Toolbar toolbar = findViewById(R.id.activityglobalcrashToolbar1);
|
||||
toolbar.setBackgroundColor(Color.BLACK);
|
||||
toolbar.setTitleTextColor(Color.WHITE);
|
||||
toolbar.setSubtitleTextColor(Color.WHITE);
|
||||
toolbar.setBackgroundColor(colorPrimary);
|
||||
toolbar.setTitleTextColor(colorAccent);
|
||||
toolbar.setSubtitleTextColor(colorAccent);
|
||||
setActionBar(toolbar);
|
||||
TextView tvLog = findViewById(R.id.activityglobalcrashTextView1);
|
||||
tvLog.setText(mLog);
|
||||
tvLog.setTextColor(Color.BLACK);
|
||||
tvLog.setBackgroundColor(Color.GRAY);
|
||||
tvLog.setTextColor(colorPrimary);
|
||||
tvLog.setBackgroundColor(colorPrimaryDark);
|
||||
|
||||
getActionBar().setTitle(CrashHandler.TITTLE);
|
||||
getActionBar().setSubtitle(GlobalApplication.getAppName(getApplicationContext()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
@@ -108,7 +122,7 @@ public final class GlobalCrashActivity extends Activity implements MenuItem.OnMe
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
MenuItem item = menu.getItem(i);
|
||||
SpannableString spanString = new SpannableString(item.getTitle().toString());
|
||||
spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0);
|
||||
spanString.setSpan(new ForegroundColorSpan(colorAccent), 0, spanString.length(), 0);
|
||||
item.setTitle(spanString);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user