Code cleanup, fixing thangs...
This commit is contained in:
parent
c56dd4172e
commit
17749bb14a
@ -102,8 +102,9 @@ public class MagiskFragment extends Fragment {
|
||||
magiskStatusContainer.setBackgroundColor(colorOK);
|
||||
magiskStatusIcon.setImageResource(statusOK);
|
||||
|
||||
magiskVersion.setTextColor(colorOK);
|
||||
|
||||
magiskVersion.setText(getString(R.string.magisk_version, String.valueOf(Utils.magiskVersion)));
|
||||
magiskVersion.setTextColor(colorOK);
|
||||
}
|
||||
|
||||
if (Utils.remoteMagiskVersion == -1) {
|
||||
@ -115,55 +116,55 @@ public class MagiskFragment extends Fragment {
|
||||
|
||||
appCheckUpdatesStatus.setText(R.string.cannot_check_updates);
|
||||
magiskCheckUpdatesStatus.setText(R.string.cannot_check_updates);
|
||||
magiskCheckUpdatesStatus.setTextColor(colorWarn);
|
||||
} else {
|
||||
if (Utils.remoteMagiskVersion > Utils.magiskVersion) {
|
||||
magiskCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
||||
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(Utils.remoteMagiskVersion)));
|
||||
magiskCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
magiskUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(Utils.remoteMagiskVersion), Utils.magiskChangelog))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> {
|
||||
Utils.downloadAndReceive(
|
||||
getActivity(),
|
||||
new Utils.DownloadReceiver(getString(R.string.magisk)) {
|
||||
@Override
|
||||
public void task(File file) {
|
||||
new Async.FlashZIP(mContext, mName, file.getPath()).execute();
|
||||
}
|
||||
},
|
||||
Utils.magiskLink, "latest_magisk.zip");
|
||||
})
|
||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
||||
getActivity(),
|
||||
new Utils.DownloadReceiver(getString(R.string.magisk)) {
|
||||
@Override
|
||||
public void task(File file) {
|
||||
new Async.FlashZIP(mContext, mName, file.getPath()).execute();
|
||||
}
|
||||
},
|
||||
Utils.magiskLink, "latest_magisk.zip"))
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
.show());
|
||||
} else {
|
||||
magiskCheckUpdatesContainer.setBackgroundColor(colorOK);
|
||||
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle);
|
||||
magiskCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.magisk)));
|
||||
magiskCheckUpdatesStatus.setTextColor(colorOK);
|
||||
}
|
||||
|
||||
if (Utils.remoteAppVersion > BuildConfig.VERSION_CODE) {
|
||||
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, String.valueOf(Utils.remoteAppVersion)));
|
||||
appCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
appUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), String.valueOf(Utils.remoteAppVersion), Utils.appChangelog))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> {
|
||||
Utils.downloadAndReceive(getActivity(),
|
||||
new Utils.DownloadReceiver() {
|
||||
@Override
|
||||
public void task(File file) {
|
||||
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.setData(FileProvider.getUriForFile(mContext, "com.topjohnwu.magisk.provider", file));
|
||||
mContext.startActivity(install);
|
||||
}
|
||||
},
|
||||
Utils.appLink, "latest_manager.apk");
|
||||
})
|
||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(getActivity(),
|
||||
new Utils.DownloadReceiver() {
|
||||
@Override
|
||||
public void task(File file) {
|
||||
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.setData(FileProvider.getUriForFile(mContext, "com.topjohnwu.magisk.provider", file));
|
||||
mContext.startActivity(install);
|
||||
}
|
||||
},
|
||||
Utils.appLink, "latest_manager.apk"))
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
.show()
|
||||
);
|
||||
@ -171,6 +172,8 @@ public class MagiskFragment extends Fragment {
|
||||
appCheckUpdatesContainer.setBackgroundColor(colorOK);
|
||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle);
|
||||
appCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.app_name)));
|
||||
appCheckUpdatesStatus.setTextColor(colorOK);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -21,12 +20,10 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@ -36,7 +33,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
|
||||
private final Handler mDrawerHandler = new Handler();
|
||||
private String currentTitle;
|
||||
private View mView;
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@ -51,7 +47,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme","");
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dh("MainActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
@ -113,8 +109,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
@ -145,45 +139,22 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
}
|
||||
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
mView = getToolbarNavigationButton();
|
||||
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if(extras != null) {
|
||||
if (extras != null) {
|
||||
navigate(R.id.settings);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ImageButton getToolbarNavigationButton() {
|
||||
int size = toolbar.getChildCount();
|
||||
for (int i = 0; i < size; i++) {
|
||||
View child = toolbar.getChildAt(i);
|
||||
if (child instanceof ImageButton) {
|
||||
ImageButton btn = (ImageButton) child;
|
||||
if (btn.getDrawable() == toolbar.getNavigationIcon()) {
|
||||
return btn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
}
|
||||
|
||||
private void startTour() {
|
||||
navigate(R.id.root);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
@ -2,12 +2,8 @@ package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -21,7 +17,6 @@ import com.topjohnwu.magisk.module.Repo;
|
||||
import com.topjohnwu.magisk.module.RepoHelper;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.wooplr.spotlight.SpotlightView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -31,8 +26,6 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
import static com.topjohnwu.magisk.R.menu.drawer;
|
||||
|
||||
public class ReposFragment extends Fragment {
|
||||
|
||||
public static List<Repo> mListRepos = new ArrayList<>();
|
||||
@ -104,7 +97,7 @@ public class ReposFragment extends Fragment {
|
||||
super.onAttachFragment(childFragment);
|
||||
}
|
||||
|
||||
private void LoadRepo (boolean doReload) {
|
||||
private void LoadRepo(boolean doReload) {
|
||||
RepoHelper.TaskDelegate taskDelegate = result -> {
|
||||
if (result.equals("Complete")) {
|
||||
Log.d("Magisk", "ReposFragment, got delegate");
|
||||
@ -159,23 +152,20 @@ public class ReposFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LoadRepo(false);
|
||||
getActivity().setTitle("Magisk");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected List<Repo> listRepos() {
|
||||
return mListRepos;
|
||||
}
|
||||
|
||||
private void UpdateUI() {
|
||||
Log.d("Magisk","ReposFragment: UpdateUI Called, size is " + listRepos().size());
|
||||
Log.d("Magisk", "ReposFragment: UpdateUI Called, size is " + listRepos().size());
|
||||
|
||||
if (listRepos().size() == 0) {
|
||||
emptyTv.setVisibility(View.VISIBLE);
|
||||
@ -190,13 +180,6 @@ public class ReposFragment extends Fragment {
|
||||
NotifyOfAlerts();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,12 +30,9 @@ import com.topjohnwu.magisk.utils.Utils;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
@ -8,7 +8,6 @@ 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;
|
||||
@ -19,11 +18,12 @@ import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private CheckBoxPreference quickTilePreference;
|
||||
private ListPreference themePreference;
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
||||
|
||||
public SettingsFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -69,7 +69,6 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
|
||||
hideRootNotificationPreference.setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
Preference.OnPreferenceClickListener preferenceClickListener = preference -> {
|
||||
if (preference == quickTilePreference) {
|
||||
boolean isChecked = quickTilePreference.isChecked();
|
||||
@ -84,10 +83,6 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
quickTilePreference.setOnPreferenceClickListener(preferenceClickListener);
|
||||
// calculate margins
|
||||
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
@ -100,19 +95,16 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
|
||||
|
||||
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
|
||||
|
||||
|
||||
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,"");
|
||||
String pref = sharedPreferences.getString(key, "");
|
||||
|
||||
themePreference.setSummary(pref);
|
||||
if (pref.equals("Dark")) {
|
||||
@ -123,15 +115,12 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
|
||||
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");
|
||||
intent.putExtra("Relaunch", "Settings");
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
Logger.dh("SettingsFragment: theme is " + pref);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -42,8 +42,13 @@ public class SplashActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
// Set up toggle states based on preferences, start services, disable root if set
|
||||
|
||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||
if (!Utils.hasServicePermission(getApplicationContext())) {
|
||||
Utils.toggleAutoRoot(false,getApplicationContext());
|
||||
}
|
||||
}
|
||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||
|
||||
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||
getApplication().startService(myIntent);
|
||||
|
@ -2,6 +2,7 @@
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="?attr/cardStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -10,7 +11,6 @@
|
||||
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">
|
||||
|
||||
@ -19,7 +19,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:padding="@dimen/card_layout_padding">
|
||||
android:padding="@dimen/card_layout_padding"
|
||||
android:paddingEnd="@dimen/card_layout_padding"
|
||||
android:paddingStart="@dimen/card_layout_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
@ -115,7 +117,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/description"
|
||||
android:minHeight="@dimen/min_rowheight"
|
||||
android:minHeight="70dp"
|
||||
android:orientation="vertical"
|
||||
|
||||
>
|
||||
@ -141,7 +143,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dip"
|
||||
android:layout_height="40dip"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="0dip"
|
||||
android:orientation="horizontal">
|
||||
|
@ -24,6 +24,7 @@
|
||||
<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>
|
||||
@ -37,6 +38,7 @@
|
||||
<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/YourAlertDialogTheme</item>
|
||||
<item name="ColorOK">@color/dh_alertOk</item>
|
||||
<item name="ColorWarn">@color/dh_alertWarn</item>
|
||||
<item name="ColorFail">@color/dh_alertFail</item>
|
||||
@ -58,6 +60,16 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="YourAlertDialogTheme">
|
||||
<item name="android:textColor">@color/dh_primary_text</item>
|
||||
<item name="android:textColorSecondary">@color/dh_primary_text</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
|
||||
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<style name="CardViewStyle.Light" parent="CardView">
|
||||
|
Loading…
Reference in New Issue
Block a user