This commit is contained in:
NekoInverter 2020-03-14 19:58:19 +08:00
parent 196098ab6a
commit 19c03a1852
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
20 changed files with 105 additions and 182 deletions

View File

@ -219,34 +219,32 @@ public class BaseActivity extends AppCompatActivity {
switch (item.getItemId()) {
case R.id.dexopt_all:
areYouSure(R.string.take_while_cannot_resore, (dialog, which) -> {
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.dexopt_now)
.setMessage(R.string.this_may_take_a_while)
.setCancelable(false)
.show();
new Thread("dexopt") {
@Override
public void run() {
if (!Shell.rootAccess()) {
dialog.dismiss();
NavUtil.showMessage(BaseActivity.this, getString(R.string.root_failed));
return;
}
Shell.su("cmd package bg-dexopt-job").exec();
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.dexopt_now)
.setMessage(R.string.this_may_take_a_while)
.setCancelable(false)
.show();
new Thread("dexopt") {
@Override
public void run() {
if (!Shell.rootAccess()) {
dialog.dismiss();
NavUtil.showMessage(BaseActivity.this, getString(R.string.root_failed));
return;
}
dialog.dismiss();
XposedApp.runOnUiThread(() -> Toast.makeText(BaseActivity.this, R.string.done, Toast.LENGTH_LONG).show());
}
}.start();
Shell.su("cmd package bg-dexopt-job").exec();
dialog.dismiss();
XposedApp.runOnUiThread(() -> Toast.makeText(BaseActivity.this, R.string.done, Toast.LENGTH_LONG).show());
}
);
}.start();
});
break;
case R.id.speed_all:
areYouSure(R.string.take_while_cannot_resore, (dialog, which) -> {
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.dexopt_now)
.setTitle(R.string.speed_now)
.setMessage(R.string.this_may_take_a_while)
.setCancelable(false)
.show();
@ -264,51 +262,26 @@ public class BaseActivity extends AppCompatActivity {
dialog.dismiss();
XposedApp.runOnUiThread(() -> Toast.makeText(BaseActivity.this, R.string.done, Toast.LENGTH_LONG).show());
}
};
});
break;
case R.id.reboot:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.reboot, (dialog, which) -> reboot(null));
} else {
reboot(null);
}
areYouSure(R.string.reboot, (dialog, which) -> reboot(null));
break;
case R.id.soft_reboot:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.soft_reboot, (dialog, which) -> softReboot());
} else {
softReboot();
}
areYouSure(R.string.soft_reboot, (dialog, which) -> softReboot());
break;
case R.id.reboot_recovery:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.reboot_recovery, (dialog, which) -> reboot("recovery"));
} else {
reboot("recovery");
}
reboot("recovery");
break;
case R.id.reboot_bootloader:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.reboot_bootloader, (dialog, which) -> reboot("bootloader"));
} else {
reboot("bootloader");
}
reboot("bootloader");
break;
case R.id.reboot_download:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.reboot_download, (dialog, which) -> reboot("download"));
} else {
reboot("download");
}
reboot("download");
break;
case R.id.reboot_edl:
if (XposedApp.getPreferences().getBoolean("confirm_reboots", true)) {
areYouSure(R.string.reboot_download, (dialog, which) -> reboot("edl"));
} else {
reboot("edl");
}
reboot("edl");
break;
}

View File

