mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1126608 - Add buttons. r=ally
This commit is contained in:
parent
efb0ac45b5
commit
a605a124b0
@ -380,6 +380,8 @@ size. -->
|
||||
<!ENTITY doorhanger_login_edit_toggle "Show password">
|
||||
<!ENTITY doorhanger_login_edit_toast_error "Failed to save login">
|
||||
<!ENTITY doorhanger_login_select_message "Copy password from &formatS;?">
|
||||
<!ENTITY doorhanger_login_select_toast_copy "Password copied to clipboard">
|
||||
<!ENTITY doorhanger_login_select_toast_copy_error "Couldn\'t copy password">
|
||||
|
||||
<!ENTITY pref_titlebar_mode "Title bar">
|
||||
<!ENTITY pref_titlebar_mode_title "Show page title">
|
||||
@ -440,6 +442,7 @@ size. -->
|
||||
<!ENTITY button_set "Set">
|
||||
<!ENTITY button_clear "Clear">
|
||||
<!ENTITY button_remember "Remember">
|
||||
<!ENTITY button_copy "Copy">
|
||||
|
||||
<!ENTITY firstrun_panel_title_welcome "Welcome">
|
||||
|
||||
|
@ -347,6 +347,8 @@
|
||||
<string name="doorhanger_login_edit_toggle">&doorhanger_login_edit_toggle;</string>
|
||||
<string name="doorhanger_login_edit_toast_error">&doorhanger_login_edit_toast_error;</string>
|
||||
<string name="doorhanger_login_select_message">&doorhanger_login_select_message;</string>
|
||||
<string name="doorhanger_login_select_toast_copy">&doorhanger_login_select_toast_copy;</string>
|
||||
<string name="doorhanger_login_select_toast_copy_error">&doorhanger_login_select_toast_copy_error;</string>
|
||||
|
||||
<string name="pref_titlebar_mode">&pref_titlebar_mode;</string>
|
||||
<string name="pref_titlebar_mode_title">&pref_titlebar_mode_title;</string>
|
||||
@ -376,6 +378,7 @@
|
||||
<string name="button_yes">&button_yes;</string>
|
||||
<string name="button_no">&button_no;</string>
|
||||
<string name="button_remember">&button_remember;</string>
|
||||
<string name="button_copy">&button_copy;</string>
|
||||
|
||||
<string name="firstrun_panel_title_welcome">&firstrun_panel_title_welcome;</string>
|
||||
|
||||
|
@ -4,9 +4,13 @@
|
||||
|
||||
package org.mozilla.gecko.toolbar;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.widget.Toast;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONArray;
|
||||
import org.mozilla.gecko.AboutPages;
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
@ -40,7 +44,7 @@ import org.mozilla.gecko.widget.SiteLogins;
|
||||
*/
|
||||
public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListener {
|
||||
|
||||
public static enum ButtonType { DISABLE, ENABLE, KEEP_BLOCKING };
|
||||
public static enum ButtonType { DISABLE, ENABLE, KEEP_BLOCKING, CANCEL, COPY };
|
||||
|
||||
private static final String LOGTAG = "GeckoSiteIdentityPopup";
|
||||
|
||||
@ -71,12 +75,12 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
|
||||
private DoorHanger mTrackingContentNotification;
|
||||
private DoorHanger mSelectLoginDoorhanger;
|
||||
|
||||
private final OnButtonClickListener mButtonClickListener;
|
||||
private final OnButtonClickListener mContentButtonClickListener;
|
||||
|
||||
public SiteIdentityPopup(Context context) {
|
||||
super(context);
|
||||
|
||||
mButtonClickListener = new PopupButtonListener();
|
||||
mContentButtonClickListener = new ContentNotificationButtonListener();
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener(this, "Doorhanger:Logins");
|
||||
}
|
||||
|
||||
@ -163,7 +167,35 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
|
||||
return;
|
||||
}
|
||||
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.LOGIN, null);
|
||||
final JSONObject login = (JSONObject) logins.get(0);
|
||||
final OnButtonClickListener buttonClickListener = new OnButtonClickListener() {
|
||||
@Override
|
||||
public void onButtonClick(JSONObject response, DoorHanger doorhanger) {
|
||||
try {
|
||||
final int buttonId = response.getInt("callback");
|
||||
if (buttonId == ButtonType.COPY.ordinal()) {
|
||||
final ClipboardManager manager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
final String password = login.getString("password");
|
||||
if (AppConstants.Versions.feature11Plus) {
|
||||
manager.setPrimaryClip(ClipData.newPlainText("password", password));
|
||||
} else {
|
||||
manager.setText(password);
|
||||
}
|
||||
Toast.makeText(mContext, R.string.doorhanger_login_select_toast_copy, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
dismiss();
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Error handling Select login button click", e);
|
||||
Toast.makeText(mContext, R.string.doorhanger_login_select_toast_copy_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.LOGIN, buttonClickListener);
|
||||
|
||||
// Set buttons.
|
||||
config.appendButton(mContext.getString(R.string.button_cancel), ButtonType.CANCEL.ordinal());
|
||||
config.appendButton(mContext.getString(R.string.button_copy), ButtonType.COPY.ordinal());
|
||||
|
||||
// Set message.
|
||||
String username = ((JSONObject) logins.get(0)).getString("username");
|
||||
@ -248,7 +280,7 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
|
||||
// Remove any existing mixed content notification.
|
||||
removeMixedContentNotification();
|
||||
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.MIXED_CONTENT, mButtonClickListener);
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.MIXED_CONTENT, mContentButtonClickListener);
|
||||
int icon;
|
||||
if (blocked) {
|
||||
icon = R.drawable.shield_enabled_doorhanger;
|
||||
@ -280,7 +312,7 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
|
||||
// Remove any existing tracking content notification.
|
||||
removeTrackingContentNotification();
|
||||
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.TRACKING, mButtonClickListener);
|
||||
final DoorhangerConfig config = new DoorhangerConfig(DoorHanger.Type.TRACKING, mContentButtonClickListener);
|
||||
|
||||
int icon;
|
||||
if (blocked) {
|
||||
@ -403,7 +435,7 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
|
||||
mDivider.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private class PopupButtonListener implements OnButtonClickListener {
|
||||
private class ContentNotificationButtonListener implements OnButtonClickListener {
|
||||
@Override
|
||||
public void onButtonClick(JSONObject response, DoorHanger doorhanger) {
|
||||
GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", response.toString());
|
||||
|
@ -127,7 +127,6 @@ public abstract class DoorHanger extends LinearLayout {
|
||||
|
||||
protected void setButtons(DoorhangerConfig config) {
|
||||
final JSONArray buttons = config.getButtons();
|
||||
final OnButtonClickListener listener = config.getButtonClickListener();
|
||||
for (int i = 0; i < buttons.length(); i++) {
|
||||
try {
|
||||
final JSONObject buttonObject = buttons.getJSONObject(i);
|
||||
|
Loading…
Reference in New Issue
Block a user