Merge "Dejank app switching." into nyc-dev
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.util.SimpleArrayMap;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@@ -71,6 +72,7 @@ class CarNavigationBarController {
|
||||
|
||||
private int mCurrentFacetIndex;
|
||||
private String mCurrentPackageName;
|
||||
private SparseBooleanArray mFacetHasMultipleAppsCache = new SparseBooleanArray();
|
||||
|
||||
public CarNavigationBarController(Context context,
|
||||
CarNavigationBarView navBar,
|
||||
@@ -96,6 +98,21 @@ class CarNavigationBarController {
|
||||
}
|
||||
}
|
||||
|
||||
public void onPackageChange(String packageName) {
|
||||
if (mFacetPackageMap.containsKey(packageName)) {
|
||||
int index = mFacetPackageMap.get(packageName);
|
||||
mFacetHasMultipleAppsCache.put(index, facetHasMultiplePackages(index));
|
||||
// No need to check categories because we've already refreshed the cache.
|
||||
return;
|
||||
}
|
||||
|
||||
String category = getPackageCategory(packageName);
|
||||
if (mFacetCategoryMap.containsKey(category)) {
|
||||
int index = mFacetCategoryMap.get(packageName);
|
||||
mFacetHasMultipleAppsCache.put(index, facetHasMultiplePackages(index));
|
||||
}
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
// Read up arrays_car.xml and populate the navigation bar here.
|
||||
Resources r = mContext.getResources();
|
||||
@@ -138,6 +155,7 @@ class CarNavigationBarController {
|
||||
initFacetFilterMaps(i,
|
||||
facetPackageNames.getString(i).split(FACET_FILTER_DEMILITER),
|
||||
facetCategories.getString(i).split(FACET_FILTER_DEMILITER));
|
||||
mFacetHasMultipleAppsCache.put(i, facetHasMultiplePackages(i));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException("Malformed intent uri", e);
|
||||
}
|
||||
@@ -229,7 +247,7 @@ class CarNavigationBarController {
|
||||
|
||||
if (mNavButtons.get(index) != null) {
|
||||
mNavButtons.get(index).setSelected(true /* selected */,
|
||||
facetHasMultiplePackages(index) /* showMoreIcon */);
|
||||
mFacetHasMultipleAppsCache.get(index) /* showMoreIcon */);
|
||||
}
|
||||
mCurrentFacetIndex = index;
|
||||
}
|
||||
@@ -268,7 +286,7 @@ class CarNavigationBarController {
|
||||
|
||||
private void startActivity(Intent intent) {
|
||||
if (mActivityStarter != null && intent != null) {
|
||||
mActivityStarter.startActivity(intent, true);
|
||||
mActivityStarter.startActivity(intent, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ package com.android.systemui.statusbar.car;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ITaskStackListener;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -52,6 +55,7 @@ public class CarStatusBar extends PhoneStatusBar {
|
||||
mTaskStackListener = new TaskStackListenerImpl(mHandler);
|
||||
mSystemServicesProxy = new SystemServicesProxy(mContext);
|
||||
mSystemServicesProxy.registerTaskStackListener(mTaskStackListener);
|
||||
registerPackageChangeReceivers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,6 +85,26 @@ public class CarStatusBar extends PhoneStatusBar {
|
||||
mController = new CarNavigationBarController(context, mCarNavigationBar,
|
||||
this /* ActivityStarter*/);
|
||||
mNavigationBarView = mCarNavigationBar;
|
||||
|
||||
}
|
||||
|
||||
private BroadcastReceiver mPackageChangeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getData() == null || mController == null) {
|
||||
return;
|
||||
}
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
mController.onPackageChange(packageName);
|
||||
}
|
||||
};
|
||||
|
||||
private void registerPackageChangeReceivers() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addDataScheme("package");
|
||||
mContext.registerReceiver(mPackageChangeReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user