summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-09-26 14:48:44 -0700
committerWinson Chung <winsonc@google.com>2013-09-26 16:17:07 -0700
commit780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d (patch)
treea9181750afb09049eda9f69c205f8af1ceb10c24 /src
parent88cc3f5aa2e9ac3ae0b24e563a44d320cc089cd8 (diff)
downloadandroid_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.tar.gz
android_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.tar.bz2
android_packages_apps_Trebuchet-780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d.zip
Integrating some aosp fixes, ensuring that we update the install queue before returning to Launcher.
- Fixing stuck page in All Apps (Bug 9347818) - Fixing shortcuts to uninstalled apps from being installed (Bug 10726510) - Consolidating vibration feedback - Ensuring that we trim names during comparison in AllApps list Change-Id: Ieaae4d85851ce771283b4684a8a60306da28cb3b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/DragController.java8
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java38
-rw-r--r--src/com/android/launcher3/Launcher.java10
-rw-r--r--src/com/android/launcher3/LauncherModel.java19
-rw-r--r--src/com/android/launcher3/PagedView.java6
5 files changed, 63 insertions, 18 deletions
diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java
index 4c4f399a9..c63042778 100644
--- a/src/com/android/launcher3/DragController.java
+++ b/src/com/android/launcher3/DragController.java
@@ -24,8 +24,8 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Handler;
import android.os.IBinder;
-import android.os.Vibrator;
import android.util.Log;
+import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -51,7 +51,6 @@ public class DragController {
private static final int SCROLL_DELAY = 500;
private static final int RESCROLL_DELAY = 750;
- private static final int VIBRATE_DURATION = 15;
private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
@@ -66,7 +65,6 @@ public class DragController {
private Launcher mLauncher;
private Handler mHandler;
- private final Vibrator mVibrator;
// temporaries to avoid gc thrash
private Rect mRectTemp = new Rect();
@@ -150,7 +148,6 @@ public class DragController {
mHandler = new Handler();
mScrollZone = r.getDimensionPixelSize(R.dimen.scroll_zone);
mVelocityTracker = VelocityTracker.obtain();
- mVibrator = (Vibrator) launcher.getSystemService(Context.VIBRATOR_SERVICE);
float density = r.getDisplayMetrics().density;
mFlingToDeleteThresholdVelocity =
@@ -240,8 +237,6 @@ public class DragController {
mDragObject.dragSource = source;
mDragObject.dragInfo = dragInfo;
- mVibrator.vibrate(VIBRATE_DURATION);
-
final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX,
registrationY, 0, 0, b.getWidth(), b.getHeight(), initialDragViewScale);
@@ -252,6 +247,7 @@ public class DragController {
dragView.setDragRegion(new Rect(dragRegion));
}
+ mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
dragView.show(mMotionDownX, mMotionDownY);
handleMoveEvent(mMotionDownX, mMotionDownY);
}
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index fd580081b..b4d6ea551 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -102,6 +102,35 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
}
+ public static void removeFromInstallQueue(SharedPreferences sharedPrefs,
+ ArrayList<String> packageNames) {
+ synchronized(sLock) {
+ Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
+ if (strings != null) {
+ Set<String> newStrings = new HashSet<String>(strings);
+ for (String json : newStrings) {
+ try {
+ JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
+ Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
+ String pn = launchIntent.getPackage();
+ if (pn == null) {
+ pn = launchIntent.getComponent().getPackageName();
+ }
+ if (packageNames.contains(pn)) {
+ newStrings.remove(json);
+ }
+ } catch (org.json.JSONException e) {
+ Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+ } catch (java.net.URISyntaxException e) {
+ Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+ }
+ }
+ sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL,
+ new HashSet<String>(newStrings)).commit();
+ }
+ }
+ }
+
private static ArrayList<PendingInstallShortcutInfo> getAndClearInstallQueue(
SharedPreferences sharedPrefs) {
synchronized(sLock) {
@@ -115,7 +144,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
try {
JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
Intent data = Intent.parseUri(object.getString(DATA_INTENT_KEY), 0);
- Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
+ Intent launchIntent =
+ Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
String name = object.getString(NAME_KEY);
String iconBase64 = object.optString(ICON_KEY);
String iconResourceName = object.optString(ICON_RESOURCE_NAME_KEY);
@@ -137,9 +167,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
new PendingInstallShortcutInfo(data, name, launchIntent);
infos.add(info);
} catch (org.json.JSONException e) {
- Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e);
+ Log.d("InstallShortcutReceiver",
+ "Exception reading shortcut to add: " + e);
} catch (java.net.URISyntaxException e) {
- Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e);
+ Log.d("InstallShortcutReceiver",
+ "Exception reading shortcut to add: " + e);
}
}
sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5bb4f7512..149a5230f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -834,9 +834,6 @@ public class Launcher extends Activity
// Background was set to gradient in onPause(), restore to black if in all apps.
setWorkspaceBackground(mState == State.WORKSPACE);
- // Process any items that were added while Launcher was away
- InstallShortcutReceiver.disableAndFlushInstallQueue(this);
-
mPaused = false;
sPausedFromUserAction = false;
if (mRestoring || mOnResumeNeedsLoad) {
@@ -885,12 +882,19 @@ public class Launcher extends Activity
// Resets the previous all apps icon press state
mAppsCustomizeContent.resetDrawableState();
}
+ // Reset AllApps to its initial state
+ if (mAppsCustomizeTabHost != null) {
+ mAppsCustomizeTabHost.reset();
+ }
// It is possible that widgets can receive updates while launcher is not in the foreground.
// Consequently, the widgets will be inflated in the orientation of the foreground activity
// (framework issue). On resuming, we ensure that any widgets are inflated for the current
// orientation.
getWorkspace().reinflateWidgetsIfNecessary();
+ // Process any items that were added while Launcher was away.
+ InstallShortcutReceiver.disableAndFlushInstallQueue(this);
+
// Again, as with the above scenario, it's possible that one or more of the global icons
// were updated in the wrong orientation.
updateGlobalIcons();
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 1598e2b47..f8644b1ec 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2565,6 +2565,12 @@ public class LauncherModel extends BroadcastReceiver {
deleteItemFromDatabase(context, i);
}
}
+
+ // Remove any queued items from the install queue
+ String spKey = LauncherAppState.getSharedPreferencesKey();
+ SharedPreferences sp =
+ context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
+ InstallShortcutReceiver.removeFromInstallQueue(sp, removedPackageNames);
} else {
for (AppInfo a : removedApps) {
ArrayList<ItemInfo> infos =
@@ -3062,7 +3068,8 @@ public class LauncherModel extends BroadcastReceiver {
final Collator collator = Collator.getInstance();
return new Comparator<AppInfo>() {
public final int compare(AppInfo a, AppInfo b) {
- int result = collator.compare(a.title.toString(), b.title.toString());
+ int result = collator.compare(a.title.toString().trim(),
+ b.title.toString().trim());
if (result == 0) {
result = a.componentName.compareTo(b.componentName);
}
@@ -3082,7 +3089,7 @@ public class LauncherModel extends BroadcastReceiver {
final Collator collator = Collator.getInstance();
return new Comparator<AppWidgetProviderInfo>() {
public final int compare(AppWidgetProviderInfo a, AppWidgetProviderInfo b) {
- return collator.compare(a.label.toString(), b.label.toString());
+ return collator.compare(a.label.toString().trim(), b.label.toString().trim());
}
};
}
@@ -3114,14 +3121,14 @@ public class LauncherModel extends BroadcastReceiver {
if (mLabelCache.containsKey(keyA)) {
labelA = mLabelCache.get(keyA);
} else {
- labelA = a.loadLabel(mPackageManager).toString();
+ labelA = a.loadLabel(mPackageManager).toString().trim();
mLabelCache.put(keyA, labelA);
}
if (mLabelCache.containsKey(keyB)) {
labelB = mLabelCache.get(keyB);
} else {
- labelB = b.loadLabel(mPackageManager).toString();
+ labelB = b.loadLabel(mPackageManager).toString().trim();
mLabelCache.put(keyB, labelB);
}
@@ -3144,7 +3151,7 @@ public class LauncherModel extends BroadcastReceiver {
} else {
labelA = (a instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) a).label :
- ((ResolveInfo) a).loadLabel(mPackageManager).toString();
+ ((ResolveInfo) a).loadLabel(mPackageManager).toString().trim();
mLabelCache.put(a, labelA);
}
if (mLabelCache.containsKey(b)) {
@@ -3152,7 +3159,7 @@ public class LauncherModel extends BroadcastReceiver {
} else {
labelB = (b instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) b).label :
- ((ResolveInfo) b).loadLabel(mPackageManager).toString();
+ ((ResolveInfo) b).loadLabel(mPackageManager).toString().trim();
mLabelCache.put(b, labelB);
}
return mCollator.compare(labelA, labelB);
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 42f3cace6..8cdd8e2cc 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -925,6 +925,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mFirstLayout = false;
}
+ if (isPageMoving()) {
+ // If the page is moving, then snap it to the final position to ensure we don't get
+ // stuck between pages
+ snapToDestination();
+ }
+
if (childCount > 0) {
final int index = isLayoutRtl() ? 0 : childCount - 1;
mMaxScrollX = getScrollForPage(index);