Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
am 6a57628: Permissions redline fixes
Browse files Browse the repository at this point in the history
* commit '6a5762884adc64ea95bd206c46d60031428e977c':
  Permissions redline fixes
  • Loading branch information
Anthony Hugh authored and Android Git Automerger committed Oct 5, 2015
2 parents 5072894 + 6a57628 commit 71b7629
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 60 deletions.
14 changes: 14 additions & 0 deletions res/drawable-watch/action_negative_bg.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="oval">
Expand Down
14 changes: 14 additions & 0 deletions res/drawable-watch/action_positive_bg.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="oval">
Expand Down
14 changes: 14 additions & 0 deletions res/drawable-watch/cancel_button.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/action_negative_bg" />
<item>
Expand Down
14 changes: 14 additions & 0 deletions res/drawable-watch/confirm_button.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/action_positive_bg" />
<item>
Expand Down
14 changes: 14 additions & 0 deletions res/drawable-watch/deny_button.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/action_negative_bg" />
<item>
Expand Down
12 changes: 8 additions & 4 deletions res/layout-watch/confirmation_dialog.xml
Expand Up @@ -29,7 +29,6 @@
<LinearLayout
android:id="@+id/content"
android:orientation="vertical"
android:paddingBottom="@dimen/conf_diag_button_container_height"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down Expand Up @@ -89,13 +88,13 @@
android:layout_marginTop="@dimen/conf_diag_2button_margin_top"
android:background="@drawable/confirm_button"/>
</FrameLayout>

<FrameLayout
android:id="@+id/vertical_button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/conf_diag_3button_margin_left"
android:layout_marginBottom="@dimen/conf_diag_3button_margin_bottom"
android:paddingLeft="@dimen/conf_diag_3button_padding_side"
android:paddingRight="@dimen/conf_diag_3button_padding_side"
android:visibility="gone">
<LinearLayout
android:id="@+id/buttonPanel"
Expand All @@ -113,6 +112,11 @@
<Button
android:id="@+id/vertical_button3"
style="@style/Widget.WearDiag.Button"/>

<!-- Adding padding to the bottom button causes rendering issues, so add
an empty view here instead -->
<Space android:layout_width="match_parent"
android:layout_height="@dimen/conf_diag_3button_padding_bottom"/>
</LinearLayout>
</FrameLayout>
</FrameLayout>
Expand Down
2 changes: 0 additions & 2 deletions res/values-round/dimens.xml
Expand Up @@ -19,7 +19,5 @@
<dimen name="conf_diag_button_container_height">96dp</dimen>
<dimen name="conf_diag_2button_margin_side">32dp</dimen>
<dimen name="conf_diag_2button_margin_top">10dp</dimen>
<dimen name="conf_diag_3button_margin_left">36dp</dimen>
<dimen name="conf_diag_3button_margin_bottom">24dp</dimen>

</resources>
4 changes: 2 additions & 2 deletions res/values-watch/dimens.xml
Expand Up @@ -30,8 +30,8 @@
<dimen name="conf_diag_button_container_height">72dp</dimen>
<dimen name="conf_diag_2button_margin_side">16dp</dimen>
<dimen name="conf_diag_2button_margin_top">9dp</dimen>
<dimen name="conf_diag_3button_margin_left">16dp</dimen>
<dimen name="conf_diag_3button_margin_bottom">9dp</dimen>
<dimen name="conf_diag_3button_padding_side">32dp</dimen>
<dimen name="conf_diag_3button_padding_bottom">22dp</dimen>


<!-- START: Ported values -->
Expand Down
4 changes: 2 additions & 2 deletions res/values-watch/strings.xml
Expand Up @@ -15,8 +15,8 @@
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the dialog button to deny a permission grant and never ask the user again. -->
<string name="grant_dialog_button_deny_dont_ask_again">Deny and don\'t ask again</string>
<!-- Title for the dialog button to deny a permission grant and never ask the user again. [CHAR LIMIT=29]-->
<string name="grant_dialog_button_deny_dont_ask_again">Deny, don\'t ask again</string>

