Bug 1444776 - Tab Queue prompt needs to use APPLICATION_OVERLAY window type when targeting (and running on) Android O.
Now using the the TYPE_APPLICATION_OVERLAY window type to display alert windows for devices running on Android O.
MozReview-Commit-ID: 7pdquyowbsB
***
***
deleted file mode 100644
index 03268c57926eba0601e3d6f217978b5ef234fb5d..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e9b5ca3dea41889e88f5406fa898169189852471..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -63,16 +63,17 @@ public class AppConstants {
*/
public static final boolean preMarshmallow = MAX_SDK_VERSION < 23 || (MIN_SDK_VERSION < 23 && Build.VERSION.SDK_INT < 23);
public static final boolean preLollipopMR1 = MAX_SDK_VERSION < 22 || (MIN_SDK_VERSION < 22 && Build.VERSION.SDK_INT < 22);
public static final boolean preLollipop = MAX_SDK_VERSION < 21 || (MIN_SDK_VERSION < 21 && Build.VERSION.SDK_INT < 21);
public static final boolean preJBMR2 = MAX_SDK_VERSION < 18 || (MIN_SDK_VERSION < 18 && Build.VERSION.SDK_INT < 18);
public static final boolean preJBMR1 = MAX_SDK_VERSION < 17 || (MIN_SDK_VERSION < 17 && Build.VERSION.SDK_INT < 17);
public static final boolean preJB = MAX_SDK_VERSION < 16 || (MIN_SDK_VERSION < 16 && Build.VERSION.SDK_INT < 16);
public static final boolean preN = MAX_SDK_VERSION < 24 || (MIN_SDK_VERSION < 24 && Build.VERSION.SDK_INT < 24);
+ public static final boolean preO = MAX_SDK_VERSION < 26 || (MIN_SDK_VERSION < 26 && Build.VERSION.SDK_INT < 26);
}
/**
* The name of the Java class that represents the android application.
*/
public static final String MOZ_ANDROID_APPLICATION_CLASS = "@MOZ_ANDROID_APPLICATION_CLASS@";
/**
* The name of the Java class that launches the browser activity.
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/TabQueuePanel.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; 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.firstrun;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.SwitchCompat;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.TextView;
-import org.mozilla.gecko.GeckoSharedPrefs;
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.Telemetry;
-import org.mozilla.gecko.TelemetryContract;
-import org.mozilla.gecko.preferences.GeckoPreferences;
-import org.mozilla.gecko.tabqueue.TabQueueHelper;
-import org.mozilla.gecko.tabqueue.TabQueuePrompt;
-
-public class TabQueuePanel extends FirstrunPanel {
- private static final int REQUEST_CODE_TAB_QUEUE = 1;
- private SwitchCompat toggleSwitch;
- private ImageView imageView;
- private TextView messageTextView;
- private TextView subtextTextView;
- private Context context;
-
- @Override
- public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstance) {
- context = getContext();
- final View root = super.onCreateView(inflater, container, savedInstance);
-
- imageView = (ImageView) root.findViewById(R.id.firstrun_image);
- messageTextView = (TextView) root.findViewById(R.id.firstrun_text);
- subtextTextView = (TextView) root.findViewById(R.id.firstrun_subtext);
-
- toggleSwitch = (SwitchCompat) root.findViewById(R.id.firstrun_switch);
- toggleSwitch.setVisibility(View.VISIBLE);
- toggleSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DIALOG, "firstrun_tabqueue-permissions");
- if (b && !TabQueueHelper.canDrawOverlays(context)) {
- Intent promptIntent = new Intent(context, TabQueuePrompt.class);
- startActivityForResult(promptIntent, REQUEST_CODE_TAB_QUEUE);
- return;
- }
-
- Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-tabqueue-" + b);
-
- final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
- final SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(GeckoPreferences.PREFS_TAB_QUEUE, b).apply();
-
- // Set image, text, and typeface changes.
- imageView.setImageResource(b ? R.drawable.firstrun_tabqueue_on : R.drawable.firstrun_tabqueue_off);
- messageTextView.setText(b ? R.string.firstrun_tabqueue_message_on : R.string.firstrun_tabqueue_message_off);
- messageTextView.setTypeface(b ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
- subtextTextView.setText(b ? R.string.firstrun_tabqueue_subtext_on : R.string.firstrun_tabqueue_subtext_off);
- subtextTextView.setTypeface(b ? Typeface.defaultFromStyle(Typeface.ITALIC) : Typeface.DEFAULT);
- subtextTextView.setTextColor(b ? ContextCompat.getColor(context, R.color.fennec_ui_accent) : ContextCompat.getColor(context, R.color.placeholder_grey));
- }
- });
-
- return root;
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_CODE_TAB_QUEUE:
- final boolean accepted = TabQueueHelper.processTabQueuePromptResponse(resultCode, context);
- if (accepted) {
- Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DIALOG, "firstrun_tabqueue-permissions-yes");
- toggleSwitch.setChecked(true);
- Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-tabqueue-true");
- }
- Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.DIALOG, "firstrun_tabqueue-permissions-" + (accepted ? "accepted" : "rejected"));
- break;
- }
- }
-
-}
--- a/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueHelper.java
@@ -16,16 +16,17 @@ import org.mozilla.gecko.util.ThreadUtil
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.PixelFormat;
+import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import org.json.JSONArray;
@@ -73,17 +74,19 @@ public class TabQueueHelper {
// Instead we'll add and remove an invisible view. If this is successful then we seem to
// have permission to draw overlays.
View view = new View(context);
view.setVisibility(View.INVISIBLE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
1, 1,
- WindowManager.LayoutParams.TYPE_PHONE,
+ AppConstants.Versions.preO ?
+ WindowManager.LayoutParams.TYPE_PHONE :
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
try {
windowManager.addView(view, layoutParams);
windowManager.removeView(view);
--- a/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueService.java
@@ -107,17 +107,19 @@ public class TabQueueService extends Ser
messageView.setText(resources.getText(R.string.tab_queue_toast_message));
openNowButton = (Button) toastLayout.findViewById(R.id.toast_button);
openNowButton.setText(resources.getText(R.string.tab_queue_toast_action));
toastLayoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
- WindowManager.LayoutParams.TYPE_PHONE,
+ AppConstants.Versions.preO ?
+ WindowManager.LayoutParams.TYPE_PHONE :
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
toastLayoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
}
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -22,22 +22,16 @@
<!ENTITY firstrun_sync_subtext2 "Use Sync to find the bookmarks, passwords, and other things you save to &brandShortName; on all your devices.">
<!ENTITY firstrun_signin_message "Get connected, get started">
<!ENTITY firstrun_signin_button "Sign in to Sync">
<!ENTITY onboard_start_button_browser "Start Browsing">
<!ENTITY firstrun_button_notnow "Not right now">
<!ENTITY firstrun_button_next "Next">
<!ENTITY firstrun_tabqueue_title "Links">
-<!-- Localization note (firstrun_tabqueue_message): 'Tab queue' is a feature that allows users to queue up or save links from outside of Firefox (without switching apps) - these links will be loaded in Firefox the next time Firefox is opened. -->
-<!ENTITY firstrun_tabqueue_message_off "Turn on Tab queue">
-<!ENTITY firstrun_tabqueue_subtext_off "Save links for later in &brandShortName; when tapping them in other apps.">
-
-<!ENTITY firstrun_tabqueue_message_on "Success!">
-<!ENTITY firstrun_tabqueue_subtext_on "You can always turn this off in &settings; under &pref_category_general;.">
<!ENTITY firstrun_readerview_title "Articles">
<!-- Localization note (firstrun_readerview_message): This is a casual way of describing getting rid of unnecessary things, and is referring to simplifying websites so only the article text and images are visible, removing unnecessary headers or ads. -->
<!ENTITY firstrun_readerview_message "Lose the clutter">
<!ENTITY firstrun_readerview_subtext "Use Reader View to make articles nicer to read \u2014 even offline.">
<!-- Localization note (firstrun_devices_title): This is a casual way of addressing the user, somewhat referring to their online identity (which would include other devices, Firefox usage, accounts, etc). -->
<!ENTITY firstrun_account_title "You">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -38,21 +38,16 @@
<string name="firstrun_customize_subtext">&firstrun_customize_subtext;</string>
<string name="firstrun_sync_title">&firstrun_sync_title;</string>
<string name="firstrun_sync_message">&firstrun_sync_message2;</string>
<string name="firstrun_sync_subtext">&firstrun_sync_subtext2;</string>
<string name="firstrun_signin_button">&firstrun_signin_button;</string>
<string name="firstrun_welcome_button_browser">&onboard_start_button_browser;</string>
<string name="firstrun_button_next">&firstrun_button_next;</string>
- <string name="firstrun_tabqueue_message_off">&firstrun_tabqueue_message_off;</string>
- <string name="firstrun_tabqueue_subtext_off">&firstrun_tabqueue_subtext_off;</string>
- <string name="firstrun_tabqueue_message_on">&firstrun_tabqueue_message_on;</string>
- <string name="firstrun_tabqueue_subtext_on">&firstrun_tabqueue_subtext_on;</string>
-
<string name="firstrun_welcome_restricted">&onboard_start_restricted1;</string>
<string name="bookmarks_title">&bookmarks_title;</string>
<string name="history_title">&history_title;</string>
<string name="switch_to_tab">&switch_to_tab;</string>
<string name="tab_offline_version">&tab_offline_version;</string>