Merge "Merge "Introduce ButtonInterface and getHomeId()" into nyc-mr1-dev am: 54c3213304" into nyc-mr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
94d9bdb86d
@@ -23,6 +23,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.ScrimView;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBouncer;
|
||||
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
|
||||
@@ -115,4 +116,11 @@ public class SystemUIFactory {
|
||||
public <T> T createInstance(Class<T> classType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id for the home button layout.
|
||||
*/
|
||||
public int getHomeLayoutId() {
|
||||
return R.layout.home;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.statusbar.policy.KeyButtonView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -65,9 +64,9 @@ public class ButtonDispatcher {
|
||||
view.setVisibility(mVisibility);
|
||||
}
|
||||
if (mImageResource > 0) {
|
||||
((ImageView) view).setImageResource(mImageResource);
|
||||
((ButtonInterface) view).setImageResource(mImageResource);
|
||||
} else if (mImageDrawable != null) {
|
||||
((ImageView) view).setImageDrawable(mImageDrawable);
|
||||
((ButtonInterface) view).setImageDrawable(mImageDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ public class ButtonDispatcher {
|
||||
mImageResource = -1;
|
||||
final int N = mViews.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
((ImageView) mViews.get(i)).setImageDrawable(mImageDrawable);
|
||||
((ButtonInterface) mViews.get(i)).setImageDrawable(mImageDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +96,7 @@ public class ButtonDispatcher {
|
||||
mImageDrawable = null;
|
||||
final int N = mViews.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
((ImageView) mViews.get(i)).setImageResource(mImageResource);
|
||||
((ButtonInterface) mViews.get(i)).setImageResource(mImageResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +113,7 @@ public class ButtonDispatcher {
|
||||
// This seems to be an instantaneous thing, so not going to persist it.
|
||||
final int N = mViews.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
((KeyButtonView) mViews.get(i)).abortCurrentGesture();
|
||||
((ButtonInterface) mViews.get(i)).abortCurrentGesture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,4 +164,15 @@ public class ButtonDispatcher {
|
||||
public void setCurrentView(View currentView) {
|
||||
mCurrentView = currentView.findViewById(mId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for ImageView button actions.
|
||||
*/
|
||||
public interface ButtonInterface {
|
||||
void setImageResource(@DrawableRes int resId);
|
||||
|
||||
void setImageDrawable(@Nullable Drawable drawable);
|
||||
|
||||
void abortCurrentGesture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Space;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.statusbar.policy.KeyButtonView;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
|
||||
@@ -219,7 +221,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
|
||||
String button = extractButton(buttonSpec);
|
||||
View v = null;
|
||||
if (HOME.equals(button)) {
|
||||
v = inflater.inflate(R.layout.home, parent, false);
|
||||
v = inflater.inflate(SystemUIFactory.getInstance().getHomeLayoutId(), parent, false);
|
||||
if (landscape && isSw600Dp()) {
|
||||
setupLandButton(v);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.statusbar.policy;
|
||||
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
@@ -42,11 +44,12 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.phone.ButtonDispatcher;
|
||||
|
||||
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
|
||||
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK;
|
||||
|
||||
public class KeyButtonView extends ImageView {
|
||||
public class KeyButtonView extends ImageView implements ButtonDispatcher.ButtonInterface {
|
||||
|
||||
private int mContentDescriptionRes;
|
||||
private long mDownTime;
|
||||
@@ -247,10 +250,21 @@ public class KeyButtonView extends ImageView {
|
||||
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortCurrentGesture() {
|
||||
setPressed(false);
|
||||
mGestureAborted = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageResource(@DrawableRes int resId) {
|
||||
super.setImageResource(resId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageDrawable(@Nullable Drawable drawable) {
|
||||
super.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user