mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 751205 - (Part 1) Refactor site identity popup and doorhanger popup to use common arrow panel container. r=wesj
--HG-- rename : mobile/android/base/resources/layout/site_identity_popup.xml => mobile/android/base/resources/layout/site_identity.xml
This commit is contained in:
parent
2a9119a0a0
commit
51d2852fa7
@ -7,36 +7,25 @@ package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.widget.ArrowPopup;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class DoorHangerPopup extends PopupWindow
|
||||
public class DoorHangerPopup extends ArrowPopup
|
||||
implements GeckoEventListener, Tabs.OnTabsChangedListener {
|
||||
private static final String LOGTAG = "GeckoDoorHangerPopup";
|
||||
|
||||
private GeckoApp mActivity;
|
||||
private View mAnchor;
|
||||
private LinearLayout mContent;
|
||||
|
||||
private boolean mInflated;
|
||||
private ImageView mArrow;
|
||||
private int mArrowWidth;
|
||||
private int mYOffset;
|
||||
|
||||
// Stores a set of all active DoorHanger notifications. A DoorHanger is
|
||||
// uniquely identified by its tabId and value.
|
||||
@ -47,16 +36,11 @@ public class DoorHangerPopup extends PopupWindow
|
||||
mActivity = aActivity;
|
||||
mAnchor = aAnchor;
|
||||
|
||||
mInflated = false;
|
||||
mArrowWidth = aActivity.getResources().getDimensionPixelSize(R.dimen.menu_popup_arrow_width);
|
||||
mYOffset = aActivity.getResources().getDimensionPixelSize(R.dimen.menu_popup_offset);
|
||||
mDoorHangers = new HashSet<DoorHanger>();
|
||||
|
||||
registerEventListener("Doorhanger:Add");
|
||||
registerEventListener("Doorhanger:Remove");
|
||||
Tabs.registerOnTabsChangedListener(this);
|
||||
|
||||
setAnimationStyle(R.style.PopupAnimation);
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
@ -141,21 +125,6 @@ public class DoorHangerPopup extends PopupWindow
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setBackgroundDrawable(new BitmapDrawable());
|
||||
setOutsideTouchable(true);
|
||||
setWindowLayoutMode(HardwareUtils.isTablet() ? ViewGroup.LayoutParams.WRAP_CONTENT : ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(mActivity);
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.doorhangerpopup, null);
|
||||
mArrow = (ImageView) layout.findViewById(R.id.doorhanger_arrow);
|
||||
mContent = (LinearLayout) layout.findViewById(R.id.doorhanger_container);
|
||||
|
||||
setContentView(layout);
|
||||
mInflated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a doorhanger.
|
||||
*
|
||||
|
@ -241,6 +241,7 @@ FENNEC_JAVA_FILES = \
|
||||
widget/ActivityChooserModel.java \
|
||||
widget/AddonsSection.java \
|
||||
widget/ButtonToast.java \
|
||||
widget/ArrowPopup.java \
|
||||
widget/DateTimePicker.java \
|
||||
widget/Divider.java \
|
||||
widget/FaviconView.java \
|
||||
@ -440,6 +441,7 @@ endif
|
||||
RES_LAYOUT = \
|
||||
$(SYNC_RES_LAYOUT) \
|
||||
res/layout/abouthome_content.xml \
|
||||
res/layout/arrow_popup.xml \
|
||||
res/layout/autocomplete_list.xml \
|
||||
res/layout/autocomplete_list_item.xml \
|
||||
res/layout/awesomebar.xml \
|
||||
@ -457,7 +459,6 @@ RES_LAYOUT = \
|
||||
res/layout/bookmark_edit.xml \
|
||||
res/layout/browser_toolbar.xml \
|
||||
res/layout/datetime_picker.xml \
|
||||
res/layout/doorhangerpopup.xml \
|
||||
res/layout/doorhanger.xml \
|
||||
res/layout/doorhanger_button.xml \
|
||||
res/layout/find_in_page_content.xml \
|
||||
@ -476,7 +477,7 @@ RES_LAYOUT = \
|
||||
res/layout/site_setting_title.xml \
|
||||
res/layout/setup_screen.xml \
|
||||
res/layout/shared_ui_components.xml \
|
||||
res/layout/site_identity_popup.xml \
|
||||
res/layout/site_identity.xml \
|
||||
res/layout/remote_tabs_child.xml \
|
||||
res/layout/remote_tabs_group.xml \
|
||||
res/layout/tabs_panel.xml \
|
||||
|
@ -5,26 +5,25 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.widget.ArrowPopup;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* SiteIdentityPopup is a singleton class that displays site identity data in
|
||||
* an arrow panel popup hanging from the lock icon in the browser toolbar.
|
||||
*/
|
||||
public class SiteIdentityPopup extends PopupWindow {
|
||||
public class SiteIdentityPopup extends ArrowPopup {
|
||||
private static final String LOGTAG = "GeckoSiteIdentityPopup";
|
||||
|
||||
public static final String UNKNOWN = "unknown";
|
||||
@ -34,26 +33,18 @@ public class SiteIdentityPopup extends PopupWindow {
|
||||
private static SiteIdentityPopup sInstance;
|
||||
|
||||
private Resources mResources;
|
||||
private boolean mInflated;
|
||||
|
||||
private TextView mHost;
|
||||
private TextView mOwner;
|
||||
private TextView mSupplemental;
|
||||
private TextView mVerifier;
|
||||
private TextView mEncrypted;
|
||||
|
||||
private ImageView mLarry;
|
||||
private ImageView mArrow;
|
||||
|
||||
private int mYOffset;
|
||||
|
||||
private SiteIdentityPopup() {
|
||||
super(GeckoAppShell.getContext());
|
||||
|
||||
mResources = GeckoAppShell.getContext().getResources();
|
||||
mYOffset = mResources.getDimensionPixelSize(R.dimen.menu_popup_offset);
|
||||
mInflated = false;
|
||||
setAnimationStyle(R.style.PopupAnimation);
|
||||
}
|
||||
|
||||
public static synchronized SiteIdentityPopup getInstance() {
|
||||
@ -67,29 +58,21 @@ public class SiteIdentityPopup extends PopupWindow {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setBackgroundDrawable(new BitmapDrawable());
|
||||
setOutsideTouchable(true);
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
// Make the popup focusable so it doesn't inadvertently trigger click events elsewhere
|
||||
// which may reshow the popup (see bug 785156)
|
||||
setFocusable(true);
|
||||
|
||||
setWindowLayoutMode(HardwareUtils.isTablet() ? LayoutParams.WRAP_CONTENT : LayoutParams.FILL_PARENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(GeckoAppShell.getContext());
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.site_identity_popup, null);
|
||||
setContentView(layout);
|
||||
LinearLayout layout = (LinearLayout) mInflater.inflate(R.layout.site_identity, null);
|
||||
mContent.addView(layout);
|
||||
|
||||
mHost = (TextView) layout.findViewById(R.id.host);
|
||||
mOwner = (TextView) layout.findViewById(R.id.owner);
|
||||
mVerifier = (TextView) layout.findViewById(R.id.verifier);
|
||||
|
||||
mLarry = (ImageView) layout.findViewById(R.id.larry);
|
||||
mArrow = (ImageView) layout.findViewById(R.id.arrow);
|
||||
|
||||
mInflated = true;
|
||||
}
|
||||
|
||||
public void show(View v) {
|
||||
@ -166,7 +149,7 @@ public class SiteIdentityPopup extends PopupWindow {
|
||||
offset = 0 - popupWidth + arrowWidth*3/2 + v.getWidth()/2;
|
||||
}
|
||||
|
||||
LayoutParams layoutParams = (LayoutParams) mArrow.getLayoutParams();
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mArrow.getLayoutParams();
|
||||
layoutParams.setMargins(leftMargin, 0, 0, 0);
|
||||
|
||||
showAsDropDown(v, offset, -mYOffset);
|
||||
|
@ -4,7 +4,7 @@
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="?attr/doorhangerWidth"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ScrollView android:layout_width="?attr/doorhangerWidth"
|
||||
@ -12,14 +12,14 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/doorhanger_popup_bg">
|
||||
|
||||
<LinearLayout android:id="@+id/doorhanger_container"
|
||||
<LinearLayout android:id="@+id/content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<ImageView android:id="@+id/doorhanger_arrow"
|
||||
<ImageView android:id="@+id/arrow"
|
||||
android:layout_width="@dimen/menu_popup_arrow_width"
|
||||
android:layout_height="12dip"
|
||||
android:layout_marginLeft="4dip"
|
54
mobile/android/base/resources/layout/site_identity.xml
Normal file
54
mobile/android/base/resources/layout/site_identity.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dip">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:text="@string/identity_connected_to"/>
|
||||
|
||||
<TextView android:id="@+id/host"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:text="@string/identity_run_by"
|
||||
android:paddingTop="12dip"/>
|
||||
|
||||
<TextView android:id="@+id/owner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView android:id="@+id/verifier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:paddingTop="12dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/larry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dip"/>
|
||||
|
||||
</LinearLayout>
|
@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="?attr/doorhangerWidth"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/doorhanger_popup_bg">
|
||||
|
||||
<LinearLayout android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dip">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:text="@string/identity_connected_to"/>
|
||||
|
||||
<TextView android:id="@+id/host"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:text="@string/identity_run_by"
|
||||
android:paddingTop="12dip"/>
|
||||
|
||||
<TextView android:id="@+id/owner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView android:id="@+id/verifier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/doorhanger_text"
|
||||
android:paddingTop="12dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/larry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/arrow"
|
||||
android:layout_width="@dimen/menu_popup_arrow_width"
|
||||
android:layout_height="12dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:src="@drawable/menu_popup_arrow_top"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
</RelativeLayout>
|
57
mobile/android/base/widget/ArrowPopup.java
Normal file
57
mobile/android/base/widget/ArrowPopup.java
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* 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.widget;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class ArrowPopup extends PopupWindow {
|
||||
protected LayoutInflater mInflater;
|
||||
protected boolean mInflated;
|
||||
|
||||
protected LinearLayout mContent;
|
||||
protected ImageView mArrow;
|
||||
|
||||
protected int mArrowWidth;
|
||||
protected int mYOffset;
|
||||
|
||||
public ArrowPopup(Context aContext) {
|
||||
super(aContext);
|
||||
mInflater = LayoutInflater.from(aContext);
|
||||
|
||||
mInflated = false;
|
||||
mArrowWidth = aContext.getResources().getDimensionPixelSize(R.dimen.menu_popup_arrow_width);
|
||||
mYOffset = aContext.getResources().getDimensionPixelSize(R.dimen.menu_popup_offset);
|
||||
|
||||
setAnimationStyle(R.style.PopupAnimation);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setBackgroundDrawable(new BitmapDrawable());
|
||||
setOutsideTouchable(true);
|
||||
|
||||
setWindowLayoutMode(HardwareUtils.isTablet() ? ViewGroup.LayoutParams.WRAP_CONTENT : ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
RelativeLayout layout = (RelativeLayout) mInflater.inflate(R.layout.arrow_popup, null);
|
||||
setContentView(layout);
|
||||
|
||||
mArrow = (ImageView) layout.findViewById(R.id.arrow);
|
||||
mContent = (LinearLayout) layout.findViewById(R.id.content);
|
||||
|
||||
mInflated = true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user