Apparently, I thought a theme was a good idea...

This commit is contained in:
d8ahazard 2016-09-25 00:16:28 -05:00
parent d2335485f2
commit c56dd4172e
26 changed files with 612 additions and 424 deletions

View File

@ -2,6 +2,8 @@ package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -45,11 +47,9 @@ 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.green500) int green500;
@BindColor(R.color.accent) int accent;
@BindColor(R.color.blue500) int blue500;
@BindColor(R.color.grey500) int grey500;
private int colorOK, colorWarn, colorNeutral;
int statusOK = R.drawable.ic_check_circle;
int statusUnknown = R.drawable.ic_help;
@ -58,7 +58,18 @@ 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();
new updateUI().execute();
return v;
@ -88,16 +99,16 @@ public class MagiskFragment extends Fragment {
magiskVersion.setTextColor(grey500);
magiskVersion.setText(R.string.magisk_version_error);
} else {
magiskStatusContainer.setBackgroundColor(green500);
magiskStatusContainer.setBackgroundColor(colorOK);
magiskStatusIcon.setImageResource(statusOK);
magiskVersion.setTextColor(green500);
magiskVersion.setTextColor(colorOK);
magiskVersion.setText(getString(R.string.magisk_version, String.valueOf(Utils.magiskVersion)));
}
if (Utils.remoteMagiskVersion == -1) {
appCheckUpdatesContainer.setBackgroundColor(accent);
magiskCheckUpdatesContainer.setBackgroundColor(accent);
appCheckUpdatesContainer.setBackgroundColor(colorWarn);
magiskCheckUpdatesContainer.setBackgroundColor(colorWarn);
appCheckUpdatesIcon.setImageResource(R.drawable.ic_warning);
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_warning);
@ -106,7 +117,7 @@ public class MagiskFragment extends Fragment {
magiskCheckUpdatesStatus.setText(R.string.cannot_check_updates);
} else {
if (Utils.remoteMagiskVersion > Utils.magiskVersion) {
magiskCheckUpdatesContainer.setBackgroundColor(blue500);
magiskCheckUpdatesContainer.setBackgroundColor(colorNeutral);
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(Utils.remoteMagiskVersion)));
magiskUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
@ -127,13 +138,13 @@ public class MagiskFragment extends Fragment {
.setNegativeButton(R.string.no_thanks, null)
.show());
} else {
magiskCheckUpdatesContainer.setBackgroundColor(green500);
magiskCheckUpdatesContainer.setBackgroundColor(colorOK);
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle);
magiskCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.magisk)));
}
if (Utils.remoteAppVersion > BuildConfig.VERSION_CODE) {
appCheckUpdatesContainer.setBackgroundColor(blue500);
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, String.valueOf(Utils.remoteAppVersion)));
appUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
@ -157,7 +168,7 @@ public class MagiskFragment extends Fragment {
.show()
);
} else {
appCheckUpdatesContainer.setBackgroundColor(green500);
appCheckUpdatesContainer.setBackgroundColor(colorOK);
appCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle);
appCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.app_name)));
}

View File

