mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +00:00
Various small fixes
This commit is contained in:
parent
0f254dca13
commit
c7e64f40f9
@ -18,6 +18,7 @@ import android.support.v4.app.ActivityCompat;
|
|||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -26,6 +27,7 @@ import android.view.View;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -33,6 +35,8 @@ import butterknife.ButterKnife;
|
|||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity
|
||||||
implements NavigationView.OnNavigationItemSelectedListener, CallbackHandler.EventListener {
|
implements NavigationView.OnNavigationItemSelectedListener, CallbackHandler.EventListener {
|
||||||
|
|
||||||
|
public static AlertDialog.Builder alertBuilder = null;
|
||||||
|
|
||||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||||
|
|
||||||
private final Handler mDrawerHandler = new Handler();
|
private final Handler mDrawerHandler = new Handler();
|
||||||
@ -54,6 +58,9 @@ public class MainActivity extends AppCompatActivity
|
|||||||
Logger.dev("MainActivity: Theme is " + theme);
|
Logger.dev("MainActivity: Theme is " + theme);
|
||||||
if (theme.equals("Dark")) {
|
if (theme.equals("Dark")) {
|
||||||
setTheme(R.style.AppTheme_dh);
|
setTheme(R.style.AppTheme_dh);
|
||||||
|
alertBuilder = new AlertDialog.Builder(this, R.style.AlertDialog_dh);
|
||||||
|
} else {
|
||||||
|
alertBuilder = new AlertDialog.Builder(this);
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
@ -109,6 +116,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
CallbackHandler.unRegister(StatusFragment.updateCheckDone, this);
|
CallbackHandler.unRegister(StatusFragment.updateCheckDone, this);
|
||||||
|
alertBuilder = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,24 +146,16 @@ public class MainActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onTrigger(CallbackHandler.Event event) {
|
public void onTrigger(CallbackHandler.Event event) {
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
if (StatusFragment.remoteMagiskVersion < 0) {
|
menu.findItem(R.id.install).setVisible(StatusFragment.remoteMagiskVersion > 0 &&
|
||||||
menu.findItem(R.id.install).setVisible(false);
|
Shell.rootAccess());
|
||||||
} else {
|
|
||||||
menu.findItem(R.id.install).setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkHideSection() {
|
private void checkHideSection() {
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
if (StatusFragment.magiskVersion < 0) {
|
menu.findItem(R.id.magiskhide).setVisible(StatusFragment.magiskVersion > 0 &&
|
||||||
menu.findItem(R.id.magiskhide).setVisible(false);
|
prefs.getBoolean("magiskhide", false) && Shell.rootAccess());
|
||||||
menu.findItem(R.id.modules).setVisible(false);
|
menu.findItem(R.id.modules).setVisible(StatusFragment.magiskVersion > 0);
|
||||||
menu.findItem(R.id.downloads).setVisible(false);
|
menu.findItem(R.id.downloads).setVisible(StatusFragment.magiskVersion > 0);
|
||||||
} else {
|
|
||||||
menu.findItem(R.id.modules).setVisible(true);
|
|
||||||
menu.findItem(R.id.downloads).setVisible(true);
|
|
||||||
menu.findItem(R.id.magiskhide).setVisible(prefs.getBoolean("magiskhide", false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigate(final int itemId) {
|
public void navigate(final int itemId) {
|
||||||
|
@ -60,8 +60,6 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
@BindColor(R.color.blue500) int colorInfo;
|
@BindColor(R.color.blue500) int colorInfo;
|
||||||
@BindColor(android.R.color.transparent) int trans;
|
@BindColor(android.R.color.transparent) int trans;
|
||||||
|
|
||||||
private AlertDialog.Builder builder;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
checkMagiskInfo();
|
checkMagiskInfo();
|
||||||
}
|
}
|
||||||
@ -72,15 +70,6 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
View v = inflater.inflate(R.layout.status_fragment, container, false);
|
View v = inflater.inflate(R.layout.status_fragment, container, false);
|
||||||
ButterKnife.bind(this, v);
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
||||||
|
|
||||||
String theme = prefs.getString("theme", "");
|
|
||||||
if (theme.equals("Dark")) {
|
|
||||||
builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialog_dh);
|
|
||||||
} else {
|
|
||||||
builder = new AlertDialog.Builder(getActivity());
|
|
||||||
}
|
|
||||||
|
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
magiskStatusContainer.setBackgroundColor(trans);
|
magiskStatusContainer.setBackgroundColor(trans);
|
||||||
magiskStatusIcon.setImageResource(0);
|
magiskStatusIcon.setImageResource(0);
|
||||||
@ -106,7 +95,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (magiskVersion < 0) {
|
if (magiskVersion < 0) {
|
||||||
builder
|
MainActivity.alertBuilder
|
||||||
.setTitle(R.string.no_magisk_title)
|
.setTitle(R.string.no_magisk_title)
|
||||||
.setMessage(R.string.no_magisk_msg)
|
.setMessage(R.string.no_magisk_msg)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
|
@ -9,6 +9,7 @@ import android.net.Uri;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
public abstract class DownloadReceiver extends BroadcastReceiver {
|
public abstract class DownloadReceiver extends BroadcastReceiver {
|
||||||
public Context mContext;
|
public Context mContext;
|
||||||
@ -42,6 +43,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
c.close();
|
c.close();
|
||||||
}
|
}
|
||||||
|
Utils.isDownloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDownloadID(long id) {
|
public void setDownloadID(long id) {
|
||||||
|
@ -13,6 +13,7 @@ import android.util.Log;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.InstallFragment;
|
import com.topjohnwu.magisk.InstallFragment;
|
||||||
|
import com.topjohnwu.magisk.MainActivity;
|
||||||
import com.topjohnwu.magisk.ModulesFragment;
|
import com.topjohnwu.magisk.ModulesFragment;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.ReposFragment;
|
import com.topjohnwu.magisk.ReposFragment;
|
||||||
@ -256,19 +257,10 @@ public class Async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void onSuccess() {
|
protected void onSuccess() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
|
||||||
|
|
||||||
StatusFragment.updateCheckDone.trigger();
|
StatusFragment.updateCheckDone.trigger();
|
||||||
new LoadModules().exec();
|
new LoadModules().exec();
|
||||||
|
|
||||||
AlertDialog.Builder builder;
|
MainActivity.alertBuilder
|
||||||
String theme = prefs.getString("theme", "");
|
|
||||||
if (theme.equals("Dark")) {
|
|
||||||
builder = new AlertDialog.Builder(mContext, R.style.AlertDialog_dh);
|
|
||||||
} else {
|
|
||||||
builder = new AlertDialog.Builder(mContext);
|
|
||||||
}
|
|
||||||
builder
|
|
||||||
.setTitle(R.string.reboot_title)
|
.setTitle(R.string.reboot_title)
|
||||||
.setMessage(R.string.reboot_msg)
|
.setMessage(R.string.reboot_msg)
|
||||||
.setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.sh("su -c reboot"))
|
.setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.sh("su -c reboot"))
|
||||||
|
@ -33,6 +33,8 @@ import javax.crypto.spec.DESKeySpec;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
public static boolean isDownloading = false;
|
||||||
|
|
||||||
private static final String cryptoPass = "MagiskRox666";
|
private static final String cryptoPass = "MagiskRox666";
|
||||||
private static final String secret = "GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus";
|
private static final String secret = "GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus";
|
||||||
|
|
||||||
@ -90,16 +92,25 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void dlAndReceive(Context context, DownloadReceiver receiver, String link, String filename) {
|
public static void dlAndReceive(Context context, DownloadReceiver receiver, String link, String filename) {
|
||||||
File file = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + filename);
|
if (isDownloading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File file = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + filename);
|
||||||
|
|
||||||
if ((!file.getParentFile().exists() && !file.getParentFile().mkdirs()) || (file.exists() && !file.delete())) {
|
if ((!file.getParentFile().exists() && !file.getParentFile().mkdirs()) || (file.exists() && !file.delete())) {
|
||||||
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toast.makeText(context, context.getString(R.string.downloading_toast, filename), Toast.LENGTH_LONG).show();
|
||||||
|
isDownloading = true;
|
||||||
|
|
||||||
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
|
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
|
||||||
request.setDestinationUri(Uri.fromFile(file));
|
request.setDestinationUri(Uri.fromFile(file));
|
||||||
|
@ -163,8 +163,7 @@
|
|||||||
android:id="@+id/safetyNet_icon"
|
android:id="@+id/safetyNet_icon"
|
||||||
android:layout_width="84dp"
|
android:layout_width="84dp"
|
||||||
android:layout_height="84dp"
|
android:layout_height="84dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"/>
|
||||||
android:src="@drawable/ic_check_circle"/>
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/safetyNet_check_progress"
|
android:id="@+id/safetyNet_check_progress"
|
||||||
|
@ -81,9 +81,6 @@
|
|||||||
<string name="no_magisk_msg">هل ترغب في تنزيل وتثبيت Magisk؟</string>
|
<string name="no_magisk_msg">هل ترغب في تنزيل وتثبيت Magisk؟</string>
|
||||||
|
|
||||||
<!--URL Templates-->
|
<!--URL Templates-->
|
||||||
<string name="url_main">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=</string>
|
|
||||||
<string name="file_url">https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s</string>
|
|
||||||
<string name="zip_url">https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip</string>
|
|
||||||
|
|
||||||
<!--Settings Activity -->
|
<!--Settings Activity -->
|
||||||
<string name="settings_general_category">عام</string>
|
<string name="settings_general_category">عام</string>
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
<string name="zip_install_progress_msg">"Installing %1$s …"</string>
|
<string name="zip_install_progress_msg">"Installing %1$s …"</string>
|
||||||
<string name="no_magisk_title">No Magisk Installed!</string>
|
<string name="no_magisk_title">No Magisk Installed!</string>
|
||||||
<string name="no_magisk_msg">Do you want to download and install Magisk?</string>
|
<string name="no_magisk_msg">Do you want to download and install Magisk?</string>
|
||||||
|
<string name="downloading_toast">Downloading %1$s</string>
|
||||||
|
|
||||||
<!--URL Templates-->
|
<!--URL Templates-->
|
||||||
<string name="url_main" translatable="false">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=%1$s</string>
|
<string name="url_main" translatable="false">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=%1$s</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user