Merge "AOD - Notif icon location" into sc-v2-dev
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
android:id="@+id/lockscreen_clock_view_large"
|
android:id="@+id/lockscreen_clock_view_large"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/keyguard_status_area"
|
android:layout_below="@id/keyguard_slice_view"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
<com.android.keyguard.AnimatableClockView
|
<com.android.keyguard.AnimatableClockView
|
||||||
android:id="@+id/animatable_clock_view_large"
|
android:id="@+id/animatable_clock_view_large"
|
||||||
@@ -68,19 +68,28 @@
|
|||||||
lockScreenWeight="400"
|
lockScreenWeight="400"
|
||||||
/>
|
/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<include layout="@layout/keyguard_status_area"
|
|
||||||
|
<!-- Not quite optimal but needed to translate these items as a group. The
|
||||||
|
NotificationIconContainer has its own logic for translation. -->
|
||||||
|
<LinearLayout
|
||||||
android:id="@+id/keyguard_status_area"
|
android:id="@+id/keyguard_status_area"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@id/lockscreen_clock_view" />
|
android:layout_below="@id/lockscreen_clock_view">
|
||||||
|
|
||||||
<com.android.systemui.statusbar.phone.NotificationIconContainer
|
<include layout="@layout/keyguard_slice_view"
|
||||||
android:id="@+id/left_aligned_notification_icon_container"
|
android:id="@+id/keyguard_slice_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/notification_shelf_height"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_below="@id/keyguard_status_area"
|
|
||||||
android:paddingStart="@dimen/below_clock_padding_start_icons"
|
<com.android.systemui.statusbar.phone.NotificationIconContainer
|
||||||
android:visibility="invisible"
|
android:id="@+id/left_aligned_notification_icon_container"
|
||||||
/>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/notification_shelf_height"
|
||||||
|
android:paddingStart="@dimen/below_clock_padding_start_icons"
|
||||||
|
android:visibility="invisible"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
</com.android.keyguard.KeyguardClockSwitch>
|
</com.android.keyguard.KeyguardClockSwitch>
|
||||||
|
|||||||
@@ -22,11 +22,10 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="start"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingStart="@dimen/below_clock_padding_start"
|
android:paddingStart="@dimen/below_clock_padding_start">
|
||||||
android:layout_centerHorizontal="true">
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -42,6 +41,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center"
|
android:gravity="start"
|
||||||
/>
|
/>
|
||||||
</com.android.keyguard.KeyguardSliceView>
|
</com.android.keyguard.KeyguardSliceView>
|
||||||
@@ -24,9 +24,6 @@
|
|||||||
|
|
||||||
<bool name="flag_monet">true</bool>
|
<bool name="flag_monet">true</bool>
|
||||||
|
|
||||||
<!-- AOD/Lockscreen alternate layout -->
|
|
||||||
<bool name="flag_keyguard_layout">true</bool>
|
|
||||||
|
|
||||||
<!-- People Tile flag -->
|
<!-- People Tile flag -->
|
||||||
<bool name="flag_conversations">false</bool>
|
<bool name="flag_conversations">false</bool>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
|
|
||||||
private static final long CLOCK_OUT_MILLIS = 150;
|
private static final long CLOCK_OUT_MILLIS = 150;
|
||||||
private static final long CLOCK_IN_MILLIS = 200;
|
private static final long CLOCK_IN_MILLIS = 200;
|
||||||
private static final long SMARTSPACE_MOVE_MILLIS = 350;
|
private static final long STATUS_AREA_MOVE_MILLIS = 350;
|
||||||
|
|
||||||
@IntDef({LARGE, SMALL})
|
@IntDef({LARGE, SMALL})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@@ -63,13 +63,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
private AnimatableClockView mClockView;
|
private AnimatableClockView mClockView;
|
||||||
private AnimatableClockView mLargeClockView;
|
private AnimatableClockView mLargeClockView;
|
||||||
|
|
||||||
/**
|
private View mStatusArea;
|
||||||
* Status area (date and other stuff) shown below the clock. Plugin can decide whether or not to
|
|
||||||
* show it below the alternate clock.
|
|
||||||
*/
|
|
||||||
private View mKeyguardStatusArea;
|
|
||||||
/** Mutually exclusive with mKeyguardStatusArea */
|
|
||||||
private View mSmartspaceView;
|
|
||||||
private int mSmartspaceTopOffset;
|
private int mSmartspaceTopOffset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +79,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
|
|
||||||
@VisibleForTesting AnimatorSet mClockInAnim = null;
|
@VisibleForTesting AnimatorSet mClockInAnim = null;
|
||||||
@VisibleForTesting AnimatorSet mClockOutAnim = null;
|
@VisibleForTesting AnimatorSet mClockOutAnim = null;
|
||||||
private ObjectAnimator mSmartspaceAnim = null;
|
private ObjectAnimator mStatusAreaAnim = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the Keyguard Slice has a header (big center-aligned text.)
|
* If the Keyguard Slice has a header (big center-aligned text.)
|
||||||
@@ -131,7 +125,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
mClockView = findViewById(R.id.animatable_clock_view);
|
mClockView = findViewById(R.id.animatable_clock_view);
|
||||||
mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
|
mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
|
||||||
mLargeClockView = findViewById(R.id.animatable_clock_view_large);
|
mLargeClockView = findViewById(R.id.animatable_clock_view_large);
|
||||||
mKeyguardStatusArea = findViewById(R.id.keyguard_status_area);
|
mStatusArea = findViewById(R.id.keyguard_status_area);
|
||||||
|
|
||||||
onDensityOrFontScaleChanged();
|
onDensityOrFontScaleChanged();
|
||||||
}
|
}
|
||||||
@@ -200,22 +194,22 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
private void animateClockChange(boolean useLargeClock) {
|
private void animateClockChange(boolean useLargeClock) {
|
||||||
if (mClockInAnim != null) mClockInAnim.cancel();
|
if (mClockInAnim != null) mClockInAnim.cancel();
|
||||||
if (mClockOutAnim != null) mClockOutAnim.cancel();
|
if (mClockOutAnim != null) mClockOutAnim.cancel();
|
||||||
if (mSmartspaceAnim != null) mSmartspaceAnim.cancel();
|
if (mStatusAreaAnim != null) mStatusAreaAnim.cancel();
|
||||||
|
|
||||||
View in, out;
|
View in, out;
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
float smartspaceYTranslation;
|
float statusAreaYTranslation;
|
||||||
if (useLargeClock) {
|
if (useLargeClock) {
|
||||||
out = mClockFrame;
|
out = mClockFrame;
|
||||||
in = mLargeClockFrame;
|
in = mLargeClockFrame;
|
||||||
if (indexOfChild(in) == -1) addView(in);
|
if (indexOfChild(in) == -1) addView(in);
|
||||||
direction = -1;
|
direction = -1;
|
||||||
smartspaceYTranslation = mSmartspaceView == null ? 0
|
statusAreaYTranslation = mClockFrame.getTop() - mStatusArea.getTop()
|
||||||
: mClockFrame.getTop() - mSmartspaceView.getTop() + mSmartspaceTopOffset;
|
+ mSmartspaceTopOffset;
|
||||||
} else {
|
} else {
|
||||||
in = mClockFrame;
|
in = mClockFrame;
|
||||||
out = mLargeClockFrame;
|
out = mLargeClockFrame;
|
||||||
smartspaceYTranslation = 0f;
|
statusAreaYTranslation = 0f;
|
||||||
|
|
||||||
// Must remove in order for notifications to appear in the proper place
|
// Must remove in order for notifications to appear in the proper place
|
||||||
removeView(out);
|
removeView(out);
|
||||||
@@ -251,18 +245,16 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
mClockInAnim.start();
|
mClockInAnim.start();
|
||||||
mClockOutAnim.start();
|
mClockOutAnim.start();
|
||||||
|
|
||||||
if (mSmartspaceView != null) {
|
mStatusAreaAnim = ObjectAnimator.ofFloat(mStatusArea, View.TRANSLATION_Y,
|
||||||
mSmartspaceAnim = ObjectAnimator.ofFloat(mSmartspaceView, View.TRANSLATION_Y,
|
statusAreaYTranslation);
|
||||||
smartspaceYTranslation);
|
mStatusAreaAnim.setDuration(STATUS_AREA_MOVE_MILLIS);
|
||||||
mSmartspaceAnim.setDuration(SMARTSPACE_MOVE_MILLIS);
|
mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
|
||||||
mSmartspaceAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
|
mStatusAreaAnim.addListener(new AnimatorListenerAdapter() {
|
||||||
mSmartspaceAnim.addListener(new AnimatorListenerAdapter() {
|
public void onAnimationEnd(Animator animation) {
|
||||||
public void onAnimationEnd(Animator animation) {
|
mStatusAreaAnim = null;
|
||||||
mSmartspaceAnim = null;
|
}
|
||||||
}
|
});
|
||||||
});
|
mStatusAreaAnim.start();
|
||||||
mSmartspaceAnim.start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,10 +344,6 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSmartspaceView(View smartspaceView) {
|
|
||||||
mSmartspaceView = smartspaceView;
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateColors(ColorExtractor.GradientColors colors) {
|
void updateColors(ColorExtractor.GradientColors colors) {
|
||||||
mSupportsDarkText = colors.supportsDarkText();
|
mSupportsDarkText = colors.supportsDarkText();
|
||||||
mColorPalette = colors.getColorPalette();
|
mColorPalette = colors.getColorPalette();
|
||||||
@@ -369,8 +357,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
pw.println(" mClockPlugin: " + mClockPlugin);
|
pw.println(" mClockPlugin: " + mClockPlugin);
|
||||||
pw.println(" mClockFrame: " + mClockFrame);
|
pw.println(" mClockFrame: " + mClockFrame);
|
||||||
pw.println(" mLargeClockFrame: " + mLargeClockFrame);
|
pw.println(" mLargeClockFrame: " + mLargeClockFrame);
|
||||||
pw.println(" mKeyguardStatusArea: " + mKeyguardStatusArea);
|
pw.println(" mStatusArea: " + mStatusArea);
|
||||||
pw.println(" mSmartspaceView: " + mSmartspaceView);
|
|
||||||
pw.println(" mDarkAmount: " + mDarkAmount);
|
pw.println(" mDarkAmount: " + mDarkAmount);
|
||||||
pw.println(" mSupportsDarkText: " + mSupportsDarkText);
|
pw.println(" mSupportsDarkText: " + mSupportsDarkText);
|
||||||
pw.println(" mColorPalette: " + Arrays.toString(mColorPalette));
|
pw.println(" mColorPalette: " + Arrays.toString(mColorPalette));
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ import android.app.WallpaperManager;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.android.internal.colorextraction.ColorExtractor;
|
import com.android.internal.colorextraction.ColorExtractor;
|
||||||
@@ -99,7 +101,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
|
|
||||||
private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
|
private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
|
||||||
|
|
||||||
// If set, will replace keyguard_status_area
|
private ViewGroup mStatusArea;
|
||||||
|
// If set will replace keyguard_slice_view
|
||||||
private View mSmartspaceView;
|
private View mSmartspaceView;
|
||||||
|
|
||||||
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
||||||
@@ -191,8 +194,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin);
|
mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin);
|
||||||
|
|
||||||
if (mOnlyClock) {
|
if (mOnlyClock) {
|
||||||
View ksa = mView.findViewById(R.id.keyguard_status_area);
|
View ksv = mView.findViewById(R.id.keyguard_slice_view);
|
||||||
ksa.setVisibility(View.GONE);
|
ksv.setVisibility(View.GONE);
|
||||||
|
|
||||||
View nic = mView.findViewById(
|
View nic = mView.findViewById(
|
||||||
R.id.left_aligned_notification_icon_container);
|
R.id.left_aligned_notification_icon_container);
|
||||||
@@ -201,19 +204,18 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
}
|
}
|
||||||
updateAodIcons();
|
updateAodIcons();
|
||||||
|
|
||||||
|
mStatusArea = mView.findViewById(R.id.keyguard_status_area);
|
||||||
|
|
||||||
if (mSmartspaceController.isEnabled()) {
|
if (mSmartspaceController.isEnabled()) {
|
||||||
mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
|
mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
|
||||||
|
View ksv = mView.findViewById(R.id.keyguard_slice_view);
|
||||||
|
int ksvIndex = mStatusArea.indexOfChild(ksv);
|
||||||
|
ksv.setVisibility(View.GONE);
|
||||||
|
|
||||||
View ksa = mView.findViewById(R.id.keyguard_status_area);
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||||
int ksaIndex = mView.indexOfChild(ksa);
|
|
||||||
ksa.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
// Place smartspace view below normal clock...
|
|
||||||
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
|
|
||||||
MATCH_PARENT, WRAP_CONTENT);
|
MATCH_PARENT, WRAP_CONTENT);
|
||||||
lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view);
|
|
||||||
|
|
||||||
mView.addView(mSmartspaceView, ksaIndex, lp);
|
mStatusArea.addView(mSmartspaceView, ksvIndex, lp);
|
||||||
int startPadding = getContext().getResources()
|
int startPadding = getContext().getResources()
|
||||||
.getDimensionPixelSize(R.dimen.below_clock_padding_start);
|
.getDimensionPixelSize(R.dimen.below_clock_padding_start);
|
||||||
int endPadding = getContext().getResources()
|
int endPadding = getContext().getResources()
|
||||||
@@ -221,14 +223,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0);
|
mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0);
|
||||||
|
|
||||||
updateClockLayout();
|
updateClockLayout();
|
||||||
|
|
||||||
View nic = mView.findViewById(
|
|
||||||
R.id.left_aligned_notification_icon_container);
|
|
||||||
lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
|
|
||||||
lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
|
|
||||||
nic.setLayoutParams(lp);
|
|
||||||
|
|
||||||
mView.setSmartspaceView(mSmartspaceView);
|
|
||||||
mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceView);
|
mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,8 +238,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
}
|
}
|
||||||
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
|
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
|
||||||
mView.setClockPlugin(null, mStatusBarStateController.getState());
|
mView.setClockPlugin(null, mStatusBarStateController.getState());
|
||||||
|
|
||||||
mSmartspaceController.disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,8 +320,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
|
PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
|
||||||
scale, props, animate);
|
scale, props, animate);
|
||||||
|
|
||||||
if (mSmartspaceView != null) {
|
if (mStatusArea != null) {
|
||||||
PropertyAnimator.setProperty(mSmartspaceView, AnimatableProperty.TRANSLATION_X,
|
PropertyAnimator.setProperty(mStatusArea, AnimatableProperty.TRANSLATION_X,
|
||||||
x, props, animate);
|
x, props, animate);
|
||||||
|
|
||||||
// If we're unlocking with the SmartSpace shared element transition, let the controller
|
// If we're unlocking with the SmartSpace shared element transition, let the controller
|
||||||
@@ -340,7 +332,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
}
|
}
|
||||||
|
|
||||||
mKeyguardSliceViewController.updatePosition(x, props, animate);
|
mKeyguardSliceViewController.updatePosition(x, props, animate);
|
||||||
mNotificationIconAreaController.updatePosition(x, props, animate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets an alpha value on every child view except for the smartspace. */
|
/** Sets an alpha value on every child view except for the smartspace. */
|
||||||
|
|||||||
@@ -33,12 +33,10 @@ import android.os.Trace;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextUtils.TruncateAt;
|
import android.text.TextUtils.TruncateAt;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.slice.SliceItem;
|
import androidx.slice.SliceItem;
|
||||||
@@ -85,8 +83,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
private boolean mHasHeader;
|
private boolean mHasHeader;
|
||||||
private View.OnClickListener mOnClickListener;
|
private View.OnClickListener mOnClickListener;
|
||||||
|
|
||||||
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
|
|
||||||
|
|
||||||
public KeyguardSliceView(Context context, AttributeSet attrs) {
|
public KeyguardSliceView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
@@ -136,35 +132,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the lockscreen mode which may change the layout of the keyguard slice view.
|
|
||||||
*/
|
|
||||||
public void updateLockScreenMode(int mode) {
|
|
||||||
mLockScreenMode = mode;
|
|
||||||
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
|
||||||
mTitle.setPaddingRelative(0, 0, 0, 0);
|
|
||||||
mTitle.setGravity(Gravity.START);
|
|
||||||
setGravity(Gravity.START);
|
|
||||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
|
|
||||||
lp.removeRule(RelativeLayout.CENTER_HORIZONTAL);
|
|
||||||
setLayoutParams(lp);
|
|
||||||
} else {
|
|
||||||
final int horizontalPaddingDpValue = (int) TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_DIP,
|
|
||||||
44,
|
|
||||||
getResources().getDisplayMetrics()
|
|
||||||
);
|
|
||||||
mTitle.setPaddingRelative(horizontalPaddingDpValue, 0, horizontalPaddingDpValue, 0);
|
|
||||||
mTitle.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
|
|
||||||
lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
|
||||||
setLayoutParams(lp);
|
|
||||||
}
|
|
||||||
mRow.setLockscreenMode(mode);
|
|
||||||
requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<View, PendingIntent> showSlice(RowContent header, List<SliceContent> subItems) {
|
Map<View, PendingIntent> showSlice(RowContent header, List<SliceContent> subItems) {
|
||||||
Trace.beginSection("KeyguardSliceView#showSlice");
|
Trace.beginSection("KeyguardSliceView#showSlice");
|
||||||
mHasHeader = header != null;
|
mHasHeader = header != null;
|
||||||
@@ -189,8 +156,7 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it
|
final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it
|
||||||
mRow.setVisibility(subItemsCount > 0 ? VISIBLE : GONE);
|
mRow.setVisibility(subItemsCount > 0 ? VISIBLE : GONE);
|
||||||
LinearLayout.LayoutParams layoutParams = (LayoutParams) mRow.getLayoutParams();
|
LinearLayout.LayoutParams layoutParams = (LayoutParams) mRow.getLayoutParams();
|
||||||
layoutParams.gravity = mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL
|
layoutParams.gravity = Gravity.START;
|
||||||
? Gravity.START : Gravity.CENTER;
|
|
||||||
mRow.setLayoutParams(layoutParams);
|
mRow.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
for (int i = startIndex; i < subItemsCount; i++) {
|
for (int i = startIndex; i < subItemsCount; i++) {
|
||||||
@@ -224,8 +190,7 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
final int iconSize = mHasHeader ? mIconSizeWithHeader : mIconSize;
|
final int iconSize = mHasHeader ? mIconSizeWithHeader : mIconSize;
|
||||||
iconDrawable = icon.getIcon().loadDrawable(mContext);
|
iconDrawable = icon.getIcon().loadDrawable(mContext);
|
||||||
if (iconDrawable != null) {
|
if (iconDrawable != null) {
|
||||||
if ((iconDrawable instanceof InsetDrawable)
|
if (iconDrawable instanceof InsetDrawable) {
|
||||||
&& mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
|
||||||
// System icons (DnD) use insets which are fine for centered slice content
|
// System icons (DnD) use insets which are fine for centered slice content
|
||||||
// but will cause a slight indent for left/right-aligned slice views
|
// but will cause a slight indent for left/right-aligned slice views
|
||||||
iconDrawable = ((InsetDrawable) iconDrawable).getDrawable();
|
iconDrawable = ((InsetDrawable) iconDrawable).getDrawable();
|
||||||
@@ -321,7 +286,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
pw.println(" mTextColor: " + Integer.toHexString(mTextColor));
|
pw.println(" mTextColor: " + Integer.toHexString(mTextColor));
|
||||||
pw.println(" mDarkAmount: " + mDarkAmount);
|
pw.println(" mDarkAmount: " + mDarkAmount);
|
||||||
pw.println(" mHasHeader: " + mHasHeader);
|
pw.println(" mHasHeader: " + mHasHeader);
|
||||||
pw.println(" mLockScreenMode: " + mLockScreenMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -332,7 +296,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
|
|
||||||
public static class Row extends LinearLayout {
|
public static class Row extends LinearLayout {
|
||||||
private Set<KeyguardSliceTextView> mKeyguardSliceTextViewSet = new HashSet();
|
private Set<KeyguardSliceTextView> mKeyguardSliceTextViewSet = new HashSet();
|
||||||
private int mLockScreenModeRow = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This view is visible in AOD, which means that the device will sleep if we
|
* This view is visible in AOD, which means that the device will sleep if we
|
||||||
@@ -407,11 +370,7 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
View child = getChildAt(i);
|
View child = getChildAt(i);
|
||||||
if (child instanceof KeyguardSliceTextView) {
|
if (child instanceof KeyguardSliceTextView) {
|
||||||
if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE);
|
||||||
((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE);
|
|
||||||
} else {
|
|
||||||
((KeyguardSliceTextView) child).setMaxWidth(width / 3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +402,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
super.addView(view, index);
|
super.addView(view, index);
|
||||||
|
|
||||||
if (view instanceof KeyguardSliceTextView) {
|
if (view instanceof KeyguardSliceTextView) {
|
||||||
((KeyguardSliceTextView) view).setLockScreenMode(mLockScreenModeRow);
|
|
||||||
mKeyguardSliceTextViewSet.add((KeyguardSliceTextView) view);
|
mKeyguardSliceTextViewSet.add((KeyguardSliceTextView) view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,24 +413,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
mKeyguardSliceTextViewSet.remove((KeyguardSliceTextView) view);
|
mKeyguardSliceTextViewSet.remove((KeyguardSliceTextView) view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the lockscreen mode which may change the layout of this view.
|
|
||||||
*/
|
|
||||||
public void setLockscreenMode(int mode) {
|
|
||||||
mLockScreenModeRow = mode;
|
|
||||||
if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
|
||||||
setOrientation(LinearLayout.VERTICAL);
|
|
||||||
setGravity(Gravity.START);
|
|
||||||
} else {
|
|
||||||
setOrientation(LinearLayout.HORIZONTAL);
|
|
||||||
setGravity(Gravity.CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (KeyguardSliceTextView textView : mKeyguardSliceTextViewSet) {
|
|
||||||
textView.setLockScreenMode(mLockScreenModeRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -480,7 +420,6 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static class KeyguardSliceTextView extends TextView {
|
static class KeyguardSliceTextView extends TextView {
|
||||||
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
|
|
||||||
|
|
||||||
@StyleRes
|
@StyleRes
|
||||||
private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary;
|
private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary;
|
||||||
@@ -509,13 +448,8 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
boolean hasText = !TextUtils.isEmpty(getText());
|
boolean hasText = !TextUtils.isEmpty(getText());
|
||||||
int padding = (int) getContext().getResources()
|
int padding = (int) getContext().getResources()
|
||||||
.getDimension(R.dimen.widget_horizontal_padding) / 2;
|
.getDimension(R.dimen.widget_horizontal_padding) / 2;
|
||||||
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
// orientation is vertical, so add padding to top & bottom
|
||||||
// orientation is vertical, so add padding to top & bottom
|
setPadding(0, padding, 0, hasText ? padding : 0);
|
||||||
setPadding(0, padding, 0, hasText ? padding : 0);
|
|
||||||
} else {
|
|
||||||
// orientation is horizontal, so add padding to left & right
|
|
||||||
setPadding(padding, 0, padding * (hasText ? 1 : -1), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCompoundDrawablePadding((int) mContext.getResources()
|
setCompoundDrawablePadding((int) mContext.getResources()
|
||||||
.getDimension(R.dimen.widget_icon_padding));
|
.getDimension(R.dimen.widget_icon_padding));
|
||||||
@@ -543,18 +477,5 @@ public class KeyguardSliceView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the lockscreen mode which may change the layout of this view.
|
|
||||||
*/
|
|
||||||
public void setLockScreenMode(int mode) {
|
|
||||||
mLockScreenMode = mode;
|
|
||||||
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
|
|
||||||
setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
|
|
||||||
} else {
|
|
||||||
setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
|
||||||
}
|
|
||||||
updatePadding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
|
|||||||
private Uri mKeyguardSliceUri;
|
private Uri mKeyguardSliceUri;
|
||||||
private Slice mSlice;
|
private Slice mSlice;
|
||||||
private Map<View, PendingIntent> mClickActions;
|
private Map<View, PendingIntent> mClickActions;
|
||||||
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
|
|
||||||
|
|
||||||
TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue);
|
TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue);
|
||||||
|
|
||||||
@@ -137,7 +136,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
|
|||||||
TAG + "@" + Integer.toHexString(
|
TAG + "@" + Integer.toHexString(
|
||||||
KeyguardSliceViewController.this.hashCode()),
|
KeyguardSliceViewController.this.hashCode()),
|
||||||
KeyguardSliceViewController.this);
|
KeyguardSliceViewController.this);
|
||||||
mView.updateLockScreenMode(mLockScreenMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,14 +157,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
|
|||||||
mView.setLayoutParams(lp);
|
mView.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the lockscreen mode which may change the layout of the keyguard slice view.
|
|
||||||
*/
|
|
||||||
public void updateLockScreenMode(int mode) {
|
|
||||||
mLockScreenMode = mode;
|
|
||||||
mView.updateLockScreenMode(mLockScreenMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the slice provider Uri.
|
* Sets the slice provider Uri.
|
||||||
*/
|
*/
|
||||||
@@ -249,6 +239,5 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
|
|||||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||||
pw.println(" mSlice: " + mSlice);
|
pw.println(" mSlice: " + mSlice);
|
||||||
pw.println(" mClickActions: " + mClickActions);
|
pw.println(" mClickActions: " + mClickActions);
|
||||||
pw.println(" mLockScreenMode: " + mLockScreenMode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyguardSlice = findViewById(R.id.keyguard_status_area);
|
mKeyguardSlice = findViewById(R.id.keyguard_slice_view);
|
||||||
mTextColor = mClockView.getCurrentTextColor();
|
mTextColor = mClockView.getCurrentTextColor();
|
||||||
|
|
||||||
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
|
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
|
||||||
|
|||||||
@@ -248,11 +248,6 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
|
|||||||
};
|
};
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
|
||||||
public void onLockScreenModeChanged(int mode) {
|
|
||||||
mKeyguardSliceViewController.updateLockScreenMode(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeChanged() {
|
public void onTimeChanged() {
|
||||||
refreshTime();
|
refreshTime();
|
||||||
|
|||||||
@@ -188,9 +188,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private static final int MSG_TIME_FORMAT_UPDATE = 344;
|
private static final int MSG_TIME_FORMAT_UPDATE = 344;
|
||||||
private static final int MSG_REQUIRE_NFC_UNLOCK = 345;
|
private static final int MSG_REQUIRE_NFC_UNLOCK = 345;
|
||||||
|
|
||||||
public static final int LOCK_SCREEN_MODE_NORMAL = 0;
|
|
||||||
public static final int LOCK_SCREEN_MODE_LAYOUT_1 = 1;
|
|
||||||
|
|
||||||
/** Biometric authentication state: Not listening. */
|
/** Biometric authentication state: Not listening. */
|
||||||
private static final int BIOMETRIC_STATE_STOPPED = 0;
|
private static final int BIOMETRIC_STATE_STOPPED = 0;
|
||||||
|
|
||||||
@@ -1867,9 +1864,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
case MSG_KEYGUARD_GOING_AWAY:
|
case MSG_KEYGUARD_GOING_AWAY:
|
||||||
handleKeyguardGoingAway((boolean) msg.obj);
|
handleKeyguardGoingAway((boolean) msg.obj);
|
||||||
break;
|
break;
|
||||||
case MSG_LOCK_SCREEN_MODE:
|
|
||||||
handleLockScreenMode();
|
|
||||||
break;
|
|
||||||
case MSG_TIME_FORMAT_UPDATE:
|
case MSG_TIME_FORMAT_UPDATE:
|
||||||
handleTimeFormatUpdate((String) msg.obj);
|
handleTimeFormatUpdate((String) msg.obj);
|
||||||
break;
|
break;
|
||||||
@@ -2011,8 +2005,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLockScreenMode(featureFlags.isKeyguardLayoutEnabled());
|
|
||||||
|
|
||||||
mTimeFormatChangeObserver = new ContentObserver(mHandler) {
|
mTimeFormatChangeObserver = new ContentObserver(mHandler) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
@@ -2028,14 +2020,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
|
false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLockScreenMode(boolean isEnabled) {
|
|
||||||
final int newMode = isEnabled ? LOCK_SCREEN_MODE_LAYOUT_1 : LOCK_SCREEN_MODE_NORMAL;
|
|
||||||
if (newMode != mLockScreenMode) {
|
|
||||||
mLockScreenMode = newMode;
|
|
||||||
mHandler.sendEmptyMessage(MSG_LOCK_SCREEN_MODE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUdfpsEnrolled(int userId) {
|
private void updateUdfpsEnrolled(int userId) {
|
||||||
mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId);
|
mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId);
|
||||||
}
|
}
|
||||||
@@ -2665,20 +2649,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle {@link #MSG_LOCK_SCREEN_MODE}
|
|
||||||
*/
|
|
||||||
private void handleLockScreenMode() {
|
|
||||||
Assert.isMainThread();
|
|
||||||
if (DEBUG) Log.d(TAG, "handleLockScreenMode(" + mLockScreenMode + ")");
|
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
|
||||||
if (cb != null) {
|
|
||||||
cb.onLockScreenModeChanged(mLockScreenMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle (@line #MSG_TIMEZONE_UPDATE}
|
* Handle (@line #MSG_TIMEZONE_UPDATE}
|
||||||
*/
|
*/
|
||||||
@@ -3057,7 +3027,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
callback.onKeyguardOccludedChanged(mKeyguardOccluded);
|
callback.onKeyguardOccludedChanged(mKeyguardOccluded);
|
||||||
callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible);
|
callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible);
|
||||||
callback.onTelephonyCapable(mTelephonyCapable);
|
callback.onTelephonyCapable(mTelephonyCapable);
|
||||||
callback.onLockScreenModeChanged(mLockScreenMode);
|
|
||||||
|
|
||||||
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
|
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
|
||||||
final SimData state = data.getValue();
|
final SimData state = data.getValue();
|
||||||
|
|||||||
@@ -324,11 +324,6 @@ public class KeyguardUpdateMonitorCallback {
|
|||||||
*/
|
*/
|
||||||
public void onSecondaryLockscreenRequirementChanged(int userId) { }
|
public void onSecondaryLockscreenRequirementChanged(int userId) { }
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to switch lock screen layout/clock layouts
|
|
||||||
*/
|
|
||||||
public void onLockScreenModeChanged(int mode) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when notifying user to unlock in order to use NFC.
|
* Called when notifying user to unlock in order to use NFC.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ public abstract class KeyguardStatusViewModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) {
|
static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) {
|
||||||
return keyguardClockSwitch.findViewById(R.id.keyguard_status_area);
|
return keyguardClockSwitch.findViewById(R.id.keyguard_slice_view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,10 +132,6 @@ public class FeatureFlags {
|
|||||||
return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2_rendering);
|
return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2_rendering);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isKeyguardLayoutEnabled() {
|
|
||||||
return mFlagReader.isEnabled(R.bool.flag_keyguard_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public boolean useNewLockscreenAnimations() {
|
public boolean useNewLockscreenAnimations() {
|
||||||
return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations);
|
return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations);
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ public class KeyguardIndicationController {
|
|||||||
private boolean mBatteryPresent = true;
|
private boolean mBatteryPresent = true;
|
||||||
private long mChargingTimeRemaining;
|
private long mChargingTimeRemaining;
|
||||||
private String mMessageToShowOnScreenOn;
|
private String mMessageToShowOnScreenOn;
|
||||||
protected int mLockScreenMode;
|
|
||||||
private boolean mInited;
|
private boolean mInited;
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mUpdateMonitorCallback;
|
private KeyguardUpdateMonitorCallback mUpdateMonitorCallback;
|
||||||
@@ -862,11 +861,6 @@ public class KeyguardIndicationController {
|
|||||||
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
|
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
|
||||||
public static final int HIDE_DELAY_MS = 5000;
|
public static final int HIDE_DELAY_MS = 5000;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLockScreenModeChanged(int mode) {
|
|
||||||
mLockScreenMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshBatteryInfo(BatteryStatus status) {
|
public void onRefreshBatteryInfo(BatteryStatus status) {
|
||||||
boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING
|
boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.net.Uri
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.android.settingslib.Utils
|
import com.android.settingslib.Utils
|
||||||
@@ -73,6 +74,10 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
@Main private val handler: Handler,
|
@Main private val handler: Handler,
|
||||||
optionalPlugin: Optional<BcSmartspaceDataPlugin>
|
optionalPlugin: Optional<BcSmartspaceDataPlugin>
|
||||||
) {
|
) {
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "LockscreenSmartspaceController"
|
||||||
|
}
|
||||||
|
|
||||||
private var session: SmartspaceSession? = null
|
private var session: SmartspaceSession? = null
|
||||||
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
|
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
|
||||||
|
|
||||||
@@ -210,6 +215,7 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
|
|
||||||
val newSession = smartspaceManager.createSmartspaceSession(
|
val newSession = smartspaceManager.createSmartspaceSession(
|
||||||
SmartspaceConfig.Builder(context, "lockscreen").build())
|
SmartspaceConfig.Builder(context, "lockscreen").build())
|
||||||
|
Log.d(TAG, "Starting smartspace session for lockscreen")
|
||||||
newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener)
|
newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener)
|
||||||
this.session = newSession
|
this.session = newSession
|
||||||
|
|
||||||
@@ -231,6 +237,8 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
* Disconnects the smartspace view from the smartspace service and cleans up any resources.
|
* Disconnects the smartspace view from the smartspace service and cleans up any resources.
|
||||||
*/
|
*/
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
|
if (!smartspaceViews.isEmpty()) return
|
||||||
|
|
||||||
execution.assertIsMainThread()
|
execution.assertIsMainThread()
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
@@ -248,6 +256,7 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
session = null
|
session = null
|
||||||
|
|
||||||
plugin?.onTargetsAvailable(emptyList())
|
plugin?.onTargetsAvailable(emptyList())
|
||||||
|
Log.d(TAG, "Ending smartspace session for lockscreen")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addListener(listener: SmartspaceTargetListener) {
|
fun addListener(listener: SmartspaceTargetListener) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.keyguard;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@@ -30,6 +29,7 @@ import android.content.res.Resources;
|
|||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
@@ -108,7 +108,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
private final View mFakeSmartspaceView = new View(mContext);
|
private final View mFakeSmartspaceView = new View(mContext);
|
||||||
|
|
||||||
private KeyguardClockSwitchController mController;
|
private KeyguardClockSwitchController mController;
|
||||||
private View mStatusArea;
|
private View mSliceView;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@@ -149,8 +149,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
||||||
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);
|
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);
|
||||||
|
|
||||||
mStatusArea = new View(getContext());
|
mSliceView = new View(getContext());
|
||||||
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea);
|
when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView);
|
||||||
|
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(
|
||||||
|
new LinearLayout(getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -215,7 +217,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
|
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
|
||||||
mController.init();
|
mController.init();
|
||||||
|
|
||||||
assertEquals(View.GONE, mStatusArea.getVisibility());
|
assertEquals(View.GONE, mSliceView.getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -223,22 +225,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
when(mSmartspaceController.isEnabled()).thenReturn(false);
|
when(mSmartspaceController.isEnabled()).thenReturn(false);
|
||||||
mController.init();
|
mController.init();
|
||||||
|
|
||||||
assertEquals(View.VISIBLE, mStatusArea.getVisibility());
|
assertEquals(View.VISIBLE, mSliceView.getVisibility());
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDetachDisconnectsSmartspace() {
|
|
||||||
when(mSmartspaceController.isEnabled()).thenReturn(true);
|
|
||||||
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
|
|
||||||
mController.init();
|
|
||||||
verify(mView).addView(eq(mFakeSmartspaceView), anyInt(), any());
|
|
||||||
|
|
||||||
ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
|
|
||||||
ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
|
|
||||||
verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
|
|
||||||
|
|
||||||
listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView);
|
|
||||||
verify(mSmartspaceController).disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
||||||
mKeyguardSliceView = (KeyguardSliceView) layoutInflater
|
mKeyguardSliceView = (KeyguardSliceView) layoutInflater
|
||||||
.inflate(R.layout.keyguard_status_area, null);
|
.inflate(R.layout.keyguard_slice_view, null);
|
||||||
mSliceUri = Uri.parse(KeyguardSliceProvider.KEYGUARD_SLICE_URI);
|
mSliceUri = Uri.parse(KeyguardSliceProvider.KEYGUARD_SLICE_URI);
|
||||||
SliceProvider.setSpecs(new HashSet<>(Collections.singletonList(SliceSpecs.LIST)));
|
SliceProvider.setSpecs(new HashSet<>(Collections.singletonList(SliceSpecs.LIST)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,8 +239,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
|
|
||||||
when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);
|
when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);
|
||||||
|
|
||||||
when(mFeatureFlags.isKeyguardLayoutEnabled()).thenReturn(false);
|
|
||||||
|
|
||||||
mMockitoSession = ExtendedMockito.mockitoSession()
|
mMockitoSession = ExtendedMockito.mockitoSession()
|
||||||
.spyStatic(SubscriptionManager.class).startMocking();
|
.spyStatic(SubscriptionManager.class).startMocking();
|
||||||
ExtendedMockito.doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
|
ExtendedMockito.doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
clearInvocations(plugin)
|
clearInvocations(plugin)
|
||||||
|
|
||||||
// WHEN the session is closed
|
// WHEN the session is closed
|
||||||
|
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
|
||||||
controller.disconnect()
|
controller.disconnect()
|
||||||
|
|
||||||
// THEN the listener receives an empty list of targets
|
// THEN the listener receives an empty list of targets
|
||||||
@@ -417,6 +418,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
connectSession()
|
connectSession()
|
||||||
|
|
||||||
// WHEN we are told to cleanup
|
// WHEN we are told to cleanup
|
||||||
|
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
|
||||||
controller.disconnect()
|
controller.disconnect()
|
||||||
|
|
||||||
// THEN we disconnect from the session and unregister any listeners
|
// THEN we disconnect from the session and unregister any listeners
|
||||||
|
|||||||
Reference in New Issue
Block a user