<!-- Template for the current permission from the total number of permissions. -->
<string name="current_permission_template">
Expand Down
Expand Up @@ -57,7 +57,7 @@ public View createView() {
@Override
public void updateWindowAttributes(WindowManager.LayoutParams outLayoutParams) {
outLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
outLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
outLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
outLayoutParams.format = PixelFormat.OPAQUE;
outLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
outLayoutParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
Expand Down
Expand Up @@ -8,6 +8,7 @@
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -24,11 +25,15 @@
public abstract class ConfirmationViewHandler implements
Handler.Callback,
View.OnClickListener,
ViewTreeObserver.OnScrollChangedListener {
ViewTreeObserver.OnScrollChangedListener,
ViewTreeObserver.OnGlobalLayoutListener {
private static final String TAG = "ConfirmationViewHandler";

public static final int MODE_HORIZONTAL_BUTTONS = 0;
public static final int MODE_VERTICAL_BUTTONS = 1;

private static final int MSG_HIDE_BUTTON_BAR = 1001;
private static final int MSG_SHOW_BUTTON_BAR = 1001;
private static final int MSG_HIDE_BUTTON_BAR = 1002;
private static final long HIDE_ANIM_DURATION = 500;

private View mRoot;
Expand Down Expand Up @@ -103,6 +108,9 @@ public View createView() {
R.dimen.conf_diag_floating_height);
mHideHandler = new Handler(this);

mScrollingContainer.getViewTreeObserver().addOnScrollChangedListener(this);
mRoot.getViewTreeObserver().addOnGlobalLayoutListener(this);

return mRoot;
}

Expand Down Expand Up @@ -158,54 +166,41 @@ public void invalidate() {
mVerticalButton3.setCompoundDrawablesWithIntrinsicBounds(
getVerticalButton3Icon(), null, null, null);
}

break;
}

mScrollingContainer.scrollTo(0, 0);

mScrollingContainer.getViewTreeObserver().addOnScrollChangedListener(this);
mHideHandler.removeMessages(MSG_HIDE_BUTTON_BAR);
mHideHandler.removeMessages(MSG_SHOW_BUTTON_BAR);
}

@Override
public void onGlobalLayout() {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "onGlobalLayout");
Log.d(TAG, " contentHeight: " + mContent.getHeight());
}

if (mButtonBarAnimator != null) {
mButtonBarAnimator.cancel();
}

// In order to fake the buttons peeking at the bottom, need to do set the
// padding properly.
if (mContent.getPaddingBottom() != mButtonBarContainer.getHeight()) {
mContent.setPadding(0, 0, 0, mButtonBarContainer.getHeight());
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, " set mContent.PaddingBottom: " + mButtonBarContainer.getHeight());
}
}

mRoot.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// Setup Button animation.
// pop the button bar back to full height, stop all animation
if (mButtonBarAnimator != null) {
mButtonBarAnimator.cancel();
}

// In order to fake the buttons peeking at the bottom, need to do set the
// padding properly.
if (mContent.getPaddingBottom() != mButtonBarContainer.getHeight()) {
mContent.setPadding(0, 0, 0, mButtonBarContainer.getHeight());
}

// stop any calls to hide the button bar in the future
mHideHandler.removeMessages(MSG_HIDE_BUTTON_BAR);
mHiddenBefore = false;

// determine which mode the scrolling should work at.
if (mContent.getHeight() > mScrollingContainer.getHeight()) {
mButtonBarContainer.setTranslationZ(mButtonBarFloatingHeight);
mHideHandler.sendEmptyMessageDelayed(MSG_HIDE_BUTTON_BAR, 3000);
int maxButtonBarHeight = 0;
if (mButtonBarContainer.getHeight() >= mRoot.getHeight() / 2) {
// If the ButtonBar is bigger than half the screen, then don't
// animate all the way.
maxButtonBarHeight = mRoot.getHeight() / 2;
}
generateButtonBarAnimator(mButtonBarContainer.getHeight(),
maxButtonBarHeight, 0, mButtonBarFloatingHeight, 1000);
} else {
mButtonBarContainer.setTranslationY(0);
mButtonBarContainer.setTranslationZ(0);
}
mRoot.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
mButtonBarContainer.setTranslationY(mButtonBarContainer.getHeight());

