Various small improvements

This commit is contained in:
topjohnwu 2016-12-11 20:38:15 +08:00
parent c9217a419a
commit 3c33f7d294
12 changed files with 61 additions and 73 deletions

View File

@ -1,13 +1,13 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 24 compileSdkVersion 25
buildToolsVersion "24.0.2" buildToolsVersion "25.0.1"
defaultConfig { defaultConfig {
applicationId "com.topjohnwu.magisk" applicationId "com.topjohnwu.magisk"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 24 targetSdkVersion 25
versionCode 7 versionCode 7
versionName "2.5" versionName "2.5"
jackOptions { jackOptions {
@ -19,8 +19,13 @@ android {
} }
} }
compileOptions {
incremental false
}
buildTypes { buildTypes {
release { release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
@ -44,11 +49,10 @@ repositories {
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:24.2.1' compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:24.2.1' compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.android.support:design:24.2.1' compile 'com.android.support:design:25.0.1'
compile 'com.jakewharton:butterknife:8.4.0' compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.github.michalis-vitos:aFileChooser:master'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.clans:fab:1.6.4' compile 'com.github.clans:fab:1.6.4'
compile 'com.madgag.spongycastle:core:1.54.0.0' compile 'com.madgag.spongycastle:core:1.54.0.0'

View File

@ -15,3 +15,29 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *; # public *;
#} #}
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.topjohnwu.magisk.module.** { *; }
-keep class com.topjohnwu.magisk.utils.ModuleHelper$ValueSortedMap { *; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

View File

@ -4,8 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.kcoppock.broadcasttilesupport" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -36,33 +34,6 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name="com.ipaulpro.afilechooser.FileChooserActivity"
android:enabled="true"
android:exported="true"
android:icon="@drawable/ic_chooser"
android:label="@string/choose_file">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<provider
android:name="com.ianhanniballake.localstorage.LocalStorageProvider"
android:authorities="com.topjohnwu.magisk.documents"
android:enabled="@bool/use_provider"
android:exported="true"
android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS">
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
<activity <activity
android:name=".AboutActivity" android:name=".AboutActivity"

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk; package com.topjohnwu.magisk;
import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -15,7 +16,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.github.clans.fab.FloatingActionButton; import com.github.clans.fab.FloatingActionButton;
import com.ipaulpro.afilechooser.utils.FileUtils;
import com.topjohnwu.magisk.adapters.ModulesAdapter; import com.topjohnwu.magisk.adapters.ModulesAdapter;
import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Async;
@ -48,10 +48,9 @@ public class ModulesFragment extends Fragment {
ButterKnife.bind(this, mView); ButterKnife.bind(this, mView);
fabio.setOnClickListener(v -> { fabio.setOnClickListener(v -> {
Intent getContentIntent = FileUtils.createGetContentIntent(null); Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
getContentIntent.setType("application/zip"); intent.setType("application/zip");
Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file"); startActivityForResult(intent, FETCH_ZIP_CODE);
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
}); });
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
@ -80,7 +79,7 @@ public class ModulesFragment extends Fragment {
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) { if (requestCode == FETCH_ZIP_CODE && resultCode == Activity.RESULT_OK && data != null) {
// Get the URI of the selected file // Get the URI of the selected file
final Uri uri = data.getData(); final Uri uri = data.getData();
new Async.FlashZIP(getActivity(), uri).exec(); new Async.FlashZIP(getActivity(), uri).exec();

View File

@ -69,23 +69,24 @@ public class SettingsActivity extends AppCompatActivity {
} }
} }
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static class SettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
private ListPreference themePreference; private ListPreference themePreference;
private SharedPreferences prefs;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.app_settings); addPreferencesFromResource(R.xml.app_settings);
PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false); PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
themePreference = (ListPreference) findPreference("theme"); themePreference = (ListPreference) findPreference("theme");
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox"); CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide"); CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
CheckBoxPreference hostsPreference = (CheckBoxPreference) findPreference("hosts"); CheckBoxPreference hostsPreference = (CheckBoxPreference) findPreference("hosts");
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
themePreference.setSummary(themePreference.getValue()); themePreference.setSummary(themePreference.getValue());
if (MagiskFragment.magiskVersion < 9) { if (MagiskFragment.magiskVersion < 9) {
@ -103,23 +104,23 @@ public class SettingsActivity extends AppCompatActivity {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this); prefs.unregisterOnSharedPreferenceChangeListener(this);
} }
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
Logger.dev("Settings: Prefs change " + key); Logger.dev("Settings: Prefs change " + key);
boolean checked; boolean checked;
switch (key) { switch (key) {
case "theme": case "theme":
String theme = sharedPreferences.getString(key, ""); String theme = prefs.getString(key, "");
themePreference.setSummary(theme); themePreference.setSummary(theme);
if (theme.equals("Dark")) { if (theme.equals("Dark")) {
@ -133,7 +134,7 @@ public class SettingsActivity extends AppCompatActivity {
startActivity(intent); startActivity(intent);
break; break;
case "magiskhide": case "magiskhide":
checked = sharedPreferences.getBoolean("magiskhide", false); checked = prefs.getBoolean("magiskhide", false);
if (checked) { if (checked) {
new Async.RootTask<Void, Void, Void>() { new Async.RootTask<Void, Void, Void>() {
@Override @Override
@ -151,9 +152,10 @@ public class SettingsActivity extends AppCompatActivity {
} }
}.exec(); }.exec();
} }
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break; break;
case "busybox": case "busybox":
checked = sharedPreferences.getBoolean("busybox", false); checked = prefs.getBoolean("busybox", false);
if (checked) { if (checked) {
new Async.RootTask<Void, Void, Void>() { new Async.RootTask<Void, Void, Void>() {
@Override @Override
@ -174,7 +176,7 @@ public class SettingsActivity extends AppCompatActivity {
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break; break;
case "hosts": case "hosts":
checked = sharedPreferences.getBoolean("hosts", false); checked = prefs.getBoolean("hosts", false);
if (checked) { if (checked) {
new Async.RootTask<Void, Void, Void>() { new Async.RootTask<Void, Void, Void>() {
@Override @Override
@ -195,10 +197,10 @@ public class SettingsActivity extends AppCompatActivity {
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break; break;
case "developer_logging": case "developer_logging":
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false); Logger.devLog = prefs.getBoolean("developer_logging", false);
break; break;
case "shell_logging": case "shell_logging":
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false); Logger.logShell = prefs.getBoolean("shell_logging", false);
break; break;
} }

View File

@ -82,7 +82,7 @@ public class ModuleHelper {
} }
// Making a request to url and getting response // Making a request to url and getting response
jsonString = WebRequest.makeWebServiceCall(context.getString(R.string.url_main) + Utils.getToken(), WebRequest.GET); jsonString = WebRequest.makeWebServiceCall(context.getString(R.string.url_main, Utils.getToken()), WebRequest.GET);
if (jsonString != null && !jsonString.isEmpty()) { if (jsonString != null && !jsonString.isEmpty()) {
// Have internet access // Have internet access

View File

@ -79,9 +79,6 @@
<string name="no_magisk_msg">Wollen Sie Magisk herunterladen und installieren?</string> <string name="no_magisk_msg">Wollen Sie Magisk herunterladen und installieren?</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 Fragment --> <!--Settings Fragment -->
<string name="settings_general_category">Allgemein</string> <string name="settings_general_category">Allgemein</string>

View File

@ -81,9 +81,6 @@
<string name="no_magisk_msg">¿Deseas descargar e instalar Magisk?</string> <string name="no_magisk_msg">¿Deseas descargar e instalar 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">General</string> <string name="settings_general_category">General</string>

View File

@ -79,9 +79,6 @@
<string name="no_magisk_msg">Vuoi scaricare ed installare Magisk?</string> <string name="no_magisk_msg">Vuoi scaricare ed installare 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 Fragment --> <!--Settings Fragment -->
<string name="settings_general_category">Generali</string> <string name="settings_general_category">Generali</string>

View File

@ -79,9 +79,6 @@
<string name="no_magisk_msg">Wilt u Magisk downloaden en installeren?</string> <string name="no_magisk_msg">Wilt u Magisk downloaden en installeren?</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 Fragment --> <!--Settings Fragment -->
<string name="settings_general_category">Algemeen</string> <string name="settings_general_category">Algemeen</string>
@ -97,6 +94,7 @@
<string name="settings_shell_logging_summary">Schakel dit in om alle shell commands en output te loggen</string> <string name="settings_shell_logging_summary">Schakel dit in om alle shell commands en output te loggen</string>
<string name="settings_magiskhide_title">Magisk verbergen</string> <string name="settings_magiskhide_title">Magisk verbergen</string>
<string name="settings_magiskhide_summary">Reboot om de instellingen toe te passen</string> <string name="settings_magiskhide_summary">Reboot om de instellingen toe te passen</string>
<string name="zip_install_unzip_zip_msg"></string>
<!-- Strings related to Settings --> <!-- Strings related to Settings -->

View File

@ -77,9 +77,6 @@
<string name="no_magisk_msg">Você quer baixar e instalar o Magisk?</string> <string name="no_magisk_msg">Você quer baixar e instalar o 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 Fragment --> <!--Settings Fragment -->
<string name="settings_general_category">Geral</string> <string name="settings_general_category">Geral</string>

View File

@ -86,9 +86,9 @@
<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>
<!--URL Templates--> <!--URL Templates-->
<string name="url_main">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=</string> <string name="url_main" translatable="false">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=%1$s</string>
<string name="file_url">https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s</string> <string name="file_url" translatable="false">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> <string name="zip_url" translatable="false">https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip</string>
<!--Settings Activity --> <!--Settings Activity -->
<string name="settings_general_category">General</string> <string name="settings_general_category">General</string>