@ -172,7 +172,7 @@ public class DownloadActivity extends BaseActivity implements RepoLoader.RepoLis
private void reloadItems() {
runOnUiThread(() -> {
adapter.swapCursor(RepoDb.queryModuleOverview(sortingOrder, filterText));
adapter.changeCursor(RepoDb.queryModuleOverview(sortingOrder, filterText));
TransitionManager.beginDelayedTransition(binding.recyclerView);
adapter.notifyDataSetChanged();
});
@ -231,7 +231,7 @@ public class DownloadActivity extends BaseActivity implements RepoLoader.RepoLis
private String[] sectionHeaders;
DownloadsAdapter(Context context, Cursor cursor) {
super(context, cursor);
super(cursor);
this.context = context;
prefs = context.getSharedPreferences("update_ignored", MODE_PRIVATE);

View File

@ -501,10 +501,18 @@ public class SettingsActivity extends BaseActivity {
}
private void updatePreference(boolean show) {
findPreference("black_dark_theme").setVisible(show);
findPreference("transparent_status_bar").setVisible(show);
//findPreference("accent_color").setVisible(show);
findPreference("colorized_action_bar").setVisible(show);
Preference black_dark_theme = findPreference("black_dark_theme");
if (black_dark_theme != null) {
black_dark_theme.setVisible(show);
}
Preference transparent_status_bar = findPreference("transparent_status_bar");
if (transparent_status_bar != null) {
transparent_status_bar.setVisible(show);
}
Preference colorized_action_bar = findPreference("colorized_action_bar");
if (colorized_action_bar != null) {
colorized_action_bar.setVisible(show);
}
}
@Override

View File

@ -1,6 +1,5 @@
package org.meowcat.edxposed.manager.adapters;
import android.content.Context;
import android.database.Cursor;
import android.database.DataSetObserver;
@ -9,9 +8,6 @@ import androidx.recyclerview.widget.RecyclerView;
public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
@SuppressWarnings("FieldCanBeLocal")
private Context context;
private Cursor cursor;
private boolean dataValid;
@ -20,8 +16,7 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
private DataSetObserver dataSetObserver;
public CursorRecyclerViewAdapter(Context context, Cursor cursor) {
this.context = context;
public CursorRecyclerViewAdapter(Cursor cursor) {
this.cursor = cursor;
dataValid = cursor != null;
rowIdColumn = dataValid ? cursor.getColumnIndex("_id") : -1;
@ -31,7 +26,7 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
}
}
public Cursor getCursor() {
protected Cursor getCursor() {
return cursor;
}
@ -85,7 +80,7 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
* {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
* closed.
*/
public Cursor swapCursor(Cursor newCursor) {
private Cursor swapCursor(Cursor newCursor) {
if (newCursor == cursor) {
return null;
}

View File

@ -7,7 +7,6 @@ import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LevelListDrawable;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.util.Log;
@ -16,6 +15,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.text.HtmlCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
@ -51,34 +51,32 @@ public class RepoParser {
public static Spanned parseSimpleHtml(final Context context, String source, final TextView textView) {
source = source.replaceAll("<li>", "\t\u0095 ");
source = source.replaceAll("</li>", "<br>");
Spanned html = Html.fromHtml(source, new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
LevelListDrawable levelListDrawable = new LevelListDrawable();
final Drawable[] drawable = new Drawable[1];
Glide.with(context).asBitmap().load(source).into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
try {
drawable[0] = new BitmapDrawable(context.getResources(), bitmap);
Point size = new Point();
((Activity) context).getWindowManager().getDefaultDisplay().getSize(size);
int multiplier = size.x / bitmap.getWidth();
if (multiplier <= 0) multiplier = 1;
levelListDrawable.addLevel(1, 1, drawable[0]);
levelListDrawable.setBounds(0, 0, bitmap.getWidth() * multiplier, bitmap.getHeight() * multiplier);
levelListDrawable.setLevel(1);
textView.setText(textView.getText());
} catch (Exception ignored) { /* Like a null bitmap, etc. */
}
}
Spanned html = HtmlCompat.fromHtml(source, HtmlCompat.FROM_HTML_MODE_LEGACY, source1 -> {
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
LevelListDrawable levelListDrawable = new LevelListDrawable();
final Drawable[] drawable = new Drawable[1];
Glide.with(context).asBitmap().load(source1).into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
try {
drawable[0] = new BitmapDrawable(context.getResources(), bitmap);
Point size = new Point();
((Activity) context).getWindowManager().getDefaultDisplay().getSize(size);
int multiplier = size.x / bitmap.getWidth();
if (multiplier <= 0) multiplier = 1;
levelListDrawable.addLevel(1, 1, drawable[0]);
levelListDrawable.setBounds(0, 0, bitmap.getWidth() * multiplier, bitmap.getHeight() * multiplier);
levelListDrawable.setLevel(1);
textView.setText(textView.getText());
} catch (Exception ignored) { /* Like a null bitmap, etc. */
}
});
return drawable[0];
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
return drawable[0];
}, null);
// trim trailing newlines

View File

@ -6,11 +6,9 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import androidx.core.content.FileProvider;
@ -23,7 +21,6 @@ import org.meowcat.edxposed.manager.XposedApp;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
public class InstallApkUtil extends AsyncTask<Void, Void, Integer> {
@ -44,9 +41,6 @@ public class InstallApkUtil extends AsyncTask<Void, Void, Integer> {
try {
if (info.labelRes > 0) {
Resources res = pm.getResourcesForApplication(info);
Configuration config = new Configuration();
config.setLocale(Locale.getDefault());
res.updateConfiguration(config, res.getDisplayMetrics());
return res.getString(info.labelRes);
}
} catch (Exception ignored) {
@ -58,12 +52,8 @@ public class InstallApkUtil extends AsyncTask<Void, Void, Integer> {
Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri;
if (Build.VERSION.SDK_INT >= 24) {
uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", new File(localFilename));
installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
uri = Uri.fromFile(new File(localFilename));
}
uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", new File(localFilename));
installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
installIntent.setDataAndType(uri, DownloadsUtil.MIME_TYPE_APK);
installIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, context.getApplicationInfo().packageName);
context.startActivity(installIntent);

View File

@ -40,7 +40,7 @@ public final class ModuleUtil {
private final String frameworkPackageName;
private final List<ModuleListener> listeners = new CopyOnWriteArrayList<>();
private SharedPreferences pref;
private InstalledModule framework = null;
//private InstalledModule framework = null;
private Map<String, InstalledModule> installedModules;
private boolean isReloading = false;
private Toast toast;
@ -93,9 +93,9 @@ public final class ModuleUtil {
if (app.metaData != null && app.metaData.containsKey("xposedmodule")) {
installed = new InstalledModule(pkg, false);
modules.put(pkg.packageName, installed);
} else if (isFramework(pkg.packageName)) {
}/* else if (isFramework(pkg.packageName)) {
framework = installed = new InstalledModule(pkg, true);
}
}*/
if (installed != null)
RepoDb.insertInstalledModule(installed);
@ -156,17 +156,17 @@ public final class ModuleUtil {
return isReloading;
}
public InstalledModule getFramework() {
/* public InstalledModule getFramework() {
return framework;
}
}*/
public String getFrameworkPackageName() {
return frameworkPackageName;
}
private boolean isFramework(String packageName) {
/* private boolean isFramework(String packageName) {
return frameworkPackageName.equals(packageName);
}
}*/
// public boolean isInstalled(String packageName) {
// return installedModules.containsKey(packageName) || isFramework(packageName);

View File

@ -35,7 +35,7 @@ public class PrefixedSharedPreferences implements SharedPreferences {
@Override
public Map<String, ?> getAll() {
Map<String, ?> baseResult = mBase.getAll();
Map<String, Object> prefixedResult = new HashMap<String, Object>(baseResult);
Map<String, Object> prefixedResult = new HashMap<>(baseResult);
for (Entry<String, ?> entry : baseResult.entrySet()) {
prefixedResult.put(mPrefix + entry.getKey(), entry.getValue());
}

View File

@ -29,12 +29,12 @@ public class JSONUtils {
return sb.toString();
}
public class XposedJson {
public static class XposedJson {
public List<XposedTab> tabs;
public ApkRelease apk;
}
public class ApkRelease {
public static class ApkRelease {
public String version;
public String changelog;
public String link;

File diff suppressed because one or more lines are too long

View File

@ -7,10 +7,19 @@
android:clipChildren="false"
android:clipToPadding="false">
<androidx.viewpager.widget.ViewPager
android:id="@+id/download_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?actionBarTheme">
android:theme="?actionBarTheme"
app:liftOnScroll="false">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
@ -28,13 +37,4 @@
app:tabMode="fixed" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/download_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -188,9 +188,6 @@
android:layout_height="wrap_content"
android:layout_below="@id/container"
android:layout_marginTop="4dp"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -305,9 +302,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/updateDescription"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"

View File

@ -24,9 +24,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -62,9 +59,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -100,9 +94,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -137,9 +128,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -173,9 +161,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -208,9 +193,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
@ -243,10 +225,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"
android:paddingHorizontal="16dp">
@ -303,9 +283,6 @@
android:id="@+id/click_to_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?roundBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal"

View File

@ -22,16 +22,16 @@
<item
android:id="@+id/menu_scroll_top"
android:title="@string/scroll_top"
app:showAsAction="ifRoom" />
app:showAsAction="never" />
<item
android:id="@+id/menu_scroll_down"
android:title="@string/scroll_bottom"
app:showAsAction="ifRoom" />
app:showAsAction="never" />
<item
android:id="@+id/menu_clear"
android:title="@string/menuClearLog"
app:showAsAction="ifRoom" />
app:showAsAction="never" />
</menu>

View File

@ -1,10 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>

View File

@ -6,7 +6,7 @@
android:id="@+id/menu_search"
android:title="@string/menuSearch"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="always" />
app:showAsAction="ifRoom" />
<item
android:title="@string/export_"

View File

@ -301,5 +301,5 @@
<string name="accent_color">强调色</string>
<string name="colorized_action_bar">着色应用栏</string>
<string name="settings_group_theme">主题</string>
<string name="material_design_2">质感设计 2</string>
<string name="material_design_2">惨白设计</string>
</resources>

View File

@ -42,7 +42,7 @@
<item name="android:colorBackground">@color/colorBackground_md2</item>
<item name="android:windowBackground">@color/colorBackground_md2</item>
<item name="modulesHorizontalPadding">16dp</item>
<item name="downloadVerticalPadding">8dp</item>
<item name="downloadVerticalPadding">12dp</item>
<item name="listItemBackground">@drawable/item_background_md2</item>
<item name="roundBackground">@drawable/item_background_md2</item>
<item name="liftOnScroll">true</item>

View File

@ -2,7 +2,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="group_app"
android:title="@string/settings_group_app"
app:iconSpaceReserved="false">
@ -70,7 +69,6 @@
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:key="group_download"
android:title="@string/settings_group_download"
app:iconSpaceReserved="false">

View File

@ -1,13 +1,11 @@
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:enabled="true"
android:icon="@drawable/shortcut_ic_modules"
android:shortcutId="modules"
android:shortcutLongLabel="@string/nav_item_modules"
android:shortcutShortLabel="@string/nav_item_modules"
tools:targetApi="n_mr1">
android:shortcutShortLabel="@string/nav_item_modules">
<intent
android:action="android.intent.action.MAIN"
android:targetClass="org.meowcat.edxposed.manager.ModulesActivity"
@ -19,8 +17,7 @@
android:icon="@drawable/shortcut_ic_downloads"
android:shortcutId="downloads"
android:shortcutLongLabel="@string/nav_item_download"
android:shortcutShortLabel="@string/nav_item_download"
tools:targetApi="n_mr1">
android:shortcutShortLabel="@string/nav_item_download">
<intent
android:action="android.intent.action.MAIN"
android:targetClass="org.meowcat.edxposed.manager.DownloadActivity"