Backed out changeset 9461cf2c40e4 (bug 1549741) for causing Android lint busage on lint-results-withoutGeckoBinariesDebug.html CLOSED TREE
authorarthur.iakab <aiakab@mozilla.com>
Thu, 09 May 2019 13:26:59 +0300
changeset 532013 281c5bc6fe5065d2f0d85b5168cdf8e05b059cbb
parent 532012 9461cf2c40e4436b189a5b904486e251e181be4e
child 532014 d7741d7e9b2c721515320e21dcbc6a8852ce2b09
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1549741
milestone68.0a1
backs out9461cf2c40e4436b189a5b904486e251e181be4e
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 9461cf2c40e4 (bug 1549741) for causing Android lint busage on lint-results-withoutGeckoBinariesDebug.html CLOSED TREE
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
mobile/android/base/java/org/mozilla/gecko/trackingprotection/TrackingProtectionPrompt.java
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -200,16 +200,20 @@
         </service>
 
         <service
             android:name="org.mozilla.gecko.GeckoServicesCreatorService"
             android:exported="false"
             android:permission="android.permission.BIND_JOB_SERVICE">
         </service>
 
+        <activity android:name="org.mozilla.gecko.trackingprotection.TrackingProtectionPrompt"
+                  android:launchMode="singleTop"
+                  android:theme="@style/OverlayActivity" />
+
         <activity android:name="org.mozilla.gecko.promotion.SimpleHelperUI"
                   android:launchMode="singleTop"
                   android:theme="@style/OverlayActivity" />
 
         <!-- The main reason for the Tab Queue build flag is to not mess with the VIEW intent filter
              before the rest of the plumbing is in place -->
 
         <service android:name="org.mozilla.gecko.tabqueue.TabQueueService" />
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -137,16 +137,17 @@ import org.mozilla.gecko.tabs.TabHistory
 import org.mozilla.gecko.tabs.TabsPanel;
 import org.mozilla.gecko.telemetry.TelemetryCorePingDelegate;
 import org.mozilla.gecko.telemetry.TelemetryUploadService;
 import org.mozilla.gecko.telemetry.measurements.SearchCountMeasurements;
 import org.mozilla.gecko.toolbar.AutocompleteHandler;
 import org.mozilla.gecko.toolbar.BrowserToolbar;
 import org.mozilla.gecko.toolbar.BrowserToolbar.TabEditingState;
 import org.mozilla.gecko.toolbar.PwaConfirm;
+import org.mozilla.gecko.trackingprotection.TrackingProtectionPrompt;
 import org.mozilla.gecko.updater.PostUpdateHandler;
 import org.mozilla.gecko.updater.UpdateServiceHelper;
 import org.mozilla.gecko.util.ActivityUtils;
 import org.mozilla.gecko.util.ContextUtils;
 import org.mozilla.gecko.util.DrawableUtil;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.FileUtils;
 import org.mozilla.gecko.util.GamepadUtils;
@@ -2174,16 +2175,30 @@ public class BrowserApp extends GeckoApp
         addTab(Tabs.LOADURL_NONE);
     }
 
     @Override
     public void addPrivateTab() {
         Tabs.getInstance().addPrivateTab();
     }
 
