am 69f49434: Merge "Limit transient nav cling to 380dp on large/land devices." into klp-dev
* commit '69f49434ec7240b3b1195b41348ddedba1bd1e98': Limit transient nav cling to 380dp on large/land devices.
This commit is contained in:
@@ -61,4 +61,6 @@
|
|||||||
Landscape's layout allows this to be smaller than for portrait. -->
|
Landscape's layout allows this to be smaller than for portrait. -->
|
||||||
<dimen name="kg_squashed_layout_threshold">400dp</dimen>
|
<dimen name="kg_squashed_layout_threshold">400dp</dimen>
|
||||||
|
|
||||||
|
<!-- width of TransientNavigationConfirmation (-1 for match_parent) -->
|
||||||
|
<dimen name="immersive_mode_cling_width">380dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -113,4 +113,6 @@
|
|||||||
<!-- Margin around the various security views -->
|
<!-- Margin around the various security views -->
|
||||||
<dimen name="keyguard_muliuser_selector_margin">12dp</dimen>
|
<dimen name="keyguard_muliuser_selector_margin">12dp</dimen>
|
||||||
|
|
||||||
|
<!-- width of TransientNavigationConfirmation (-1 for match_parent) -->
|
||||||
|
<dimen name="immersive_mode_cling_width">380dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -356,4 +356,6 @@
|
|||||||
<!-- Outline width for video subtitles. -->
|
<!-- Outline width for video subtitles. -->
|
||||||
<dimen name="subtitle_outline_width">2dp</dimen>
|
<dimen name="subtitle_outline_width">2dp</dimen>
|
||||||
|
|
||||||
|
<!-- width of TransientNavigationConfirmation (-1 for match_parent) -->
|
||||||
|
<dimen name="immersive_mode_cling_width">-1px</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -346,6 +346,7 @@
|
|||||||
<java-symbol type="dimen" name="notification_text_size" />
|
<java-symbol type="dimen" name="notification_text_size" />
|
||||||
<java-symbol type="dimen" name="notification_title_text_size" />
|
<java-symbol type="dimen" name="notification_title_text_size" />
|
||||||
<java-symbol type="dimen" name="notification_subtext_size" />
|
<java-symbol type="dimen" name="notification_subtext_size" />
|
||||||
|
<java-symbol type="dimen" name="immersive_mode_cling_width" />
|
||||||
|
|
||||||
<java-symbol type="string" name="add_account_button_label" />
|
<java-symbol type="string" name="add_account_button_label" />
|
||||||
<java-symbol type="string" name="addToDictionary" />
|
<java-symbol type="string" name="addToDictionary" />
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
package com.android.internal.policy.impl;
|
package com.android.internal.policy.impl;
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.ArgbEvaluator;
|
import android.animation.ArgbEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -166,6 +168,31 @@ public class TransientNavigationConfirmation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WindowManager.LayoutParams getClingWindowLayoutParams() {
|
||||||
|
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
WindowManager.LayoutParams.TYPE_TOAST,
|
||||||
|
0
|
||||||
|
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|
||||||
|
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||||
|
| WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
|
||||||
|
,
|
||||||
|
PixelFormat.TRANSLUCENT);
|
||||||
|
lp.setTitle("TransientNavigationConfirmation");
|
||||||
|
lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications;
|
||||||
|
lp.gravity = Gravity.FILL;
|
||||||
|
return lp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrameLayout.LayoutParams getBubbleLayoutParams() {
|
||||||
|
return new FrameLayout.LayoutParams(
|
||||||
|
mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.immersive_mode_cling_width),
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
||||||
|
}
|
||||||
|
|
||||||
private class ClingWindowView extends FrameLayout {
|
private class ClingWindowView extends FrameLayout {
|
||||||
private static final int BGCOLOR = 0x80000000;
|
private static final int BGCOLOR = 0x80000000;
|
||||||
private static final int OFFSET_DP = 48;
|
private static final int OFFSET_DP = 48;
|
||||||
@@ -173,6 +200,18 @@ public class TransientNavigationConfirmation {
|
|||||||
private final Runnable mConfirm;
|
private final Runnable mConfirm;
|
||||||
private final ColorDrawable mColor = new ColorDrawable(0);
|
private final ColorDrawable mColor = new ColorDrawable(0);
|
||||||
private ValueAnimator mColorAnim;
|
private ValueAnimator mColorAnim;
|
||||||
|
private ViewGroup mClingLayout;
|
||||||
|
|
||||||
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
|
||||||
|
if (mClingLayout != null && mClingLayout.getParent() != null) {
|
||||||
|
mClingLayout.setLayoutParams(getBubbleLayoutParams());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ClingWindowView(Context context, Runnable confirm) {
|
public ClingWindowView(Context context, Runnable confirm) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -190,23 +229,20 @@ public class TransientNavigationConfirmation {
|
|||||||
float density = metrics.density;
|
float density = metrics.density;
|
||||||
|
|
||||||
// create the confirmation cling
|
// create the confirmation cling
|
||||||
final ViewGroup clingLayout = (ViewGroup)
|
mClingLayout = (ViewGroup)
|
||||||
View.inflate(getContext(), R.layout.transient_navigation_cling, null);
|
View.inflate(getContext(), R.layout.transient_navigation_cling, null);
|
||||||
|
|
||||||
final Button ok = (Button) clingLayout.findViewById(R.id.ok);
|
final Button ok = (Button) mClingLayout.findViewById(R.id.ok);
|
||||||
ok.setOnClickListener(new OnClickListener() {
|
ok.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mConfirm.run();
|
mConfirm.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addView(clingLayout, new FrameLayout.LayoutParams(
|
addView(mClingLayout, getBubbleLayoutParams());
|
||||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
));
|
|
||||||
|
|
||||||
if (ActivityManager.isHighEndGfx()) {
|
if (ActivityManager.isHighEndGfx()) {
|
||||||
final View bubble = clingLayout.findViewById(R.id.text);
|
final View bubble = mClingLayout.findViewById(R.id.text);
|
||||||
bubble.setAlpha(0f);
|
bubble.setAlpha(0f);
|
||||||
bubble.setTranslationY(-OFFSET_DP*density);
|
bubble.setTranslationY(-OFFSET_DP*density);
|
||||||
bubble.animate()
|
bubble.animate()
|
||||||
@@ -238,6 +274,13 @@ public class TransientNavigationConfirmation {
|
|||||||
} else {
|
} else {
|
||||||
mColor.setColor(BGCOLOR);
|
mColor.setColor(BGCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mContext.registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetachedFromWindow() {
|
||||||
|
mContext.unregisterReceiver(mReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -259,19 +302,7 @@ public class TransientNavigationConfirmation {
|
|||||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||||
|
|
||||||
// show the confirmation
|
// show the confirmation
|
||||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
WindowManager.LayoutParams lp = getClingWindowLayoutParams();
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
WindowManager.LayoutParams.TYPE_TOAST,
|
|
||||||
0
|
|
||||||
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
|
||||||
| WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
|
|
||||||
,
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
lp.setTitle("TransientNavigationConfirmation");
|
|
||||||
lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications;
|
|
||||||
lp.gravity = Gravity.FILL;
|
|
||||||
mWindowManager.addView(mClingWindow, lp);
|
mWindowManager.addView(mClingWindow, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user