mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Slightly better app filtering
git-svn-id: https://zxing.googlecode.com/svn/trunk@1126 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
d1973dce0a
commit
1cd7c7e44c
|
@ -37,8 +37,12 @@ public final class AppPickerActivity extends ListActivity {
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
dialog = ProgressDialog.show(this, "", getString(R.string.msg_loading_apps), true, true);
|
dialog = ProgressDialog.show(this, "", getString(R.string.msg_loading_apps), true, true);
|
||||||
|
if (labelsPackages.isEmpty()) {
|
||||||
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
||||||
}
|
}
|
||||||
|
// otherwise use last copy we loaded -- apps don't change much, and it takes
|
||||||
|
// forever to load for some reason
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View view, int position, long id) {
|
protected void onListItemClick(ListView l, View view, int position, long id) {
|
||||||
|
|
|
@ -27,8 +27,24 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a list of packages installed on the device asynchronously.
|
||||||
|
*
|
||||||
|
* @author Sean Owen
|
||||||
|
*/
|
||||||
final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<String[]>> {
|
final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<String[]>> {
|
||||||
|
|
||||||
|
private static final String[] PKG_PREFIX_WHITELIST = {
|
||||||
|
"com.google.android.apps.",
|
||||||
|
};
|
||||||
|
private static final String[] PKG_PREFIX_BLACKLIST = {
|
||||||
|
"com.android.",
|
||||||
|
"android",
|
||||||
|
"com.google.android.",
|
||||||
|
"com.htc",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private final AppPickerActivity appPickerActivity;
|
private final AppPickerActivity appPickerActivity;
|
||||||
|
|
||||||
LoadPackagesAsyncTask(AppPickerActivity appPickerActivity) {
|
LoadPackagesAsyncTask(AppPickerActivity appPickerActivity) {
|
||||||
|
@ -58,10 +74,20 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isHidden(String packageName) {
|
private static boolean isHidden(String packageName) {
|
||||||
return packageName == null ||
|
if (packageName == null) {
|
||||||
packageName.startsWith("com.android.") ||
|
return true;
|
||||||
(packageName.startsWith("com.google.android.") &&
|
}
|
||||||
!packageName.startsWith("com.google.android.apps."));
|
for (String prefix : PKG_PREFIX_WHITELIST) {
|
||||||
|
if (packageName.startsWith(prefix)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String prefix : PKG_PREFIX_BLACKLIST) {
|
||||||
|
if (packageName.startsWith(prefix)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue