parent
e0e7674715
commit
48c40f9516
@ -3,8 +3,6 @@ package com.topjohnwu.magisk.adapters;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -17,8 +15,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.utils.LocaleManager;
|
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -52,19 +50,6 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
return new ViewHolder(v);
|
return new ViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLabel(ApplicationInfo info) {
|
|
||||||
if (info.labelRes > 0) {
|
|
||||||
try {
|
|
||||||
Resources res = pm.getResourcesForApplication(info);
|
|
||||||
Configuration config = new Configuration();
|
|
||||||
config.setLocale(LocaleManager.locale);
|
|
||||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
|
||||||
return res.getString(info.labelRes);
|
|
||||||
} catch (PackageManager.NameNotFoundException ignored) { /* Impossible */ }
|
|
||||||
}
|
|
||||||
return info.loadLabel(pm).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadApps() {
|
private void loadApps() {
|
||||||
fullList = pm.getInstalledApplications(0);
|
fullList = pm.getInstalledApplications(0);
|
||||||
hideList = Shell.su("magiskhide --ls").exec().getOut();
|
hideList = Shell.su("magiskhide --ls").exec().getOut();
|
||||||
@ -78,7 +63,8 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
boolean ah = hideList.contains(a.packageName);
|
boolean ah = hideList.contains(a.packageName);
|
||||||
boolean bh = hideList.contains(b.packageName);
|
boolean bh = hideList.contains(b.packageName);
|
||||||
if (ah == bh) {
|
if (ah == bh) {
|
||||||
return getLabel(a).toLowerCase().compareTo(getLabel(b).toLowerCase());
|
return Utils.getAppLabel(a, pm).toLowerCase()
|
||||||
|
.compareTo(Utils.getAppLabel(b, pm).toLowerCase());
|
||||||
} else if (ah) {
|
} else if (ah) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
@ -93,7 +79,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
ApplicationInfo info = showList.get(position);
|
ApplicationInfo info = showList.get(position);
|
||||||
|
|
||||||
holder.appIcon.setImageDrawable(info.loadIcon(pm));
|
holder.appIcon.setImageDrawable(info.loadIcon(pm));
|
||||||
holder.appName.setText(getLabel(info));
|
holder.appName.setText(Utils.getAppLabel(info, pm));
|
||||||
holder.appPackage.setText(info.packageName);
|
holder.appPackage.setText(info.packageName);
|
||||||
|
|
||||||
holder.checkBox.setOnCheckedChangeListener(null);
|
holder.checkBox.setOnCheckedChangeListener(null);
|
||||||
@ -149,7 +135,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
showList = new ArrayList<>();
|
showList = new ArrayList<>();
|
||||||
String filter = constraint.toString().toLowerCase();
|
String filter = constraint.toString().toLowerCase();
|
||||||
for (ApplicationInfo info : fullList) {
|
for (ApplicationInfo info : fullList) {
|
||||||
if (lowercaseContains(getLabel(info), filter)
|
if (lowercaseContains(Utils.getAppLabel(info, pm), filter)
|
||||||
|| lowercaseContains(info.packageName, filter)) {
|
|| lowercaseContains(info.packageName, filter)) {
|
||||||
showList.add(info);
|
showList.add(info);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ public class Policy implements Comparable<Policy>{
|
|||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
packageName = pkgs[0];
|
packageName = pkgs[0];
|
||||||
info = pm.getApplicationInfo(packageName, 0);
|
info = pm.getApplicationInfo(packageName, 0);
|
||||||
appName = info.loadLabel(pm).toString();
|
appName = Utils.getAppLabel(info, pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy(Cursor c, PackageManager pm) throws PackageManager.NameNotFoundException {
|
public Policy(Cursor c, PackageManager pm) throws PackageManager.NameNotFoundException {
|
||||||
|
@ -31,7 +31,7 @@ public class SuperuserFragment extends BaseFragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_superuser, container, false);
|
View view = inflater.inflate(R.layout.fragment_superuser, container, false);
|
||||||
unbinder = new SuperuserFragment_ViewBinding(this, view);
|
unbinder = new SuperuserFragment_ViewBinding(this, view);
|
||||||
|
|
||||||
pm = getActivity().getPackageManager();
|
pm = requireActivity().getPackageManager();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
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.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -123,4 +127,17 @@ public class Utils {
|
|||||||
Topic.publish(Topic.MODULE_LOAD_DONE, moduleMap);
|
Topic.publish(Topic.MODULE_LOAD_DONE, moduleMap);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAppLabel(ApplicationInfo info, PackageManager pm) {
|
||||||
|
try {
|
||||||
|
if (info.labelRes > 0) {
|
||||||
|
Resources res = pm.getResourcesForApplication(info);
|
||||||
|
Configuration config = new Configuration();
|
||||||
|
config.setLocale(LocaleManager.locale);
|
||||||
|
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||||
|
return res.getString(info.labelRes);
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
return info.loadLabel(pm).toString();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user