зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1201346 - Make menu button have LWT on phones. r=liuche
This was not broken on tablet. The new ShapedButtonFrameLayout class is a duplicate of ShapedButton's LWT code. I tried an approach that extracted this code out to an external class, to prevent code duplication and reduce the code size but due to the access rights on the super classes, it was really messy and, imo, not worth it. --HG-- extra : commitid : 9Nlrj5wMUgb extra : rebase_source : 05edfdd8f16a60a5677c0ac5d204cf32d8df4b3a
This commit is contained in:
Родитель
7e2a704b4f
Коммит
baa7064d18
|
@ -500,6 +500,7 @@ gbjar.sources += [
|
|||
'toolbar/PageActionLayout.java',
|
||||
'toolbar/PhoneTabsButton.java',
|
||||
'toolbar/ShapedButton.java',
|
||||
'toolbar/ShapedButtonFrameLayout.java',
|
||||
'toolbar/SiteIdentityPopup.java',
|
||||
'toolbar/TabCounter.java',
|
||||
'toolbar/ToolbarDisplayLayout.java',
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- If you change this view, update ShapedButton*,
|
||||
which dynamically resets to this view. -->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"
|
||||
|
@ -11,7 +13,7 @@
|
|||
<item android:state_focused="true"
|
||||
android:state_pressed="false"
|
||||
android:drawable="@color/highlight_shaped_focused"/>
|
||||
|
||||
|
||||
<item android:drawable="@color/text_and_tabs_tray_grey"/>
|
||||
|
||||
</selector>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
android:src="@drawable/url_bar_translating_edge"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
<org.mozilla.gecko.widget.themed.ThemedFrameLayout
|
||||
<org.mozilla.gecko.toolbar.ShapedButtonFrameLayout
|
||||
android:id="@+id/menu"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@ -54,7 +54,7 @@
|
|||
android:src="@drawable/menu"
|
||||
android:tint="@color/tabs_tray_icon_grey"/>
|
||||
|
||||
</org.mozilla.gecko.widget.themed.ThemedFrameLayout>
|
||||
</org.mozilla.gecko.toolbar.ShapedButtonFrameLayout>
|
||||
|
||||
<org.mozilla.gecko.toolbar.PhoneTabsButton android:id="@+id/tabs"
|
||||
style="@style/UrlBar.ImageButton"
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.toolbar;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.lwt.LightweightThemeDrawable;
|
||||
import org.mozilla.gecko.util.ColorUtils;
|
||||
import org.mozilla.gecko.widget.themed.ThemedFrameLayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class ShapedButtonFrameLayout extends ThemedFrameLayout {
|
||||
|
||||
public ShapedButtonFrameLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
// The drawable is constructed as per @drawable/shaped_button.
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
final int background = ColorUtils.getColor(getContext(), R.color.text_and_tabs_tray_grey);
|
||||
final LightweightThemeDrawable lightWeight = getTheme().getColorDrawable(this, background);
|
||||
|
||||
if (lightWeight == null)
|
||||
return;
|
||||
|
||||
lightWeight.setAlpha(34, 34);
|
||||
|
||||
final StateListDrawable stateList = new StateListDrawable();
|
||||
stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.highlight_shaped));
|
||||
stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_shaped_focused));
|
||||
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.text_and_tabs_tray_grey));
|
||||
stateList.addState(EMPTY_STATE_SET, lightWeight);
|
||||
|
||||
setBackgroundDrawable(stateList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.shaped_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
if (getBackground() == null || drawable == null) {
|
||||
super.setBackgroundDrawable(drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
drawable.setLevel(getBackground().getLevel());
|
||||
super.setBackgroundDrawable(drawable);
|
||||
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundResource(int resId) {
|
||||
setBackgroundDrawable(getResources().getDrawable(resId));
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче