[app] Fix going back when scope list loading (#478)
This commit is contained in:
parent
d116c6cb83
commit
7985af5d16
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package org.lsposed.manager.adapters;
|
||||
|
||||
import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
|
@ -60,14 +62,6 @@ import com.bumptech.glide.request.transition.Transition;
|
|||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.lsposed.lspd.Application;
|
||||
import org.lsposed.manager.App;
|
||||
import org.lsposed.manager.BuildConfig;
|
||||
|
|
@ -77,11 +71,18 @@ import org.lsposed.manager.ui.activity.AppListActivity;
|
|||
import org.lsposed.manager.ui.fragment.CompileDialogFragment;
|
||||
import org.lsposed.manager.util.GlideApp;
|
||||
import org.lsposed.manager.util.ModuleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import rikka.core.res.ResourcesKt;
|
||||
import rikka.widget.switchbar.SwitchBar;
|
||||
|
||||
import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder> implements Filterable {
|
||||
|
||||
|
|
@ -256,7 +257,6 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
|||
if (itemId == R.id.use_recommended) {
|
||||
if (!checkedList.isEmpty()) {
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.use_recommended)
|
||||
.setMessage(R.string.use_recommended_message)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
checkRecommended();
|
||||
|
|
@ -572,9 +572,8 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
|||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (activity.binding.masterSwitch.isChecked() && checkedList.isEmpty()) {
|
||||
if (!refreshing && activity.binding.masterSwitch.isChecked() && checkedList.isEmpty()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(R.string.use_recommended);
|
||||
builder.setMessage(!recommendedList.isEmpty() ? R.string.no_scope_selected_has_recommended : R.string.no_scope_selected);
|
||||
if (!recommendedList.isEmpty()) {
|
||||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class MainActivity extends BaseActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int moduleCount = ModuleUtil.getInstance().getEnabledModules().size();
|
||||
int moduleCount = ModuleUtil.getInstance().getEnabledModulesCount();
|
||||
binding.modulesSummary.setText(getResources().getQuantityString(R.plurals.modules_enabled_count, moduleCount, moduleCount));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,33 +28,31 @@ import android.os.Build;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.lsposed.manager.App;
|
||||
import org.lsposed.manager.ConfigManager;
|
||||
import org.lsposed.manager.repo.RepoLoader;
|
||||
import org.lsposed.manager.repo.model.OnlineModule;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public final class ModuleUtil {
|
||||
// xposedminversion below this
|
||||
public static int MIN_MODULE_VERSION = 2; // reject modules with
|
||||
private static ModuleUtil instance = null;
|
||||
private final PackageManager pm;
|
||||
private final List<ModuleListener> listeners = new CopyOnWriteArrayList<>();
|
||||
private final List<String> enabledModules;
|
||||
private final HashSet<String> enabledModules;
|
||||
private Map<String, InstalledModule> installedModules;
|
||||
private boolean isReloading = false;
|
||||
|
||||
private ModuleUtil() {
|
||||
pm = App.getInstance().getPackageManager();
|
||||
enabledModules = new ArrayList<>(Arrays.asList(ConfigManager.getEnabledModules()));
|
||||
enabledModules = new HashSet<>(Arrays.asList(ConfigManager.getEnabledModules()));
|
||||
}
|
||||
|
||||
public static synchronized ModuleUtil getInstance() {
|
||||
|
|
@ -153,9 +151,7 @@ public final class ModuleUtil {
|
|||
return false;
|
||||
}
|
||||
if (enabled) {
|
||||
if (!enabledModules.contains(packageName)) {
|
||||
enabledModules.add(packageName);
|
||||
}
|
||||
enabledModules.add(packageName);
|
||||
} else {
|
||||
enabledModules.remove(packageName);
|
||||
}
|
||||
|
|
@ -166,18 +162,8 @@ public final class ModuleUtil {
|
|||
return enabledModules.contains(packageName);
|
||||
}
|
||||
|
||||
public List<InstalledModule> getEnabledModules() {
|
||||
LinkedList<InstalledModule> result = new LinkedList<>();
|
||||
Iterator<String> iterator = enabledModules.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
InstalledModule module = getModule(iterator.next());
|
||||
if (module != null) {
|
||||
result.add(module);
|
||||
} else {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
public int getEnabledModulesCount() {
|
||||
return enabledModules.size();
|
||||
}
|
||||
|
||||
public void addListener(ModuleListener listener) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue