Skip to content

Commit

Permalink
Remove redundant option "Runnable packages"
Browse files Browse the repository at this point in the history
  • Loading branch information
solkin committed Feb 4, 2020
1 parent c0f4dbc commit a02f747
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.tomclaw.appsend.main.local;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.text.TextUtils;

Expand All @@ -22,10 +20,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import static com.tomclaw.appsend.util.states.StateHolder.stateHolder;

Expand Down Expand Up @@ -86,18 +82,9 @@ List<AppItem> loadItemsSync() {
return null;
}
boolean isShowSystemApps = PreferenceHelper.isShowSystemApps(context);
boolean isRunnableOnly = PreferenceHelper.isRunnableOnly(context);
PackageManager packageManager = context.getPackageManager();
ArrayList<AppItem> appItemList = new ArrayList<>();

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> appList = packageManager.queryIntentActivities(mainIntent, 0);
Set<String> appSet = new HashSet<>();
for (ResolveInfo info : appList) {
appSet.add(info.resolvePackageName);
}

List<ApplicationInfo> packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo info : packages) {
try {
Expand All @@ -113,10 +100,7 @@ List<AppItem> loadItemsSync() {
boolean isUserApp = ((info.flags & ApplicationInfo.FLAG_SYSTEM) != ApplicationInfo.FLAG_SYSTEM &&
(info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != ApplicationInfo.FLAG_UPDATED_SYSTEM_APP);
if (isUserApp || isShowSystemApps) {
boolean isRunnable = appSet.contains(info.packageName);
if (isRunnable || !isRunnableOnly) {
appItemList.add(appItem);
}
appItemList.add(appItem);
}
}
} catch (Throwable ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
startActivity(intent);
} else if (TextUtils.equals(key, getString(R.string.pref_sort_order))) {
setResult(RESULT_OK);
} else if (TextUtils.equals(key, getString(R.string.pref_runnable))) {
setResult(RESULT_OK);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public static boolean isShowSystemApps(Context context) {
return getBooleanPreference(context, R.string.pref_show_system, R.bool.pref_show_system_default);
}

public static boolean isRunnableOnly(Context context) {
return getBooleanPreference(context, R.string.pref_runnable, R.bool.pref_runnable_default);
}

public static String getSortOrder(Context context) {
return getStringPreference(context, R.string.pref_sort_order, R.string.pref_sort_order_default);
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
<string name="info">Информация</string>
<string name="pref_base_title">Основные настройки</string>
<string name="pref_summary_show_system">Показывать системные приложения в общем списке</string>
<string name="pref_summary_runnable">Показывать только исполнимые приложения</string>
<string name="pref_title_show_system">Системные приложения</string>
<string name="pref_title_runnable">Исполнимые пакеты</string>
<string name="got_it">Понятно</string>
<string name="system_apps_warning_title">Внимание!</string>
<string name="system_apps_warning_message">Системные приложения хранятся в несколько ином виде и их экспорт и последующая работоспособность не гарантированы!</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<resources>
<bool name="pref_dark_theme_default">false</bool>
<bool name="pref_show_system_default">false</bool>
<bool name="pref_runnable_default">false</bool>
<string name="pref_sort_order_default" translatable="false">@string/sort_order_ascending_value</string>
<integer name="pref_last_run_build_number_default">0</integer>
<bool name="pref_responsibility_denial_default">true</bool>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/pref_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<string name="pref_base_settings" translatable="false">pref_base_settings</string>
<string name="pref_dark_theme" translatable="false">pref_dark_theme</string>
<string name="pref_show_system" translatable="false">pref_show_system</string>
<string name="pref_runnable" translatable="false">pref_runnable</string>
<string name="pref_sort_order" translatable="false">pref_sort_order</string>
<string name="pref_clear_cache" translatable="false">pref_clear_cache</string>

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
<string name="info">Info</string>
<string name="pref_base_title">Base settings</string>
<string name="pref_summary_show_system">Show system applications in list</string>
<string name="pref_summary_runnable">Show runnable packages only</string>
<string name="pref_title_show_system">System apps</string>
<string name="pref_title_runnable">Runnable packages</string>
<string name="got_it">Got it!</string>
<string name="system_apps_warning_title">Warning!</string>
<string name="system_apps_warning_message">System apps are not usual apps and there is no warranty of its
Expand Down
30 changes: 12 additions & 18 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/pref_base_title"
android:key="@string/pref_base_settings">
android:key="@string/pref_base_settings"
android:title="@string/pref_base_title">
<CheckBoxPreference
android:defaultValue="@bool/pref_dark_theme_default"
android:key="@string/pref_dark_theme"
android:summary="@string/pref_dark_theme_system"
android:title="@string/pref_title_dark_theme"
android:defaultValue="@bool/pref_dark_theme_default" />
android:title="@string/pref_title_dark_theme" />
<CheckBoxPreference
android:defaultValue="@bool/pref_show_system_default"
android:key="@string/pref_show_system"
android:summary="@string/pref_summary_show_system"
android:title="@string/pref_title_show_system"
android:defaultValue="@bool/pref_show_system_default" />
<CheckBoxPreference
android:key="@string/pref_runnable"
android:summary="@string/pref_summary_runnable"
android:title="@string/pref_title_runnable"
android:defaultValue="@bool/pref_runnable_default" />
android:title="@string/pref_title_show_system" />
<ListPreference
android:key="@string/pref_sort_order"
android:summary="@string/pref_summary_sort_order"
android:title="@string/pref_title_sort_order"
android:defaultValue="@string/pref_sort_order_default"
android:entries="@array/pref_sort_order_strings"
android:entryValues="@array/pref_sort_order_values" />
android:entryValues="@array/pref_sort_order_values"
android:key="@string/pref_sort_order"
android:summary="@string/pref_summary_sort_order"
android:title="@string/pref_title_sort_order" />
<Preference
android:key="@string/pref_clear_cache"
android:title="@string/pref_title_clear_cache"
android:summary="@string/pref_summary_clear_cache" />
android:summary="@string/pref_summary_clear_cache"
android:title="@string/pref_title_clear_cache" />
</PreferenceCategory>
</PreferenceScreen>

0 comments on commit a02f747

Please sign in to comment.