diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5152a606..e69ea1bd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -201,9 +201,7 @@ dependencies { implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0-alpha03") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") - implementation("com.caverock:androidsvg-aar:1.4") implementation("com.github.bumptech.glide:glide:$glideVersion") - implementation("com.github.bumptech.glide:okhttp3-integration:$glideVersion") implementation("com.google.android.material:material:1.4.0") implementation("com.google.code.gson:gson:2.8.7") implementation("com.takisoft.preferencex:preferencex:1.1.0") diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png deleted file mode 100644 index 1837cd55..00000000 Binary files a/app/src/main/ic_launcher-playstore.png and /dev/null differ diff --git a/app/src/main/java/org/lsposed/manager/ui/fragment/HomeFragment.java b/app/src/main/java/org/lsposed/manager/ui/fragment/HomeFragment.java index b40aa11d..362c8813 100644 --- a/app/src/main/java/org/lsposed/manager/ui/fragment/HomeFragment.java +++ b/app/src/main/java/org/lsposed/manager/ui/fragment/HomeFragment.java @@ -19,6 +19,8 @@ package org.lsposed.manager.ui.fragment; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.os.Build; import android.os.Bundle; import android.text.method.LinkMovementMethod; @@ -42,7 +44,6 @@ import org.lsposed.manager.databinding.FragmentMainBinding; import org.lsposed.manager.ui.activity.base.BaseActivity; import org.lsposed.manager.ui.dialog.BlurBehindDialogBuilder; import org.lsposed.manager.ui.dialog.InfoDialogBuilder; -import org.lsposed.manager.util.GlideHelper; import org.lsposed.manager.util.ModuleUtil; import org.lsposed.manager.util.NavUtil; import org.lsposed.manager.util.chrome.LinkTransformationMethod; @@ -56,6 +57,16 @@ public class HomeFragment extends BaseFragment { private FragmentHomeBinding binding; private View snackbar; + private static PackageInfo wrap(ApplicationInfo applicationInfo, int longVersionCode) { + PackageInfo packageInfo = new PackageInfo(); + packageInfo.applicationInfo = applicationInfo; + packageInfo.versionCode = longVersionCode; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + packageInfo.setLongVersionCode(System.currentTimeMillis()); + } + return packageInfo; + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentMainBinding mainBinding = FragmentMainBinding.inflate(inflater, container, false); @@ -93,13 +104,13 @@ public class HomeFragment extends BaseFragment { binding.translators.setMovementMethod(LinkMovementMethod.getInstance()); binding.translators.setTransformationMethod(new LinkTransformationMethod(activity)); binding.translators.setText(HtmlCompat.fromHtml(getString(R.string.about_translators, getString(R.string.translators)), HtmlCompat.FROM_HTML_MODE_LEGACY)); - binding.version.setText(String.format(Locale.US, "%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); + binding.version.setText(String.format(Locale.US, "LSPosed %s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); new BlurBehindDialogBuilder(activity) .setView(binding.getRoot()) .show(); }); Glide.with(binding.appIcon) - .load(GlideHelper.wrapApplicationInfoForIconLoader(activity.getApplicationInfo())) + .load(wrap(activity.getApplicationInfo(), getResources().getConfiguration().hashCode())) .into(binding.appIcon); String installXposedVersion = ConfigManager.getXposedVersionName(); int cardBackgroundColor; diff --git a/app/src/main/java/org/lsposed/manager/util/AppModule.java b/app/src/main/java/org/lsposed/manager/util/AppModule.java index dabfe943..98805f46 100644 --- a/app/src/main/java/org/lsposed/manager/util/AppModule.java +++ b/app/src/main/java/org/lsposed/manager/util/AppModule.java @@ -23,41 +23,29 @@ package org.lsposed.manager.util; import android.content.Context; import android.content.pm.PackageInfo; import android.graphics.Bitmap; -import android.graphics.drawable.AdaptiveIconDrawable; -import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; import com.bumptech.glide.Glide; import com.bumptech.glide.Registry; import com.bumptech.glide.annotation.GlideModule; -import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; -import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.module.AppGlideModule; -import com.caverock.androidsvg.SVG; -import org.lsposed.manager.App; import org.lsposed.manager.R; -import org.lsposed.manager.util.svg.ExternalFileResolver; -import org.lsposed.manager.util.svg.SvgDecoder; -import org.lsposed.manager.util.svg.SvgDrawableTranscoder; - -import java.io.InputStream; import me.zhanghai.android.appiconloader.glide.AppIconModelLoader; @GlideModule public class AppModule extends AppGlideModule { + @Override + public boolean isManifestParsingEnabled() { + return false; + } + @Override public void registerComponents(Context context, @NonNull Glide glide, Registry registry) { int iconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size); - registry.prepend(PackageInfo.class, Bitmap.class, new AppIconModelLoader.Factory(iconSize, - context.getApplicationInfo().loadIcon(context.getPackageManager()) instanceof AdaptiveIconDrawable, context)); - OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(App.getOkHttpClient()); - registry.replace(GlideUrl.class, InputStream.class, factory); - SVG.registerExternalFileResolver(new ExternalFileResolver()); - registry.register(SVG.class, Drawable.class, new SvgDrawableTranscoder(context)) - .append(InputStream.class, SVG.class, new SvgDecoder()); + var factory = new AppIconModelLoader.Factory(iconSize, true, context); + registry.prepend(PackageInfo.class, Bitmap.class, factory); } } - diff --git a/app/src/main/java/org/lsposed/manager/util/GlideHelper.java b/app/src/main/java/org/lsposed/manager/util/GlideHelper.java deleted file mode 100644 index 28a6f4e8..00000000 --- a/app/src/main/java/org/lsposed/manager/util/GlideHelper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.manager.util; - -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageInfo; - -public class GlideHelper { - public static PackageInfo wrapApplicationInfoForIconLoader(ApplicationInfo applicationInfo) { - PackageInfo packageInfo = new PackageInfo(); - packageInfo.applicationInfo = applicationInfo; - return packageInfo; - } -} diff --git a/app/src/main/java/org/lsposed/manager/util/svg/ExternalFileResolver.java b/app/src/main/java/org/lsposed/manager/util/svg/ExternalFileResolver.java deleted file mode 100644 index 1da60ba8..00000000 --- a/app/src/main/java/org/lsposed/manager/util/svg/ExternalFileResolver.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.manager.util.svg; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Picture; -import android.util.Base64; - -import com.caverock.androidsvg.SVG; -import com.caverock.androidsvg.SVGExternalFileResolver; - -public class ExternalFileResolver extends SVGExternalFileResolver { - @Override - public Bitmap resolveImage(String filename) { - if (filename.startsWith("data:image/svg+xml;base64,")) { - // com.shatyuka.zhiliao - try { - String base64 = filename.substring(filename.indexOf(",")); - SVG svg = SVG.getFromString(new String(Base64.decode(base64, Base64.DEFAULT))); - float width = svg.getDocumentWidth(); - float height = svg.getDocumentHeight(); - Bitmap bitmap; - if (width > 0 && height > 0) { - bitmap = Bitmap.createBitmap(Math.round(width), Math.round(width), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - svg.renderToCanvas(canvas); - } else { - Picture picture = svg.renderToPicture(); - bitmap = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - canvas.drawPicture(picture); - } - return bitmap; - } catch (Exception e) { - e.printStackTrace(); - } - } - return super.resolveImage(filename); - } -} diff --git a/app/src/main/java/org/lsposed/manager/util/svg/SvgDecoder.java b/app/src/main/java/org/lsposed/manager/util/svg/SvgDecoder.java deleted file mode 100644 index a1ae9076..00000000 --- a/app/src/main/java/org/lsposed/manager/util/svg/SvgDecoder.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.manager.util.svg; - -import static com.bumptech.glide.request.target.Target.SIZE_ORIGINAL; - -import androidx.annotation.NonNull; - -import com.bumptech.glide.load.Options; -import com.bumptech.glide.load.ResourceDecoder; -import com.bumptech.glide.load.engine.Resource; -import com.bumptech.glide.load.resource.SimpleResource; -import com.caverock.androidsvg.SVG; -import com.caverock.androidsvg.SVGParseException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Decodes an SVG internal representation from an {@link InputStream}. - */ -public class SvgDecoder implements ResourceDecoder { - - @Override - public boolean handles(@NonNull InputStream source, @NonNull Options options) { - // TODO: Can we tell? - return true; - } - - public Resource decode( - @NonNull InputStream source, int width, int height, @NonNull Options options) - throws IOException { - try { - SVG svg = SVG.getFromInputStream(source); - if (width != SIZE_ORIGINAL) { - svg.setDocumentWidth(width); - } - if (height != SIZE_ORIGINAL) { - svg.setDocumentHeight(height); - } - return new SimpleResource<>(svg); - } catch (SVGParseException ex) { - throw new IOException("Cannot load SVG from stream", ex); - } - } -} diff --git a/app/src/main/java/org/lsposed/manager/util/svg/SvgDrawableTranscoder.java b/app/src/main/java/org/lsposed/manager/util/svg/SvgDrawableTranscoder.java deleted file mode 100644 index d75c393b..00000000 --- a/app/src/main/java/org/lsposed/manager/util/svg/SvgDrawableTranscoder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.manager.util.svg; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Picture; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.PictureDrawable; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.bumptech.glide.load.Options; -import com.bumptech.glide.load.engine.Resource; -import com.bumptech.glide.load.resource.SimpleResource; -import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; -import com.caverock.androidsvg.SVG; - -/** - * Convert the {@link SVG}'s internal representation to an Android-compatible one ({@link Picture}). - */ -public class SvgDrawableTranscoder implements ResourceTranscoder { - private final Resources resources; - - public SvgDrawableTranscoder(Context context) { - resources = context.getResources(); - } - - @Nullable - @Override - public Resource transcode( - @NonNull Resource toTranscode, @NonNull Options options) { - SVG svg = toTranscode.get(); - float width = svg.getDocumentWidth(); - float height = svg.getDocumentHeight(); - - Drawable drawable; - if (width > 0 && height > 0) { - float density = resources.getDisplayMetrics().density; - Bitmap bitmap = Bitmap.createBitmap(Math.round(width * density), Math.round(height * density), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - canvas.scale(density, density); - svg.renderToCanvas(canvas); - drawable = new BitmapDrawable(resources, bitmap); - } else { - Picture picture = svg.renderToPicture(); - drawable = new PictureDrawable(picture); - } - return new SimpleResource<>(drawable); - } -} diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index b4ef8ccb..00000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml index b44bae90..8e75c220 100644 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -14,7 +14,6 @@ ~ You should have received a copy of the GNU General Public License ~ along with LSPosed. If not, see . ~ - ~ Copyright (C) 2020 EdXposed Contributors ~ Copyright (C) 2021 LSPosed Contributors --> @@ -22,23 +21,14 @@ android:width="108dp" android:height="108dp" android:viewportWidth="108" - android:viewportHeight="108" - android:tint="#562135"> + android:viewportHeight="108"> - - - - - + android:scaleX="2" + android:scaleY="2" + android:translateX="30" + android:translateY="30"> + diff --git a/app/src/main/res/layout/activity_crash_report.xml b/app/src/main/res/layout/activity_crash_report.xml index 5d26e944..64857fb1 100644 --- a/app/src/main/res/layout/activity_crash_report.xml +++ b/app/src/main/res/layout/activity_crash_report.xml @@ -77,8 +77,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" - android:text="Copy logs" + android:text="@android:string/copy" android:theme="@style/Widget.AppCompat.Button.Colored" /> - \ No newline at end of file + diff --git a/app/src/main/res/layout/dialog_about.xml b/app/src/main/res/layout/dialog_about.xml index 8855ff58..a2d18708 100644 --- a/app/src/main/res/layout/dialog_about.xml +++ b/app/src/main/res/layout/dialog_about.xml @@ -20,85 +20,35 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingHorizontal="?android:dialogPreferredPadding" + android:paddingVertical="?android:dialogPreferredPadding"> - - - - - - - - - - - - - - + android:textSize="14sp" + tools:text="@tools:sample/lorem" /> - + - - - - - + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 38bbb9cd..c16bb8f9 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -19,6 +19,6 @@ --> - + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index bea2dc86..acdb7a2d 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -19,4 +19,7 @@ @color/color_primary_dark + + @color/material_pink_300 + @color/material_light_blue_50 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 5d0a2d15..616feffd 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -22,4 +22,7 @@ @color/google_blue_600 @color/google_blue_300 @color/color_primary_light + + @android:color/white + @color/material_pink_200