summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Shvadskiy <ashvadskiy@cyngn.com>2015-12-14 23:39:36 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-12-15 23:53:33 (GMT)
commitacf61e0834d2c0f605a3abc6fde86f0866a8b5a2 (patch)
tree2e600a43a80b1a681bbe68dd5502cb20193e40d2
parent174345ec50101d61f9b1950d4c30afcb962de7e2 (diff)
downloadandroid_packages_apps_Trebuchet-acf61e0834d2c0f605a3abc6fde86f0866a8b5a2.zip
android_packages_apps_Trebuchet-acf61e0834d2c0f605a3abc6fde86f0866a8b5a2.tar.gz
android_packages_apps_Trebuchet-acf61e0834d2c0f605a3abc6fde86f0866a8b5a2.tar.bz2
1. Move RemoteFolderManager and RemoteFolderUpdater into launcher3 package
and move RemoteFolderManager implementation to overlay. 2. Modify settings to hide remote folder preference on CM builds. 3. Remove remote folder from default workspace. Change-Id: I6cc3409cf0a9ada68779c41e62f46bc08f2f9ad4 issue-id: CYNGNOS-1429
-rw-r--r--Android.mk4
-rw-r--r--RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java27
-rw-r--r--RemoteFolder/src/com/android/launcher3/RemoteFolderUpdater.java (renamed from RemoteFolder/src/com.cyngn.RemoteFolder/RemoteFolderUpdater.java)2
-rw-r--r--res/xml/default_workspace_4x4.xml4
-rw-r--r--src/com/android/launcher3/Folder.java1
-rw-r--r--src/com/android/launcher3/LauncherModel.java3
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java46
-rw-r--r--src/com/android/launcher3/RemoteFolderManager.java159
-rw-r--r--src/com/android/launcher3/Workspace.java6
9 files changed, 57 insertions, 195 deletions
diff --git a/Android.mk b/Android.mk
index 70770fc..04d4e4e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -34,8 +34,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \
$(call all-proto-files-under, protos)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/WallpaperPicker/res $(LOCAL_PATH)/res
-LOCAL_AAPT_FLAGS := --auto-add-overlay \
- --extra-packages com.cyngn.RemoteFolder
+LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/
@@ -59,7 +58,6 @@ include $(REMOTE_FOLDER_UPDATER)/Android.mk
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
-include $(REMOTE_FOLDER_UPDATER)/Android.mk
include $(BUILD_MULTI_PREBUILT)
#
diff --git a/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java b/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
new file mode 100644
index 0000000..477f710
--- /dev/null
+++ b/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
@@ -0,0 +1,27 @@
+package com.android.launcher3;
+
+/**
+ * Manages adding and removing the remote folder from the workspace.
+ */
+public class RemoteFolderManager {
+
+ public RemoteFolderManager(final Launcher launcher) { }
+
+ public void setRemoteFolder(final FolderIcon remoteFolder) { }
+
+ /**
+ * Called when Launcher finishes binding items from the model.
+ */
+ public void bindFinished() { }
+
+ /**
+ * Called when the setting for remote folder is updated.
+ * @param newValue the new setting for remote folder
+ */
+ public void onSettingChanged(final boolean newValue) { }
+
+ /**
+ * Called when the remote folder is dropped into the delete area on the workspace.
+ */
+ public void onFolderDeleted() { }
+}
diff --git a/RemoteFolder/src/com.cyngn.RemoteFolder/RemoteFolderUpdater.java b/RemoteFolder/src/com/android/launcher3/RemoteFolderUpdater.java
index 1322c05..954595e 100644
--- a/RemoteFolder/src/com.cyngn.RemoteFolder/RemoteFolderUpdater.java
+++ b/RemoteFolder/src/com/android/launcher3/RemoteFolderUpdater.java
@@ -1,4 +1,4 @@
-package com.cyngn.RemoteFolder;
+package com.android.launcher3;
import android.content.Context;
import android.content.Intent;
diff --git a/res/xml/default_workspace_4x4.xml b/res/xml/default_workspace_4x4.xml
index 809697e..5970f12 100644
--- a/res/xml/default_workspace_4x4.xml
+++ b/res/xml/default_workspace_4x4.xml
@@ -29,10 +29,6 @@
launcher:spanX="4"
launcher:spanY="2" />
- <!-- Recommended Folder -->
- <remote-folder launcher:screen="1" launcher:x="0" launcher:y="2" launcher:title="@string/recommendations_title">
- </remote-folder>
-
<!-- Google Folder -->
<folder launcher:screen="1" launcher:x="0" launcher:y="3" launcher:title="@string/google_title">
<favorite
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index a0bb2dc..2bd6565 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -64,7 +64,6 @@ import android.widget.TextView;
import com.android.launcher3.FolderInfo.FolderListener;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.settings.SettingsProvider;
-import com.cyngn.RemoteFolder.RemoteFolderUpdater;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 365396b..600fbd2 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -30,7 +30,6 @@ import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.content.pm.LauncherApps.Callback;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
@@ -63,8 +62,6 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.settings.SettingsProvider;
import com.android.launcher3.stats.internal.service.AggregationIntentService;
-import com.cyngn.RemoteFolder.RemoteFolderUpdater;
-
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.security.InvalidParameterException;
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index 58567ab..6ce0d63 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -10,6 +10,10 @@ import android.widget.ImageView;
import android.widget.ListView;
import com.android.launcher3.list.PinnedHeaderListView;
import com.android.launcher3.list.SettingsPinnedHeaderAdapter;
+import com.android.launcher3.settings.SettingsProvider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
public class OverviewSettingsPanel {
public static final String ANDROID_SETTINGS = "com.android.settings";
@@ -41,14 +45,6 @@ public class OverviewSettingsPanel {
res.getString(R.string.drawer_settings),
res.getString(R.string.app_settings)};
- String[] values = new String[]{
- res.getString(R.string.home_screen_search_text),
- res.getString(R.string.scroll_effect_text),
- res.getString(R.string.icon_labels),
- res.getString(R.string.scrolling_wallpaper),
- res.getString(R.string.grid_size_text),
- res.getString(R.string.recommendations_title)};
-
String[] valuesDrawer = new String[] {
res.getString(R.string.drawer_type),
res.getString(R.string.scroll_effect_text),
@@ -59,7 +55,6 @@ public class OverviewSettingsPanel {
res.getString(R.string.larger_icons_text),
res.getString(R.string.protected_app_settings)};
-
mSettingsAdapter = new SettingsPinnedHeaderAdapter(mLauncher);
mSettingsAdapter.setHeaders(headers);
mSettingsAdapter.addPartition(false, true);
@@ -67,7 +62,8 @@ public class OverviewSettingsPanel {
mSettingsAdapter.addPartition(false, true);
mSettingsAdapter.mPinnedHeaderCount = headers.length;
- mSettingsAdapter.changeCursor(HOME_SETTINGS_POSITION, createCursor(headers[0], values));
+ mSettingsAdapter.changeCursor(HOME_SETTINGS_POSITION,
+ createCursor(headers[0], getValues()));
mSettingsAdapter.changeCursor(DRAWER_SETTINGS_POSITION, createCursor(headers[1],
valuesDrawer));
mSettingsAdapter.changeCursor(APP_SETTINGS_POSITION, createCursor(headers[2], valuesApp));
@@ -83,6 +79,27 @@ public class OverviewSettingsPanel {
return cursor;
}
+ private String[] getValues() {
+ Resources res = mLauncher.getResources();
+ ArrayList<String> values = new ArrayList<String>(Arrays.asList(new String[]{
+ res.getString(R.string.home_screen_search_text),
+ res.getString(R.string.scroll_effect_text),
+ res.getString(R.string.icon_labels),
+ res.getString(R.string.scrolling_wallpaper),
+ res.getString(R.string.grid_size_text)}));
+
+ // Optionally add additional value based on setting
+ boolean remoteAppsEnabled = SettingsProvider.getBoolean(mLauncher, null,
+ R.bool.preferences_interface_homescreen_remote_folder_default);
+ if (remoteAppsEnabled) {
+ values.add(res.getString(R.string.recommendations_title));
+ }
+
+ String[] valuesArr = new String[values.size()];
+ values.toArray(valuesArr);
+ return valuesArr;
+ }
+
// One time View setup
public void initializeViews() {
mOverviewPanel.setAlpha(0f);
@@ -170,15 +187,8 @@ public class OverviewSettingsPanel {
mSettingsAdapter.changeCursor(0, createCursor(res
.getString(R.string.home_screen_settings), new String[]{}));
} else {
- String[] values = new String[] {
- res.getString(R.string.home_screen_search_text),
- res.getString(R.string.scroll_effect_text),
- res.getString(R.string.icon_labels),
- res.getString(R.string.scrolling_wallpaper),
- res.getString(R.string.grid_size_text),
- res.getString(R.string.recommendations_title)};
mSettingsAdapter.changeCursor(0, createCursor(res
- .getString(R.string.home_screen_settings), values));
+ .getString(R.string.home_screen_settings), getValues()));
}
// Make sure overview panel is drawn above apps customize and collapsed
diff --git a/src/com/android/launcher3/RemoteFolderManager.java b/src/com/android/launcher3/RemoteFolderManager.java
deleted file mode 100644
index efbc915..0000000
--- a/src/com/android/launcher3/RemoteFolderManager.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package com.android.launcher3;
-
-import android.util.Log;
-import android.util.Pair;
-import android.view.View;
-import com.android.launcher3.settings.SettingsProvider;
-
-import java.util.ArrayList;
-
-/**
- * Manages adding and removing the remote folder from the workspace.
- */
-public class RemoteFolderManager {
- private static final String TAG = "RemoteFolderManager";
-
- private final Launcher mLauncher;
-
- /** View which is displayed in the workspace **/
- private FolderIcon mRemoteFolder;
- /** Coordinates of the folder's position before being hidden **/
- private int[] mRemoteFolderCell;
-
- public RemoteFolderManager(final Launcher launcher) {
- mLauncher = launcher;
- mRemoteFolderCell = new int[2];
- }
-
- public void setRemoteFolder(final FolderIcon remoteFolder) {
- mRemoteFolder = remoteFolder;
- }
-
- /**
- * Called when Launcher finishes binding items from the model.
- */
- public void bindFinished() {
- boolean remoteFolderEnabled = SettingsProvider.getBoolean(mLauncher,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_REMOTE_FOLDER,
- R.bool.preferences_interface_homescreen_remote_folder_default);
- if (remoteFolderEnabled && mRemoteFolder == null) {
- showRemoteFolder();
- } else if (!remoteFolderEnabled) {
- // We might load the remote folder on startup, but we shouldn't show it
- hideRemoteFolder();
- }
- }
-
- /**
- * Called when the setting for remote folder is updated.
- * @param newValue the new setting for remote folder
- */
- public void onSettingChanged(final boolean newValue) {
- if (newValue) {
- showRemoteFolder();
- } else {
- hideRemoteFolder();
- }
- }
-
- /**
- * Called when the remote folder is dropped into the delete area on the workspace.
- */
- public void onFolderDeleted() {
- hideRemoteFolder();
- SettingsProvider.putBoolean(mLauncher,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_REMOTE_FOLDER, false);
- mLauncher.mOverviewSettingsPanel.notifyDataSetInvalidated();
- }
-
- private void showRemoteFolder() {
- int[] cell;
- long screen;
- long container;
- boolean findNewSpace = true;
- FolderInfo folderInfo = null;
- Workspace workspace = mLauncher.getWorkspace();
-
- // Check if we can re-add at our old location
- if (mRemoteFolder != null) {
- folderInfo = mRemoteFolder.getFolderInfo();
- CellLayout cellLayout = mLauncher.getCellLayout(
- folderInfo.container, folderInfo.screenId);
- if (cellLayout != null
- && !cellLayout.isOccupied(mRemoteFolderCell[0], mRemoteFolderCell[1])) {
- findNewSpace = false;
- }
- }
- if (findNewSpace) {
- // Try to find a new space to add.
- Pair<Long, int[]> space = LauncherModel.findNextAvailableIconSpace(mLauncher, null,
- null, 0, new ArrayList<Long>(workspace.getWorkspaceScreenIds()));
-
- // All screens are full. Create a new screen.
- if (space == null) {
- workspace.addExtraEmptyScreen();
- screen = workspace.commitExtraEmptyScreen();
- cell = new int[2];
- } else {
- screen = space.first;
- cell = space.second;
- }
-
- container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
- } else {
- screen = folderInfo.screenId;
- cell = mRemoteFolderCell;
- container = folderInfo.container;
- }
-
- // Create the folder if this is our first time showing it
- if (mRemoteFolder == null) {
- folderInfo = new FolderInfo();
- folderInfo.setTitle(mLauncher.getString(R.string.recommendations_title));
- folderInfo.setRemote(true);
-
- CellLayout cellLayout = mLauncher.getCellLayout(container, screen);
- mRemoteFolder = mLauncher.addFolder(cellLayout, container, screen,
- cell[0], cell[1], folderInfo);
-
- mLauncher.getModel().syncRemoteFolder(folderInfo, mLauncher);
- } else {
- // Folder may be hidden by drop delete animation, so force visibility.
- mRemoteFolder.setVisibility(View.VISIBLE);
- workspace.addInScreen(mRemoteFolder, container, screen,
- cell[0], cell[1], 1, 1, mLauncher.isWorkspaceLocked());
- mLauncher.getCellLayout(container, screen)
- .getShortcutsAndWidgets().measureChild(mRemoteFolder);
-
- // Update the model
- folderInfo.cellX = cell[0];
- folderInfo.cellY = cell[1];
- folderInfo.container = container;
- folderInfo.screenId = screen;
- LauncherModel.updateItemInDatabase(mLauncher, folderInfo);
- }
- }
-
- private void hideRemoteFolder() {
- // Remote folder does not exist
- if (mRemoteFolder == null) {
- Log.e(TAG, "Remote folder is null");
- return;
- }
-
- FolderInfo info = mRemoteFolder.getFolderInfo();
-
- // Store our current location so we can try to re-add in the same spot later.
- mRemoteFolderCell[0] = info.cellX;
- mRemoteFolderCell[1] = info.cellY;
-
- // Clear the spot
- mLauncher.getCellLayout(info.container, info.screenId).removeView(mRemoteFolder);
- info.cellX = -1;
- info.cellY = -1;
- LauncherModel.updateItemInDatabase(mLauncher, info);
-
- // We may be removing from a screen we're on alone, so remove it if necessary.
- mLauncher.getWorkspace().removeExtraEmptyScreen(false, true);
- }
-}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index e6087a6..e98f12f 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -31,10 +31,7 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -76,14 +73,11 @@ import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.settings.SettingsProvider;
-import com.cyngn.RemoteFolder.RemoteFolderUpdater;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;