Merge "Fix ActionButtons background and ripple" into sc-dev
This commit is contained in:
@@ -26,10 +26,54 @@
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="`?android:attr/dialogCornerRadius` requires API level 28 (current min is 21)"
|
||||
errorLine1=" android:radius="?android:attr/dialogCornerRadius""
|
||||
errorLine1=" android:topLeftRadius="?android:attr/dialogCornerRadius""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/settingslib_rounded_background.xml"
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/half_rounded_left_bk.xml"
|
||||
line="23"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="`?android:attr/dialogCornerRadius` requires API level 28 (current min is 21)"
|
||||
errorLine1=" android:bottomLeftRadius="?android:attr/dialogCornerRadius""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/half_rounded_left_bk.xml"
|
||||
line="25"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="`?android:attr/dialogCornerRadius` requires API level 28 (current min is 21)"
|
||||
errorLine1=" android:topRightRadius="?android:attr/dialogCornerRadius""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/half_rounded_right_bk.xml"
|
||||
line="24"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="`?android:attr/dialogCornerRadius` requires API level 28 (current min is 21)"
|
||||
errorLine1=" android:bottomRightRadius="?android:attr/dialogCornerRadius""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/half_rounded_right_bk.xml"
|
||||
line="26"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="`?android:attr/dialogCornerRadius` requires API level 28 (current min is 21)"
|
||||
errorLine1=" android:bottomRightRadius="?android:attr/dialogCornerRadius""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/ActionButtonsPreference/res/drawable/rounded_bk.xml"
|
||||
line="23"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?androidprv:attr/colorSurface" />
|
||||
<corners
|
||||
android:topLeftRadius="?android:attr/dialogCornerRadius"
|
||||
android:topRightRadius="0dp"
|
||||
android:bottomLeftRadius="?android:attr/dialogCornerRadius"
|
||||
android:bottomRightRadius="0dp"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?androidprv:attr/colorSurface" />
|
||||
<corners
|
||||
android:topLeftRadius="0dp"
|
||||
android:topRightRadius="?android:attr/dialogCornerRadius"
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="?android:attr/dialogCornerRadius"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:drawable="@drawable/half_rounded_left_bk"/>
|
||||
</ripple>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:drawable="@drawable/half_rounded_right_bk"/>
|
||||
</ripple>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?androidprv:attr/colorSurface" />
|
||||
<corners
|
||||
android:radius="?android:attr/dialogCornerRadius"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:drawable="@drawable/rounded_bk"/>
|
||||
</ripple>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?androidprv:attr/colorSurface" />
|
||||
<corners
|
||||
android:radius="?android:attr/dialogCornerRadius"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?androidprv:attr/colorSurface" />
|
||||
<corners
|
||||
android:radius="0dp"
|
||||
/>
|
||||
</shape>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:drawable="@drawable/square_bk"/>
|
||||
</ripple>
|
||||
@@ -21,14 +21,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/settingslib_rounded_background">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
style="@style/SettingsLibActionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View
|
||||
@@ -43,7 +42,7 @@
|
||||
android:id="@+id/button2"
|
||||
style="@style/SettingsLibActionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View
|
||||
@@ -58,7 +57,7 @@
|
||||
android:id="@+id/button3"
|
||||
style="@style/SettingsLibActionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View
|
||||
@@ -73,6 +72,6 @@
|
||||
android:id="@+id/button4"
|
||||
style="@style/SettingsLibActionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<!-- Do not translate. -->
|
||||
<integer-array name="background_style1">
|
||||
<item>@drawable/rounded_ripple</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Do not translate. -->
|
||||
<integer-array name="background_style2">
|
||||
<item>@drawable/left_rounded_ripple</item>
|
||||
<item>@drawable/right_rounded_ripple</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Do not translate. -->
|
||||
<integer-array name="background_style3">
|
||||
<item>@drawable/left_rounded_ripple</item>
|
||||
<item>@drawable/square_ripple</item>
|
||||
<item>@drawable/right_rounded_ripple</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Do not translate. -->
|
||||
<integer-array name="background_style4">
|
||||
<item>@drawable/left_rounded_ripple</item>
|
||||
<item>@drawable/square_ripple</item>
|
||||
<item>@drawable/square_ripple</item>
|
||||
<item>@drawable/right_rounded_ripple</item>
|
||||
</integer-array>
|
||||
</resources>
|
||||
@@ -18,6 +18,7 @@ package com.android.settingslib.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
@@ -54,12 +55,21 @@ import java.util.List;
|
||||
public class ActionButtonsPreference extends Preference {
|
||||
|
||||
private static final String TAG = "ActionButtonPreference";
|
||||
private static final boolean mIsAtLeastS = BuildCompatUtils.isAtLeastS();
|
||||
private static final int SINGLE_BUTTON_STYLE = 1;
|
||||
private static final int TWO_BUTTONS_STYLE = 2;
|
||||
private static final int THREE_BUTTONS_STYLE = 3;
|
||||
private static final int FOUR_BUTTONS_STYLE = 4;
|
||||
|
||||
private final ButtonInfo mButton1Info = new ButtonInfo();
|
||||
private final ButtonInfo mButton2Info = new ButtonInfo();
|
||||
private final ButtonInfo mButton3Info = new ButtonInfo();
|
||||
private final ButtonInfo mButton4Info = new ButtonInfo();
|
||||
private final List<ButtonInfo> mVisibleButtonInfos = new ArrayList<>(4);
|
||||
private final List<Drawable> mBtnBackgroundStyle1 = new ArrayList<>(1);
|
||||
private final List<Drawable> mBtnBackgroundStyle2 = new ArrayList<>(2);
|
||||
private final List<Drawable> mBtnBackgroundStyle3 = new ArrayList<>(3);
|
||||
private final List<Drawable> mBtnBackgroundStyle4 = new ArrayList<>(4);
|
||||
|
||||
private View mDivider1;
|
||||
private View mDivider2;
|
||||
@@ -89,15 +99,27 @@ public class ActionButtonsPreference extends Preference {
|
||||
private void init() {
|
||||
setLayoutResource(R.layout.settingslib_action_buttons);
|
||||
setSelectable(false);
|
||||
|
||||
final Resources res = getContext().getResources();
|
||||
fetchDrawableArray(mBtnBackgroundStyle1, res.obtainTypedArray(R.array.background_style1));
|
||||
fetchDrawableArray(mBtnBackgroundStyle2, res.obtainTypedArray(R.array.background_style2));
|
||||
fetchDrawableArray(mBtnBackgroundStyle3, res.obtainTypedArray(R.array.background_style3));
|
||||
fetchDrawableArray(mBtnBackgroundStyle4, res.obtainTypedArray(R.array.background_style4));
|
||||
}
|
||||
|
||||
private void fetchDrawableArray(List<Drawable> drawableList, TypedArray typedArray) {
|
||||
for (int i = 0; i < typedArray.length(); i++) {
|
||||
drawableList.add(
|
||||
getContext().getDrawable(typedArray.getResourceId(i, 0 /* defValue */)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
|
||||
final boolean allowedDivider = !BuildCompatUtils.isAtLeastS();
|
||||
holder.setDividerAllowedAbove(allowedDivider);
|
||||
holder.setDividerAllowedBelow(allowedDivider);
|
||||
holder.setDividerAllowedAbove(!mIsAtLeastS);
|
||||
holder.setDividerAllowedBelow(!mIsAtLeastS);
|
||||
|
||||
mButton1Info.mButton = (Button) holder.findViewById(R.id.button1);
|
||||
mButton2Info.mButton = (Button) holder.findViewById(R.id.button2);
|
||||
@@ -113,25 +135,95 @@ public class ActionButtonsPreference extends Preference {
|
||||
mButton3Info.setUpButton();
|
||||
mButton4Info.setUpButton();
|
||||
|
||||
// Add visible button into list only
|
||||
if (mButton1Info.isVisible()) {
|
||||
// Clear info list to avoid duplicate setup.
|
||||
if (!mVisibleButtonInfos.isEmpty()) {
|
||||
mVisibleButtonInfos.clear();
|
||||
}
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyChanged() {
|
||||
super.notifyChanged();
|
||||
|
||||
// Update buttons background and layout when notified and visible button list exist.
|
||||
if (!mVisibleButtonInfos.isEmpty()) {
|
||||
mVisibleButtonInfos.clear();
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLayout() {
|
||||
// Add visible button into list only when platform version is newer than S.
|
||||
if (mButton1Info.isVisible() && mIsAtLeastS) {
|
||||
mVisibleButtonInfos.add(mButton1Info);
|
||||
}
|
||||
if (mButton2Info.isVisible()) {
|
||||
if (mButton2Info.isVisible() && mIsAtLeastS) {
|
||||
mVisibleButtonInfos.add(mButton2Info);
|
||||
}
|
||||
if (mButton3Info.isVisible()) {
|
||||
if (mButton3Info.isVisible() && mIsAtLeastS) {
|
||||
mVisibleButtonInfos.add(mButton3Info);
|
||||
}
|
||||
if (mButton4Info.isVisible()) {
|
||||
if (mButton4Info.isVisible() && mIsAtLeastS) {
|
||||
mVisibleButtonInfos.add(mButton4Info);
|
||||
}
|
||||
|
||||
final boolean isRtl = getContext().getResources().getConfiguration()
|
||||
.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||
switch (mVisibleButtonInfos.size()) {
|
||||
case SINGLE_BUTTON_STYLE :
|
||||
if (isRtl) {
|
||||
setupRtlBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle1);
|
||||
} else {
|
||||
setupBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle1);
|
||||
}
|
||||
break;
|
||||
case TWO_BUTTONS_STYLE :
|
||||
if (isRtl) {
|
||||
setupRtlBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle2);
|
||||
} else {
|
||||
setupBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle2);
|
||||
}
|
||||
break;
|
||||
case THREE_BUTTONS_STYLE :
|
||||
if (isRtl) {
|
||||
setupRtlBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle3);
|
||||
} else {
|
||||
setupBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle3);
|
||||
}
|
||||
break;
|
||||
case FOUR_BUTTONS_STYLE :
|
||||
if (isRtl) {
|
||||
setupRtlBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle4);
|
||||
} else {
|
||||
setupBackgrounds(mVisibleButtonInfos, mBtnBackgroundStyle4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "No visible buttons info, skip background settings.");
|
||||
break;
|
||||
}
|
||||
|
||||
setupDivider1();
|
||||
setupDivider2();
|
||||
setupDivider3();
|
||||
}
|
||||
|
||||
private void setupBackgrounds(
|
||||
List<ButtonInfo> buttonInfoList, List<Drawable> buttonBackgroundStyles) {
|
||||
for (int i = 0; i < buttonBackgroundStyles.size(); i++) {
|
||||
buttonInfoList.get(i).mButton.setBackground(buttonBackgroundStyles.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupRtlBackgrounds(
|
||||
List<ButtonInfo> buttonInfoList, List<Drawable> buttonBackgroundStyles) {
|
||||
for (int i = buttonBackgroundStyles.size() - 1; i >= 0; i--) {
|
||||
buttonInfoList.get(buttonBackgroundStyles.size() - 1 - i)
|
||||
.mButton.setBackground(buttonBackgroundStyles.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility state of button1.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user