+    public void showTrackingProtectionPromptIfApplicable() {
+        final SharedPreferences prefs = getSharedPreferences();
+
+        final boolean hasTrackingProtectionPromptBeShownBefore = prefs.getBoolean(GeckoPreferences.PREFS_TRACKING_PROTECTION_PROMPT_SHOWN, false);
+
+        if (hasTrackingProtectionPromptBeShownBefore) {
+            return;
+        }
+
+        prefs.edit().putBoolean(GeckoPreferences.PREFS_TRACKING_PROTECTION_PROMPT_SHOWN, true).apply();
+
+        startActivity(new Intent(BrowserApp.this, TrackingProtectionPrompt.class));
+    }
+
     @Override
     public void showNormalTabs() {
         showTabs(TabsPanel.Panel.NORMAL_TABS);
     }
 
     @Override
     public void showPrivateTabs() {
         showTabs(TabsPanel.Panel.PRIVATE_TABS);
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -55,16 +55,18 @@ import android.widget.HorizontalScrollVi
 * {@code ToolbarDisplayLayout} is meant to be owned by {@code BrowserToolbar}
 * which is the main event bus for the toolbar subsystem.
 */
 public class ToolbarDisplayLayout extends ThemedLinearLayout {
     private static final String LOGTAG = "GeckoToolbarDisplayLayout";
 
     private static final int MIN_DOMAIN_SCROLL_MARGIN_DP = 10;
 
+    private boolean mTrackingProtectionEnabled;
+
     // To be used with updateFromTab() to allow the caller
     // to give enough context for the requested state change.
     enum UpdateFlags {
         TITLE,
         FAVICON,
         PROGRESS,
         SITE_IDENTITY,
         PRIVATE_MODE,
@@ -356,16 +358,17 @@ public class ToolbarDisplayLayout extend
     }
 
     private void updateSiteIdentity(@NonNull Tab tab) {
         final SiteIdentity siteIdentity = tab.getSiteIdentity();
         final SecurityModeUtil.IconType type = SecurityModeUtil.resolve(siteIdentity, tab.getURL());
         final int imageLevel = type.getImageLevel();
 
         mSiteIdentityPopup.setSiteIdentity(siteIdentity);
+        mTrackingProtectionEnabled = SecurityModeUtil.isTrackingProtectionEnabled(siteIdentity);
 
         if (mSecurityImageLevel != imageLevel) {
             mSecurityImageLevel = imageLevel;
             mSiteSecurity.setImageLevel(mSecurityImageLevel);
             updatePageActions();
         }
     }
 
@@ -415,16 +418,20 @@ public class ToolbarDisplayLayout extend
         final int scrollTarget = domainTextWidth + targetMargin - scrollViewWidth;
         mTitleScroll.scrollTo(scrollTarget, 0);
     }
 
     private void updateProgress(@NonNull Tab tab) {
         final boolean shouldShowThrobber = tab.getState() == Tab.STATE_LOADING;
 
         updateUiMode(shouldShowThrobber ? UIMode.PROGRESS : UIMode.DISPLAY);
+
+        if (Tab.STATE_SUCCESS == tab.getState() && mTrackingProtectionEnabled) {
+            mActivity.showTrackingProtectionPromptIfApplicable();
+        }
     }
 
     private void updateUiMode(UIMode uiMode) {
         if (mUiMode == uiMode) {
             return;
         }
 
         mUiMode = uiMode;
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/trackingprotection/TrackingProtectionPrompt.java
@@ -0,0 +1,131 @@
+/* -*- 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.trackingprotection;
+
+import org.mozilla.gecko.Locales;
+import org.mozilla.gecko.R;
+import org.mozilla.gecko.preferences.GeckoPreferences;
+import org.mozilla.gecko.util.HardwareUtils;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.MotionEvent;
+import android.view.View;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+
+public class TrackingProtectionPrompt extends Locales.LocaleAwareActivity {
+        public static final String LOGTAG = "Gecko" + TrackingProtectionPrompt.class.getSimpleName();
+
+        // Flag set during animation to prevent animation multiple-start.
+        private boolean isAnimating;
+
+        private View containerView;
+
+        @Override
+        protected void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+
+            showPrompt();
+        }
+
+        private void showPrompt() {
+            setContentView(R.layout.tracking_protection_prompt);
+
+            findViewById(R.id.ok_button).setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    onConfirmButtonPressed();
+                }
+            });
+            findViewById(R.id.link_text).setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    slideOut();
+                    final Intent settingsIntent = new Intent(TrackingProtectionPrompt.this, GeckoPreferences.class);
+                    GeckoPreferences.setResourceToOpen(settingsIntent, "preferences_privacy");
+                    startActivity(settingsIntent);
+
+                    // Don't use a transition to settings if we're on a device where that
+                    // would look bad.
+                    if (HardwareUtils.IS_KINDLE_DEVICE) {
+                        overridePendingTransition(0, 0);
+                    }
+                }
+            });
+
+            containerView = findViewById(R.id.tracking_protection_inner_container);
+
+            containerView.setTranslationY(500);
+            containerView.setAlpha(0);
+
+            final Animator translateAnimator = ObjectAnimator.ofFloat(containerView, "translationY", 0);
+            translateAnimator.setDuration(400);
+
+            final Animator alphaAnimator = ObjectAnimator.ofFloat(containerView, "alpha", 1);
+            alphaAnimator.setStartDelay(200);
+            alphaAnimator.setDuration(600);
+
+            final AnimatorSet set = new AnimatorSet();
+            set.playTogether(alphaAnimator, translateAnimator);
+            set.setStartDelay(400);
+
+            set.start();
+        }
+
+        @Override
+        public void finish() {
+            super.finish();
+
+            // Don't perform an activity-dismiss animation.
+            overridePendingTransition(0, 0);
+        }
+
+        private void onConfirmButtonPressed() {
+            slideOut();
+        }
+
+        /**
+         * Slide the overlay down off the screen and destroy it.
+         */
+        private void slideOut() {
+            if (isAnimating) {
+                return;
+            }
+
+            isAnimating = true;
+
+            ObjectAnimator animator = ObjectAnimator.ofFloat(containerView, "translationY", containerView.getHeight());
+            animator.addListener(new AnimatorListenerAdapter() {
+
+                @Override
+                public void onAnimationEnd(Animator animation) {
+                    finish();
+                }
+
+            });
+            animator.start();
+        }
+
+        /**
+         * Close the dialog if back is pressed.
+         */
+        @Override
+        public void onBackPressed() {
+            slideOut();
+        }
+
+        /**
+         * Close the dialog if the anything that isn't a button is tapped.
+         */
+        @Override
+        public boolean onTouchEvent(MotionEvent event) {
+            slideOut();
+            return true;
+        }
+    }