mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847578: Flat Holo styled door hanger buttons. [r=mfinkle]
--HG-- extra : rebase_source : 18ed2e6e987f663d0a17f7025e11454ef7c90e39
This commit is contained in:
parent
7413f43a3b
commit
e10b68b08b
40
mobile/android/base/Divider.java
Normal file
40
mobile/android/base/Divider.java
Normal file
@ -0,0 +1,40 @@
|
||||
/* 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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
public class Divider extends View {
|
||||
public static enum Orientation { HORIZONTAL, VERTICAL };
|
||||
|
||||
// Orientation of the divider.
|
||||
private Orientation mOrientation;
|
||||
|
||||
// Density of the device.
|
||||
private int mDensity;
|
||||
|
||||
public Divider(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mDensity = (int) context.getResources().getDisplayMetrics().density;
|
||||
|
||||
setOrientation(Orientation.HORIZONTAL);
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation orientation) {
|
||||
if (mOrientation != orientation) {
|
||||
mOrientation = orientation;
|
||||
|
||||
if (mOrientation == Orientation.HORIZONTAL)
|
||||
setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, mDensity));
|
||||
else
|
||||
setLayoutParams(new LayoutParams(mDensity, LayoutParams.FILL_PARENT));
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,9 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
|
||||
// Optional checkbox added underneath message text
|
||||
private CheckBox mCheckBox;
|
||||
|
||||
// Divider between doorhangers.
|
||||
private View mDivider;
|
||||
|
||||
private int mPersistence = 0;
|
||||
private boolean mPersistWhileVisible = false;
|
||||
private long mTimeout = 0;
|
||||
@ -60,6 +63,14 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void showDivider() {
|
||||
mDivider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hideDivider() {
|
||||
mDivider.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Postpone stuff that needs to be done on the main thread
|
||||
void init(String message, JSONArray buttons, JSONObject options) {
|
||||
setOrientation(VERTICAL);
|
||||
@ -72,6 +83,8 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
|
||||
|
||||
mChoicesLayout = (LinearLayout) findViewById(R.id.doorhanger_choices);
|
||||
|
||||
mDivider = findViewById(R.id.divider_doorhanger);
|
||||
|
||||
// Set the doorhanger text and buttons
|
||||
for (int i = 0; i < buttons.length(); i++) {
|
||||
try {
|
||||
@ -86,7 +99,7 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
|
||||
|
||||
// Enable the button layout if we have buttons.
|
||||
if (buttons.length() > 0) {
|
||||
findViewById(R.id.divider).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.divider_choices).setVisibility(View.VISIBLE);
|
||||
mChoicesLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@ -103,6 +116,14 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
|
||||
button.setText(aText);
|
||||
button.setTag(Integer.toString(aCallback));
|
||||
button.setOnClickListener(this);
|
||||
|
||||
if (mChoicesLayout.getChildCount() > 0) {
|
||||
Divider divider = new Divider(mActivity, null);
|
||||
divider.setOrientation(Divider.Orientation.VERTICAL);
|
||||
divider.setBackgroundColor(0xFFD1D5DA);
|
||||
mChoicesLayout.addView(divider);
|
||||
}
|
||||
|
||||
mChoicesLayout.addView(button, mLayoutParams);
|
||||
}
|
||||
|
||||
|
@ -259,6 +259,7 @@ public class DoorHangerPopup extends PopupWindow
|
||||
return;
|
||||
}
|
||||
|
||||
showDividers();
|
||||
if (isShowing()) {
|
||||
update();
|
||||
return;
|
||||
@ -280,6 +281,17 @@ public class DoorHangerPopup extends PopupWindow
|
||||
setFocusable(true);
|
||||
}
|
||||
|
||||
private void showDividers() {
|
||||
int count = mContent.getChildCount();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
DoorHanger dh = (DoorHanger) mContent.getChildAt(i);
|
||||
dh.showDivider();
|
||||
}
|
||||
|
||||
((DoorHanger) mContent.getChildAt(count-1)).hideDivider();
|
||||
}
|
||||
|
||||
private void registerEventListener(String event) {
|
||||
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
|
||||
}
|
||||
|
@ -432,16 +432,6 @@ public class GeckoMenu extends ListView
|
||||
private Context mContext;
|
||||
private LinearLayout mContainer;
|
||||
private List<View> mItems;
|
||||
|
||||
private class Divider extends LinearLayout {
|
||||
public Divider(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
setLayoutParams(new LinearLayout.LayoutParams((int) context.getResources().getDisplayMetrics().density,
|
||||
LinearLayout.LayoutParams.FILL_PARENT));
|
||||
setBackgroundColor(0xFFD1D5DA);
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultActionItemBarPresenter(Context context, LinearLayout container) {
|
||||
mContext = context;
|
||||
@ -457,6 +447,8 @@ public class GeckoMenu extends ListView
|
||||
|
||||
if (mItems.size() > 0) {
|
||||
Divider divider = new Divider(mContext, null);
|
||||
divider.setOrientation(Divider.Orientation.VERTICAL);
|
||||
divider.setBackgroundColor(0xFFD1D5DA);
|
||||
mContainer.addView(divider);
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ FENNEC_JAVA_FILES = \
|
||||
db/LocalBrowserDB.java \
|
||||
db/DBUtils.java \
|
||||
Distribution.java \
|
||||
Divider.java \
|
||||
DoorHanger.java \
|
||||
DoorHangerPopup.java \
|
||||
Favicons.java \
|
||||
|
@ -21,7 +21,7 @@
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/divider"
|
||||
<View android:id="@+id/divider_choices"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#FFD1D5DA"
|
||||
@ -33,4 +33,9 @@
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/divider_doorhanger"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#FFFF9500"/>
|
||||
|
||||
</merge>
|
||||
|
Loading…
Reference in New Issue
Block a user