Fix possible crash & layout adjustments & transparent status bar

This commit is contained in:
NekoInverter 2020-02-07 11:56:04 +08:00
parent fac904009d
commit 6adf2bc14d
16 changed files with 124 additions and 78 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "org.meowcat.edxposed.manager"
minSdkVersion 21
targetSdkVersion 27
versionCode 45405
versionName "4.5.4.1"
versionCode 45406
versionName "4.5.4.2"
}
buildTypes {
release {
@ -34,7 +34,7 @@ dependencies {
implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation "com.github.topjohnwu.libsu:core:2.5.0"
implementation "com.github.topjohnwu.libsu:core:2.5.1"
implementation 'androidx.browser:browser:1.2.0'
implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar'
implementation 'com.takisoft.preferencex:preferencex:1.1.0'

View File

@ -21,6 +21,7 @@ import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -85,6 +86,13 @@ public class BaseActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
if (!(this instanceof MainActivity) && !XposedApp.getPreferences().getBoolean("black_dark_theme", false)) {
if (XposedApp.getPreferences().getBoolean("transparent_status_bar", false)) {
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorActionBar));
} else {
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
}
if (!Objects.equals(mTheme, getTheme(this))) {
recreate();
}

View File

@ -177,8 +177,10 @@ public class DownloadActivity extends BaseActivity implements RepoLoader.RepoLis
}
private void reloadItems() {
mAdapter.swapCursor(RepoDb.queryModuleOverview(mSortingOrder, mFilterText));
mAdapter.notifyDataSetChanged();
runOnUiThread(() -> {
mAdapter.swapCursor(RepoDb.queryModuleOverview(mSortingOrder, mFilterText));
mAdapter.notifyDataSetChanged();
});
}
@Override

View File

@ -54,10 +54,12 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@ -72,7 +74,7 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
private SearchView mSearchView;
private SearchView.OnQueryTextListener mSearchListener;
private PackageManager mPm;
private DateFormat dateformat = DateFormat.getDateInstance(DateFormat.SHORT);
private DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
private ModuleUtil mModuleUtil;
private ModuleAdapter mAdapter = null;
private MenuItem mClickedMenuItem = null;

View File

@ -1,6 +1,7 @@
package org.meowcat.edxposed.manager;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@ -16,6 +17,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
@ -321,6 +323,20 @@ public class SettingsActivity extends BaseActivity {
return (enabled == mDisableResourcesFlag.exists());
});
SwitchPreference transparent_status_bar = findPreference("transparent_status_bar");
Objects.requireNonNull(transparent_status_bar).setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
Activity activity = getActivity();
if (activity != null && !XposedApp.getPreferences().getBoolean("black_dark_theme", false)) {
if (enabled) {
Objects.requireNonNull(getActivity()).getWindow().setStatusBarColor(ContextCompat.getColor(activity, R.color.colorActionBar));
} else {
Objects.requireNonNull(getActivity()).getWindow().setStatusBarColor(ContextCompat.getColor(activity, R.color.colorPrimaryDark));
}
}
return true;
});
Preference compat_mode = findPreference("compat_mode");
if (compat_mode != null) {
compat_mode.setOnPreferenceClickListener(preference -> {

View File

@ -191,7 +191,7 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem
@SuppressWarnings("JavaReflectionMemberAccess")
@SuppressLint({"PrivateApi", "NewApi"})
private void createDirectories() {
//FileUtils.setPermissions(BASE_DIR, 00777, -1, -1);
FileUtils.setPermissions(BASE_DIR, 00777, -1, -1);
mkdirAndChmod("conf", 00777);
mkdirAndChmod("log", 00777);
@ -212,7 +212,6 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem
runOnUiThread(() -> {
synchronized (XposedApp.this) {
if (mCurrentActivity != null) {
mCurrentActivity.setProgressBarIndeterminateVisibility(isLoading);
if (refreshLayout != null)
refreshLayout.setRefreshing(isLoading);
}
@ -222,8 +221,9 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem
@Override
public synchronized void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
if (mIsUiLoaded)
if (mIsUiLoaded) {
return;
}
RepoLoader.getInstance().triggerFirstLoadIfNecessary();
mIsUiLoaded = true;
@ -242,7 +242,6 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem
@Override
public synchronized void onActivityPaused(Activity activity) {
activity.setProgressBarIndeterminateVisibility(false);
mCurrentActivity = null;
}

View File

@ -22,11 +22,13 @@ import org.meowcat.edxposed.manager.XposedApp;
import org.meowcat.edxposed.manager.util.InstallApkUtil;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
@ -34,7 +36,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
private final ApplicationInfo.DisplayNameComparator displayNameComparator;
private Callback callback;
private List<ApplicationInfo> fullList, showList;
private DateFormat dateformat = DateFormat.getDateInstance(DateFormat.SHORT);
private DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
private List<String> checkedList;
private PackageManager pm;
private ApplicationFilter filter;

View File

@ -15,8 +15,8 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
android:layout_centerInParent="true"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="@+id/warning_crash"

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -8,9 +9,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical"
android:padding="8dp"
android:paddingEnd="?android:attr/scrollbarSize"
tools:ignore="RtlSymmetry">
<TextView
@ -34,13 +35,21 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/download_moreinfo_container"
<com.google.android.material.card.MaterialCardView
android:id="@+id/activity_main_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" />
android:layout_marginBottom="10dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:id="@+id/download_moreinfo_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>

View File

@ -1,8 +1,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
android:orientation="vertical">
<TextView
android:id="@android:id/title"

View File

@ -5,74 +5,74 @@
android:layout_gravity="center"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:minHeight="?android:attr/listPreferredItemHeight">
android:focusable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:padding="8dp"
android:paddingStart="18dp"
android:paddingEnd="12dp">
<ImageView
android:id="@+id/app_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
tools:ignore="ContentDescription" />
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/app_icon">
<TextView
android:id="@+id/app_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false" />
<TextView
android:id="@+id/version_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:ellipsize="marquee"
android:gravity="end"
android:marqueeRepeatLimit="marquee_forever"
android:maxWidth="100dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/linear"
android:layout_marginStart="8dp"
android:layout_toStartOf="@id/checkbox"
android:layout_toEndOf="@id/app_icon"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp">
<ImageView
android:id="@+id/app_icon"
android:layout_width="48dp"
android:layout_height="48dp"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/app_icon"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/app_icon"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false" />
<TextView
android:id="@+id/version_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/app_name"
android:layout_marginStart="4dip"
android:layout_toEndOf="@id/app_name"
android:ellipsize="marquee"
android:maxWidth="100dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
tools:ignore="RtlHardcoded" />
<TextView
android:id="@+id/package_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/app_name"
android:layout_alignBottom="@id/app_icon"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/app_icon"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false" />
</RelativeLayout>
<TextView
android:id="@+id/package_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false" />
<TextView
android:id="@+id/timestamps"

View File

@ -293,8 +293,9 @@
<string name="pref_disable_modules_log_summary">模块抛出的的异常堆栈仍将正常抓取</string>
<string name="follow_system">跟随系统</string>
<string name="pure_black_dark_theme">使用纯黑深色主题</string>>
<string name="install_timestamps">安装于 %1$s \u00b7 更新于 %2$s</string>
<string name="install_timestamps">安装于 %1$s\n更新于 %2$s</string>
<string name="pref_compat_mode_summary">兼容模式应用列表</string>
<string name="pref_compat_mode_title">兼容模式</string>
<string name="xposed_not_active">EdXposed 框架未安装或未激活, 您可在设置中关闭状态检查</string>
<string name="transparent_status_bar">透明状态栏</string>
</resources>

View File

@ -293,8 +293,9 @@
<string name="pref_disable_modules_log_summary">模塊拋出的的異常堆棧仍將正常抓取</string>
<string name="follow_system">跟隨系統</string>
<string name="pure_black_dark_theme">使用純黑深色主題</string>>
<string name="install_timestamps">安裝於 %1$s \u00b7 更新於 %2$s</string>
<string name="install_timestamps">安裝於 %1$s\n更新於 %2$s</string>
<string name="pref_compat_mode_summary">兼容模式應用列表</string>
<string name="pref_compat_mode_title">兼容模式</string>
<string name="xposed_not_active">EdXposed 框架未安裝或未啟用, 您可在設定中關閉狀態檢查</string>
<string name="transparent_status_bar">透明狀態欄</string>
</resources>

View File

@ -293,8 +293,9 @@
<string name="pref_disable_modules_log_summary">模組丟擲的的異常堆疊仍將正常抓取</string>
<string name="follow_system">跟隨系統</string>
<string name="pure_black_dark_theme">使用純黑深色主題</string>>
<string name="install_timestamps">安裝於 %1$s \u00b7 更新於 %2$s</string>
<string name="install_timestamps">安裝於 %1$s\n更新於 %2$s</string>
<string name="pref_compat_mode_summary">相容模式應用列表</string>
<string name="pref_compat_mode_title">相容模式</string>
<string name="xposed_not_active">EdXposed 框架未安裝或未啟用, 您可在設定中關閉狀態檢查</string>
<string name="transparent_status_bar">透明狀態列</string>
</resources>

View File

@ -88,7 +88,7 @@
<string name="download_status_installed">Installed (version %s)</string>
<string name="download_status_update_available">Update available (version %1$s \u2192 %2$s)</string>
<string name="download_timestamps">Added on %1$s \u00b7 Updated on %2$s</string>
<string name="install_timestamps">Installed on %1$s \nUpdated on %2$s</string>
<string name="install_timestamps">Installed on %1$s\nUpdated on %2$s</string>
<string name="download_sorting_title">Sorting order</string>
<string name="download_sorting_status">Sort by status</string>
<string name="download_sorting_updated">Sort by last update</string>
@ -331,4 +331,5 @@
<string name="pref_compat_mode_title">Compat List</string>
<string name="pref_compat_mode_summary">Compat mode app list</string>
<string name="xposed_not_active">EdXposed Framework is not currently installed or active\nYou can close status check in settings</string>
<string name="transparent_status_bar">Transparent status bar</string>
</resources>

View File

@ -19,6 +19,11 @@
android:title="@string/pure_black_dark_theme"
app:iconSpaceReserved="false" />
<SwitchPreference
android:key="transparent_status_bar"
android:title="@string/transparent_status_bar"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="true"
android:key="confirm_reboots"