Backed out changeset 9461cf2c40e4 (bug 1549741) for causing Android lint busage on lint-results-withoutGeckoBinariesDebug.html CLOSED TREE

This commit is contained in:
arthur.iakab 2019-05-09 13:26:59 +03:00
Родитель 8a6b7522e7
Коммит 1df56d2ae8
4 изменённых файлов: 157 добавлений и 0 удалений

Просмотреть файл

@ -205,6 +205,10 @@
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" />

Просмотреть файл

@ -142,6 +142,7 @@ 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;
@ -2179,6 +2180,20 @@ public class BrowserApp extends GeckoApp
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);

Просмотреть файл

@ -60,6 +60,8 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
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 {
@ -361,6 +363,7 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
final int imageLevel = type.getImageLevel();
mSiteIdentityPopup.setSiteIdentity(siteIdentity);
mTrackingProtectionEnabled = SecurityModeUtil.isTrackingProtectionEnabled(siteIdentity);
if (mSecurityImageLevel != imageLevel) {
mSecurityImageLevel = imageLevel;
@ -420,6 +423,10 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
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) {

Просмотреть файл

@ -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;
}
}