am 780fe59a: Integrating some aosp fixes, ensuring that we update the install queue before returning to Launcher.

* commit '780fe59a7af8b12fbdcd7f6841edaa7f2c2e019d':
  Integrating some aosp fixes, ensuring that we update the install queue before returning to Launcher.
This commit is contained in:
Winson Chung
2013-09-26 16:19:03 -07:00
committed by Android Git Automerger
5 changed files with 63 additions and 18 deletions
@@ -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);
}
@@ -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();
+7 -3
View File
@@ -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();
+13 -6
View File
@@ -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);
+6
View File
@@ -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);