+ Adjusted dark theme colors
+ Moved setting to an activity
+ Code format
+ Changed some icons
+ Minor fixes
This commit is contained in:
dvdandroid 2016-09-29 22:18:41 +02:00 committed by topjohnwu
parent 9eb108f13e
commit d788bd8323
26 changed files with 287 additions and 308 deletions

View File

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.topjohnwu.magisk"
@ -32,13 +32,11 @@ repositories {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.github.michalis-vitos:aFileChooser:master'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:support-v4:24.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.topjohnwu.magisk">
<manifest package="com.topjohnwu.magisk"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.kcoppock.broadcatsttilesupport" />
@ -24,6 +25,7 @@
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:exported="true"/>
<activity
android:name=".SplashActivity"
android:configChanges="orientation|screenSize"
@ -31,7 +33,6 @@
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -65,6 +66,9 @@
<activity
android:name=".AboutActivity"
android:theme="@style/AppTheme.Transparent"/>
<activity
android:name=".SettingsActivity"
android:theme="@style/AppTheme.Transparent" />
<provider

View File

@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
@ -31,10 +30,7 @@ public class AboutActivity extends AppCompatActivity {
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
private static final String DONATION_URL = "http://topjohnwu.github.io/donate";
private AlertDialog.Builder builder;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.app_version_info) RowItem appVersionInfo;
@BindView(R.id.app_changelog) RowItem appChangelog;
@BindView(R.id.app_developers) RowItem appDevelopers;
@ -42,6 +38,7 @@ public class AboutActivity extends AppCompatActivity {
@BindView(R.id.app_source_code) RowItem appSourceCode;
@BindView(R.id.support_thread) RowItem supportThread;
@BindView(R.id.donation) RowItem donation;
private AlertDialog.Builder builder;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -52,9 +49,6 @@ public class AboutActivity extends AppCompatActivity {
setTheme(R.style.AppTheme_dh);
}
setContentView(R.layout.activity_about);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
ButterKnife.bind(this);
setSupportActionBar(toolbar);
@ -83,7 +77,7 @@ public class AboutActivity extends AppCompatActivity {
appChangelog.removeSummary();
if (theme.equals("Dark")) {
builder = new AlertDialog.Builder(this,R.style.AlertDialog_dh);
builder = new AlertDialog.Builder(this, R.style.AlertDialog_dh);
} else {
builder = new AlertDialog.Builder(this);
}
@ -92,7 +86,7 @@ public class AboutActivity extends AppCompatActivity {
} else {
Spanned result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
result = Html.fromHtml(changes,Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
result = Html.fromHtml(changes, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
} else {
result = Html.fromHtml(changes);
}
@ -114,7 +108,7 @@ public class AboutActivity extends AppCompatActivity {
appDevelopers.setOnClickListener(view -> {
Spanned result;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
result = Html.fromHtml(getString(R.string.app_developers_),Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
result = Html.fromHtml(getString(R.string.app_developers_), Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
} else {
result = Html.fromHtml(getString(R.string.app_developers_));
}
@ -148,8 +142,6 @@ public class AboutActivity extends AppCompatActivity {
setFloating();
}
public void setFloating() {
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
if (isTablet) {
@ -164,12 +156,4 @@ public class AboutActivity extends AppCompatActivity {
}
}
@Override
protected void onResume() {
super.onResume();
setTitle("About");
}
}

View File

@ -49,20 +49,6 @@ public class LogFragment extends Fragment {
private MenuItem mClickedMenuItem;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("Log");
setHasOptionsMenu(true);
reloadErrorLog();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.log_fragment, container, false);
@ -72,10 +58,16 @@ public class LogFragment extends Fragment {
reloadErrorLog();
setHasOptionsMenu(true);
return view;
}
@Override
public void onResume() {
super.onResume();
setHasOptionsMenu(true);
reloadErrorLog();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_log, menu);

View File

@ -3,13 +3,13 @@ package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.graphics.drawable.animated.BuildConfig;
import android.support.v4.content.FileProvider;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
@ -55,12 +55,16 @@ public class MagiskFragment extends Fragment {
@BindView(R.id.magisk_check_updates_status) TextView magiskCheckUpdatesStatus;
@BindView(R.id.magisk_check_updates_progress) ProgressBar magiskCheckUpdatesProgress;
@BindColor(R.color.grey500) int grey500;
@BindColor(R.color.green500) int colorOK;
@BindColor(R.color.yellow500) int colorWarn;
@BindColor(R.color.grey500) int colorNeutral;
@BindColor(R.color.blue500) int colorInfo;
@BindColor(android.R.color.transparent) int trans;
private int colorOK, colorWarn, colorNeutral;
int statusOK = R.drawable.ic_check_circle;
int statusUnknown = R.drawable.ic_help;
private AlertDialog.Builder builder;
private SharedPreferences prefs;
@ -71,24 +75,12 @@ public class MagiskFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.magisk_fragment, container, false);
ButterKnife.bind(this, v);
int[] attrs0 = {R.attr.ColorOK};
int[] attrs1 = {R.attr.ColorWarn};
int[] attrs2 = {R.attr.ColorNeutral};
TypedArray ta0 = getActivity().obtainStyledAttributes(attrs0);
TypedArray ta1 = getActivity().obtainStyledAttributes(attrs1);
TypedArray ta2 = getActivity().obtainStyledAttributes(attrs2);
colorOK = ta0.getColor(0, Color.GRAY);
colorWarn = ta1.getColor(0, Color.GRAY);
colorNeutral = ta2.getColor(0, Color.GRAY);
ta0.recycle();
ta1.recycle();
ta2.recycle();
if (magiskVersion == -1) {
magiskStatusContainer.setBackgroundColor(grey500);
magiskStatusContainer.setBackgroundColor(colorNeutral);
magiskStatusIcon.setImageResource(statusUnknown);
magiskVersionText.setTextColor(grey500);
magiskVersionText.setTextColor(colorNeutral);
magiskVersionText.setText(R.string.magisk_version_error);
} else {
magiskStatusContainer.setBackgroundColor(colorOK);
@ -137,7 +129,6 @@ public class MagiskFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(R.string.magisk);
prefs.registerOnSharedPreferenceChangeListener(listener);
}
@ -169,10 +160,10 @@ public class MagiskFragment extends Fragment {
magiskCheckUpdatesStatus.setTextColor(colorWarn);
} else {
if (remoteMagiskVersion > magiskVersion) {
magiskCheckUpdatesContainer.setBackgroundColor(colorNeutral);
magiskCheckUpdatesContainer.setBackgroundColor(colorInfo);
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(remoteMagiskVersion)));
magiskCheckUpdatesStatus.setTextColor(colorNeutral);
magiskCheckUpdatesStatus.setTextColor(colorInfo);
magiskUpdateView.setOnClickListener(view -> builder
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(remoteMagiskVersion), magiskChangelog))
@ -213,11 +204,17 @@ public class MagiskFragment extends Fragment {
.show());
}
if (remoteAppVersionCode > BuildConfig.VERSION_CODE) {
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
int appVersionCode = 0;
try {
appVersionCode = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (remoteAppVersionCode > appVersionCode) {
appCheckUpdatesContainer.setBackgroundColor(colorInfo);
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, remoteAppVersion));
appCheckUpdatesStatus.setTextColor(colorNeutral);
appCheckUpdatesStatus.setTextColor(colorInfo);
appUpdateView.setOnClickListener(view -> builder
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), remoteAppVersion, appChangelog))

View File

@ -33,7 +33,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
private final Handler mDrawerHandler = new Handler();
private String currentTitle;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.drawer_layout) DrawerLayout drawer;
@ -85,22 +84,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
mSelectedId = savedInstanceState == null ? mSelectedId : savedInstanceState.getInt(SELECTED_ITEM_ID);
navigationView.setCheckedItem(mSelectedId);
if (savedInstanceState == null) {
mDrawerHandler.removeCallbacksAndMessages(null);
mDrawerHandler.postDelayed(() -> navigate(mSelectedId), 250);
}
navigationView.setNavigationItemSelectedListener(this);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String toLaunch = "";
toLaunch = getIntent().getExtras().getString("Relaunch");
if (toLaunch.equals("Settings")) {
Logger.dev("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch"));
mSelectedId = R.id.settings;
}
}
mDrawerHandler.removeCallbacksAndMessages(null);
navigate(mSelectedId);
}
@Override
@ -130,12 +120,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return true;
}
@Override
protected void onResume() {
super.onResume();
setTitle(currentTitle);
}
public void navigate(final int itemId) {
Fragment navFragment = null;
String tag = "";
@ -166,9 +150,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
navFragment = new LogFragment();
break;
case R.id.settings:
setTitle(R.string.settings);
tag = "settings";
navFragment = new SettingsFragment();
startActivity(new Intent(this, SettingsActivity.class));
break;
case R.id.app_about:
startActivity(new Intent(this, AboutActivity.class));
@ -176,14 +158,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
if (navFragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
try {
toolbar.setElevation(navFragment instanceof ModulesFragment ? 0 : 10);
currentTitle = getTitle().toString();
transaction.replace(R.id.content_frame, navFragment, tag).addToBackStack(currentTitle).commit();
transaction.replace(R.id.content_frame, navFragment, tag).commit();
} catch (IllegalStateException ignored) {
}
}

View File

@ -47,8 +47,6 @@ public class ModulesFragment extends Fragment {
mView = inflater.inflate(R.layout.modules_fragment, container, false);
ButterKnife.bind(this, mView);
mSwipeRefreshLayout.setRefreshing(true);
fabio.setOnClickListener(v -> {
Intent getContentIntent = FileUtils.createGetContentIntent(null);
getContentIntent.setType("application/zip");
@ -95,7 +93,6 @@ public class ModulesFragment extends Fragment {
public void onResume() {
super.onResume();
mView = this.getView();
getActivity().setTitle(R.string.modules);
prefs.registerOnSharedPreferenceChangeListener(listener);
}

View File

@ -26,15 +26,13 @@ import butterknife.ButterKnife;
public class ReposFragment extends Fragment {
@BindView(R.id.recyclerView) RecyclerView recyclerView;
@BindView(R.id.empty_rv) TextView emptyTv;
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
private List<Repo> mListRepos = new ArrayList<>();
private List<Repo> mUpdateRepos = new ArrayList<>();
private List<Repo> mInstalledRepos = new ArrayList<>();
private List<Repo> mOthersRepos = new ArrayList<>();
@BindView(R.id.recyclerView) RecyclerView recyclerView;
@BindView(R.id.empty_rv) TextView emptyTv;
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
private SharedPreferences.OnSharedPreferenceChangeListener listener;
private SharedPreferences prefs;
@ -79,7 +77,6 @@ public class ReposFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(R.string.downloads);
prefs.registerOnSharedPreferenceChangeListener(listener);
}

View File

@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
@ -24,6 +23,7 @@ import com.topjohnwu.magisk.utils.Utils;
import java.io.File;
import java.util.List;
import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -52,8 +52,11 @@ public class RootFragment extends Fragment {
int statusError = R.drawable.ic_error;
int statusUnknown = R.drawable.ic_help;
private int colorOK, colorFail, colorNeutral, colorWarn;
//private boolean autoRootStatus;
@BindColor(R.color.green500) int colorOK;
@BindColor(R.color.yellow500) int colorWarn;
@BindColor(R.color.grey500) int colorNeutral;
@BindColor(R.color.red500) int colorFail;
private SharedPreferences.OnSharedPreferenceChangeListener listener;
@Nullable
@ -61,22 +64,6 @@ public class RootFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.root_fragment, container, false);
ButterKnife.bind(this, view);
int[] attrs0 = {R.attr.ColorOK};
int[] attrs1 = {R.attr.ColorFail};
int[] attrs2 = {R.attr.ColorNeutral};
int[] attrs3 = {R.attr.ColorWarn};
TypedArray ta0 = getActivity().obtainStyledAttributes(attrs0);
TypedArray ta1 = getActivity().obtainStyledAttributes(attrs1);
TypedArray ta2 = getActivity().obtainStyledAttributes(attrs2);
TypedArray ta3 = getActivity().obtainStyledAttributes(attrs3);
colorOK = ta0.getColor(0, Color.GRAY);
colorFail = ta1.getColor(0, Color.GRAY);
colorNeutral = ta2.getColor(0, Color.GRAY);
colorWarn = ta2.getColor(0, Color.GRAY);
ta0.recycle();
ta1.recycle();
ta2.recycle();
ta3.recycle();
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
@ -115,7 +102,6 @@ public class RootFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(R.string.root);
listener = (pref, key) -> {
if ((key.contains("autoRootEnable")) || (key.equals("root"))) {
Logger.dev("RootFragmnet, keychange detected for " + key);

View File

@ -0,0 +1,143 @@
package com.topjohnwu.magisk;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.WindowManager;
import android.widget.Toast;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Utils;
import butterknife.BindView;
import butterknife.ButterKnife;
public class SettingsActivity extends AppCompatActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
Logger.dev("AboutActivity: Theme is " + theme);
if (theme.equals("Dark")) {
setTheme(R.style.AppTheme_dh);
}
setContentView(R.layout.activity_container);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(view -> finish());
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setTitle(R.string.settings);
ab.setDisplayHomeAsUpEnabled(true);
}
setFloating();
if (savedInstanceState == null) {
getFragmentManager().beginTransaction().add(R.id.container, new SettingsFragment()).commit();
}
}
public void setFloating() {
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
if (isTablet) {
WindowManager.LayoutParams params = getWindow().getAttributes();
params.height = getResources().getDimensionPixelSize(R.dimen.floating_height);
params.width = getResources().getDimensionPixelSize(R.dimen.floating_width);
params.alpha = 1.0f;
params.dimAmount = 0.6f;
params.flags |= 2;
getWindow().setAttributes(params);
setFinishOnTouchOutside(true);
}
}
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private ListPreference themePreference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.uisettings);
PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false);
themePreference = (ListPreference) findPreference("theme");
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
busyboxPreference.setChecked(Utils.commandExists("unzip"));
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
themePreference.setSummary(themePreference.getValue());
if (MagiskFragment.magiskVersion == -1) {
busyboxPreference.setEnabled(false);
} else {
busyboxPreference.setEnabled(true);
}
}
@Override
public void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Logger.dev("Settings: Prefs change " + key);
switch (key) {
case "theme":
String theme = sharedPreferences.getString(key, "");
themePreference.setSummary(theme);
if (theme.equals("Dark")) {
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
} else {
getActivity().getApplication().setTheme(R.style.AppTheme);
}
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
break;
case "busybox":
boolean checked = sharedPreferences.getBoolean("busybox", false);
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
break;
case "developer_logging":
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
break;
case "shell_logging":
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false);
break;
}
}
}
}

