Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21d44da7 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

Trebuchet: Make remove workspace items of hidden apps optional



Change-Id: Id5c1f7a105d4140747a9f841b210cd7a7d1825df
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 7fd44abe
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -111,8 +111,13 @@
    <string name="preferences_interface_drawer_summary">Apps and widgets drawer</string>
    <string name="preferences_interface_drawer_orientation_title">Orientation</string>
    <string name="preferences_interface_drawer_orientation_summary">Choose which way the drawer scrolls</string>
    <string name="preferences_interface_drawer_apps_category">Apps</string>
    <string name="preferences_interface_drawer_hidden_apps_title">Hidden apps</string>
    <string name="preferences_interface_drawer_hidden_apps_summary">Hide apps from the drawer</string>
    <string name="preferences_interface_drawer_hidden_apps_shortcuts_title">Hidden apps (shortcuts)</string>
    <string name="preferences_interface_drawer_hidden_apps_shortcuts_summary">Remove hidden apps\'s shortcuts from workspace</string>
    <string name="preferences_interface_drawer_hidden_apps_widgets_title">Hidden apps (widgets)</string>
    <string name="preferences_interface_drawer_hidden_apps_widgets_summary">Remove hidden apps\'s widgets from workspace</string>
    <string name="preferences_interface_drawer_widgets_category">Widgets</string>
    <string name="preferences_interface_drawer_widgets_join_apps_title">Join with apps</string>
    <string name="preferences_interface_drawer_widgets_join_apps_summary">Swipe from apps drawer to widgets drawer without changing tabs</string>
+17 −7
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
        android:entries="@array/preferences_interface_drawer_orientation_entries"
        android:entryValues="@array/preferences_interface_drawer_orientation_values"
        android:defaultValue="horizontal" />
    <PreferenceCategory android:title="@string/preferences_interface_drawer_apps_category">
        <Preference android:key="ui_drawer_hidden_apps"
            android:title="@string/preferences_interface_drawer_hidden_apps_title"
            android:summary="@string/preferences_interface_drawer_hidden_apps_summary">
@@ -31,6 +32,15 @@
                android:targetPackage="com.cyanogenmod.trebuchet"
                android:targetClass="com.cyanogenmod.trebuchet.preference.HiddenAppsActivity"/>
        </Preference>
        <CheckBoxPreference android:key="ui_drawer_remove_hidden_apps_shortcuts"
            android:title="@string/preferences_interface_drawer_hidden_apps_shortcuts_title"
            android:summary="@string/preferences_interface_drawer_hidden_apps_shortcuts_summary"
            android:defaultValue="true" />
        <CheckBoxPreference android:key="ui_drawer_remove_hidden_apps_widgets"
            android:title="@string/preferences_interface_drawer_hidden_apps_widgets_title"
            android:summary="@string/preferences_interface_drawer_hidden_apps_widgets_summary"
            android:defaultValue="true" />
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/preferences_interface_drawer_widgets_category">
        <CheckBoxPreference android:key="ui_drawer_widgets_join_apps"
            android:title="@string/preferences_interface_drawer_widgets_join_apps_title"
+10 −2
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
    private ArrayList<ApplicationInfo> mApps;
    private ArrayList<ApplicationInfo> mFilteredApps;
    private ArrayList<ComponentName> mHiddenApps;
    private ArrayList<String> mHiddenAppsPackages;
    private ArrayList<Object> mWidgets;

    // Cling
@@ -370,6 +371,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
        mApps = new ArrayList<ApplicationInfo>();
        mFilteredApps = new ArrayList<ApplicationInfo>();
        mHiddenApps = new ArrayList<ComponentName>();
        mHiddenAppsPackages = new ArrayList<String>();
        mWidgets = new ArrayList<Object>();
        mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
        mCanvas = new Canvas();
@@ -392,7 +394,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen

        String[] flattened = PreferencesProvider.Interface.Drawer.getHiddenApps().split("\\|");
        for (String flat : flattened) {
            mHiddenApps.add(ComponentName.unflattenFromString(flat));
            ComponentName cmp = ComponentName.unflattenFromString(flat);
            mHiddenApps.add(cmp);
            mHiddenAppsPackages.add(cmp.getPackageName());
        }


@@ -658,7 +662,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
                int minSpanY = Math.min(spanXY[1], minSpanXY[1]);
                if (minSpanX <= LauncherModel.getWorkspaceCellCountX() &&
                        minSpanY <= LauncherModel.getWorkspaceCellCountY()) {
                    if (widget.provider != null) {
                        if (!mHiddenAppsPackages.contains(widget.provider.getPackageName())) {
                            mWidgets.add(widget);
                        }
                    }
                } else {
                    Log.e(TAG, "Widget " + widget.provider + " can not fit on this device (" +
                            widget.minWidth + ", " + widget.minHeight + ")");
+45 −41
Original line number Diff line number Diff line
@@ -1667,6 +1667,7 @@ public class LauncherModel extends BroadcastReceiver {
            }

            // Shortcuts
            if (PreferencesProvider.Interface.Drawer.getRemoveShortcutsOfHiddenApps()) {
                int N = workspaceItems.size() - 1;
                for (int i = N; i >= 0; i--) {
                    final ItemInfo item = workspaceItems.get(i);
@@ -1708,9 +1709,11 @@ public class LauncherModel extends BroadcastReceiver {
                        }
                    }
                }
            }

            // AppWidgets
            N = appWidgets.size() - 1;
            if (PreferencesProvider.Interface.Drawer.getRemoveWidgetsOfHiddenApps()) {
                int N = appWidgets.size() - 1;
                for (int i = N; i >= 0; i--) {
                    final LauncherAppWidgetInfo item = appWidgets.get(i);
                    if (item.providerName != null) {
@@ -1721,6 +1724,7 @@ public class LauncherModel extends BroadcastReceiver {
                    }
                }
            }
        }

        private void bindWorkspaceItems(final Callbacks oldCallbacks,
                final ArrayList<ItemInfo> workspaceItems,
+9 −3
Original line number Diff line number Diff line
@@ -144,12 +144,18 @@ public final class PreferencesProvider {
            public static boolean getVertical() {
                return getString("ui_drawer_orientation", "horizontal").equals("vertical");
            }
            public static boolean getJoinWidgetsApps() {
                return getBoolean("ui_drawer_widgets_join_apps", true);
            }
            public static String getHiddenApps() {
                return getString("ui_drawer_hidden_apps", "");
            }
            public static boolean getRemoveShortcutsOfHiddenApps() {
                return getBoolean("ui_drawer_remove_hidden_apps_shortcuts", true);
            }
            public static boolean getRemoveWidgetsOfHiddenApps() {
                return getBoolean("ui_drawer_remove_hidden_apps_widgets", true);
            }
            public static boolean getJoinWidgetsApps() {
                return getBoolean("ui_drawer_widgets_join_apps", true);
            }
            public static class Scrolling {
                public static AppsCustomizePagedView.TransitionEffect getTransitionEffect(String def) {
                    try {