新增 夜间模式
This commit is contained in:
@@ -7,6 +7,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
@@ -26,6 +27,7 @@ import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.autojs.key.GlobalKeyObserver;
|
||||
import org.autojs.autojs.external.receiver.DynamicBroadcastReceivers;
|
||||
import org.autojs.autojs.network.GlideApp;
|
||||
import org.autojs.autojs.theme.ThemeColorManagerCompat;
|
||||
import org.autojs.autojs.timing.IntentTask;
|
||||
import org.autojs.autojs.timing.TimedTaskManager;
|
||||
import org.autojs.autojs.timing.TimedTaskScheduler;
|
||||
@@ -99,8 +101,7 @@ public class App extends MultiDexApplication {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
ThemeColorManager.setDefaultThemeColor(new ThemeColor(getResources().getColor(R.color.colorPrimary), getResources().getColor(R.color.colorPrimaryDark), getResources().getColor(R.color.colorAccent)));
|
||||
ThemeColorManager.init(this);
|
||||
ThemeColorManagerCompat.init(this, new ThemeColor(getResources().getColor(R.color.colorPrimary), getResources().getColor(R.color.colorPrimaryDark), getResources().getColor(R.color.colorAccent)));
|
||||
AutoJs.initInstance(this);
|
||||
if (Pref.isRunningVolumeControlEnabled()) {
|
||||
GlobalKeyObserver.init();
|
||||
|
||||
@@ -7,8 +7,10 @@ import android.preference.PreferenceManager;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.runtime.accessibility.AccessibilityConfig;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
|
||||
import org.autojs.autojs.autojs.key.GlobalKeyObserver;
|
||||
import org.autojs.autojs.theme.ThemeColorManagerCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -55,6 +57,10 @@ public class Pref {
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isNightModeEnabled() {
|
||||
return def().getBoolean(getString(R.string.key_night_mode), false);
|
||||
}
|
||||
|
||||
public static boolean isFirstGoToAccessibilitySetting() {
|
||||
return getDisposableBoolean("isFirstGoToAccessibilitySetting", true);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
package org.autojs.autojs.theme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
|
||||
import org.autojs.autojs.*;
|
||||
import org.autojs.autojs.R;
|
||||
|
||||
import com.stardust.theme.ThemeColor;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
|
||||
/**
|
||||
@@ -11,6 +20,14 @@ import com.stardust.theme.ThemeColorManager;
|
||||
|
||||
public class ThemeColorManagerCompat {
|
||||
|
||||
private static SharedPreferences sSharedPreferences;
|
||||
private static Context sContext;
|
||||
private static SharedPreferences.OnSharedPreferenceChangeListener sPreferenceChangeListener = (sharedPreferences, key) -> {
|
||||
if (key.equals(sContext.getString(R.string.key_night_mode))) {
|
||||
setNightModeEnabled(sharedPreferences.getBoolean(key, false));
|
||||
}
|
||||
};
|
||||
|
||||
public static int getColorPrimary() {
|
||||
int color = ThemeColorManager.getColorPrimary();
|
||||
if (color == 0) {
|
||||
@@ -19,4 +36,29 @@ public class ThemeColorManagerCompat {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setNightModeEnabled(boolean enabled) {
|
||||
if (enabled) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
ThemeColor currentTheme = ThemeColor.fromPreferences(PreferenceManager.getDefaultSharedPreferences(sContext), null);
|
||||
if (currentTheme != null) {
|
||||
currentTheme.saveIn(sSharedPreferences);
|
||||
}
|
||||
ThemeColorManager.setThemeColor(ContextCompat.getColor(sContext, R.color.theme_color_black));
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
ThemeColor previousTheme = ThemeColor.fromPreferences(sSharedPreferences, null);
|
||||
if (previousTheme != null) {
|
||||
ThemeColorManager.setThemeColor(previousTheme.colorPrimary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context, ThemeColor defaultThemeColor) {
|
||||
sContext = context;
|
||||
sSharedPreferences = context.getSharedPreferences("theme_color", Context.MODE_PRIVATE);
|
||||
ThemeColorManager.setDefaultThemeColor(defaultThemeColor);
|
||||
ThemeColorManager.init(context);
|
||||
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(sPreferenceChangeListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package org.autojs.autojs.ui;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.network.VersionService;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.util.BackPressedHandler;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -30,14 +34,33 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
protected static final int PERMISSION_REQUEST_CODE = 11186;
|
||||
private boolean mShouldApplyDayNightModeForOptionsMenu = true;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
protected void applyDayNightMode() {
|
||||
GlobalAppContext.post(() -> {
|
||||
if (Pref.isNightModeEnabled()) {
|
||||
setNightModeEnabled(Pref.isNightModeEnabled());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setNightModeEnabled(boolean enabled) {
|
||||
if (enabled) {
|
||||
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
if (getDelegate().applyDayNight()) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
@@ -85,7 +108,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public static void setToolbarAsBack(final AppCompatActivity activity, int id, String title) {
|
||||
Toolbar toolbar = (Toolbar) activity.findViewById(id);
|
||||
Toolbar toolbar = activity.findViewById(id);
|
||||
toolbar.setTitle(title);
|
||||
activity.setSupportActionBar(toolbar);
|
||||
if (activity.getSupportActionBar() != null) {
|
||||
@@ -100,4 +123,24 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
if (mShouldApplyDayNightModeForOptionsMenu && Pref.isNightModeEnabled()) {
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
Drawable drawable = menu.getItem(i).getIcon();
|
||||
if (drawable != null) {
|
||||
drawable.mutate();
|
||||
drawable.setColorFilter(ContextCompat.getColor(this, R.color.toolbar), PorterDuff.Mode.SRC_ATOP);
|
||||
}
|
||||
}
|
||||
mShouldApplyDayNightModeForOptionsMenu = false;
|
||||
}
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.model.indices.AndroidClassIndices;
|
||||
import org.autojs.autojs.model.indices.ClassSearchingItem;
|
||||
import org.autojs.autojs.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import org.autojs.autojs.tool.MaterialDialogFactory;
|
||||
import org.autojs.autojs.ui.widget.AutoAdapter;
|
||||
import org.autojs.autojs.ui.widget.BindableViewHolder;
|
||||
import org.autojs.autojs.ui.widget.SimpleTextWatcher;
|
||||
|
||||
@@ -272,7 +272,7 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC
|
||||
|
||||
@AfterViews
|
||||
void init() {
|
||||
setTheme(Theme.getDefault(getContext()));
|
||||
//setTheme(Theme.getDefault(getContext()));
|
||||
setUpEditor();
|
||||
setUpInputMethodEnhancedBar();
|
||||
setUpFunctionsKeyboard();
|
||||
|
||||
@@ -85,7 +85,6 @@ public class CodeEditor extends HVScrollView {
|
||||
mCodeEditText.addTextChangedListener(new AutoIndent(mCodeEditText));
|
||||
mTextViewRedoUndo = new TextViewUndoRedo(mCodeEditText);
|
||||
mJavaScriptHighlighter = new JavaScriptHighlighter(mTheme, mCodeEditText);
|
||||
setTheme(Theme.getDefault(getContext()));
|
||||
mJsBeautifier = new JsBeautifier(this, "js/js-beautify");
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.subjects.PublishSubject;
|
||||
|
||||
@@ -25,6 +24,7 @@ public class Themes {
|
||||
|
||||
private static final String ASSETS_THEMES_PATH = "editor/theme";
|
||||
private static final String DEFAULT_THEME = "Quiet Light";
|
||||
private static final String DARK_THEME = "Dark (Visual Studio)";
|
||||
|
||||
private static List<Theme> sThemes;
|
||||
private static Theme sDefaultTheme;
|
||||
@@ -80,7 +80,7 @@ public class Themes {
|
||||
}
|
||||
|
||||
public static Observable<Theme> getCurrent(Context context) {
|
||||
String currentTheme = Pref.getCurrentTheme();
|
||||
String currentTheme = Pref.isNightModeEnabled() ? DARK_THEME : Pref.getCurrentTheme();
|
||||
if (currentTheme == null)
|
||||
return getDefault(context);
|
||||
return getAllThemes(context)
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.heinrichreimersoftware.androidissuereporter.model.github.GithubTarget
|
||||
import com.heinrichreimersoftware.androidissuereporter.util.ColorUtils;
|
||||
import com.heinrichreimersoftware.androidissuereporter.util.ThemeUtils;
|
||||
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
import org.eclipse.egit.github.core.Issue;
|
||||
import org.eclipse.egit.github.core.client.GitHubClient;
|
||||
import org.eclipse.egit.github.core.client.RequestException;
|
||||
@@ -64,7 +65,7 @@ import com.stardust.theme.ThemeColorManager;
|
||||
* Created by Stardust on 2017/4/3.
|
||||
*/
|
||||
|
||||
public abstract class AbstractIssueReporterActivity extends AppCompatActivity {
|
||||
public abstract class AbstractIssueReporterActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = AbstractIssueReporterActivity.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@@ -207,6 +208,7 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
}
|
||||
|
||||
private void init() {
|
||||
Log.d(LOG_TAG, "item bg = " + Integer.toHexString(ContextCompat.getColor(getContext(), R.color.item_background)));
|
||||
setOnRefreshListener(this);
|
||||
inflate(getContext(), R.layout.explorer_view, this);
|
||||
mExplorerItemListView = findViewById(R.id.explorer_item_list);
|
||||
@@ -437,7 +439,7 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
|
||||
@Override
|
||||
public BindableViewHolder<?> onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
return ExplorerView.this.onCreateViewHolder(inflater, parent, viewType);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.Theme;
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.Theme;
|
||||
import com.stardust.app.DialogUtils;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.enhancedfloaty.FloatyService;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.ui.codegeneration.CodeGenerateDialog;
|
||||
import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
import org.autojs.autojs.ui.widget.BubblePopupMenu;
|
||||
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
package org.autojs.autojs.ui.log;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.autojs.core.console.ConsoleView;
|
||||
import com.stardust.autojs.core.console.StardustConsole;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
|
||||
@EActivity(R.layout.activity_log)
|
||||
public class LogActivity extends BaseActivity {
|
||||
@@ -26,10 +23,16 @@ public class LogActivity extends BaseActivity {
|
||||
|
||||
private StardustConsole mStardustConsole;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
applyDayNightMode();
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
void setupViews() {
|
||||
setToolbarAsBack(getString(R.string.text_log));
|
||||
mStardustConsole = (StardustConsole) AutoJs.getInstance().getGlobalConsole();
|
||||
mStardustConsole = AutoJs.getInstance().getGlobalConsole();
|
||||
mConsoleView.setConsole(mStardustConsole);
|
||||
mConsoleView.findViewById(R.id.input_container).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
mVersionGuard = new VersionGuard(this);
|
||||
showAnnunciationIfNeeded();
|
||||
EventBus.getDefault().register(this);
|
||||
applyDayNightMode();
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.autojs.autojs.external.foreground.ForegroundService;
|
||||
import org.autojs.autojs.network.GlideApp;
|
||||
import org.autojs.autojs.network.UserService;
|
||||
import org.autojs.autojs.tool.Observers;
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
import org.autojs.autojs.ui.common.NotAskAgainDialog;
|
||||
import org.autojs.autojs.ui.floating.CircularMenu;
|
||||
import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||
@@ -146,7 +147,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
setChecked(mFloatingWindowItem, true);
|
||||
}
|
||||
setChecked(mConnectionItem, DevPluginService.getInstance().isConnected());
|
||||
if(Pref.isForegroundServiceEnabled()){
|
||||
if (Pref.isForegroundServiceEnabled()) {
|
||||
ForegroundService.start(GlobalAppContext.get());
|
||||
setChecked(mForegroundServiceItem, true);
|
||||
}
|
||||
@@ -167,6 +168,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
new DrawerMenuGroup(R.string.text_others),
|
||||
mConnectionItem,
|
||||
new DrawerMenuItem(R.drawable.ic_personalize, R.string.text_theme_color, this::openThemeColorSettings),
|
||||
new DrawerMenuItem(R.drawable.ic_night_mode, R.string.text_night_mode, R.string.key_night_mode, this::toggleNightMode),
|
||||
mCheckForUpdatesItem
|
||||
)));
|
||||
mDrawerMenu.setAdapter(mDrawerMenuAdapter);
|
||||
@@ -239,6 +241,10 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
SettingsActivity.selectThemeColor(getActivity());
|
||||
}
|
||||
|
||||
void toggleNightMode(DrawerMenuItemViewHolder holder) {
|
||||
((BaseActivity) getActivity()).setNightModeEnabled(holder.getSwitchCompat().isChecked());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void enableAccessibilityServiceByRootIfNeeded() {
|
||||
Observable.fromCallable(() -> Pref.shouldEnableAccessibilityServiceByRoot() && !isAccessibilityServiceEnabled())
|
||||
@@ -264,9 +270,9 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
|
||||
private void toggleForegroundService(DrawerMenuItemViewHolder holder) {
|
||||
boolean checked = holder.getSwitchCompat().isChecked();
|
||||
if(checked){
|
||||
if (checked) {
|
||||
ForegroundService.start(GlobalAppContext.get());
|
||||
}else {
|
||||
} else {
|
||||
ForegroundService.stop(GlobalAppContext.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.ThemeColorRecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -62,7 +63,7 @@ public class TaskListRecyclerView extends ThemeColorRecyclerView {
|
||||
private ScriptExecutionListener mScriptExecutionListener = new SimpleScriptExecutionListener() {
|
||||
@Override
|
||||
public void onStart(final ScriptExecution execution) {
|
||||
post(()-> mAdapter.notifyChildInserted(0, mRunningTaskGroup.addTask(execution)));
|
||||
post(() -> mAdapter.notifyChildInserted(0, mRunningTaskGroup.addTask(execution)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,8 +76,8 @@ public class TaskListRecyclerView extends ThemeColorRecyclerView {
|
||||
onFinish(execution);
|
||||
}
|
||||
|
||||
private void onFinish(ScriptExecution execution){
|
||||
post(()->{
|
||||
private void onFinish(ScriptExecution execution) {
|
||||
post(() -> {
|
||||
final int i = mRunningTaskGroup.removeTask(execution);
|
||||
if (i >= 0) {
|
||||
mAdapter.notifyChildRemoved(0, i);
|
||||
@@ -105,7 +106,7 @@ public class TaskListRecyclerView extends ThemeColorRecyclerView {
|
||||
private void init() {
|
||||
setLayoutManager(new WrapContentLinearLayoutManager(getContext()));
|
||||
addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext())
|
||||
.color(0xffEDEEEF)
|
||||
.color(ContextCompat.getColor(getContext(), R.color.divider))
|
||||
.size(2)
|
||||
.marginResId(R.dimen.script_and_folder_list_divider_left_margin, R.dimen.script_and_folder_list_divider_right_margin)
|
||||
.showLastDivider()
|
||||
|
||||
@@ -3,9 +3,9 @@ package org.autojs.autojs.ui.splash;
|
||||
import android.Manifest;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SplashActivity extends BaseActivity {
|
||||
public static final String FORCE_SHOW_AD = "forceShowAd";
|
||||
|
||||
private static final String LOG_TAG = SplashActivity.class.getSimpleName();
|
||||
private static final long INIT_TIMEOUT = 1000;
|
||||
private static final long INIT_TIMEOUT = 500;
|
||||
|
||||
|
||||
private boolean mCanEnterNextActivity = false;
|
||||
|
||||
@@ -66,9 +66,9 @@ public class EWebView extends FrameLayout implements SwipeRefreshLayout.OnRefres
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.ewebview, this);
|
||||
mWebView = (WebView) findViewById(R.id.web_view);
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
|
||||
mWebView = findViewById(R.id.web_view);
|
||||
mSwipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
|
||||
mProgressBar = findViewById(R.id.progress_bar);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
setUpWebView();
|
||||
}
|
||||
|
||||
@@ -6,13 +6,18 @@ import android.content.res.TypedArray;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.stardust.theme.ThemeColor;
|
||||
import com.stardust.theme.ThemeColorHelper;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.theme.ThemeColorMutable;
|
||||
|
||||
import org.autojs.autojs.R;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/8/6.
|
||||
*/
|
||||
|
||||
public class PrefSwitch extends SwitchCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class PrefSwitch extends SwitchCompat implements SharedPreferences.OnSharedPreferenceChangeListener, ThemeColorMutable {
|
||||
|
||||
private String mPrefKey;
|
||||
private SharedPreferences mSharedPreferences;
|
||||
@@ -47,6 +52,11 @@ public class PrefSwitch extends SwitchCompat implements SharedPreferences.OnShar
|
||||
setChecked(mDefaultChecked, false);
|
||||
}
|
||||
a.recycle();
|
||||
ThemeColorManager.add(this);
|
||||
}
|
||||
|
||||
public void setThemeColor(ThemeColor color) {
|
||||
ThemeColorHelper.setColorPrimary(this, color.colorPrimary);
|
||||
}
|
||||
|
||||
private void readInitialState() {
|
||||
@@ -99,6 +109,7 @@ public class PrefSwitch extends SwitchCompat implements SharedPreferences.OnShar
|
||||
if (visibility == VISIBLE) {
|
||||
readInitialState();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,11 @@ public class SwitchCompat extends android.support.v7.widget.SwitchCompat {
|
||||
|
||||
@Override
|
||||
public void setOnCheckedChangeListener(final OnCheckedChangeListener listener) {
|
||||
super.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (mIgnoreCheckedChange) {
|
||||
return;
|
||||
}
|
||||
listener.onCheckedChanged(buttonView, isChecked);
|
||||
super.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (mIgnoreCheckedChange) {
|
||||
return;
|
||||
}
|
||||
listener.onCheckedChanged(buttonView, isChecked);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -20,24 +21,31 @@ import org.autojs.autojs.R;
|
||||
|
||||
public class ToolbarMenuItem extends LinearLayout {
|
||||
|
||||
private static final int COLOR_DISABLED = 0X77e0e0e0;
|
||||
private final int mColorDisabled;
|
||||
private final int mColorEnabled;
|
||||
private ImageView mImageView;
|
||||
private TextView mTextView;
|
||||
private Drawable mEnabledDrawable, mDisabledDrawable;
|
||||
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mColorDisabled = ContextCompat.getColor(context, R.color.toolbar_disabled);
|
||||
mColorEnabled = ContextCompat.getColor(context, R.color.toolbar);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mColorDisabled = ContextCompat.getColor(context, R.color.toolbar_disabled);
|
||||
mColorEnabled = ContextCompat.getColor(context, R.color.toolbar);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
mColorDisabled = ContextCompat.getColor(context, R.color.toolbar_disabled);
|
||||
mColorEnabled = ContextCompat.getColor(context, R.color.toolbar);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
@@ -48,12 +56,13 @@ public class ToolbarMenuItem extends LinearLayout {
|
||||
int iconResId = a.getResourceId(R.styleable.ToolbarMenuItem_icon, 0);
|
||||
int iconColor = a.getColor(R.styleable.ToolbarMenuItem_icon_color, Color.TRANSPARENT);
|
||||
a.recycle();
|
||||
mImageView = (ImageView) findViewById(R.id.icon);
|
||||
mTextView = (TextView) findViewById(R.id.text);
|
||||
mImageView = findViewById(R.id.icon);
|
||||
mTextView = findViewById(R.id.text);
|
||||
mTextView.setText(text);
|
||||
mTextView.setTextColor(mColorEnabled);
|
||||
mImageView.setImageResource(iconResId);
|
||||
if (iconColor != Color.TRANSPARENT) {
|
||||
mImageView.setImageDrawable(convertDrawableToGrayScale(mImageView.getDrawable(), iconColor));
|
||||
mImageView.setImageDrawable(tintDrawable(mImageView.getDrawable(), iconColor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,12 +74,12 @@ public class ToolbarMenuItem extends LinearLayout {
|
||||
ensureEnabledDrawable();
|
||||
ensureDisabledDrawable();
|
||||
mImageView.setImageDrawable(enabled ? mEnabledDrawable : mDisabledDrawable);
|
||||
mTextView.setTextColor(enabled ? Color.WHITE : COLOR_DISABLED);
|
||||
mTextView.setTextColor(enabled ? mColorEnabled : mColorDisabled);
|
||||
}
|
||||
|
||||
private void ensureDisabledDrawable() {
|
||||
if (mDisabledDrawable == null) {
|
||||
mDisabledDrawable = convertDrawableToGrayScale(mEnabledDrawable, COLOR_DISABLED);
|
||||
mDisabledDrawable = tintDrawable(mEnabledDrawable, mColorDisabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +89,7 @@ public class ToolbarMenuItem extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable convertDrawableToGrayScale(Drawable drawable, int color) {
|
||||
public static Drawable tintDrawable(Drawable drawable, int color) {
|
||||
if (drawable == null || drawable.getConstantState() == null)
|
||||
return null;
|
||||
Drawable res = drawable.getConstantState().newDrawable().mutate();
|
||||
|
||||
Reference in New Issue
Block a user