View File

@ -1,110 +0,0 @@
package com.topjohnwu.magisk;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Utils;
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private ListPreference themePreference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.uisettings);
PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false);
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(R.string.settings);
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
themePreference = (ListPreference) findPreference("theme");
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
busyboxPreference.setChecked(Utils.commandExists("unzip"));
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
themePreference.setSummary(themePreference.getValue());
if (MagiskFragment.magiskVersion == -1) {
busyboxPreference.setEnabled(false);
} else {
busyboxPreference.setEnabled(true);
}
// calculate margins
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
TypedValue tv = new TypedValue();
int actionBarHeight = 130;
if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
}
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
return view;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Logger.dev("Settings: NewValue is " + key);
switch (key) {
case "theme":
String pref = sharedPreferences.getString(key, "");
themePreference.setSummary(pref);
if (pref.equals("Dark")) {
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
} else {
getActivity().getApplication().setTheme(R.style.AppTheme);
}
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("Relaunch", "Settings");
startActivity(intent);
Logger.dev("SettingsFragment: theme is " + pref);
break;
case "busybox":
boolean checked = sharedPreferences.getBoolean("busybox", false);
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
break;
case "developer_logging":
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
break;
case "shell_logging":
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false);
break;
}
}
}

View File

@ -28,9 +28,21 @@ public class Module extends BaseModule {
Logger.dev("Creating Module, id: " + mId);
mEnable = !Utils.itemExist(mDisableFile);
mRemove = Utils.itemExist(mRemoveFile);
mUpdated = Utils.itemExist(mUpdateFile);
try {
mEnable = !Utils.itemExist(mDisableFile);
} catch (Exception e) {
mEnable = false;
}
try {
mRemove = Utils.itemExist(mRemoveFile);
} catch (Exception e) {
mRemove = false;
}
try {
mUpdated = Utils.itemExist(mUpdateFile);
} catch (Exception e) {
mUpdated = false;
}
}