// Give everything a chance to render
mHideHandler.removeMessages(MSG_HIDE_BUTTON_BAR);
mHideHandler.removeMessages(MSG_SHOW_BUTTON_BAR);
mHideHandler.sendEmptyMessageDelayed(MSG_SHOW_BUTTON_BAR, 50);
}

@Override
Expand All @@ -229,6 +224,9 @@ public void onClick(View v) {
@Override
public boolean handleMessage (Message msg) {
switch (msg.what) {
case MSG_SHOW_BUTTON_BAR:
showButtonBar();
return true;
case MSG_HIDE_BUTTON_BAR:
hideButtonBar();
return true;
Expand All @@ -237,21 +235,72 @@ public boolean handleMessage (Message msg) {
}

@Override
public void onScrollChanged() {
public void onScrollChanged () {
mHideHandler.removeMessages(MSG_HIDE_BUTTON_BAR);
hideButtonBar();
}

private void showButtonBar() {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "showButtonBar");
}

// Setup Button animation.
// pop the button bar back to full height, stop all animation
if (mButtonBarAnimator != null) {
mButtonBarAnimator.cancel();
}

// stop any calls to hide the button bar in the future
mHideHandler.removeMessages(MSG_HIDE_BUTTON_BAR);
mHiddenBefore = false;

// Evaluate the max height the button bar can go
final int screenHeight = mRoot.getHeight();
final int buttonBarHeight = mButtonBarContainer.getHeight();
final int buttonBarMaxHeight =
Math.min(buttonBarHeight, screenHeight / 2);

if (Log.isLoggable(TAG, Log.DEBUG)) {
final int contentHeight = mContent.getHeight() - buttonBarHeight;
Log.d(TAG, " screenHeight: " + screenHeight);
Log.d(TAG, " contentHeight: " + contentHeight);
Log.d(TAG, " buttonBarHeight: " + buttonBarHeight);
Log.d(TAG, " buttonBarMaxHeight: " + buttonBarMaxHeight);
}

mButtonBarContainer.setTranslationZ(mButtonBarFloatingHeight);
mHideHandler.sendEmptyMessageDelayed(MSG_HIDE_BUTTON_BAR, 3000);

generateButtonBarAnimator(buttonBarHeight,
buttonBarHeight - buttonBarMaxHeight, 0, mButtonBarFloatingHeight, 1000);
}

private void hideButtonBar() {
// get the offset to the top of the button bar
int offset = mScrollingContainer.getHeight() + mButtonBarContainer.getHeight() -
mContent.getHeight() + Math.max(mScrollingContainer.getScrollY(), 0);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "hideButtonBar");
}

// The desired margin space between the button bar and the bottom of the dialog text
int topMargin = mContext.getResources().getDimensionPixelSize(
final int topMargin = mContext.getResources().getDimensionPixelSize(
R.dimen.conf_diag_button_container_top_margin);
int translationY = topMargin + (offset > 0 ?
final int contentHeight = mContent.getHeight() + topMargin;
final int screenHeight = mRoot.getHeight();
final int buttonBarHeight = mButtonBarContainer.getHeight();

final int offset = screenHeight + buttonBarHeight
- contentHeight + Math.max(mScrollingContainer.getScrollY(), 0);
final int translationY = (offset > 0 ?
mButtonBarContainer.getHeight() - offset : mButtonBarContainer.getHeight());

if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, " contentHeight: " + contentHeight);
Log.d(TAG, " buttonBarHeight: " + buttonBarHeight);
Log.d(TAG, " mContent.getPaddingBottom(): " + mContent.getPaddingBottom());
Log.d(TAG, " mScrollingContainer.getScrollY(): " + mScrollingContainer.getScrollY());
Log.d(TAG, " translationY: " + translationY);
}

if (!mHiddenBefore || mButtonBarAnimator == null) {
// hasn't hidden the bar yet, just hide now to the right height
generateButtonBarAnimator(
Expand Down

0 comments on commit 71b7629

Please sign in to comment.