Highlight car nav facet when recent task changes.
CarStatusBar will now register a ITaskStackListener
to handle changes in task stack and highlight the
appropriate facet for the current task. Currently using resource
defined package names and category to the filter for a given
facet. OEMs are expected to use categories definied in Intent.java
Also refactored business logic from CarNavigationBarView
into CarNavigationBar controller.
Change-Id: I203917ea43f2f488a1167f27dab84f1c451b3e93
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java
index e2d64b04..efc3646 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java
@@ -17,36 +17,29 @@
package com.android.systemui.statusbar.car;
import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.R.color;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.ActivityStarter;
import com.android.systemui.statusbar.phone.NavigationBarView;
-import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
-import com.android.systemui.statusbar.policy.KeyButtonView;
-import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
/**
* A custom navigation bar for the automotive use case.
* <p>
- * The navigation bar in the automotive use case is more like a list of shortcuts, which we
- * expect to be customizable by the car OEMs. This implementation populates the nav_buttons layout
- * from resources rather than the layout file so customization would then mean updating
- * arrays_car.xml appropriately in an overlay.
+ * The navigation bar in the automotive use case is more like a list of shortcuts, rendered
+ * in a linear layout.
*/
class CarNavigationBarView extends NavigationBarView {
- private ActivityStarter mActivityStarter;
+ private LinearLayout mNavButtons;
+ private LinearLayout mLightsOutButtons;
public CarNavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -54,83 +47,13 @@
@Override
public void onFinishInflate() {
- // Read up arrays_car.xml and populate the navigation bar here.
- Context context = getContext();
- Resources r = getContext().getResources();
- TypedArray icons = r.obtainTypedArray(R.array.car_shortcut_icons);
- TypedArray intents = r.obtainTypedArray(R.array.car_shortcut_intent_uris);
- TypedArray longpressIntents =
- r.obtainTypedArray(R.array.car_shortcut_longpress_intent_uris);
-
- if (icons.length() != intents.length()) {
- throw new RuntimeException("car_shortcut_icons and car_shortcut_intents do not match");
- }
-
- LinearLayout navButtons = (LinearLayout) findViewById(R.id.nav_buttons);
- LinearLayout lightsOut = (LinearLayout) findViewById(R.id.lights_out);
-
- for (int i = 0; i < icons.length(); i++) {
- Drawable icon = icons.getDrawable(i);
-
- try {
- Intent intent = Intent.parseUri(intents.getString(i), Intent.URI_INTENT_SCHEME);
- Intent longpress = null;
- String longpressUri = longpressIntents.getString(i);
- if (!longpressUri.isEmpty()) {
- longpress = Intent.parseUri(longpressUri, Intent.URI_INTENT_SCHEME);
- }
-
- // nav_buttons and lights_out should match exactly.
- navButtons.addView(makeButton(context, icon, intent, longpress));
- lightsOut.addView(makeButton(context, icon, intent, longpress));
- } catch (URISyntaxException e) {
- throw new RuntimeException("Malformed intent uri", e);
- }
- }
+ mNavButtons = (LinearLayout) findViewById(R.id.nav_buttons);
+ mLightsOutButtons = (LinearLayout) findViewById(R.id.lights_out);
}
- private ImageButton makeButton(Context context, Drawable icon,
- final Intent intent, final Intent longpress) {
- ImageButton button = new ImageButton(context);
-
- button.setImageDrawable(icon);
- button.setScaleType(ScaleType.CENTER);
- button.setBackgroundColor(color.transparent);
- LinearLayout.LayoutParams lp =
- new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
- button.setLayoutParams(lp);
-
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mActivityStarter != null) {
- mActivityStarter.startActivity(intent, true);
- }
- }
- });
-
- // Long click handlers are optional.
- if (longpress != null) {
- button.setLongClickable(true);
- button.setOnLongClickListener(new OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if (mActivityStarter != null) {
- mActivityStarter.startActivity(longpress, true);
- return true;
- }
- return false;
- }
- });
- } else {
- button.setLongClickable(false);
- }
-
- return button;
- }
-
- public void setActivityStarter(ActivityStarter activityStarter) {
- mActivityStarter = activityStarter;
+ public void addButton(CarNavigationButton button, CarNavigationButton lightsOutButton){
+ mNavButtons.addView(button);
+ mLightsOutButtons.addView(lightsOutButton);
}
@Override