View File

@ -12,8 +12,8 @@ import com.topjohnwu.magisk.R;
public abstract class DownloadReceiver extends BroadcastReceiver {
public Context mContext;
long downloadID;
public String mName;
long downloadID;
public DownloadReceiver() {}

View File

@ -149,10 +149,10 @@ public class Async {
public static class FlashZIP extends AsyncTask<Void, Void, Integer> {
private String mName;
protected Uri mUri;
private ProgressDialog progress;
protected File mFile, sdFile;
private String mName;
private ProgressDialog progress;
private Context mContext;
private boolean copyToSD;

View File

@ -91,9 +91,6 @@ public class Utils {
} else {
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
}
// if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
// setupQuickSettingsTile(context);
// }
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", b).apply();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -1,5 +0,0 @@
<vector android:height="30dp" android:viewportHeight="512.0"
android:viewportWidth="512.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M356.2,365.6C326.6,382.4 292.4,392 256,392c-36.4,0 -70.6,-9.6 -100.1,-26.4C77.5,389.5 29.4,443 11.7,512h488.5C482.6,442.9 434.6,389.5 356.2,365.6z"/>
<path android:fillColor="#FF000000" android:pathData="M256,0C158.8,0 80,78.8 80,176s78.8,176 176,176s176,-78.8 176,-176S353.2,0 256,0zM256,308c-56,0 -103.8,-34.8 -123,-84h246C359.8,273.2 312,308 256,308z"/>
</vector>

View File

@ -1,4 +1,10 @@
<vector android:height="30dp" android:viewportHeight="1024.0"
android:viewportWidth="896.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M128,768h256v64L128,832v-64zM448,384L128,384v64h320v-64zM576,576L576,448L384,640l192,192L576,704h320L896,576L576,576zM288,512L128,512v64h160v-64zM128,704h160v-64L128,640v64zM704,768h64v128c-1,18 -7,33 -19,45s-27,18 -45,19L64,960c-35,0 -64,-29 -64,-64L0,192c0,-35 29,-64 64,-64h192C256,57 313,0 384,0s128,57 128,128h192c35,0 64,29 64,64v320h-64L704,320L64,320v576h640L704,768zM128,256h512c0,-35 -29,-64 -64,-64h-64c-35,0 -64,-29 -64,-64s-29,-64 -64,-64 -64,29 -64,64 -29,64 -64,64h-64c-35,0 -64,29 -64,64z"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#000"
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
</vector>

View File

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/darker_gray"/>
<item android:drawable="@color/primary"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
android:src="@drawable/logo"/>
</item>
</layer-list>

View File

@ -1,4 +0,0 @@
<vector android:height="30dp" android:viewportHeight="512.0"
android:viewportWidth="512.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M256,0C114.8,0 0,114.8 0,256C0,397.2 114.8,512 256,512C397.2,512 512,397.2 512,256C512,114.8 397.2,0 256,0zM368.4,302.6c6,-14.4 9.3,-30.1 9.3,-46.6c0,-16.5 -3.3,-32.2 -9.3,-46.6l113.6,-47c12,28.9 18.7,60.5 18.7,93.6c0,33.2 -6.7,64.8 -18.7,93.6L368.4,302.6zM256,366.3c-60.8,0 -110.3,-49.5 -110.3,-110.3c0,-60.8 49.5,-110.3 110.3,-110.3c60.8,0 110.3,49.5 110.3,110.3C366.3,316.8 316.8,366.3 256,366.3zM30,349.6c-12,-28.8 -18.6,-60.4 -18.6,-93.6c0,-33.1 6.7,-64.7 18.6,-93.6l113.6,47c-6,14.3 -9.3,30.1 -9.3,46.6c0,16.5 3.3,32.2 9.3,46.6L30,349.6zM349.6,30L302.6,143.6c-14.4,-6 -30.1,-9.3 -46.6,-9.3c-16.5,0 -32.2,3.3 -46.6,9.3L162.4,30c28.9,-12 60.5,-18.7 93.6,-18.7C289.1,11.4 320.8,18 349.6,30zM162.4,482l47,-113.6c14.4,6 30.1,9.3 46.6,9.3c16.5,0 32.2,-3.3 46.6,-9.3L349.6,482c-28.8,12 -60.5,18.7 -93.6,18.7C222.9,500.6 191.2,494 162.4,482z"/>
</vector>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
style="?attr/cardStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
@ -11,9 +11,9 @@
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin"
android:minHeight="?android:attr/listPreferredItemHeight"
style="?attr/cardStyle"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation">
card_view:cardElevation="@dimen/card_elevation"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
@ -43,11 +43,11 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic" />
android:textStyle="bold|italic"/>
<TextView
android:id="@+id/author"
@ -55,8 +55,8 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/version_name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"/>
@ -68,9 +68,9 @@
android:layout_alignParentStart="true"
android:layout_below="@id/author"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/no_info_provided"
android:textIsSelectable="false" />
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
<ImageView
android:id="@+id/update"
@ -82,7 +82,7 @@
android:background="@drawable/ic_file_download_black"
android:backgroundTint="@color/icon_grey"
android:focusable="false"
android:gravity="end" />
android:gravity="end"/>
<LinearLayout
@ -93,13 +93,11 @@
android:layout_below="@id/description"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_margin="15dip">
android:orientation="horizontal">
<ImageView
android:id="@+id/changeLog"
@ -107,8 +105,10 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_changelog"
android:backgroundTint="@color/icon_grey"/>
android:background="?android:attr/selectableItemBackground"
android:padding="15dp"
android:src="@drawable/ic_changelog"
android:tint="@color/icon_grey"/>
<ImageView
android:id="@+id/authorLink"
@ -116,8 +116,10 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_author"
android:backgroundTint="@color/icon_grey"/>
android:background="?android:attr/selectableItemBackground"
android:padding="15dp"
android:src="@drawable/ic_person"
android:tint="@color/icon_grey"/>
<ImageView
android:id="@+id/supportLink"
@ -125,8 +127,10 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:background="@drawable/ic_support"
android:backgroundTint="@color/icon_grey"/>
android:background="?android:attr/selectableItemBackground"
android:padding="15dp"
android:src="@drawable/ic_help"
android:tint="@color/icon_grey"/>
</LinearLayout>
@ -143,7 +147,7 @@
android:layout_marginStart="@dimen/card_imageview_margin"
android:focusable="false"
android:gravity="end"
android:visibility="gone" />
android:visibility="gone"/>
</RelativeLayout>

View File

@ -4,5 +4,4 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
/>
android:elevation="4dp"/>

View File

@ -20,26 +20,30 @@
android:icon="@drawable/ic_cloud_download"
android:title="@string/downloads"/>
<item
android:id="@+id/root"
android:icon="@drawable/root"
android:title="@string/root"/>
<item
android:id="@+id/log"
android:icon="@drawable/ic_bug_report"
android:title="@string/log"/>
<item
android:id="@+id/root"
android:icon="@drawable/root"
android:title="@string/root"/>
</group>
<group
android:id="@+id/option_items"
android:checkableBehavior="none">
<item
android:id="@+id/settings"
android:icon="@drawable/ic_settings"
android:title="@string/settings"/>
<item
android:id="@+id/app_about"
android:icon="@drawable/ic_info_outline"
android:title="@string/about"/>
</group>
<item
android:id="@+id/app_about"
android:icon="@drawable/ic_info_outline"
android:title="@string/about"/>
</menu>

View File

@ -5,9 +5,11 @@
<color name="primary_dark">#00796B</color>
<color name="accent">#FFC107</color>
<color name="icon_grey">#757575</color>
<color name="red500">#F44336</color>
<color name="green500">#4CAF50</color>
<color name="grey500">#9E9E9E</color>
<color name="blue500">#2196F3</color>
<color name="yellow500">#FFC107</color>
<color name="dh_primary">#3F51B5</color>
@ -17,9 +19,5 @@
<color name="dh_primary_text">#dedede</color>
<color name="dh_icons">#dedede</color>
<color name="dh_divider">#313131</color>
<color name="dh_alertWarn">#FF9800</color>
<color name="dh_alertOk">@color/dh_accent</color>
<color name="dh_alertFail">@color/red500</color>
</resources>
</resources>

View File

@ -11,10 +11,6 @@
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="ColorOK">@color/green500</item>
<item name="ColorWarn">@color/yellow500</item>
<item name="ColorFail">@color/red500</item>
<item name="ColorNeutral">@color/grey500</item>
</style>
<style name="AppTheme.dh" parent="ThemeOverlay.AppCompat.Dark">
@ -27,7 +23,6 @@
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="cardStyle">@style/CardViewStyle.Dark</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:textColorPrimary">@color/dh_primary_text</item>
<item name="android:textColorSecondary">@color/dh_primary_text</item>
<item name="android:alertDialogTheme">@style/AlertDialog.dh</item>
@ -36,19 +31,12 @@
<item name="colorControlNormal">@color/dh_primary_text</item>
<item name="colorControlActivated">@color/dh_accent</item>
<item name="colorControlHighlight">@color/dh_icons</item>
<item name="ColorOK">@color/dh_alertOk</item>
<item name="ColorWarn">@color/dh_alertWarn</item>
<item name="ColorFail">@color/dh_alertFail</item>
<item name="ColorNeutral">@color/dh_alertWarn</item>
</style>
<style name="OverFlow" parent="@android:style/Widget.ActionBar">
<item name="android:backgroundTint">@color/dh_icons</item>
</style>
<style name="AppTheme.Toolbar.dh" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorPrimary">@color/dh_primary</item>
<item name="android:elevation">4dp</item>
@ -59,7 +47,6 @@
<style name="CardViewStyle.Dark" parent="CardView">
<item name="cardBackgroundColor">@android:color/background_dark</item>
</style>
<style name="AlertDialog.dh" parent="ThemeOverlay.AppCompat.Dark">
@ -86,8 +73,6 @@
<item name="android:textColor">@color/dh_primary_text</item>
</style>
<style name="ListPrefAlertDialogStyle">
<item name="android:fullDark" >@android:color/transparent</item>
<item name="android:topDark" >@android:color/transparent</item>
@ -132,6 +117,8 @@
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/ic_splash_activity</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>