@ -9,6 +9,7 @@ import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
@ -49,6 +50,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override
protected void onCreate(final Bundle savedInstanceState) {
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme","");
Logger.dh("MainActivity: Theme is " + theme);
if (theme.equals("Dark")) {
setTheme(R.style.AppTheme_dh);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
@ -106,6 +113,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
);
setSupportActionBar(toolbar);
@ -137,10 +146,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
navigationView.setNavigationItemSelectedListener(this);
mView = getToolbarNavigationButton();
if (getIntent().hasExtra("relaunch")) {
navigate(R.id.root);
Bundle extras = getIntent().getExtras();
if(extras != null) {
Logger.dh("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch"));
String data = extras.getString("Relaunch"); // retrieve the data using keyName
if (data.contains("Settings")) {
navigate(R.id.settings);
}
startTour();
}
}
public ImageButton getToolbarNavigationButton() {

View File

@ -3,21 +3,24 @@ package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;
import com.ipaulpro.afilechooser.FileInfo;
import com.ipaulpro.afilechooser.utils.FileUtils;
import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.utils.Async;
@ -29,9 +32,12 @@ import butterknife.BindView;
import butterknife.ButterKnife;
public class ModulesFragment extends Fragment {
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recyclerView) RecyclerView recyclerView;
@BindView(R.id.empty_rv) TextView emptyTv;
@BindView(R.id.swipeRefreshLayout)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recyclerView)
RecyclerView recyclerView;
@BindView(R.id.empty_rv)
TextView emptyTv;
private static final int FETCH_ZIP_CODE = 2;
private SharedPreferences prefs;
public static List<Module> listModules = new ArrayList<>();
@ -43,7 +49,6 @@ private static final int FETCH_ZIP_CODE = 2;
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View viewMain = inflater.inflate(R.layout.modules_fragment, container, false);
ButterKnife.bind(this, viewMain);
fabio.setOnClickListener(v -> {
Intent getContentIntent = FileUtils.createGetContentIntent(null);
@ -76,6 +81,23 @@ private static final int FETCH_ZIP_CODE = 2;
return viewMain;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
// Get the URI of the selected file
final Uri uri = data.getData();
try {
// Get the file path from the URI
new Async.FlashZIP(getActivity(), uri).execute();
FileInfo fileInfo = FileUtils.getFileInfo(getActivity(), uri);
} catch (Exception e) {
Log.e("FileSelectorTestAc...", "File select error", e);
}
}
}
@Override
public void onResume() {
super.onResume();

View File

@ -1,19 +1,16 @@
package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -25,11 +22,8 @@ import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetSequence;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
@ -40,6 +34,8 @@ import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
import static com.topjohnwu.magisk.R.attr.cardStyle;
public class RootFragment extends Fragment {
public SharedPreferences prefs;
@ -79,29 +75,37 @@ public class RootFragment extends Fragment {
TextView safetyNetStatus;
@BindView(R.id.safety_net_icon)
ImageView safetyNetStatusIcon;
@BindColor(R.color.red500)
int red500;
@BindColor(R.color.green500)
int green500;
@BindColor(R.color.grey500)
int grey500;
@BindColor(R.color.accent)
int accent;
int statusOK = R.drawable.ic_check_circle;
int statusAuto = R.drawable.ic_autoroot;
int statusError = R.drawable.ic_error;
int statusUnknown = R.drawable.ic_help;
private int colorOK, colorFail, colorNeutral, colorWarn;
private boolean autoRootStatus;
private View view;
private SharedPreferences.OnSharedPreferenceChangeListener listener;
private View view;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.root_fragment, container, false);
ButterKnife.bind(this, view);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
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();
autoRootStatus = Utils.autoToggleEnabled(getActivity());
if (autoRootStatus) {
@ -128,33 +132,21 @@ public class RootFragment extends Fragment {
);
listener = (prefs1, key) -> {
if ((key.contains("autoRootEnable")) | (key.equals("root"))) {
Logger.dh("RootFragmnet, keychange detected for " + key);
new updateUI().execute();
}
};
prefs.registerOnSharedPreferenceChangeListener(listener);
selinuxToggle.setOnClickListener(toggle -> {
Shell.su(((CompoundButton) toggle).isChecked() ? "setenforce 1" : "setenforce 0");
new updateUI().execute();
});
return view;
}
@Override
public void onDestroy() {
super.onDestroy();
if (null != listener) {
prefs.unregisterOnSharedPreferenceChangeListener(listener);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -162,8 +154,9 @@ public class RootFragment extends Fragment {
Log.d("Magisk", "Got result: " + requestCode + " and " + resultCode);
if (requestCode == 100) {
if (Utils.hasServicePermission(getActivity())) {
Log.d("Magisk", "Got result code OK for permissions");
ToggleAutoRoot(true);
Snackbar.make(view, getActivity().getString(R.string.auto_toggle) + " has been enabled.", Snackbar.LENGTH_LONG).show();
} else {
autoRootToggle.setChecked(false);
Snackbar.make(view, getActivity().getString(R.string.auto_toggle) + " disabled, permissions required.", Snackbar.LENGTH_LONG).show();
@ -196,6 +189,17 @@ public class RootFragment extends Fragment {
public void onResume() {
super.onResume();
getActivity().setTitle("Root");
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
listener = (prefs1, key) -> {
if ((key.contains("autoRootEnable")) | (key.equals("root"))) {
Logger.dh("RootFragmnet, keychange detected for " + key);
new updateUI().execute();
}
};
prefs.registerOnSharedPreferenceChangeListener(listener);
new updateUI().execute();
}
@ -207,7 +211,7 @@ public class RootFragment extends Fragment {
// Make sure static block invoked
Shell.rootAccess();
// Set up Tile on UI Refresh
if (PrefHelper.CheckBool("enable_quicktile", getActivity())) {
if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("enable_quicktile", false)) {
Utils.SetupQuickSettingsTile(getActivity());
}
autoRootStatus = Utils.autoToggleEnabled(getActivity());
@ -232,25 +236,25 @@ public class RootFragment extends Fragment {
List<String> selinux = Shell.sh("getenforce");
if (selinux.isEmpty()) {
selinuxStatusContainer.setBackgroundColor(grey500);
selinuxStatusContainer.setBackgroundColor(colorNeutral);
selinuxStatusIcon.setImageResource(statusUnknown);
selinuxStatus.setText(R.string.selinux_error_info);
selinuxStatus.setTextColor(grey500);
selinuxStatus.setTextColor(colorNeutral);
selinuxToggle.setChecked(false);
} else if (selinux.get(0).equals("Enforcing")) {
selinuxStatusContainer.setBackgroundColor(green500);
selinuxStatusContainer.setBackgroundColor(colorOK);
selinuxStatusIcon.setImageResource(statusOK);
selinuxStatus.setText(R.string.selinux_enforcing_info);
selinuxStatus.setTextColor(green500);
selinuxStatus.setTextColor(colorOK);
selinuxToggle.setChecked(true);
} else {
selinuxStatusContainer.setBackgroundColor(red500);
selinuxStatusContainer.setBackgroundColor(colorFail);
selinuxStatusIcon.setImageResource(statusError);
selinuxStatus.setText(R.string.selinux_permissive_info);
selinuxStatus.setTextColor(red500);
selinuxStatus.setTextColor(colorFail);
selinuxToggle.setChecked(false);
}
@ -261,9 +265,9 @@ public class RootFragment extends Fragment {
switch (Shell.rootStatus) {
case -1:
// Root Error
rootStatusContainer.setBackgroundColor(grey500);
rootStatusContainer.setBackgroundColor(colorFail);
rootStatusIcon.setImageResource(statusUnknown);
rootStatus.setTextColor(grey500);
rootStatus.setTextColor(colorNeutral);
rootStatus.setText(R.string.root_error);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusUnknown);
@ -271,9 +275,9 @@ public class RootFragment extends Fragment {
break;
case 0:
// Not rooted
rootStatusContainer.setBackgroundColor(green500);
rootStatusContainer.setBackgroundColor(colorOK);
rootStatusIcon.setImageResource(statusOK);
rootStatus.setTextColor(green500);
rootStatus.setTextColor(colorOK);
rootStatus.setText(R.string.root_none);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusOK);
@ -282,10 +286,10 @@ public class RootFragment extends Fragment {
case 1:
// Proper root
if (autoRootStatus) {
rootStatusContainer.setBackgroundColor(green500);
rootStatusContainer.setBackgroundColor(colorOK);
rootStatusIcon.setImageResource(statusAuto);
rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
rootStatus.setTextColor(green500);
rootStatus.setTextColor(colorOK);
rootStatus.setText(R.string.root_auto_unmounted);
rootToggle.setEnabled(false);
autoRootToggle.setChecked(true);
@ -296,9 +300,9 @@ public class RootFragment extends Fragment {
rootToggle.setEnabled(true);
if (Utils.rootEnabled()) {
// Mounted
rootStatusContainer.setBackgroundColor(accent);
rootStatusContainer.setBackgroundColor(colorWarn);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(accent);
rootStatus.setTextColor(colorWarn);
rootStatus.setText(R.string.root_enabled);
rootToggle.setChecked(true);
safetyNetStatusIcon.setImageResource(statusError);
@ -306,9 +310,9 @@ public class RootFragment extends Fragment {
break;
} else {
// Disabled
rootStatusContainer.setBackgroundColor(green500);
rootStatusContainer.setBackgroundColor(colorOK);
rootStatusIcon.setImageResource(statusOK);
rootStatus.setTextColor(green500);
rootStatus.setTextColor(colorOK);
rootStatus.setText(R.string.root_disabled);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusOK);
@ -318,9 +322,9 @@ public class RootFragment extends Fragment {
}
case 2:
// Improper root
rootStatusContainer.setBackgroundColor(red500);
rootStatusContainer.setBackgroundColor(colorFail);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(red500);
rootStatus.setTextColor(colorFail);
rootStatus.setText(R.string.root_system);
rootToggle.setChecked(true);
safetyNetStatusIcon.setImageResource(statusError);

View File

@ -1,21 +1,29 @@
package com.topjohnwu.magisk;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Utils;
import butterknife.ButterKnife;
public class SettingsFragment extends PreferenceFragment {
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
private CheckBoxPreference quickTilePreference;
private ListPreference themePreference;
private SharedPreferences.OnSharedPreferenceChangeListener listener;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -30,6 +38,15 @@ public class SettingsFragment extends PreferenceFragment {
public void onResume() {
super.onResume();
getActivity().setTitle("Settings");
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroy() {
super.onDestroy();
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
}
@Override
@ -37,9 +54,11 @@ public class SettingsFragment extends PreferenceFragment {
View view = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.bind(this, view);
quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile");
themePreference = (ListPreference) findPreference("theme");
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
CheckBoxPreference keepRootOffPreference = (CheckBoxPreference) findPreference("keep_root_off");
CheckBoxPreference hideRootNotificationPreference = (CheckBoxPreference) findPreference("hide_root_notification");
themePreference.setSummary(themePreference.getValue());
if (Utils.magiskVersion == -1) {
quickTilePreference.setEnabled(false);
keepRootOffPreference.setEnabled(false);
@ -50,6 +69,7 @@ public class SettingsFragment extends PreferenceFragment {
hideRootNotificationPreference.setEnabled(true);
}
Preference.OnPreferenceClickListener preferenceClickListener = preference -> {
if (preference == quickTilePreference) {
boolean isChecked = quickTilePreference.isChecked();
@ -64,6 +84,10 @@ public class SettingsFragment extends PreferenceFragment {
return false;
};
quickTilePreference.setOnPreferenceClickListener(preferenceClickListener);
// calculate margins
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
@ -78,5 +102,36 @@ public class SettingsFragment extends PreferenceFragment {
return view;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Logger.dh("Settings: NewValue is " + key);
if (key.equals("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.dh("SettingsFragment: theme is " + pref);
}
}
}

View File

@ -10,7 +10,6 @@ import android.support.v7.app.AppCompatActivity;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Utils;
import java.util.HashSet;
@ -19,6 +18,9 @@ import java.util.Set;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme","").equals("Dark")) {
setTheme(R.style.AppTheme_dh);
}
super.onCreate(savedInstanceState);
//setups go here
@ -47,7 +49,7 @@ public class SplashActivity extends AppCompatActivity {
getApplication().startService(myIntent);
}
} else {
if (PrefHelper.CheckBool("keep_root_off", getApplication())) {
if (PreferenceManager.getDefaultSharedPreferences(getApplication()).getBoolean("keep_root_off", false)) {
Utils.toggleRoot(false, getApplication());
}
}
@ -61,6 +63,7 @@ public class SplashActivity extends AppCompatActivity {
new Async.LoadModules(this).execute();
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// Start main activity
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);

View File

@ -3,10 +3,10 @@ package com.topjohnwu.magisk.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.util.Log;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Utils;
public class AutoStartReceiver extends BroadcastReceiver {
@ -15,14 +15,13 @@ public class AutoStartReceiver extends BroadcastReceiver {
Log.d("Magisk", "Received Boot call, attempting to start service");
Intent myIntent = new Intent(context, MonitorService.class);
context.startService(myIntent);
if (PrefHelper.CheckBool("keep_root_off",context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("keep_root_off", false)) {
Utils.toggleRoot(false, context);
}
if (PrefHelper.CheckBool("enable_quicktile",context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
Utils.SetupQuickSettingsTile(context);
}
}
}

View File

@ -18,7 +18,6 @@ import android.view.accessibility.AccessibilityEvent;
import com.topjohnwu.magisk.MainActivity;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Utils;
import java.util.Set;
@ -109,7 +108,7 @@ public class MonitorService extends AccessibilityService {
private void ShowNotification(boolean rootAction, String packageName) {
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder;
if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) {
if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("hide_root_notification", false)) {
if (rootAction) {
Intent intent = new Intent(getApplication(), MainActivity.class);

View File

@ -74,15 +74,26 @@ public class TileServiceCompat extends Service {
private void onSimpleClick() {
updateRoots();
updateTile();
Utils.toggleAutoRoot(false,getApplicationContext());
Utils.toggleRoot(!root,getApplicationContext());
if (autoRoot) {
Utils.toggleAutoRoot(false, getApplicationContext());
if (!Utils.hasServicePermission(getApplicationContext())) {
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(it);
}
} else {
Utils.toggleRoot(!root, getApplicationContext());
}
}
private void onLongClick() {
updateRoots();
updateTile();
Utils.toggleAutoRoot(!autoRoot,getApplicationContext());
if (!Utils.hasServicePermission(getApplicationContext())) {
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(it);
}
}
private void updateTile() {

View File

@ -5,11 +5,12 @@ import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.DocumentsContract;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.widget.Toast;
import com.ipaulpro.afilechooser.FileInfo;
import com.ipaulpro.afilechooser.utils.FileUtils;
import com.topjohnwu.magisk.ModulesFragment;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.ReposFragment;
@ -87,8 +88,7 @@ public class Async {
.setTitle(R.string.no_magisk_title)
.setMessage(R.string.no_magisk_msg)
.setCancelable(true)
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> {
new AlertDialog.Builder(mContext)
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext)
.setTitle(R.string.root_method_title)
.setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> {
Utils.DownloadReceiver rootReceiver;
@ -132,8 +132,7 @@ public class Async {
};
Utils.downloadAndReceive(mContext, magiskReceiver, Utils.magiskLink, "latest_magisk.zip");
})
.show();
})
.show())
.setNegativeButton(R.string.no_thanks, null)
.show();
} else if (Shell.rootStatus == 2) {
@ -141,8 +140,7 @@ public class Async {
.setTitle(R.string.root_system)
.setMessage(R.string.root_system_msg)
.setCancelable(true)
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> {
new AlertDialog.Builder(mContext)
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext)
.setTitle(R.string.root_method_title)
.setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> {
switch (root) {
@ -170,8 +168,7 @@ public class Async {
break;
}
})
.show();
})
.show())
.setNegativeButton(R.string.no_thanks, null)
.show();
}
@ -216,8 +213,6 @@ public class Async {
public static class LoadRepos extends AsyncTask<Void, Void, Void> {
private Context mContext;
private boolean doReload;
private RepoHelper.TaskDelegate mTaskDelegate;
public LoadRepos(Context context) {
mContext = context;
@ -255,33 +250,31 @@ public class Async {
mContext = context;
mUri = uRi;
deleteFileAfter = true;
String file = "";
final String docId = DocumentsContract.getDocumentId(mUri);
Log.d("Magisk", "Utils: FlashZip Running, " + docId + " and " + mUri.toString());
if (docId.contains(":"))
mName = docId.split(":")[1];
else mName = docId;
if (mName.contains("/"))
mName = mName.substring(mName.lastIndexOf('/') + 1);
if (mName.contains(".zip")) {
file = mContext.getFilesDir() + "/" + mName;
Log.d("Magisk", "Utils: FlashZip running for uRI " + mUri.toString());
} else {
Log.e("Magisk", "Utils: error parsing Zipfile " + mUri.getPath());
String file;
FileInfo fileInfo = FileUtils.getFileInfo(context, mUri);
Logger.dh("Utils: FlashZip Running, " + fileInfo.getPath());
String filename = fileInfo.getPath();
String idStr = filename.substring(filename.lastIndexOf('/') + 1);
if (!idStr.contains(".zip")) {
Logger.dh("Async: Improper name, cancelling " + idStr);
this.cancel(true);
progress.cancel();
}
file = mContext.getFilesDir() + "/" + idStr;
ContentResolver contentResolver = mContext.getContentResolver();
//contentResolver.takePersistableUriPermission(mUri, flags);
try {
InputStream in = contentResolver.openInputStream(mUri);
Log.d("Magisk", "Firing inputStream");
mFile = createFileFromInputStream(in, file, mContext);
mFile = createFileFromInputStream(in, file);
if (mFile != null) {
mPath = mFile.getPath();
Log.d("Magisk", "Utils: Mpath is " + mPath);
Logger.dh("Async: Mpath is " + mPath);
} else {
Log.e("Magisk", "Utils: error creating file " + mUri.getPath());
Log.e("Magisk", "Async: error creating file " + mUri.getPath());
this.cancel(true);
}
} catch (FileNotFoundException e) {
@ -292,7 +285,7 @@ public class Async {
}
private static File createFileFromInputStream(InputStream inputStream, String fileName, Context context) {
private static File createFileFromInputStream(InputStream inputStream, String fileName) {
try {
File f = new File(fileName);
@ -307,12 +300,13 @@ public class Async {
outputStream.close();
inputStream.close();
Log.d("Magisk", "Holy balls, I think it worked. File is " + f.getPath());
Logger.dh("Async: File created successfully - " + f.getPath());
return f;
} catch (IOException e) {
System.out.println("error in creating a file");
e.printStackTrace();
}
return null;
@ -327,23 +321,24 @@ public class Async {
@Override
protected Boolean doInBackground(Void... voids) {
if (mPath != null) {
if (mPath == null) {
Log.e("Magisk", "Utils: Error, flashZIP called without a valid zip file to flash.");
progress.dismiss();
this.cancel(true);
progress.cancel();
return false;
}
if (!Shell.rootAccess()) {
return false;
} else {
ret = Shell.su(
"rm -rf /dev/tmp",
"mkdir -p /dev/tmp",
"cp -af " + mPath + " /dev/tmp/install.zip",
"unzip -o /dev/tmp/install.zip META-INF/com/google/android/* -d /dev/tmp",
"BOOTMODE=true sh /dev/tmp/META-INF/com/google/android/update-binary dummy 1 /dev/tmp/install.zip",
"rm -rf /data/tmp",
"mkdir -p /data/tmp",
"cp -af " + mPath + " /data/tmp/install.zip",
"unzip -o /data/tmp/install.zip META-INF/com/google/android/* -d /data/tmp",
"BOOTMODE=true sh /data/tmp/META-INF/com/google/android/update-binary dummy 1 /data/tmp/install.zip",
"if [ $? -eq 0 ]; then echo true; else echo false; fi"
);
Logger.dh("Async: ret is " + ret);
return ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1));
}
}
@ -351,6 +346,7 @@ public class Async {
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
//Shell.su("rm -rf /data/tmp");
if (deleteFileAfter) {
Shell.su("rm -rf " + mPath);
Log.d("Magisk", "Utils: Deleting file " + mPath);

View File

@ -2,6 +2,7 @@ package com.topjohnwu.magisk.utils;
import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
import android.util.Log;
public class Logger {
@ -15,7 +16,7 @@ public class Logger {
} catch (Exception e) {
e.printStackTrace();
}
if (PrefHelper.CheckBool("developer_logging", context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("developer_logging", false)) {
if (args.length == 1 && args[0] instanceof Throwable) {
Log.d(LOG_TAG, msg, (Throwable) args[0]);
} else {

View File

@ -1,23 +0,0 @@
package com.topjohnwu.magisk.utils;
import android.content.Context;
import android.preference.PreferenceManager;
public class PrefHelper {
public PrefHelper() {
}
public static boolean CheckBool(String key, Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false);
}
public static void SetBool(String key, Boolean value, Context context) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
}
}

View File

@ -72,10 +72,10 @@ public class Utils {
if (!Shell.rootAccess()) {
Snackbar.make(((Activity) context).findViewById(android.R.id.content), R.string.no_root_access, Snackbar.LENGTH_LONG).show();
}
if (PrefHelper.CheckBool("keep_root_off", context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("keep_root_off", false)) {
Utils.toggleRoot(false, context);
}
if (PrefHelper.CheckBool("enable_quicktile", context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
Utils.SetupQuickSettingsTile(context);
}
}
@ -137,10 +137,10 @@ public class Utils {
} else {
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
}
if (PrefHelper.CheckBool("enable_quicktile", context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
SetupQuickSettingsTile(context);
}
PrefHelper.SetBool("root",b,context);
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root",b).apply();
}
}
@ -156,6 +156,7 @@ public class Utils {
Logger.dh("Utils: toggleAuto checks passed, setting" + b );
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply();
Intent myServiceIntent = new Intent(context, MonitorService.class);
myServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (b) {
context.startService(myServiceIntent);
} else {
@ -163,7 +164,7 @@ public class Utils {
}
}
}
if (PrefHelper.CheckBool("enable_quicktile", context)) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
SetupQuickSettingsTile(context);
}
UpdateRootFragmentUI(context);

View File

@ -30,6 +30,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
style="?attr/navStyle"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>

View File

@ -6,11 +6,11 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/card_vertical_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginEnd="@dimen/card_horizontal_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin"
android:background="?android:attr/selectableItemBackground"
style="?attr/cardStyle"
android:minHeight="?android:attr/listPreferredItemHeight"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation">
@ -33,11 +33,11 @@
android:id="@+id/textLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignBottom="@+id/app_icon"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingEnd="@dimen/card_appicon_size"
android:paddingStart="65dp"
android:gravity="center_horizontal"
android:layout_alignBottom="@+id/app_icon"
android:weightSum="1">
@ -46,21 +46,21 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_weight="1"
android:paddingEnd="3dp"
android:paddingStart="3dp"
android:textStyle="bold"
android:layout_weight="1"/>
android:textStyle="bold"/>
<TextView
android:id="@+id/app_paackage"
android:layout_width="fill_parent"
android:layout_height="25dp"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:paddingEnd="3dp"
android:paddingStart="3dp"
android:maxLines="1"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"/>
android:maxLines="1"
android:paddingEnd="3dp"
android:paddingStart="3dp"/>
</LinearLayout>
<LinearLayout

View File

@ -6,20 +6,20 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/card_vertical_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginEnd="@dimen/card_horizontal_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin"
android:background="?android:attr/selectableItemBackground"
android:minHeight="?android:attr/listPreferredItemHeight"
style="?attr/cardStyle"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:padding="@dimen/card_layout_padding"
android:layout_gravity="center_vertical">
android:padding="@dimen/card_layout_padding">
<TextView
android:id="@+id/title"
@ -36,20 +36,20 @@
android:id="@+id/version_name"
android:layout_width="@dimen/card_textview_width"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"
android:layout_alignParentStart="true"/>
android:textStyle="bold|italic"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:layout_above="@+id/expand_layout"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:paddingTop="15dp">
@ -133,11 +133,11 @@
android:id="@+id/updateStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dip"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"
android:layout_gravity="center_horizontal" />
android:textIsSelectable="false"/>
<LinearLayout
android:layout_width="wrap_content"
@ -152,8 +152,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_changelog" />
android:background="@drawable/ic_changelog"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/authorLink"
@ -161,8 +161,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_author" />
android:background="@drawable/ic_author"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/supportLink"
@ -170,8 +170,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_support" />
android:background="@drawable/ic_support"
android:backgroundTint="@color/icon_grey"/>
</LinearLayout>
@ -181,6 +181,4 @@
</RelativeLayout>
</android.support.v7.widget.CardView>

View File

@ -6,11 +6,11 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/card_vertical_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginEnd="@dimen/card_horizontal_margin"
android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin"
android:background="?android:attr/selectableItemBackground"
android:minHeight="?android:attr/listPreferredItemHeight"
style="?attr/cardStyle"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation">
@ -31,47 +31,47 @@
android:id="@+id/title"
android:layout_width="@dimen/card_textview_width"
android:layout_height="wrap_content"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp" />
android:layout_marginTop="0dp"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false"/>
<TextView
android:id="@+id/version_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
/>
<ImageView
android:id="@+id/update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="end"
android:background="@drawable/ic_file_download_black"
android:backgroundTint="@color/icon_grey"
android:layout_gravity="end"
android:layout_alignBaseline="@id/title"
android:layout_alignParentEnd="true"
android:layout_gravity="end"
android:background="@drawable/ic_file_download_black"
android:backgroundTint="@color/icon_grey"
android:focusable="false"
android:gravity="end"
/>
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/update"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"
android:layout_alignParentStart="true"
android:layout_below="@id/update"
/>
@ -79,10 +79,10 @@
android:id="@+id/expand_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/description"
android:minHeight="100dp"
android:orientation="vertical"
android:layout_below="@id/description"
android:layout_alignParentStart="true"
>
@ -108,40 +108,43 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"
android:layout_marginBottom="20dip" />
android:textIsSelectable="false"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dip"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginBottom="0dip">
android:layout_marginBottom="0dip"
android:orientation="horizontal">
<ImageView
android:id="@+id/changeLog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_changelog"/>
android:background="@drawable/ic_changelog"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/authorLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_author"/>
android:background="@drawable/ic_author"
android:backgroundTint="@color/icon_grey"/>
<ImageView
android:id="@+id/supportLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:backgroundTint="@color/icon_grey"
android:background="@drawable/ic_support"/>
android:background="@drawable/ic_support"
android:backgroundTint="@color/icon_grey"/>
</LinearLayout>
@ -149,18 +152,17 @@
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/installed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:visibility="gone"
android:gravity="end"
android:layout_marginEnd="@dimen/card_imageview_margin"
android:layout_marginStart="@dimen/card_imageview_margin"
android:focusable="false"
android:gravity="end"
android:visibility="gone"
/>
</RelativeLayout>

View File

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_marginBottom="8dp"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
@ -20,6 +21,7 @@
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
@ -70,6 +72,7 @@
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
@ -121,6 +124,7 @@
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout

View File

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_marginBottom="8dp"
android:layout_marginTop="?attr/actionBarSize">
@ -23,6 +24,7 @@
android:layout_height="wrap_content"
android:elevation="2dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardCornerRadius="0dp">
<Switch
@ -41,6 +43,7 @@
android:layout_height="wrap_content"
android:elevation="2dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardCornerRadius="0dp">
<Switch
@ -60,6 +63,7 @@
android:layout_height="wrap_content"
android:elevation="2dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardCornerRadius="0dp">
<Switch
@ -82,6 +86,7 @@
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
@ -126,6 +131,7 @@
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
@ -162,6 +168,7 @@
android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
android:visibility="gone"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout

View File

@ -5,5 +5,5 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/AppTheme.Toolbar"/>
/>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="themes">
<item>"Default"</item>
<item>"Dark"</item>
</string-array>
</resources>

View File

@ -20,6 +20,12 @@
<declare-styleable name="RowItem">
<attr name="icon" format="reference"/>
<attr name="text" format="string"/>
<attr name="cardStyle" format="reference"/>
<attr name="navStyle" format="reference"/>
<attr name="ColorOK" format="reference"/>
<attr name="ColorWarn" format="reference"/>
<attr name="ColorFail" format="reference"/>
<attr name="ColorNeutral" format="reference"/>
</declare-styleable>
</resources>

View File

@ -11,5 +11,20 @@
<color name="green500">#4CAF50</color>
<color name="blue500">#2196F3</color>
<color name="grey500">#9E9E9E</color>
<color name="yellow500">#FFC107</color>
<color name="dh_primary">#3F51B5</color>
<color name="dh_primary_dark">#303F9F</color>
<color name="dh_primary_light">#C5CAE9</color>
<color name="dh_accent">#03A9F4</color>
<color name="dh_primary_text">#dedede</color>
<color name="dh_secondary_text">#8A8A8A</color>
<color name="dh_icons">#000000</color>
<color name="dh_divider">#424242</color>
<color name="dh_alertWarn">#FF9800</color>
<color name="dh_alertOk">#2196F3</color>
<color name="dh_alertNeutral">#2196F3</color>
<color name="dh_alertFail">#FF5722</color>
</resources>

View File

@ -127,4 +127,5 @@
<string name="auto_toggle_apps">Auto-toggle List</string>
<string name="toast_error_makedir">Error creating directory, could not download file.</string>
<string name="toast_error_removing_files">Error removing old files, cancelled.</string>
<string name="settings_general_title">General</string>
</resources>

View File

@ -7,10 +7,14 @@
<item name="colorAccent">@color/accent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="cardStyle">@style/CardViewStyle.Light</item>
<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.Toolbar" parent="ThemeOverlay.AppCompat.Light">
@ -20,6 +24,45 @@
<item name="android:textColorSecondary">@color/primary_text</item> <!-- force -->
<item name="actionMenuTextColor">@color/icons</item>
</style>
<style name="AppTheme.dh" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorPrimary">@color/dh_primary</item>
<item name="colorPrimaryDark">@color/dh_primary_dark</item>
<item name="colorAccent">@color/dh_accent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="cardBackgroundColor">@color/dh_accent</item>
<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="ColorOK">@color/dh_alertOk</item>
<item name="ColorWarn">@color/dh_alertWarn</item>
<item name="ColorFail">@color/dh_alertFail</item>
<item name="ColorNeutral">@color/grey500</item>
</style>
<style name="AppTheme.Toolbar.dh" parent="ThemeOverlay.AppCompat.Dark">
<item name="colorPrimary">@color/dh_primary</item>
<item name="android:elevation">4dp</item>
<item name="android:textColorPrimary">@color/dh_primary_text</item>
<item name="android:textColorSecondary">@color/dh_primary_text</item> <!-- force -->
<item name="actionMenuTextColor">@color/dh_icons</item>
</style>
<style name="CardViewStyle.Dark" parent="CardView">
<item name="cardBackgroundColor">@android:color/background_dark</item>
</style>
<style name="CardViewStyle.Light" parent="CardView">
<item name="cardBackgroundColor">@android:color/background_light</item>
</style>
<style name="AppTheme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
</style>

View File

@ -1,7 +1,16 @@
<PreferenceScreen
android:layout_marginTop="?attr/actionBarSize"
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/settings_general_title">
<ListPreference
android:key="theme"
android:title="Theme"
android:summary="Select a theme"
android:entries="@array/themes"
android:entryValues="@array/themes"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/settings_quicksettings_category">