Merge fx-team to m-c. a=merge
Merge fx-team to m-c. a=merge
--- a/browser/base/content/safeMode.js
+++ b/browser/base/content/safeMode.js
@@ -67,17 +67,16 @@ function onExtra1() {
}
function onLoad() {
let dialog = document.documentElement;
if (appStartup.automaticSafeModeNecessary) {
document.getElementById("autoSafeMode").hidden = false;
document.getElementById("safeMode").hidden = true;
if (ResetProfile.resetSupported()) {
- populateResetPane("resetProfileItems");
document.getElementById("resetProfile").hidden = false;
} else {
// Hide the reset button is it's not supported.
document.documentElement.getButton("extra1").hidden = true;
}
} else {
if (!ResetProfile.resetSupported()) {
// Hide the reset button and text if it's not supported.
--- a/browser/base/content/safeMode.xul
+++ b/browser/base/content/safeMode.xul
@@ -16,47 +16,36 @@
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/content/safeMode.css"?>
<dialog id="safeModeDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&safeModeDialog.title;"
buttons="accept,extra1"
buttonlabelaccept="&startSafeMode.label;"
- buttonlabelextra1="&resetProfile.label;"
+ buttonlabelextra1="&refreshProfile.label;"
maxwidth="&window.maxWidth;"
ondialogaccept="return onDefaultButton()"
ondialogcancel="onCancel();"
ondialogextra1="return onExtra1()"
onload="onLoad()">
<script type="application/javascript" src="chrome://global/content/resetProfile.js"/>
<script type="application/javascript" src="chrome://browser/content/safeMode.js"/>
<vbox id="autoSafeMode" hidden="true">
- <description>&autoSafeModeDescription2.label;</description>
+ <description>&autoSafeModeDescription3.label;</description>
</vbox>
- <vbox id ="safeMode">
+ <vbox id="safeMode">
<label>&safeModeDescription3.label;</label>
<separator class="thin"/>
<label>&safeModeDescription4.label;</label>
<separator class="thin"/>
- <label id="resetProfileInstead">&resetProfileInstead.label;</label>
+ <label id="resetProfileInstead">&refreshProfileInstead.label;</label>
</vbox>
<vbox id="resetProfile" hidden="true">
- <label>&resetProfile.dialog.items2.label;</label>
-
- <vbox id="resetProfileItems" class="indent">
- </vbox>
-
- <separator class="thin"/>
-
- <label id="resetProfileFooter">&resetProfileFooter.label;</label>
-
- <label>&safeModeInstead.label;</label>
-
- <separator/>
+ <label id="resetProfileInstead">&refreshProfileInstead.label;</label>
</vbox>
<separator class="thin"/>
</dialog>
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -183,17 +183,17 @@
<vbox class="panel-subview-body">
<hbox id="PanelUI-panic-timeframe">
<image id="PanelUI-panic-timeframe-icon" alt=""/>
<vbox flex="1">
<hbox id="PanelUI-panic-header">
<image id="PanelUI-panic-timeframe-icon-small" alt=""/>
<description id="PanelUI-panic-mainDesc" flex="1">&panicButton.view.mainTimeframeDesc;</description>
</hbox>
- <radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc">
+ <radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc" closemenu="none">
<radio id="PanelUI-panic-5min" label="&panicButton.view.5min;" selected="true"
value="5" class="subviewradio"/>
<radio id="PanelUI-panic-2hr" label="&panicButton.view.2hr;"
value="2" class="subviewradio"/>
<radio id="PanelUI-panic-day" label="&panicButton.view.day;"
value="6" class="subviewradio"/>
</radiogroup>
</vbox>
--- a/browser/components/migration/content/aboutWelcomeBack.xhtml
+++ b/browser/components/migration/content/aboutWelcomeBack.xhtml
@@ -28,25 +28,27 @@
<body dir="&locale.dir;">
<!-- PAGE CONTAINER (for styling purposes only) -->
<div id="errorPageContainer">
<!-- Error Title -->
<div id="errorTitle">
- <h1 id="errorTitleText">&welcomeback.pageTitle;</h1>
+ <h1 id="errorTitleText">&welcomeback2.pageTitle;</h1>
</div>
<!-- LONG CONTENT (the section most likely to require scrolling) -->
<div id="errorLongContent">
<!-- Short Description -->
<div id="errorShortDesc">
- <p id="errorShortDescText">&welcomeback.pageInfo;</p>
+ <p>&welcomeback2.pageInfo1;</p>
+ <!-- Note a href in the anchor below is added by JS -->
+ <p>&welcomeback2.beforelink.pageInfo2;<a id="linkMoreTroubleshooting" target="_blank">&welcomeback2.link.pageInfo2;</a>&welcomeback2.afterlink.pageInfo2;</p>
</div>
<!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
<div id="errorLongDesc">
</div>
<!-- Short Description -->
<div id="errorTrailerDesc">
@@ -61,30 +63,18 @@
</treecols>
<treechildren flex="1"/>
</tree>
</div>
</div>
<!-- Buttons -->
<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="buttons">
-#ifdef XP_UNIX
- <button id="errorCancel" label="&restorepage.closeButton;"
- accesskey="&restorepage.close.access;"
- oncommand="startNewSession();"/>
- <button id="errorTryAgain" label="&restorepage.tryagainButton;"
- accesskey="&restorepage.restore.access;"
+ <button id="errorTryAgain" label="&welcomeback2.restoreButton;"
+ accesskey="&welcomeback2.restoreButton.access;"
oncommand="restoreSession();"/>
-#else
- <button id="errorTryAgain" label="&restorepage.tryagainButton;"
- accesskey="&restorepage.restore.access;"
- oncommand="restoreSession();"/>
- <button id="errorCancel" label="&restorepage.closeButton;"
- accesskey="&restorepage.close.access;"
- oncommand="startNewSession();"/>
-#endif
</hbox>
<!-- holds the session data for when the tab is closed -->
<input type="text" id="sessionData" style="display: none;"/>
</div>
</body>
</html>
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -632,18 +632,18 @@ BrowserGlue.prototype = {
.createBundle("chrome://branding/locale/brand.properties")
.GetStringFromName("brandShortName");
let resetBundle = Services.strings
.createBundle("chrome://global/locale/resetProfile.properties");
let message = resetBundle.formatStringFromName("resetUnusedProfile.message", [productName], 1);
let buttons = [
{
- label: resetBundle.formatStringFromName("resetProfile.resetButton.label", [productName], 1),
- accessKey: resetBundle.GetStringFromName("resetProfile.resetButton.accesskey"),
+ label: resetBundle.formatStringFromName("refreshProfile.resetButton.label", [productName], 1),
+ accessKey: resetBundle.GetStringFromName("refreshProfile.resetButton.accesskey"),
callback: function () {
ResetProfile.openConfirmationDialog(win);
}
},
];
let nb = win.document.getElementById("global-notificationbox");
nb.appendNotification(message, "reset-unused-profile",
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -1,21 +1,30 @@
/* 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/. */
-const Cc = Components.classes;
-const Ci = Components.interfaces;
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/Services.jsm");
var gStateObject;
var gTreeData;
// Page initialization
window.onload = function() {
+ // pages used by this script may have a link that needs to be updated to
+ // the in-product link.
+ let anchor = document.getElementById("linkMoreTroubleshooting");
+ if (anchor) {
+ let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
+ anchor.setAttribute("href", baseURL + "troubleshooting");
+ }
+
// the crashed session state is kept inside a textbox so that SessionStore picks it up
// (for when the tab is closed or the session crashes right again)
var sessionData = document.getElementById("sessionData");
if (!sessionData.value) {
document.getElementById("errorTryAgain").disabled = true;
return;
}
@@ -65,16 +74,24 @@ function initTreeView() {
tabList.view.selection.select(0);
}
// User actions
function restoreSession() {
document.getElementById("errorTryAgain").disabled = true;
+ if (!gTreeData.some(aItem => aItem.checked)) {
+ // This should only be possible when we have no "cancel" button, and thus
+ // the "Restore session" button always remains enabled. In that case and
+ // when nothing is selected, we just want a new session.
+ startNewSession();
+ return;
+ }
+
// remove all unselected tabs from the state before restoring it
var ix = gStateObject.windows.length - 1;
for (var t = gTreeData.length - 1; t >= 0; t--) {
if (treeView.isContainer(t)) {
if (gTreeData[t].checked === 0)
// this window will be restored partially
gStateObject.windows[ix].tabs =
gStateObject.windows[ix].tabs.filter(function(aTabData, aIx)
@@ -186,17 +203,20 @@ function toggleRowChecked(aIx) {
}
else {
// update the window's checkmark as well (0 means "partially checked")
item.parent.checked = item.parent.tabs.every(isChecked) ? true :
item.parent.tabs.some(isChecked) ? 0 : false;
treeView.treeBox.invalidateRow(gTreeData.indexOf(item.parent));
}
- document.getElementById("errorTryAgain").disabled = !gTreeData.some(isChecked);
+ // we only disable the button when there's no cancel button.
+ if (document.getElementById("errorCancel")) {
+ document.getElementById("errorTryAgain").disabled = !gTreeData.some(isChecked);
+ }
}
function restoreSingleTab(aIx, aShifted) {
var tabbrowser = getBrowserWindow().gBrowser;
var newTab = tabbrowser.addTab();
var item = gTreeData[aIx];
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
--- a/browser/locales/en-US/chrome/browser/aboutSessionRestore.dtd
+++ b/browser/locales/en-US/chrome/browser/aboutSessionRestore.dtd
@@ -18,17 +18,33 @@
<!ENTITY restorepage.close.access "C">
<!ENTITY restorepage.restoreHeader "Restore">
<!ENTITY restorepage.listHeader "Windows and Tabs">
<!-- LOCALIZATION NOTE: %S will be replaced with a number. -->
<!ENTITY restorepage.windowLabel "Window %S">
-<!-- LOCALIZATION NOTE: The following 'welcomeback' strings are for about:welcomeback,
+<!-- LOCALIZATION NOTE: The following 'welcomeback2' strings are for about:welcomeback,
not for about:sessionstore -->
-<!ENTITY welcomeback.tabtitle "Welcome Back!">
+
+<!ENTITY welcomeback2.restoreButton "Let's go!">
+<!ENTITY welcomeback2.restoreButton.access "L">
+
+<!ENTITY welcomeback2.tabtitle "Success!">
+
+<!ENTITY welcomeback2.pageTitle "Success!">
+<!ENTITY welcomeback2.pageInfo1 "&brandShortName; is ready to go.">
-<!-- LOCALIZATION NOTE: The title is intended to be welcoming and congratulatory,
- expressing joy that the user has successfully migrated their stuff and hope
- that now they have a better experience. -->
-<!ENTITY welcomeback.pageTitle "Welcome Back!">
-<!ENTITY welcomeback.pageInfo "&brandShortName; successfully reset your profile. Below is a list of windows and tabs you had open; you can restore them or start with a clean slate.">
+<!ENTITY welcomeback2.label.restoreAll "Restore all Windows and Tabs">
+<!ENTITY welcomeback2.label.restoreSome "Restore only the ones you want">
+
+
+<!-- LOCALIZATION NOTE (welcomeback2.beforelink.pageInfo2,
+welcomeback2.afterlink.pageInfo2): these two string are used respectively
+before and after the the "learn more" link (welcomeback2.link.pageInfo2).
+Localizers can use one of them, or both, to better adapt this sentence to
+their language.
+-->
+<!ENTITY welcomeback2.beforelink.pageInfo2 "Your add-ons and customizations have been removed and your browser settings have been restored to their defaults. If this didn't fix your issue, ">
+<!ENTITY welcomeback2.afterlink.pageInfo2 "">
+
+<!ENTITY welcomeback2.link.pageInfo2 "learn more about what you can do.">
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -599,8 +599,17 @@ slowStartup.disableNotificationButton.ac
# LOCALIZATION NOTE(customizeTips.tip0): %1$S will be replaced with the text defined
# in customizeTips.tip0.hint, %2$S will be replaced with brandShortName, %3$S will
# be replaced with a hyperlink containing the text defined in customizeTips.tip0.learnMore.
customizeTips.tip0 = %1$S: You can customize %2$S to work the way you do. Simply drag any of the above to the menu or toolbar. %3$S about customizing %2$S.
customizeTips.tip0.hint = Hint
customizeTips.tip0.learnMore = Learn more
+
+# LOCALIZATION NOTE(appmenu.*.description, appmenu.*.label): these are used for
+# the appmenu labels and buttons that appear when an update is staged for
+# installation or a background update has failed and a manual download is required.
+# %S is brandShortName
+appmenu.restartNeeded.description = Restart %S to apply updates
+appmenu.updateFailed.description = Background update failed, please download update
+appmenu.restartBrowserButton.label = Restart %S
+appmenu.downloadUpdateButton.label = Download Update
--- a/browser/locales/en-US/chrome/browser/loop/loop.properties
+++ b/browser/locales/en-US/chrome/browser/loop/loop.properties
@@ -92,16 +92,17 @@ contacts_search_placesholder=Search…
## for where this appears on the UI
new_contact_button=New Contact
## LOCALIZATION NOTE (new_contact_name_placeholder, new_contact_email_placeholder):
## These are the placeholders for the fields for entering a new contact
## See https://people.mozilla.org/~dhenein/labs/loop-mvp-spec/#contacts
## and click the 'New Contact' button to see the fields.
new_contact_name_placeholder=Name
new_contact_email_placeholder=Email
+new_contact_phone_placeholder=Firefox OS Phone
contacts_blocked_contacts=Blocked Contacts
## LOCALIZATION NOTE (add_contact_button):
## This is the button to actually add the new contact
## See https://people.mozilla.org/~dhenein/labs/loop-mvp-spec/#contacts
## and click the 'New Contact' button to see the fields.
add_contact_button=Add Contact
--- a/browser/locales/en-US/chrome/browser/safeMode.dtd
+++ b/browser/locales/en-US/chrome/browser/safeMode.dtd
@@ -1,19 +1,17 @@
<!-- 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/. -->
<!ENTITY safeModeDialog.title "&brandShortName; Safe Mode">
<!ENTITY window.maxWidth "400">
<!ENTITY startSafeMode.label "Start in Safe Mode">
-<!ENTITY resetProfile.label "Reset &brandShortName;">
+<!ENTITY refreshProfile.label "Refresh &brandShortName;">
<!ENTITY safeModeDescription3.label "Safe Mode is a special mode of &brandShortName; that can be used to troubleshoot issues.">
<!ENTITY safeModeDescription4.label "Your add-ons and custom settings will be temporarily disabled.">
-<!ENTITY resetProfileInstead.label "You can also Reset &brandShortName; if you want to start fresh.">
+<!ENTITY refreshProfileInstead.label "You can also skip troubleshooting and try refreshing &brandShortName;.">
-<!-- LOCALIZATION NOTE (autoSafeModeDescription2.label safeModeInstead.label resetProfileFooter.label): Shown on the safe mode dialog after multiple startup crashes. See also chrome/global/resetProfile.dtd -->
-<!ENTITY autoSafeModeDescription2.label "&brandShortName; closed unexpectedly while starting. This might be caused by add-ons or other problems. You can try to resolve the problem by resetting &brandShortName; to its default state or troubleshooting in Safe Mode.">
-<!ENTITY resetProfileFooter.label "Everything else will be reset to factory defaults.">
-<!ENTITY safeModeInstead.label "If you don't want this, you can continue in Safe Mode to do your own troubleshooting with your add-ons and custom settings temporarily disabled.">
+<!-- LOCALIZATION NOTE (autoSafeModeDescription3.label): Shown on the safe mode dialog after multiple startup crashes. See also chrome/global/resetProfile.dtd -->
+<!ENTITY autoSafeModeDescription3.label "&brandShortName; closed unexpectedly while starting. This might be caused by add-ons or other problems. You can try to resolve the problem by troubleshooting in Safe Mode.">
--- a/mobile/android/base/ActionModeCompat.java
+++ b/mobile/android/base/ActionModeCompat.java
@@ -13,19 +13,19 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
class ActionModeCompat implements GeckoPopupMenu.OnMenuItemClickListener,
GeckoPopupMenu.OnMenuItemLongClickListener,
View.OnClickListener {
private final String LOGTAG = "GeckoActionModeCompat";
- private Callback mCallback;
- private ActionModeCompatView mView;
- private Presenter mPresenter;
+ private final Callback mCallback;
+ private final ActionModeCompatView mView;
+ private final Presenter mPresenter;
/* A set of callbacks to be called during this ActionMode's lifecycle. These will control the
* creation, interaction with, and destruction of menuitems for the view */
public static interface Callback {
/* Called when action mode is first created. Implementors should use this to inflate menu resources. */
public boolean onCreateActionMode(ActionModeCompat mode, Menu menu);
/* Called to refresh an action mode's action menu. Called whenever the mode is invalidated. Implementors
--- a/mobile/android/base/AlertNotification.java
+++ b/mobile/android/base/AlertNotification.java
@@ -28,17 +28,17 @@ public class AlertNotification
private final String mText;
private final NotificationManager mNotificationManager;
private boolean mProgressStyle;
private double mPrevPercent = -1;
private String mPrevAlertText = "";
private static final double UPDATE_THRESHOLD = .01;
- private Context mContext;
+ private final Context mContext;
public AlertNotification(Context aContext, int aNotificationId, int aIcon,
String aTitle, String aText, long aWhen, Uri aIconUri) {
super(aIcon, (aText.length() > 0) ? aText : aTitle, aWhen);
mIcon = aIcon;
mTitle = aTitle;
mText = aText;
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* -*- 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;
import org.mozilla.gecko.mozglue.RobocopTarget;
@@ -26,21 +26,21 @@ public class AppConstants {
/**
* Encapsulates access to compile-time version definitions, allowing
* for dead code removal for particular APKs.
*/
public static final class Versions {
public static final int MIN_SDK_VERSION = @MOZ_ANDROID_MIN_SDK_VERSION@;
public static final int MAX_SDK_VERSION =
-#ifdef MOZ_ANDROID_MAX_SDK_VERSION
+//#ifdef MOZ_ANDROID_MAX_SDK_VERSION
@MOZ_ANDROID_MAX_SDK_VERSION@;
-#else
+//#else
999;
-#endif
+//#endif
/*
* The SDK_INT >= N check can only pass if our MAX_SDK_VERSION is
* _greater than or equal_ to that number, because otherwise we
* won't be installed on the device.
*
* If MIN_SDK_VERSION is greater than or equal to the number, there
* is no need to do the runtime check.
@@ -88,21 +88,21 @@ public class AppConstants {
public static final String MOZ_APP_VENDOR = "@MOZ_APP_VENDOR@";
public static final String MOZ_APP_VERSION = "@MOZ_APP_VERSION@";
// MOZILLA_VERSION is already quoted when it gets substituted in. If we
// add additional quotes we end up with ""x.y"", which is a syntax error.
public static final String MOZILLA_VERSION = @MOZILLA_VERSION@;
public static final String MOZ_STUMBLER_API_KEY =
-#ifdef MOZ_ANDROID_MLS_STUMBLER
+//#ifdef MOZ_ANDROID_MLS_STUMBLER
"@MOZ_STUMBLER_API_KEY@";
-#else
+//#else
null;
-#endif
+//#endif
public static final boolean MOZ_STUMBLER_BUILD_TIME_ENABLED = (MOZ_STUMBLER_API_KEY != null);
public static final String MOZ_CHILD_PROCESS_NAME = "@MOZ_CHILD_PROCESS_NAME@";
public static final String MOZ_UPDATE_CHANNEL = "@MOZ_UPDATE_CHANNEL@";
public static final String OMNIJAR_NAME = "@OMNIJAR_NAME@";
public static final String OS_TARGET = "@OS_TARGET@";
public static final String TARGET_XPCOM_ABI = @TARGET_XPCOM_ABI@;
@@ -117,147 +117,147 @@ public class AppConstants {
public static final String USER_AGENT_FENNEC_TABLET = "Mozilla/5.0 (Android; Tablet; rv:" +
AppConstants.MOZ_APP_VERSION + ") Gecko/" +
AppConstants.MOZ_APP_VERSION + " Firefox/" +
AppConstants.MOZ_APP_VERSION;
public static final int MOZ_MIN_CPU_VERSION = @MOZ_MIN_CPU_VERSION@;
public static final boolean MOZ_ANDROID_ANR_REPORTER =
-#ifdef MOZ_ANDROID_ANR_REPORTER
+//#ifdef MOZ_ANDROID_ANR_REPORTER
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final String MOZ_PKG_SPECIAL =
-#ifdef MOZ_PKG_SPECIAL
+//#ifdef MOZ_PKG_SPECIAL
"@MOZ_PKG_SPECIAL@";
-#else
+//#else
null;
-#endif
+//#endif
/**
* Whether this APK was built with constrained resources --
* no xhdpi+ images, for example.
*/
public static final boolean MOZ_ANDROID_RESOURCE_CONSTRAINED =
-#ifdef MOZ_ANDROID_RESOURCE_CONSTRAINED
+//#ifdef MOZ_ANDROID_RESOURCE_CONSTRAINED
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_SERVICES_HEALTHREPORT =
-#ifdef MOZ_SERVICES_HEALTHREPORT
+//#ifdef MOZ_SERVICES_HEALTHREPORT
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_TELEMETRY_ON_BY_DEFAULT =
-#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
+//#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final String TELEMETRY_PREF_NAME =
"toolkit.telemetry.enabled";
public static final boolean MOZ_TELEMETRY_REPORTING =
-#ifdef MOZ_TELEMETRY_REPORTING
+//#ifdef MOZ_TELEMETRY_REPORTING
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_CRASHREPORTER =
-#if MOZ_CRASHREPORTER
+//#if MOZ_CRASHREPORTER
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_DATA_REPORTING =
-#ifdef MOZ_DATA_REPORTING
+//#ifdef MOZ_DATA_REPORTING
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_LOCALE_SWITCHER =
-#ifdef MOZ_LOCALE_SWITCHER
+//#ifdef MOZ_LOCALE_SWITCHER
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_UPDATER =
-#ifdef MOZ_UPDATER
+//#ifdef MOZ_UPDATER
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_WEBSMS_BACKEND =
-#ifdef MOZ_WEBSMS_BACKEND
+//#ifdef MOZ_WEBSMS_BACKEND
true;
-#else
+//#else
false;
-#endif
+//#endif
// Android Beam is only supported on API14+, so we don't even bother building
// it if this APK doesn't include API14 support.
public static final boolean MOZ_ANDROID_BEAM =
-#ifdef MOZ_ANDROID_BEAM
+//#ifdef MOZ_ANDROID_BEAM
Versions.feature14Plus;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_ANDROID_APZ =
-#ifdef MOZ_ANDROID_APZ
+//#ifdef MOZ_ANDROID_APZ
true;
-#else
+//#else
false;
-#endif
+//#endif
// See this wiki page for more details about channel specific build defines:
// https://wiki.mozilla.org/Platform/Channel-specific_build_defines
public static final boolean RELEASE_BUILD =
-#ifdef RELEASE_BUILD
+//#ifdef RELEASE_BUILD
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean DEBUG_BUILD =
-#ifdef MOZ_DEBUG
+//#ifdef MOZ_DEBUG
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean MOZ_MEDIA_PLAYER =
-#ifdef MOZ_NATIVE_DEVICES
+//#ifdef MOZ_NATIVE_DEVICES
true;
-#else
+//#else
false;
-#endif
+//#endif
// Official corresponds, roughly, to whether this build is performed on
// Mozilla's continuous integration infrastructure. You should disable
// developer-only functionality when this flag is set.
public static final boolean MOZILLA_OFFICIAL =
-#ifdef MOZILLA_OFFICIAL
+//#ifdef MOZILLA_OFFICIAL
true;
-#else
+//#else
false;
-#endif
+//#endif
public static final boolean ANDROID_DOWNLOADS_INTEGRATION =
-#ifdef MOZ_ANDROID_DOWNLOADS_INTEGRATION
+//#ifdef MOZ_ANDROID_DOWNLOADS_INTEGRATION
AppConstants.Versions.feature12Plus;
-#else
+//#else
false;
-#endif
+//#endif
}
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -235,17 +235,17 @@ public class BrowserApp extends GeckoApp
private Integer mTargetTabForEditingMode;
// The animator used to toggle HomePager visibility has a race where if the HomePager is shown
// (starting the animation), the HomePager is hidden, and the HomePager animation completes,
// both the web content and the HomePager will be hidden. This flag is used to prevent the
// race by determining if the web content should be hidden at the animation's end.
private boolean mHideWebContentOnAnimationEnd;
- private DynamicToolbar mDynamicToolbar = new DynamicToolbar();
+ private final DynamicToolbar mDynamicToolbar = new DynamicToolbar();
@Override
public View onCreateView(final String name, final Context context, final AttributeSet attrs) {
final View view;
if (BrowserToolbar.class.getName().equals(name)) {
view = BrowserToolbar.create(context, attrs);
} else if (TabsPanel.TabsLayout.class.getName().equals(name)) {
view = TabsPanel.createTabsLayout(context, attrs);
--- a/mobile/android/base/BrowserLocaleManager.java
+++ b/mobile/android/base/BrowserLocaleManager.java
@@ -50,21 +50,21 @@ public class BrowserLocaleManager implem
private static final String FALLBACK_LOCALE_TAG = "en-US";
// These are volatile because we don't impose restrictions
// over which thread calls our methods.
private volatile Locale currentLocale;
private volatile Locale systemLocale = Locale.getDefault();
- private AtomicBoolean inited = new AtomicBoolean(false);
+ private final AtomicBoolean inited = new AtomicBoolean(false);
private boolean systemLocaleDidChange;
private BroadcastReceiver receiver;
- private static AtomicReference<LocaleManager> instance = new AtomicReference<LocaleManager>();
+ private static final AtomicReference<LocaleManager> instance = new AtomicReference<LocaleManager>();
public static LocaleManager getInstance() {
LocaleManager localeManager = instance.get();
if (localeManager != null) {
return localeManager;
}
localeManager = new BrowserLocaleManager();
--- a/mobile/android/base/ChromeCast.java
+++ b/mobile/android/base/ChromeCast.java
@@ -38,17 +38,17 @@ class ChromeCast implements GeckoMediaPl
private static final boolean SHOW_DEBUG = false;
static final String MIRROR_RECIEVER_APP_ID = "5F72F863";
private final Context context;
private final RouteInfo route;
private GoogleApiClient apiClient;
private RemoteMediaPlayer remoteMediaPlayer;
- private boolean canMirror;
+ private final boolean canMirror;
private String mSessionId;
private MirrorChannel mMirrorChannel;
private boolean mApplicationStarted = false;
// Callback to start playback of a url on a remote device
private class VideoPlayCallback implements ResultCallback<ApplicationConnectionResult>,
RemoteMediaPlayer.OnStatusUpdatedListener,
RemoteMediaPlayer.OnMetadataUpdatedListener {
--- a/mobile/android/base/ContactService.java
+++ b/mobile/android/base/ContactService.java
@@ -85,18 +85,18 @@ public class ContactService implements G
private HashMap<String, String> mColumnNameConstantsMap;
private HashMap<String, String> mMimeTypeConstantsMap;
private HashMap<String, Integer> mAddressTypesMap;
private HashMap<String, Integer> mPhoneTypesMap;
private HashMap<String, Integer> mEmailTypesMap;
private HashMap<String, Integer> mWebsiteTypesMap;
private HashMap<String, Integer> mImTypesMap;
- private ContentResolver mContentResolver;
- private GeckoApp mActivity;
+ private final ContentResolver mContentResolver;
+ private final GeckoApp mActivity;
ContactService(EventDispatcher eventDispatcher, GeckoApp activity) {
mEventDispatcher = eventDispatcher;
mActivity = activity;
mContentResolver = mActivity.getContentResolver();
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Android:Contacts:Clear",
@@ -666,17 +666,17 @@ public class ContactService implements G
final String typeColumn, final String typeLabelColumn,
final HashMap<String, Integer> typeMap) throws JSONException {
String value = cursor.getString(cursor.getColumnIndex(dataColumn));
int typeConstant = cursor.getInt(cursor.getColumnIndex(typeColumn));
String type;
if (typeConstant == BaseTypes.TYPE_CUSTOM) {
type = cursor.getString(cursor.getColumnIndex(typeLabelColumn));
} else {
- type = getKeyFromMapValue(typeMap, Integer.valueOf(typeConstant));
+ type = getKeyFromMapValue(typeMap, typeConstant);
}
// Since an object may have multiple types, it may have already been added,
// but still needs the new type added
boolean found = false;
if (type != null) {
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
@@ -707,17 +707,17 @@ public class ContactService implements G
private void getPhoneDataAsJSONObject(Cursor cursor, JSONArray phones) throws JSONException {
String value = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
int typeConstant = cursor.getInt(cursor.getColumnIndex(Phone.TYPE));
String type;
if (typeConstant == Phone.TYPE_CUSTOM) {
type = cursor.getString(cursor.getColumnIndex(Phone.LABEL));
} else {
- type = getKeyFromMapValue(mPhoneTypesMap, Integer.valueOf(typeConstant));
+ type = getKeyFromMapValue(mPhoneTypesMap, typeConstant);
}
// Since a phone may have multiple types, it may have already been added,
// but still needs the new type added
boolean found = false;
if (type != null) {
for (int i = 0; i < phones.length(); i++) {
JSONObject phone = phones.getJSONObject(i);
@@ -754,17 +754,17 @@ public class ContactService implements G
String region = cursor.getString(cursor.getColumnIndex(StructuredPostal.REGION));
String postalCode = cursor.getString(cursor.getColumnIndex(StructuredPostal.POSTCODE));
String countryName = cursor.getString(cursor.getColumnIndex(StructuredPostal.COUNTRY));
int typeConstant = cursor.getInt(cursor.getColumnIndex(StructuredPostal.TYPE));
String type;
if (typeConstant == StructuredPostal.TYPE_CUSTOM) {
type = cursor.getString(cursor.getColumnIndex(StructuredPostal.LABEL));
} else {
- type = getKeyFromMapValue(mAddressTypesMap, Integer.valueOf(typeConstant));
+ type = getKeyFromMapValue(mAddressTypesMap, typeConstant);
}
// Since an email may have multiple types, it may have already been added,
// but still needs the new type added
boolean found = false;
if (type != null) {
for (int i = 0; i < addresses.length(); i++) {
JSONObject address = addresses.getJSONObject(i);
@@ -979,17 +979,17 @@ public class ContactService implements G
for (ContentValues values : newContactValues) {
newContactOptions.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, 0)
.withValues(values)
.build());
}
String returnStatus = "KO";
- Long newRawContactId = new Long(-1);
+ Long newRawContactId = -1L;
// Insert the contact!
ContentProviderResult[] insertResults = applyBatch(newContactOptions);
if (insertResults != null) {
try {
// Get the ID of the newly created contact
newRawContactId = getRawContactIdFromContentProviderResults(insertResults);
@@ -1471,17 +1471,17 @@ public class ContactService implements G
}
}
return contentValues;
}
private void getContactsCount(final String requestID) {
Cursor cursor = getAllRawContactIdsCursor();
- Integer numContacts = Integer.valueOf(cursor.getCount());
+ Integer numContacts = cursor.getCount();
cursor.close();
sendCallbackToJavascript("Android:Contacts:Count", requestID, new String[] {"count"},
new Object[] {numContacts});
}
private void sendCallbackToJavascript(final String subject, final String requestID,
final String[] argNames, final Object[] argValues) {
@@ -1818,17 +1818,17 @@ public class ContactService implements G
private static void putPossibleNullValueInJSONObject(final String key, final Object value, JSONObject jsonObject) throws JSONException{
if (value != null) {
jsonObject.put(key, value);
} else {
jsonObject.put(key, JSONObject.NULL);
}
}
- private static String getKeyFromMapValue(final HashMap<String, Integer> map, Integer value) {
+ private static String getKeyFromMapValue(final HashMap<String, Integer> map, int value) {
for (Entry<String, Integer> entry : map.entrySet()) {
if (value == entry.getValue()) {
return entry.getKey();
}
}
return null;
}
@@ -1893,33 +1893,33 @@ public class ContactService implements G
mMimeTypeConstantsMap.put("sex", MIMETYPE_SEX);
mMimeTypeConstantsMap.put("genderidentity", MIMETYPE_GENDER_IDENTITY);
mMimeTypeConstantsMap.put("key", MIMETYPE_KEY);
}
private int getAddressType(String addressType) {
initAddressTypesMap();
Integer type = mAddressTypesMap.get(addressType.toLowerCase());
- return (type != null ? Integer.valueOf(type) : StructuredPostal.TYPE_CUSTOM);
+ return type != null ? type : StructuredPostal.TYPE_CUSTOM;
}
private void initAddressTypesMap() {
if (mAddressTypesMap != null) {
return;
}
mAddressTypesMap = new HashMap<String, Integer>();
mAddressTypesMap.put("home", StructuredPostal.TYPE_HOME);
mAddressTypesMap.put("work", StructuredPostal.TYPE_WORK);
}
private int getPhoneType(String phoneType) {
initPhoneTypesMap();
Integer type = mPhoneTypesMap.get(phoneType.toLowerCase());
- return (type != null ? Integer.valueOf(type) : Phone.TYPE_CUSTOM);
+ return type != null ? type : Phone.TYPE_CUSTOM;
}
private void initPhoneTypesMap() {
if (mPhoneTypesMap != null) {
return;
}
mPhoneTypesMap = new HashMap<String, Integer>();
@@ -1944,34 +1944,34 @@ public class ContactService implements G
mPhoneTypesMap.put("work pager", Phone.TYPE_WORK_PAGER);
mPhoneTypesMap.put("assistant", Phone.TYPE_ASSISTANT);
mPhoneTypesMap.put("mms", Phone.TYPE_MMS);
}
private int getEmailType(String emailType) {
initEmailTypesMap();
Integer type = mEmailTypesMap.get(emailType.toLowerCase());
- return (type != null ? Integer.valueOf(type) : Email.TYPE_CUSTOM);
+ return type != null ? type : Email.TYPE_CUSTOM;
}
private void initEmailTypesMap() {
if (mEmailTypesMap != null) {
return;
}
mEmailTypesMap = new HashMap<String, Integer>();
mEmailTypesMap.put("home", Email.TYPE_HOME);
mEmailTypesMap.put("mobile", Email.TYPE_MOBILE);
mEmailTypesMap.put("work", Email.TYPE_WORK);
}
private int getWebsiteType(String webisteType) {
initWebsiteTypesMap();
Integer type = mWebsiteTypesMap.get(webisteType.toLowerCase());
- return (type != null ? Integer.valueOf(type) : Website.TYPE_CUSTOM);
+ return type != null ? type : Website.TYPE_CUSTOM;
}
private void initWebsiteTypesMap() {
if (mWebsiteTypesMap != null) {
return;
}
mWebsiteTypesMap = new HashMap<String, Integer>();
@@ -1981,17 +1981,17 @@ public class ContactService implements G
mWebsiteTypesMap.put("home", Website.TYPE_HOME);
mWebsiteTypesMap.put("work", Website.TYPE_WORK);
mWebsiteTypesMap.put("ftp", Website.TYPE_FTP);
}
private int getImType(String imType) {
initImTypesMap();
Integer type = mImTypesMap.get(imType.toLowerCase());
- return (type != null ? Integer.valueOf(type) : Im.TYPE_CUSTOM);
+ return type != null ? type : Im.TYPE_CUSTOM;
}
private void initImTypesMap() {
if (mImTypesMap != null) {
return;
}
mImTypesMap = new HashMap<String, Integer>();
--- a/mobile/android/base/CrashReporter.java
+++ b/mobile/android/base/CrashReporter.java
@@ -277,18 +277,18 @@ public class CrashReporter extends Activ
}
}
reader.close();
return true;
}
private String generateBoundary() {
// Generate some random numbers to fill out the boundary
- int r0 = (int)((double)Integer.MAX_VALUE * Math.random());
- int r1 = (int)((double)Integer.MAX_VALUE * Math.random());
+ int r0 = (int)(Integer.MAX_VALUE * Math.random());
+ int r1 = (int)(Integer.MAX_VALUE * Math.random());
return String.format("---------------------------%08X%08X", r0, r1);
}
private void sendPart(OutputStream os, String boundary, String name, String data) {
try {
os.write(("--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"" + name + "\"\r\n" +
"\r\n" +
--- a/mobile/android/base/DoorHangerPopup.java
+++ b/mobile/android/base/DoorHangerPopup.java
@@ -26,17 +26,17 @@ import android.widget.CheckBox;
public class DoorHangerPopup extends ArrowPopup
implements GeckoEventListener,
Tabs.OnTabsChangedListener,
DoorHanger.OnButtonClickListener {
private static final String LOGTAG = "GeckoDoorHangerPopup";
// Stores a set of all active DoorHanger notifications. A DoorHanger is
// uniquely identified by its tabId and value.
- private HashSet<DoorHanger> mDoorHangers;
+ private final HashSet<DoorHanger> mDoorHangers;
// Whether or not the doorhanger popup is disabled.
private boolean mDisabled;
public DoorHangerPopup(Context context) {
super(context);
mDoorHangers = new HashSet<DoorHanger>();
--- a/mobile/android/base/DynamicToolbar.java
+++ b/mobile/android/base/DynamicToolbar.java
@@ -101,17 +101,17 @@ public class DynamicToolbar {
public void setVisible(boolean visible, VisibilityTransition transition) {
ThreadUtils.assertOnUiThread();
if (layerView == null) {
return;
}
- final boolean immediate = transition.equals(VisibilityTransition.IMMEDIATE);
+ final boolean immediate = transition == VisibilityTransition.IMMEDIATE;
if (visible) {
layerView.getLayerMarginsAnimator().showMargins(immediate);
} else {
layerView.getLayerMarginsAnimator().hideMargins(immediate);
}
}
public void setPinned(boolean pinned, PinReason reason) {
--- a/mobile/android/base/FormAssistPopup.java
+++ b/mobile/android/base/FormAssistPopup.java
@@ -396,18 +396,18 @@ public class FormAssistPopup extends Rel
});
}
private static void broadcastGeckoEvent(String eventName, String eventData) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(eventName, eventData));
}
private class AutoCompleteListAdapter extends ArrayAdapter<Pair<String, String>> {
- private LayoutInflater mInflater;
- private int mTextViewResourceId;
+ private final LayoutInflater mInflater;
+ private final int mTextViewResourceId;
public AutoCompleteListAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mTextViewResourceId = textViewResourceId;
}
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -178,17 +178,17 @@ public abstract class GeckoApp
protected ButtonToast mToast;
protected LayerView mLayerView;
private AbsoluteLayout mPluginContainer;
private FullScreenHolder mFullScreenPluginContainer;
private View mFullScreenPluginView;
- private HashMap<String, PowerManager.WakeLock> mWakeLocks = new HashMap<String, PowerManager.WakeLock>();
+ private final HashMap<String, PowerManager.WakeLock> mWakeLocks = new HashMap<String, PowerManager.WakeLock>();
protected boolean mShouldRestore;
protected boolean mInitialized;
private Telemetry.Timer mJavaUiStartupTimer;
private Telemetry.Timer mGeckoReadyStartupTimer;
private String mPrivateBrowsingSession;
@@ -1011,19 +1011,19 @@ public abstract class GeckoApp
}
private int getBitmapSampleSize(BitmapFactory.Options options, int idealWidth, int idealHeight) {
int width = options.outWidth;
int height = options.outHeight;
int inSampleSize = 1;
if (height > idealHeight || width > idealWidth) {
if (width > height) {
- inSampleSize = Math.round((float)height / (float)idealHeight);
+ inSampleSize = Math.round((float)height / idealHeight);
} else {
- inSampleSize = Math.round((float)width / (float)idealWidth);
+ inSampleSize = Math.round((float)width / idealWidth);
}
}
return inSampleSize;
}
private void hidePluginLayer(Layer layer) {
LayerView layerView = mLayerView;
layerView.removeLayer(layer);
--- a/mobile/android/base/GeckoBatteryManager.java
+++ b/mobile/android/base/GeckoBatteryManager.java
@@ -25,17 +25,17 @@ public class GeckoBatteryManager extends
private final static double kUnknownRemainingTime = -1.0;
private static long sLastLevelChange;
private static boolean sNotificationsEnabled;
private static double sLevel = kDefaultLevel;
private static boolean sCharging = kDefaultCharging;
private static double sRemainingTime = kDefaultRemainingTime;
- private static GeckoBatteryManager sInstance = new GeckoBatteryManager();
+ private static final GeckoBatteryManager sInstance = new GeckoBatteryManager();
private final IntentFilter mFilter;
private Context mApplicationContext;
private boolean mIsEnabled;
public static GeckoBatteryManager getInstance() {
return sInstance;
}
@@ -102,18 +102,18 @@ public class GeckoBatteryManager extends
if (sCharging != previousCharging) {
sRemainingTime = kUnknownRemainingTime;
// The new remaining time is going to take some time to show up but
// it's the best way to show a not too wrong value.
sLastLevelChange = 0;
}
// We need two doubles because sLevel is a double.
- double current = (double)intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
- double max = (double)intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
+ double current = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
+ double max = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
if (current == -1 || max == -1) {
Log.e(LOGTAG, "Failed to get battery level!");
sLevel = kDefaultLevel;
} else {
sLevel = current / max;
}
if (sLevel == 1.0 && sCharging) {
--- a/mobile/android/base/GeckoConnectivityReceiver.java
+++ b/mobile/android/base/GeckoConnectivityReceiver.java
@@ -20,17 +20,17 @@ public class GeckoConnectivityReceiver e
*/
private static final String LINK_DATA_UP = "up";
private static final String LINK_DATA_DOWN = "down";
private static final String LINK_DATA_CHANGED = "changed";
private static final String LINK_DATA_UNKNOWN = "unknown";
private static final String LOGTAG = "GeckoConnectivityReceiver";
- private static GeckoConnectivityReceiver sInstance = new GeckoConnectivityReceiver();
+ private static final GeckoConnectivityReceiver sInstance = new GeckoConnectivityReceiver();
private final IntentFilter mFilter;
private Context mApplicationContext;
private boolean mIsEnabled;
public static GeckoConnectivityReceiver getInstance() {
return sInstance;
}
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -38,17 +38,17 @@ import org.mozilla.gecko.mozglue.Robocop
*/
@JNITarget
public class GeckoEvent {
private static final String LOGTAG = "GeckoEvent";
private static final int EVENT_FACTORY_SIZE = 5;
// Maybe we're probably better to just make mType non final, and just store GeckoEvents in here...
- private static SparseArray<ArrayBlockingQueue<GeckoEvent>> mEvents = new SparseArray<ArrayBlockingQueue<GeckoEvent>>();
+ private static final SparseArray<ArrayBlockingQueue<GeckoEvent>> mEvents = new SparseArray<ArrayBlockingQueue<GeckoEvent>>();
public static GeckoEvent get(NativeGeckoEvent type) {
synchronized (mEvents) {
ArrayBlockingQueue<GeckoEvent> events = mEvents.get(type.value);
if (events != null && events.size() > 0) {
return events.poll();
}
}
--- a/mobile/android/base/GeckoInputConnection.java
+++ b/mobile/android/base/GeckoInputConnection.java
@@ -992,17 +992,17 @@ class GeckoInputConnection
}
}
final class DebugGeckoInputConnection
extends GeckoInputConnection
implements InvocationHandler {
private InputConnection mProxy;
- private StringBuilder mCallLevel;
+ private final StringBuilder mCallLevel;
private DebugGeckoInputConnection(View targetView,
GeckoEditableClient editable) {
super(targetView, editable);
mCallLevel = new StringBuilder();
}
public static GeckoEditableListener create(View targetView,
--- a/mobile/android/base/GeckoJavaSampler.java
+++ b/mobile/android/base/GeckoJavaSampler.java
@@ -57,17 +57,17 @@ public class GeckoJavaSampler {
private static class SamplingThread implements Runnable {
private final int mInterval;
private final int mSampleCount;
private boolean mPauseSampler;
private boolean mStopSampler;
- private SparseArray<Sample[]> mSamples = new SparseArray<Sample[]>();
+ private final SparseArray<Sample[]> mSamples = new SparseArray<Sample[]>();
private int mSamplePos;
public SamplingThread(final int aInterval, final int aSampleCount) {
// If we sample faster then 10ms we get to many missed samples
mInterval = Math.max(10, aInterval);
mSampleCount = aSampleCount;
}
@@ -137,17 +137,17 @@ public class GeckoJavaSampler {
return sSamplingRunnable.getSample(aThreadId, aSampleId);
}
@WrapElementForJNI(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
public synchronized static double getSampleTime(int aThreadId, int aSampleId) {
Sample sample = getSample(aThreadId, aSampleId);
if (sample != null) {
if (sample.mJavaTime != 0) {
- return (double)(sample.mJavaTime -
+ return (sample.mJavaTime -
SystemClock.elapsedRealtime()) + getProfilerTime();
}
System.out.println("Sample: " + sample.mTime);
return sample.mTime;
}
return 0;
}
--- a/mobile/android/base/GeckoProfile.java
+++ b/mobile/android/base/GeckoProfile.java
@@ -35,17 +35,17 @@ import android.util.Log;
public final class GeckoProfile {
private static final String LOGTAG = "GeckoProfile";
// Used to "lock" the guest profile, so that we'll always restart in it
private static final String LOCK_FILE_NAME = ".active_lock";
public static final String DEFAULT_PROFILE = "default";
public static final String GUEST_PROFILE = "guest";
- private static HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
+ private static final HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
private static String sDefaultProfileName;
// Caches the guest profile dir.
private static File sGuestDir;
private static GeckoProfile sGuestProfile;
public static boolean sIsUsingCustomProfile;
--- a/mobile/android/base/GeckoProfileDirectories.java
+++ b/mobile/android/base/GeckoProfileDirectories.java
@@ -53,27 +53,27 @@ public class GeckoProfileDirectories {
public boolean matches(INISection section);
}
private static final String MOZILLA_DIR_NAME = "mozilla";
/**
* Returns true if the supplied profile entry represents the default profile.
*/
- private static INISectionPredicate sectionIsDefault = new INISectionPredicate() {
+ private static final INISectionPredicate sectionIsDefault = new INISectionPredicate() {
@Override
public boolean matches(INISection section) {
return section.getIntProperty("Default") == 1;
}
};
/**
* Returns true if the supplied profile entry has a 'Name' field.
*/
- private static INISectionPredicate sectionHasName = new INISectionPredicate() {
+ private static final INISectionPredicate sectionHasName = new INISectionPredicate() {
@Override
public boolean matches(INISection section) {
final String name = section.getStringProperty("Name");
return name != null;
}
};
@RobocopTarget
--- a/mobile/android/base/GeckoThread.java
+++ b/mobile/android/base/GeckoThread.java
@@ -32,17 +32,17 @@ public class GeckoThread extends Thread
Launching,
WaitForDebugger,
Launched,
GeckoRunning,
GeckoExiting,
GeckoExited
}
- private static AtomicReference<LaunchState> sLaunchState =
+ private static final AtomicReference<LaunchState> sLaunchState =
new AtomicReference<LaunchState>(LaunchState.Launching);
private static GeckoThread sGeckoThread;
private final String mArgs;
private final String mAction;
private final String mUri;
--- a/mobile/android/base/IntentHelper.java
+++ b/mobile/android/base/IntentHelper.java
@@ -26,17 +26,17 @@ public final class IntentHelper implemen
private static final String[] EVENTS = {
"Intent:GetHandlers",
"Intent:Open",
"Intent:OpenForResult",
"WebActivity:Open"
};
private static IntentHelper instance;
- private Activity activity;
+ private final Activity activity;
private IntentHelper(Activity activity) {
this.activity = activity;
EventDispatcher.getInstance().registerGeckoThreadListener(this, EVENTS);
}
public static IntentHelper init(Activity activity) {
if (instance == null) {
--- a/mobile/android/base/LightweightThemeDrawable.java
+++ b/mobile/android/base/LightweightThemeDrawable.java
@@ -21,21 +21,21 @@ import android.graphics.Shader;
import android.graphics.drawable.Drawable;
/**
* A special drawable used with lightweight themes. This draws a color
* (with an optional color-filter) and a bitmap (with a linear gradient
* to specify the alpha) in order.
*/
public class LightweightThemeDrawable extends Drawable {
- private Paint mPaint;
+ private final Paint mPaint;
private Paint mColorPaint;
- private Bitmap mBitmap;
- private Resources mResources;
+ private final Bitmap mBitmap;
+ private final Resources mResources;
private int mStartColor;
private int mEndColor;
public LightweightThemeDrawable(Resources resources, Bitmap bitmap) {
mBitmap = bitmap;
mResources = resources;
@@ -48,18 +48,19 @@ public class LightweightThemeDrawable ex
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
initializeBitmapShader();
}
@Override
public void draw(Canvas canvas) {
// Draw the colors, if available.
- if (mColorPaint != null)
+ if (mColorPaint != null) {
canvas.drawPaint(mColorPaint);
+ }
// Draw the bitmap.
canvas.drawPaint(mPaint);
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
@@ -70,17 +71,17 @@ public class LightweightThemeDrawable ex
// A StateListDrawable will reset the alpha value with 255.
// We cannot use to be the bitmap alpha.
mPaint.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter filter) {
mPaint.setColorFilter(filter);
- }
+ }
/**
* Creates a paint that paint a particular color.
*
* @param color The color to be painted.
*/
public void setColor(int color) {
mColorPaint = new Paint(mPaint);
@@ -107,22 +108,22 @@ public class LightweightThemeDrawable ex
*/
public void setAlpha(int startAlpha, int endAlpha) {
mStartColor = startAlpha << 24;
mEndColor = endAlpha << 24;
initializeBitmapShader();
}
private void initializeBitmapShader() {
- // A bitmap-shader to draw the bitmap.
+ // A bitmap-shader to draw the bitmap.
// Clamp mode will repeat the last row of pixels.
// Hence its better to have an endAlpha of 0 for the linear-gradient.
- BitmapShader bitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
+ BitmapShader bitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
- // A linear-gradient to specify the opacity of the bitmap.
- LinearGradient gradient = new LinearGradient(0, 0, 0, mBitmap.getHeight(), mStartColor, mEndColor, Shader.TileMode.CLAMP);
+ // A linear-gradient to specify the opacity of the bitmap.
+ LinearGradient gradient = new LinearGradient(0, 0, 0, mBitmap.getHeight(), mStartColor, mEndColor, Shader.TileMode.CLAMP);
- // Make a combined shader -- a performance win.
+ // Make a combined shader -- a performance win.
// The linear-gradient is the 'SRC' and the bitmap-shader is the 'DST'.
- // Drawing the DST in the SRC will provide the opacity.
- mPaint.setShader(new ComposeShader(bitmapShader, gradient, PorterDuff.Mode.DST_IN));
+ // Drawing the DST in the SRC will provide the opacity.
+ mPaint.setShader(new ComposeShader(bitmapShader, gradient, PorterDuff.Mode.DST_IN));
}
}
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -196,29 +196,31 @@ PP_TARGETS += manifest
# Certain source files need to be preprocessed. This special rule
# generates these files into generated/org/mozilla/gecko for
# consumption by the build system and IDEs.
preprocessed := $(addsuffix .in,$(subst generated/org/mozilla/gecko/,,$(filter generated/org/mozilla/gecko/%,$(PP_JAVAFILES))))
preprocessed_PATH := generated/org/mozilla/gecko
preprocessed_KEEP_PATH := 1
+preprocessed_FLAGS := --marker='//\\\#'
PP_TARGETS += preprocessed
# Certain source files have Java package name @ANDROID_PACKAGE_NAME@.
# We hate these files but they are necessary for backwards
# compatibility. These special rules generate these files into
# generated/org/mozilla/{firefox,firefox_beta,fennec,fennec_$USER} for
# consumption by the build system and IDEs.
preprocessed_package := $(addsuffix .in,$(subst $(android_package_dir)/,,$(filter $(android_package_dir)/%,$(PP_JAVAFILES))))
preprocessed_package_PATH := $(android_package_dir)
preprocessed_package_KEEP_PATH := 1
+preprocessed_package_FLAGS := --marker='//\\\#'
PP_TARGETS += preprocessed_package
include $(topsrcdir)/config/rules.mk
not_android_res_files := \
*.mkdir.done* \
*.DS_Store* \
--- a/mobile/android/base/MemoryMonitor.java
+++ b/mobile/android/base/MemoryMonitor.java
@@ -42,17 +42,17 @@ class MemoryMonitor extends BroadcastRec
// Memory pressure levels. Keep these in sync with those in AndroidJavaWrappers.h
private static final int MEMORY_PRESSURE_NONE = 0;
private static final int MEMORY_PRESSURE_CLEANUP = 1;
private static final int MEMORY_PRESSURE_LOW = 2;
private static final int MEMORY_PRESSURE_MEDIUM = 3;
private static final int MEMORY_PRESSURE_HIGH = 4;
- private static MemoryMonitor sInstance = new MemoryMonitor();
+ private static final MemoryMonitor sInstance = new MemoryMonitor();
static MemoryMonitor getInstance() {
return sInstance;
}
private final PressureDecrementer mPressureDecrementer;
private int mMemoryPressure; // Synchronized access only.
private volatile boolean mStoragePressure; // Accessed via UI thread intent, background runnables.
--- a/mobile/android/base/NotificationHelper.java
+++ b/mobile/android/base/NotificationHelper.java
@@ -59,17 +59,17 @@ public final class NotificationHelper im
private static final String NOTIFICATION_SCHEME = "moz-notification";
private static final String BUTTON_EVENT = "notification-button-clicked";
private static final String CLICK_EVENT = "notification-clicked";
private static final String CLEARED_EVENT = "notification-cleared";
private static final String CLOSED_EVENT = "notification-closed";
- private Context mContext;
+ private final Context mContext;
// Holds a list of notifications that should be cleared if the Fennec Activity is shut down.
// Will not include ongoing or persistent notifications that are tied to Gecko's lifecycle.
private HashMap<String, String> mClearableNotifications;
private boolean mInitialized;
private static NotificationHelper sInstance;
--- a/mobile/android/base/ScrollAnimator.java
+++ b/mobile/android/base/ScrollAnimator.java
@@ -21,17 +21,17 @@ public class ScrollAnimator implements V
// Assuming 60fps, this will make the view scroll once per frame
static final long MS_PER_FRAME = 1000 / 60;
// Maximum number of pixels that can be scrolled per frame
static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi();
private class ScrollRunnable extends TimerTask {
- private View mView;
+ private final View mView;
public ScrollRunnable(View view) {
mView = view;
}
@Override
public final void run() {
mView.scrollBy(mX, mY);
--- a/mobile/android/base/SuggestClient.java
+++ b/mobile/android/base/SuggestClient.java
@@ -41,17 +41,17 @@ public class SuggestClient {
// should contain the string "__searchTerms__", which is replaced with the query
private final String mSuggestTemplate;
// the maximum number of suggestions to return
private final int mMaxResults;
// used by robocop for testing
- private boolean mCheckNetwork;
+ private final boolean mCheckNetwork;
// used to make suggestions appear instantly after opt-in
private String mPrevQuery;
private ArrayList<String> mPrevResults;
public SuggestClient(Context context, String suggestTemplate, int timeout, int maxResults) {
mContext = context;
mMaxResults = maxResults;
--- a/mobile/android/base/SysInfo.java.in
+++ b/mobile/android/base/SysInfo.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* -*- 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;
import org.mozilla.gecko.util.HardwareUtils;
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -40,37 +40,37 @@ public class Tab {
private String mBaseDomain;
private String mUserRequested; // The original url requested. May be typed by the user or sent by an extneral app for example.
private String mTitle;
private Bitmap mFavicon;
private String mFaviconUrl;
private int mFaviconSize;
private boolean mHasFeeds;
private boolean mHasOpenSearch;
- private SiteIdentity mSiteIdentity;
+ private final SiteIdentity mSiteIdentity;
private boolean mReaderEnabled;
private BitmapDrawable mThumbnail;
private int mHistoryIndex;
private int mHistorySize;
- private int mParentId;
- private boolean mExternal;
+ private final int mParentId;
+ private final boolean mExternal;
private boolean mBookmark;
private int mFaviconLoadId;
private String mContentType;
private boolean mHasTouchListeners;
private ZoomConstraints mZoomConstraints;
private boolean mIsRTL;
- private ArrayList<View> mPluginViews;
- private HashMap<Object, Layer> mPluginLayers;
+ private final ArrayList<View> mPluginViews;
+ private final HashMap<Object, Layer> mPluginLayers;
private int mBackgroundColor;
private int mState;
private Bitmap mThumbnailBitmap;
private boolean mDesktopMode;
private boolean mEnteringReaderMode;
- private Context mAppContext;
+ private final Context mAppContext;
private ErrorType mErrorType = ErrorType.NONE;
private static final int MAX_HISTORY_LIST_SIZE = 50;
private volatile int mLoadProgress;
private volatile int mRecordingCount;
private String mMostRecentHomePanel;
public static final int STATE_DELAYED = 0;
public static final int STATE_LOADING = 1;
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -60,17 +60,17 @@ public class Tabs implements GeckoEventL
public static final int LOADURL_DESKTOP = 1 << 5;
public static final int LOADURL_BACKGROUND = 1 << 6;
public static final int LOADURL_EXTERNAL = 1 << 7;
private static final long PERSIST_TABS_AFTER_MILLISECONDS = 1000 * 5;
public static final int INVALID_TAB_ID = -1;
- private static AtomicInteger sTabId = new AtomicInteger(0);
+ private static final AtomicInteger sTabId = new AtomicInteger(0);
private volatile boolean mInitialTabsAdded;
private Context mAppContext;
private ContentObserver mContentObserver;
private final Runnable mPersistTabsRunnable = new Runnable() {
@Override
public void run() {
--- a/mobile/android/base/TextSelection.java
+++ b/mobile/android/base/TextSelection.java
@@ -49,17 +49,17 @@ class TextSelection extends Layer implem
private float mViewZoom;
private String mCurrentItems;
private TextSelectionActionModeCallback mCallback;
// These timers are used to avoid flicker caused by selection handles showing/hiding quickly. For isntance
// when moving between single handle caret mode and two handle selection mode.
- private Timer mActionModeTimer = new Timer("actionMode");
+ private final Timer mActionModeTimer = new Timer("actionMode");
private class ActionModeTimerTask extends TimerTask {
@Override
public void run() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
endActionMode();
}
@@ -184,21 +184,21 @@ class TextSelection extends Layer implem
} catch (JSONException e) {
Log.e(LOGTAG, "JSON exception", e);
}
}
});
}
private void showActionMode(final JSONArray items) {
- String itemsString = items.toString();
- if (itemsString.equals(mCurrentItems)) {
- return;
- }
- mCurrentItems = itemsString;
+ String itemsString = items.toString();
+ if (itemsString.equals(mCurrentItems)) {
+ return;
+ }
+ mCurrentItems = itemsString;
if (mCallback != null) {
mCallback.updateItems(items);
return;
}
final Context context = mStartHandle.getContext();
if (context instanceof ActionModeCompat.Presenter) {
@@ -209,17 +209,17 @@ class TextSelection extends Layer implem
}
private void endActionMode() {
Context context = mStartHandle.getContext();
if (context instanceof ActionModeCompat.Presenter) {
final ActionModeCompat.Presenter presenter = (ActionModeCompat.Presenter) context;
presenter.endActionModeCompat();
}
- mCurrentItems = null;
+ mCurrentItems = null;
}
@Override
public void draw(final RenderContext context) {
// cache the relevant values from the context and bail out if they are the same. we do this
// because this draw function gets called a lot (once per compositor frame) and we want to
// avoid doing a lot of extra work in cases where it's not needed.
final float viewLeft = context.viewport.left - context.offset.x;
--- a/mobile/android/base/TextSelectionHandle.java
+++ b/mobile/android/base/TextSelectionHandle.java
@@ -127,17 +127,17 @@ class TextSelectionHandle extends ImageV
Log.e(LOGTAG, "Error building JSON arguments for TextSelection:Move");
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("TextSelection:Move", args.toString()));
// If we're positioning a cursor, don't move the handle here. Gecko
// will tell us the position of the caret, so we set the handle
// position then. This allows us to lock the handle to wherever the
// caret appears.
- if (!mHandleType.equals(HandleType.MIDDLE)) {
+ if (mHandleType != HandleType.MIDDLE) {
setLayoutPosition();
}
}
void positionFromGecko(int left, int top, boolean rtl) {
LayerView layerView = GeckoAppShell.getLayerView();
if (layerView == null) {
Log.e(LOGTAG, "Can't position handle because layerView is null");
@@ -161,22 +161,23 @@ class TextSelectionHandle extends ImageV
mLeft = viewPoint.x - adjustLeftForHandle();
mTop = viewPoint.y;
setLayoutPosition();
}
private float adjustLeftForHandle() {
- if (mHandleType.equals(HandleType.START))
+ if (mHandleType == HandleType.START) {
return mIsRTL ? mShadow : mWidth - mShadow;
- else if (mHandleType.equals(HandleType.MIDDLE))
+ } else if (mHandleType == HandleType.MIDDLE) {
return mWidth / 2;
- else
+ } else {
return mIsRTL ? mWidth - mShadow : mShadow;
+ }
}
private void setLayoutPosition() {
if (mLayoutParams == null) {
mLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
// Set negative right/bottom margins so that the handles can be dragged outside of
// the content area (if they are dragged to the left/top, the dyanmic margins set
// below will take care of that).
--- a/mobile/android/base/animation/AnimatorProxy.java
+++ b/mobile/android/base/animation/AnimatorProxy.java
@@ -30,17 +30,17 @@ class AnimatorProxy {
public void setTranslationX(float translationX);
public float getTranslationY();
public void setTranslationY(float translationY);
public View getView();
}
- private AnimatorProxyImpl mImpl;
+ private final AnimatorProxyImpl mImpl;
private AnimatorProxy(AnimatorProxyImpl impl) {
mImpl = impl;
}
public static AnimatorProxy create(View view) {
AnimatorProxy proxy = PROXIES.get(view);
final boolean needsAnimationProxy = Versions.preHC;
@@ -141,17 +141,17 @@ class AnimatorProxy {
/*
* AnimatorProxyPreHC uses the technique used by the NineOldAndroids described here:
* http://jakewharton.com/advanced-pre-honeycomb-animation/
*
* Some of this code is based on Jake Wharton's AnimatorProxy released as part of
* the NineOldAndroids library under the Apache License 2.0.
*/
private static class AnimatorProxyPreHC extends Animation implements AnimatorProxyImpl {
- private WeakReference<View> mViewRef;
+ private final WeakReference<View> mViewRef;
private final RectF mBefore;
private final RectF mAfter;
private final Matrix mTempMatrix;
private float mAlpha;
private float mTranslationX;
private float mTranslationY;
@@ -286,17 +286,17 @@ class AnimatorProxy {
if (view != null) {
t.setAlpha(mAlpha);
transformMatrix(t.getMatrix(), view);
}
}
}
private static class AnimatorProxyPostHC implements AnimatorProxyImpl {
- private WeakReference<View> mViewRef;
+ private final WeakReference<View> mViewRef;
public AnimatorProxyPostHC(View view) {
mViewRef = new WeakReference<View>(view);
}
@Override
public float getAlpha() {
View view = mViewRef.get();
--- a/mobile/android/base/animation/BounceAnimator.java
+++ b/mobile/android/base/animation/BounceAnimator.java
@@ -27,17 +27,17 @@ public class BounceAnimator extends Valu
public Attributes(float value, int duration) {
this.value = value;
this.durationMs = duration;
}
}
private final View mView;
private final String mPropertyName;
- private List<Animator> animatorChain = new LinkedList<Animator>();
+ private final List<Animator> animatorChain = new LinkedList<Animator>();
public BounceAnimator(View view, String property) {
mView = view;
mPropertyName = property;
}
public void queue(Attributes attrs) {
final ValueAnimator animator = ObjectAnimator.ofFloat(mView, mPropertyName, attrs.value);
--- a/mobile/android/base/animation/PropertyAnimator.java
+++ b/mobile/android/base/animation/PropertyAnimator.java
@@ -41,32 +41,32 @@ public class PropertyAnimator implements
float to;
}
public static interface PropertyAnimationListener {
public void onPropertyAnimationStart();
public void onPropertyAnimationEnd();
}
- private Interpolator mInterpolator;
+ private final Interpolator mInterpolator;
private long mStartTime;
- private long mDuration;
- private float mDurationReciprocal;
- private List<ElementHolder> mElementsList;
+ private final long mDuration;
+ private final float mDurationReciprocal;
+ private final List<ElementHolder> mElementsList;
private List<PropertyAnimationListener> mListeners;
FramePoster mFramePoster;
private boolean mUseHardwareLayer;
public PropertyAnimator(long duration) {
this(duration, new DecelerateInterpolator());
}
public PropertyAnimator(long duration, Interpolator interpolator) {
mDuration = duration;
- mDurationReciprocal = 1.0f / (float) mDuration;
+ mDurationReciprocal = 1.0f / mDuration;
mInterpolator = interpolator;
mElementsList = new ArrayList<ElementHolder>();
mFramePoster = FramePoster.create(this);
mUseHardwareLayer = true;
}
public void setUseHardwareLayer(boolean useHardwareLayer) {
mUseHardwareLayer = useHardwareLayer;
--- a/mobile/android/base/animation/ViewHelper.java
+++ b/mobile/android/base/animation/ViewHelper.java
@@ -2,61 +2,61 @@
* 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.animation;
import android.view.View;
public final class ViewHelper {
- private ViewHelper() {
- }
+ private ViewHelper() {
+ }
- public static float getTranslationX(View view) {
- AnimatorProxy proxy = AnimatorProxy.create(view);
- return proxy.getTranslationX();
- }
+ public static float getTranslationX(View view) {
+ AnimatorProxy proxy = AnimatorProxy.create(view);
+ return proxy.getTranslationX();
+ }
- public static void setTranslationX(View view, float translationX) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- proxy.setTranslationX(translationX);
- }
+ public static void setTranslationX(View view, float translationX) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ proxy.setTranslationX(translationX);
+ }
- public static float getTranslationY(View view) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- return proxy.getTranslationY();
- }
+ public static float getTranslationY(View view) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ return proxy.getTranslationY();
+ }
- public static void setTranslationY(View view, float translationY) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- proxy.setTranslationY(translationY);
- }
+ public static void setTranslationY(View view, float translationY) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ proxy.setTranslationY(translationY);
+ }
- public static float getAlpha(View view) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- return proxy.getAlpha();
- }
+ public static float getAlpha(View view) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ return proxy.getAlpha();
+ }
- public static void setAlpha(View view, float alpha) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- proxy.setAlpha(alpha);
- }
+ public static void setAlpha(View view, float alpha) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ proxy.setAlpha(alpha);
+ }
- public static int getWidth(View view) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- return proxy.getWidth();
- }
+ public static int getWidth(View view) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ return proxy.getWidth();
+ }
- public static void setWidth(View view, int width) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- proxy.setWidth(width);
- }
+ public static void setWidth(View view, int width) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ proxy.setWidth(width);
+ }
- public static int getHeight(View view) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- return proxy.getHeight();
- }
+ public static int getHeight(View view) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ return proxy.getHeight();
+ }
- public static void setHeight(View view, int height) {
- final AnimatorProxy proxy = AnimatorProxy.create(view);
- proxy.setHeight(height);
- }
+ public static void setHeight(View view, int height) {
+ final AnimatorProxy proxy = AnimatorProxy.create(view);
+ proxy.setHeight(height);
+ }
}
--- a/mobile/android/base/background/common/GlobalConstants.java.in
+++ b/mobile/android/base/background/common/GlobalConstants.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* 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.background.common;
/**
* Preprocessed class for storing preprocessed values common to all
@@ -11,21 +11,21 @@ package org.mozilla.gecko.background.com
*/
public class GlobalConstants {
public static final String ANDROID_CPU_ARCH = "@ANDROID_CPU_ARCH@";
// One of 'beta', 'aurora', 'nightly', 'default'.
// If this is an official build, 'default' means 'release'.
// Otherwise, it means 'dev'.
public static final String MOZ_UPDATE_CHANNEL = "@MOZ_UPDATE_CHANNEL@";
-#ifdef MOZ_OFFICIAL_BRANDING
+//#ifdef MOZ_OFFICIAL_BRANDING
public static final boolean MOZ_OFFICIAL_BRANDING = true;
-#else
+//#else
public static final boolean MOZ_OFFICIAL_BRANDING = false;
-#endif
+//#endif
public static final long BUILD_TIMESTAMP_SECONDS = @MOZ_BUILD_TIMESTAMP@L;
public static final long BUILD_TIMESTAMP_MSEC = 1000L * @MOZ_BUILD_TIMESTAMP@L;
public static final String MOZ_APP_DISPLAYNAME = "@MOZ_APP_DISPLAYNAME@";
public static final String MOZ_APP_VERSION = "@MOZ_APP_VERSION@";
public static final String BROWSER_INTENT_PACKAGE = "@ANDROID_PACKAGE_NAME@";
public static final String BROWSER_INTENT_CLASS = "org.mozilla.gecko.BrowserApp";
--- a/mobile/android/base/background/datareporting/TelemetryRecorder.java
+++ b/mobile/android/base/background/datareporting/TelemetryRecorder.java
@@ -45,17 +45,17 @@ import android.util.Base64;
public class TelemetryRecorder {
private final String LOG_TAG = "TelemetryRecorder";
private final File parentDir;
private final String filename;
private File tmpFile;
private File destFile;
- private File cacheDir;
+ private final File cacheDir;
private OutputStream outputStream;
private MessageDigest checksum;
private String base64Checksum;
/**
* Charset to use for writing pings; default is us-ascii.
*
--- a/mobile/android/base/background/healthreport/HealthReportConstants.java.in
+++ b/mobile/android/base/background/healthreport/HealthReportConstants.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* 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.background.healthreport;
import org.mozilla.gecko.background.common.GlobalConstants;
--- a/mobile/android/base/background/healthreport/HealthReportDatabaseStorage.java
+++ b/mobile/android/base/background/healthreport/HealthReportDatabaseStorage.java
@@ -904,17 +904,17 @@ public class HealthReportDatabaseStorage
c.close();
}
}
/**
* Cache the lookup from measurement and field specifier to field instance.
* This allows us to memoize the field ID lookup, too.
*/
- private HashMap<String, Field> fields = new HashMap<String, Field>();
+ private final HashMap<String, Field> fields = new HashMap<String, Field>();
private boolean fieldsCacheUpdated = false;
private void invalidateFieldsCache() {
synchronized (this.fields) {
fieldsCacheUpdated = false;
}
}
--- a/mobile/android/base/background/healthreport/HealthReportDatabases.java
+++ b/mobile/android/base/background/healthreport/HealthReportDatabases.java
@@ -12,17 +12,17 @@ import org.mozilla.gecko.background.comm
import android.content.Context;
/**
* Manages a set of per-profile Health Report storage helpers.
*/
public class HealthReportDatabases {
private static final String LOG_TAG = "HealthReportDatabases";
- private Context context;
+ private final Context context;
private final HashMap<File, HealthReportDatabaseStorage> storages = new HashMap<File, HealthReportDatabaseStorage>();
public HealthReportDatabases(final Context context) {
this.context = context;
}
public synchronized HealthReportDatabaseStorage getDatabaseHelperForProfile(final File profileDir) {
--- a/mobile/android/base/background/preferences/PreferenceFragment.java
+++ b/mobile/android/base/background/preferences/PreferenceFragment.java
@@ -48,17 +48,17 @@ public abstract class PreferenceFragment
private static final int FIRST_REQUEST_CODE = 100;
private static final int MSG_BIND_PREFERENCES = 1;
// This triggers "This Handler class should be static or leaks might occur".
// The issue is that the Handler references the Fragment; messages targeting
// the Handler reference it; and if such messages are long lived, the Fragment
// cannot be GCed. This is not an issue for us; our messages are short-lived.
- private Handler mHandler = new Handler() {
+ private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_BIND_PREFERENCES:
bindPreferences();
break;
}
@@ -294,17 +294,17 @@ public abstract class PreferenceFragment
throw new RuntimeException(
"Your content must have a ListView whose id attribute is " +
"'android.R.id.list'");
}
mList.setOnKeyListener(mListOnKeyListener);
mHandler.post(mRequestFocus);
}
- private OnKeyListener mListOnKeyListener = new OnKeyListener() {
+ private final OnKeyListener mListOnKeyListener = new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Object selectedItem = mList.getSelectedItem();
if (selectedItem instanceof Preference) {
@SuppressWarnings("unused")
View selectedView = mList.getSelectedView();
//return ((Preference)selectedItem).onKey(
--- a/mobile/android/base/background/preferences/PreferenceManagerCompat.java
+++ b/mobile/android/base/background/preferences/PreferenceManagerCompat.java
@@ -27,17 +27,17 @@ import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.Log;
public class PreferenceManagerCompat {
- private static final String TAG = PreferenceManagerCompat.class.getSimpleName();
+ private static final String TAG = PreferenceManagerCompat.class.getSimpleName();
/**
* Interface definition for a callback to be invoked when a
* {@link Preference} in the hierarchy rooted at this {@link PreferenceScreen} is
* clicked.
*/
interface OnPreferenceTreeClickListener {
/**
@@ -47,185 +47,185 @@ public class PreferenceManagerCompat {
* @param preferenceScreen The {@link PreferenceScreen} that the
* preference is located in.
* @param preference The preference that was clicked.
* @return Whether the click was handled.
*/
boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference);
}
- static PreferenceManager newInstance(Activity activity, int firstRequestCode) {
- try {
- Constructor<PreferenceManager> c = PreferenceManager.class.getDeclaredConstructor(Activity.class, int.class);
- c.setAccessible(true);
- return c.newInstance(activity, firstRequestCode);
- } catch (Exception e) {
- Log.w(TAG, "Couldn't call constructor PreferenceManager by reflection", e);
- }
- return null;
- }
+ static PreferenceManager newInstance(Activity activity, int firstRequestCode) {
+ try {
+ Constructor<PreferenceManager> c = PreferenceManager.class.getDeclaredConstructor(Activity.class, int.class);
+ c.setAccessible(true);
+ return c.newInstance(activity, firstRequestCode);
+ } catch (Exception e) {
+ Log.w(TAG, "Couldn't call constructor PreferenceManager by reflection", e);
+ }
+ return null;
+ }
- /**
+ /**
* Sets the owning preference fragment
*/
static void setFragment(PreferenceManager manager, PreferenceFragment fragment) {
- // stub
+ // stub
}
/**
* Sets the callback to be invoked when a {@link Preference} in the
* hierarchy rooted at this {@link PreferenceManager} is clicked.
*
* @param listener The callback to be invoked.
*/
- static void setOnPreferenceTreeClickListener(PreferenceManager manager, final OnPreferenceTreeClickListener listener) {
- try {
- Field onPreferenceTreeClickListener = PreferenceManager.class.getDeclaredField("mOnPreferenceTreeClickListener");
- onPreferenceTreeClickListener.setAccessible(true);
- if (listener != null) {
- Object proxy = Proxy.newProxyInstance(
- onPreferenceTreeClickListener.getType().getClassLoader(),
- new Class<?>[] { onPreferenceTreeClickListener.getType() },
- new InvocationHandler() {
- @Override
+ static void setOnPreferenceTreeClickListener(PreferenceManager manager, final OnPreferenceTreeClickListener listener) {
+ try {
+ Field onPreferenceTreeClickListener = PreferenceManager.class.getDeclaredField("mOnPreferenceTreeClickListener");
+ onPreferenceTreeClickListener.setAccessible(true);
+ if (listener != null) {
+ Object proxy = Proxy.newProxyInstance(
+ onPreferenceTreeClickListener.getType().getClassLoader(),
+ new Class<?>[] { onPreferenceTreeClickListener.getType() },
+ new InvocationHandler() {
+ @Override
public Object invoke(Object proxy, Method method, Object[] args) {
- if (method.getName().equals("onPreferenceTreeClick")) {
- return Boolean.valueOf(listener.onPreferenceTreeClick((PreferenceScreen) args[0], (Preference) args[1]));
- } else {
- return null;
- }
- }
- });
- onPreferenceTreeClickListener.set(manager, proxy);
- } else {
- onPreferenceTreeClickListener.set(manager, null);
- }
- } catch (Exception e) {
- Log.w(TAG, "Couldn't set PreferenceManager.mOnPreferenceTreeClickListener by reflection", e);
- }
- }
+ if (method.getName().equals("onPreferenceTreeClick")) {
+ return Boolean.valueOf(listener.onPreferenceTreeClick((PreferenceScreen) args[0], (Preference) args[1]));
+ } else {
+ return null;
+ }
+ }
+ });
+ onPreferenceTreeClickListener.set(manager, proxy);
+ } else {
+ onPreferenceTreeClickListener.set(manager, null);
+ }
+ } catch (Exception e) {
+ Log.w(TAG, "Couldn't set PreferenceManager.mOnPreferenceTreeClickListener by reflection", e);
+ }
+ }
- /**
+ /**
* Inflates a preference hierarchy from the preference hierarchies of
* {@link Activity Activities} that match the given {@link Intent}. An
* {@link Activity} defines its preference hierarchy with meta-data using
* the {@link #METADATA_KEY_PREFERENCES} key.
* <p>
* If a preference hierarchy is given, the new preference hierarchies will
* be merged in.
*
* @param queryIntent The intent to match activities.
* @param rootPreferences Optional existing hierarchy to merge the new
* hierarchies into.
* @return The root hierarchy (if one was not provided, the new hierarchy's
* root).
*/
- static PreferenceScreen inflateFromIntent(PreferenceManager manager, Intent intent, PreferenceScreen screen) {
- try {
+ static PreferenceScreen inflateFromIntent(PreferenceManager manager, Intent intent, PreferenceScreen screen) {
+ try {
Method m = PreferenceManager.class.getDeclaredMethod("inflateFromIntent", Intent.class, PreferenceScreen.class);
m.setAccessible(true);
PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(manager, intent, screen);
return prefScreen;
} catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.inflateFromIntent by reflection", e);
- }
- return null;
- }
+ Log.w(TAG, "Couldn't call PreferenceManager.inflateFromIntent by reflection", e);
+ }
+ return null;
+ }
- /**
+ /**
* Inflates a preference hierarchy from XML. If a preference hierarchy is
* given, the new preference hierarchies will be merged in.
*
* @param context The context of the resource.
* @param resId The resource ID of the XML to inflate.
* @param rootPreferences Optional existing hierarchy to merge the new
* hierarchies into.
* @return The root hierarchy (if one was not provided, the new hierarchy's
* root).
* @hide
*/
- static PreferenceScreen inflateFromResource(PreferenceManager manager, Activity activity, int resId, PreferenceScreen screen) {
- try {
+ static PreferenceScreen inflateFromResource(PreferenceManager manager, Activity activity, int resId, PreferenceScreen screen) {
+ try {
Method m = PreferenceManager.class.getDeclaredMethod("inflateFromResource", Context.class, int.class, PreferenceScreen.class);
m.setAccessible(true);
PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(manager, activity, resId, screen);
return prefScreen;
} catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.inflateFromResource by reflection", e);
- }
- return null;
- }
+ Log.w(TAG, "Couldn't call PreferenceManager.inflateFromResource by reflection", e);
+ }
+ return null;
+ }
- /**
+ /**
* Returns the root of the preference hierarchy managed by this class.
*
* @return The {@link PreferenceScreen} object that is at the root of the hierarchy.
*/
- static PreferenceScreen getPreferenceScreen(PreferenceManager manager) {
- try {
+ static PreferenceScreen getPreferenceScreen(PreferenceManager manager) {
+ try {
Method m = PreferenceManager.class.getDeclaredMethod("getPreferenceScreen");
m.setAccessible(true);
return (PreferenceScreen) m.invoke(manager);
} catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.getPreferenceScreen by reflection", e);
- }
- return null;
- }
+ Log.w(TAG, "Couldn't call PreferenceManager.getPreferenceScreen by reflection", e);
+ }
+ return null;
+ }
- /**
+ /**
* Called by the {@link PreferenceManager} to dispatch a subactivity result.
*/
- static void dispatchActivityResult(PreferenceManager manager, int requestCode, int resultCode, Intent data) {
- try {
+ static void dispatchActivityResult(PreferenceManager manager, int requestCode, int resultCode, Intent data) {
+ try {
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityResult", int.class, int.class, Intent.class);
m.setAccessible(true);
m.invoke(manager, requestCode, resultCode, data);
} catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityResult by reflection", e);
- }
- }
+ Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityResult by reflection", e);
+ }
+ }
- /**
+ /**
* Called by the {@link PreferenceManager} to dispatch the activity stop
* event.
*/
- static void dispatchActivityStop(PreferenceManager manager) {
- try {
+ static void dispatchActivityStop(PreferenceManager manager) {
+ try {
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityStop");
m.setAccessible(true);
m.invoke(manager);
} catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityStop by reflection", e);
- }
- }
+ Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityStop by reflection", e);
+ }
+ }
- /**
+ /**
* Called by the {@link PreferenceManager} to dispatch the activity destroy
* event.
*/
- static void dispatchActivityDestroy(PreferenceManager manager) {
- try {
- Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
- m.setAccessible(true);
- m.invoke(manager);
- } catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityDestroy by reflection", e);
- }
- }
+ static void dispatchActivityDestroy(PreferenceManager manager) {
+ try {
+ Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
+ m.setAccessible(true);
+ m.invoke(manager);
+ } catch (Exception e) {
+ Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityDestroy by reflection", e);
+ }
+ }
- /**
+ /**
* Sets the root of the preference hierarchy.
*
* @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
* @return Whether the {@link PreferenceScreen} given is different than the previous.
*/
- static boolean setPreferences(PreferenceManager manager, PreferenceScreen screen) {
- try {
- Method m = PreferenceManager.class.getDeclaredMethod("setPreferences", PreferenceScreen.class);
- m.setAccessible(true);
- return ((Boolean) m.invoke(manager, screen));
- } catch (Exception e) {
- Log.w(TAG, "Couldn't call PreferenceManager.setPreferences by reflection", e);
- }
- return false;
- }
+ static boolean setPreferences(PreferenceManager manager, PreferenceScreen screen) {
+ try {
+ Method m = PreferenceManager.class.getDeclaredMethod("setPreferences", PreferenceScreen.class);
+ m.setAccessible(true);
+ return ((Boolean) m.invoke(manager, screen));
+ } catch (Exception e) {
+ Log.w(TAG, "Couldn't call PreferenceManager.setPreferences by reflection", e);
+ }
+ return false;
+ }
}
--- a/mobile/android/base/db/AbstractTransactionalProvider.java
+++ b/mobile/android/base/db/AbstractTransactionalProvider.java
@@ -45,18 +45,18 @@ import android.util.Log;
* single ContentProvider to access each per-profile database.
* * {@link SharedBrowserDatabaseProvider} is an example of a per-profile provider
* that allows for multiple providers to safely work with the same databases.
*/
@SuppressWarnings("javadoc")
public abstract class AbstractTransactionalProvider extends ContentProvider {
private static final String LOGTAG = "GeckoTransProvider";
- private static boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
- private static boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
+ private static final boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
+ private static final boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
protected abstract SQLiteDatabase getReadableDatabase(Uri uri);
protected abstract SQLiteDatabase getWritableDatabase(Uri uri);
public abstract SQLiteDatabase getWritableDatabaseForTesting(Uri uri);
protected abstract Uri insertInTransaction(Uri uri, ContentValues values);
protected abstract int deleteInTransaction(Uri uri, String selection, String[] selectionArgs);
@@ -98,17 +98,18 @@ public abstract class AbstractTransactio
return Versions.feature11Plus;
}
private boolean isInBatch() {
final Boolean isInBatch = isInBatchOperation.get();
if (isInBatch == null) {
return false;
}
- return isInBatch.booleanValue();
+
+ return isInBatch;
}
/**
* If we're not currently in a transaction, and we should be, start one.
*/
protected void beginWrite(final SQLiteDatabase db) {
if (isInBatch()) {
trace("Not bothering with an intermediate write transaction: inside batch operation.");
--- a/mobile/android/base/db/BrowserDatabaseHelper.java
+++ b/mobile/android/base/db/BrowserDatabaseHelper.java
@@ -1560,18 +1560,18 @@ final class BrowserDatabaseHelper extend
}
private static final String qualifyColumn(String table, String column) {
return DBUtils.qualifyColumn(table, column);
}
// Calculate these once, at initialization. isLoggable is too expensive to
// have in-line in each log call.
- private static boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
- private static boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
+ private static final boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
+ private static final boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
protected static void trace(String message) {
if (logVerbose) {
Log.v(LOGTAG, message);
}
}
protected static void debug(String message) {
if (logDebug) {
--- a/mobile/android/base/db/BrowserProvider.java
+++ b/mobile/android/base/db/BrowserProvider.java
@@ -242,18 +242,18 @@ public class BrowserProvider extends Sha
return true;
}
return false;
}
// Calculate these once, at initialization. isLoggable is too expensive to
// have in-line in each log call.
- private static boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
- private static boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
+ private static final boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
+ private static final boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
protected static void trace(String message) {
if (logVerbose) {
Log.v(LOGTAG, message);
}
}
protected static void debug(String message) {
if (logDebug) {
@@ -1060,17 +1060,17 @@ public class BrowserProvider extends Sha
trace("Updating history entry with ID: " + id);
if (shouldIncrementVisits(uri)) {
long existing = cursor.getLong(2);
Long additional = values.getAsLong(History.VISITS);
// Increment visit count by a specified amount, or default to increment by 1
- values.put(History.VISITS, existing + ((additional != null) ? additional.longValue() : 1));
+ values.put(History.VISITS, existing + ((additional != null) ? additional : 1));
}
updated += db.update(TABLE_HISTORY, values, "_id = ?",
new String[] { Long.toString(id) });
}
} finally {
cursor.close();
}
--- a/mobile/android/base/db/FormHistoryProvider.java
+++ b/mobile/android/base/db/FormHistoryProvider.java
@@ -27,18 +27,18 @@ public class FormHistoryProvider extends
private static final int FORM_HISTORY = 100;
private static final int DELETED_FORM_HISTORY = 101;
private static final UriMatcher URI_MATCHER;
// This should be kept in sync with the db version in toolkit/components/satchel/nsFormHistory.js
- private static int DB_VERSION = 4;
- private static String DB_FILENAME = "formhistory.sqlite";
+ private static final int DB_VERSION = 4;
+ private static final String DB_FILENAME = "formhistory.sqlite";
private static final String TELEMETRY_TAG = "SQLITEBRIDGE_PROVIDER_FORMS";
private static final String WHERE_GUID_IS_NULL = BrowserContract.DeletedFormHistory.GUID + " IS NULL";
private static final String WHERE_GUID_IS_VALUE = BrowserContract.DeletedFormHistory.GUID + " = ?";
private static final String LOG_TAG = "FormHistoryProvider";
static {
--- a/mobile/android/base/db/HomeProvider.java
+++ b/mobile/android/base/db/HomeProvider.java
@@ -22,18 +22,18 @@ import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.util.Log;
public class HomeProvider extends SQLiteBridgeContentProvider {
private static final String LOGTAG = "GeckoHomeProvider";
// This should be kept in sync with the db version in mobile/android/modules/HomeProvider.jsm
- private static int DB_VERSION = 2;
- private static String DB_FILENAME = "home.sqlite";
+ private static final int DB_VERSION = 2;
+ private static final String DB_FILENAME = "home.sqlite";
private static final String TELEMETRY_TAG = "SQLITEBRIDGE_PROVIDER_HOME";
private static final String TABLE_ITEMS = "items";
// Endpoint to return static fake data.
static final int ITEMS_FAKE = 100;
static final int ITEMS = 101;
static final int ITEMS_ID = 102;
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -1073,17 +1073,17 @@ public class LocalBrowserDB {
new String[] { faviconUri });
if (updated == 0) {
return;
}
// After writing the encodedFavicon, ensure that the favicon_id in both the bookmark and
// history tables are also up-to-date.
- final Integer id = getIDForFaviconURL(cr, faviconUri);
+ final int id = getIDForFaviconURL(cr, faviconUri);
if (id == FAVICON_ID_NOT_FOUND) {
return;
}
updateHistoryAndBookmarksFaviconID(cr, pageUri, id);
}
/**
--- a/mobile/android/base/db/PasswordsProvider.java
+++ b/mobile/android/base/db/PasswordsProvider.java
@@ -34,18 +34,18 @@ public class PasswordsProvider extends S
private static final int PASSWORDS = 100;
private static final int DELETED_PASSWORDS = 101;
static final String DEFAULT_PASSWORDS_SORT_ORDER = Passwords.HOSTNAME + " ASC";
static final String DEFAULT_DELETED_PASSWORDS_SORT_ORDER = DeletedPasswords.TIME_DELETED + " ASC";
private static final UriMatcher URI_MATCHER;
- private static HashMap<String, String> PASSWORDS_PROJECTION_MAP;
- private static HashMap<String, String> DELETED_PASSWORDS_PROJECTION_MAP;
+ private static final HashMap<String, String> PASSWORDS_PROJECTION_MAP;
+ private static final HashMap<String, String> DELETED_PASSWORDS_PROJECTION_MAP;
// this should be kept in sync with the version in toolkit/components/passwordmgr/storage-mozStorage.js
private static final int DB_VERSION = 5;
private static final String DB_FILENAME = "signons.sqlite";
private static final String WHERE_GUID_IS_NULL = BrowserContract.DeletedPasswords.GUID + " IS NULL";
private static final String WHERE_GUID_IS_VALUE = BrowserContract.DeletedPasswords.GUID + " = ?";
private static final String LOG_TAG = "GeckPasswordsProvider";
@@ -171,17 +171,17 @@ public class PasswordsProvider extends S
case PASSWORDS:
values.put(Passwords.TIME_CREATED, now);
// Generate GUID for new password. Don't override specified GUIDs.
if (!values.containsKey(Passwords.GUID)) {
String guid = Utils.generateGuid();
values.put(Passwords.GUID, guid);
}
- String nowString = new Long(now).toString();
+ String nowString = Long.toString(now);
DBUtils.replaceKey(values, null, Passwords.HOSTNAME, "");
DBUtils.replaceKey(values, null, Passwords.HTTP_REALM, "");
DBUtils.replaceKey(values, null, Passwords.FORM_SUBMIT_URL, "");
DBUtils.replaceKey(values, null, Passwords.USERNAME_FIELD, "");
DBUtils.replaceKey(values, null, Passwords.PASSWORD_FIELD, "");
DBUtils.replaceKey(values, null, Passwords.ENCRYPTED_USERNAME, "");
DBUtils.replaceKey(values, null, Passwords.ENCRYPTED_PASSWORD, "");
DBUtils.replaceKey(values, null, Passwords.ENC_TYPE, "0");
--- a/mobile/android/base/favicons/decoders/ICODecoder.java
+++ b/mobile/android/base/favicons/decoders/ICODecoder.java
@@ -288,20 +288,20 @@ public class ICODecoder implements Itera
// Copy the ICONDIRENTRY we need into the new buffer.
System.arraycopy(decodand, offset + iconDirEntry.getOffset(), decodeTarget, ICO_HEADER_LENGTH_BYTES, ICO_ICONDIRENTRY_LENGTH_BYTES);
// Copy the payload into the new buffer.
final int singlePayloadOffset = ICO_HEADER_LENGTH_BYTES + ICO_ICONDIRENTRY_LENGTH_BYTES;
System.arraycopy(decodand, offset + iconDirEntry.payloadOffset, decodeTarget, singlePayloadOffset, iconDirEntry.payloadSize);
// Update the offset field of the ICONDIRENTRY to make the new ICO valid.
- decodeTarget[ICO_HEADER_LENGTH_BYTES + 12] = (byte) singlePayloadOffset;
- decodeTarget[ICO_HEADER_LENGTH_BYTES + 13] = (byte) (singlePayloadOffset >>> 8);
- decodeTarget[ICO_HEADER_LENGTH_BYTES + 14] = (byte) (singlePayloadOffset >>> 16);
- decodeTarget[ICO_HEADER_LENGTH_BYTES + 15] = (byte) (singlePayloadOffset >>> 24);
+ decodeTarget[ICO_HEADER_LENGTH_BYTES + 12] = singlePayloadOffset;
+ decodeTarget[ICO_HEADER_LENGTH_BYTES + 13] = (singlePayloadOffset >>> 8);
+ decodeTarget[ICO_HEADER_LENGTH_BYTES + 14] = (singlePayloadOffset >>> 16);
+ decodeTarget[ICO_HEADER_LENGTH_BYTES + 15] = (singlePayloadOffset >>> 24);
// Decode the newly-constructed singleton-ICO.
return BitmapUtils.decodeByteArray(decodeTarget);
}
/**
* Fetch an iterator over the images in this ICO, or null if this ICO seems to be invalid.
*
--- a/mobile/android/base/fxa/FxAccountConstants.java.in
+++ b/mobile/android/base/fxa/FxAccountConstants.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* 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.fxa;
import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.background.common.log.Logger;
--- a/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java
+++ b/mobile/android/base/fxa/activities/FxAccountAbstractSetupActivity.java
@@ -69,17 +69,17 @@ abstract public class FxAccountAbstractS
protected FxAccountAbstractSetupActivity(int resume) {
super(resume);
}
private static final String LOG_TAG = FxAccountAbstractSetupActivity.class.getSimpleName();
// By default, any custom server configuration is only shown when the account
// is configured to use a custom server.
- private static boolean ALWAYS_SHOW_CUSTOM_SERVER_LAYOUT = false;
+ private static final boolean ALWAYS_SHOW_CUSTOM_SERVER_LAYOUT = false;
protected int minimumPasswordLength = 8;
protected AutoCompleteTextView emailEdit;
protected EditText passwordEdit;
protected Button showPasswordButton;
protected TextView remoteErrorTextView;
protected Button button;
--- a/mobile/android/base/fxa/login/FxAccountLoginStateMachine.java
+++ b/mobile/android/base/fxa/login/FxAccountLoginStateMachine.java
@@ -1,16 +1,16 @@
/* 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.fxa.login;
import java.security.NoSuchAlgorithmException;
-import java.util.HashSet;
+import java.util.EnumSet;
import java.util.Set;
import org.mozilla.gecko.background.fxa.FxAccountClient;
import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.Transition;
import org.mozilla.gecko.fxa.login.State.StateLabel;
public class FxAccountLoginStateMachine {
@@ -24,17 +24,17 @@ public class FxAccountLoginStateMachine
public void handleFinal(State state);
public BrowserIDKeyPair generateKeyPair() throws NoSuchAlgorithmException;
}
public static class ExecuteDelegate {
protected final LoginStateMachineDelegate delegate;
protected final StateLabel desiredStateLabel;
// It's as difficult to detect arbitrary cycles as repeated states.
- protected final Set<StateLabel> stateLabelsSeen = new HashSet<StateLabel>();
+ protected final Set<StateLabel> stateLabelsSeen = EnumSet.noneOf(StateLabel.class);
protected ExecuteDelegate(StateLabel initialStateLabel, StateLabel desiredStateLabel, LoginStateMachineDelegate delegate) {
this.delegate = delegate;
this.desiredStateLabel = desiredStateLabel;
this.stateLabelsSeen.add(initialStateLabel);
}
public FxAccountClient getClient() {
--- a/mobile/android/base/fxa/sync/FxAccountGlobalSession.java
+++ b/mobile/android/base/fxa/sync/FxAccountGlobalSession.java
@@ -2,17 +2,19 @@
* 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.fxa.sync;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collections;
+import java.util.EnumMap;
import java.util.HashMap;
+import java.util.Map;
import org.json.simple.parser.ParseException;
import org.mozilla.gecko.sync.GlobalSession;
import org.mozilla.gecko.sync.NonObjectJSONException;
import org.mozilla.gecko.sync.SyncConfiguration;
import org.mozilla.gecko.sync.SyncConfigurationException;
import org.mozilla.gecko.sync.delegates.BaseGlobalSessionCallback;
import org.mozilla.gecko.sync.delegates.ClientsDataDelegate;
@@ -29,14 +31,14 @@ public class FxAccountGlobalSession exte
ClientsDataDelegate clientsDelegate)
throws SyncConfigurationException, IllegalArgumentException, IOException, ParseException, NonObjectJSONException, URISyntaxException {
super(config, callback, context, clientsDelegate, null);
}
@Override
public void prepareStages() {
super.prepareStages();
- HashMap<Stage, GlobalSyncStage> stages = new HashMap<Stage, GlobalSyncStage>();
+ Map<Stage, GlobalSyncStage> stages = new EnumMap<>(Stage.class);
stages.putAll(this.stages);
stages.put(Stage.ensureClusterURL, new CheckPreconditionsStage());
this.stages = Collections.unmodifiableMap(stages);
}
}
--- a/mobile/android/base/gfx/Axis.java
+++ b/mobile/android/base/gfx/Axis.java
@@ -48,17 +48,17 @@ abstract class Axis {
private static float SNAP_LIMIT;
// The minimum amount of space that must be present for an axis to be considered scrollable,
// in pixels.
private static float MIN_SCROLLABLE_DISTANCE;
private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
Integer value = (prefs == null ? null : prefs.get(prefName));
- return (float)(value == null || value < 0 ? defaultValue : value) / 1000f;
+ return (value == null || value < 0 ? defaultValue : value) / 1000f;
}
private static int getIntPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
Integer value = (prefs == null ? null : prefs.get(prefName));
return (value == null || value < 0 ? defaultValue : value);
}
static void initPrefs() {
@@ -125,17 +125,17 @@ abstract class Axis {
private final SubdocumentScrollHelper mSubscroller;
private int mOverscrollMode; /* Default to only overscrolling if we're allowed to scroll in a direction */
private float mFirstTouchPos; /* Position of the first touch event on the current drag. */
private float mTouchPos; /* Position of the most recent touch event on the current drag. */
private float mLastTouchPos; /* Position of the touch event before touchPos. */
private float mVelocity; /* Velocity in this direction; pixels per animation frame. */
- private float[] mRecentVelocities; /* Circular buffer of recent velocities since last touch start. */
+ private final float[] mRecentVelocities;/* Circular buffer of recent velocities since last touch start. */
private int mRecentVelocityCount; /* Number of values put into mRecentVelocities (unbounded). */
private boolean mScrollingDisabled; /* Whether movement on this axis is locked. */
private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */
private float mDisplacement;
private FlingStates mFlingState = FlingStates.STOPPED; /* The fling state we're in on this axis. */
protected abstract float getOrigin();
--- a/mobile/android/base/gfx/BufferedCairoImage.java
+++ b/mobile/android/base/gfx/BufferedCairoImage.java
@@ -13,17 +13,17 @@ import android.util.Log;
import java.nio.ByteBuffer;
/** A Cairo image that simply saves a buffer of pixel data. */
public class BufferedCairoImage extends CairoImage {
private ByteBuffer mBuffer;
private IntSize mSize;
private int mFormat;
- private static String LOGTAG = "GeckoBufferedCairoImage";
+ private static final String LOGTAG = "GeckoBufferedCairoImage";
/** Creates a buffered Cairo image from a byte buffer. */
public BufferedCairoImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
setBuffer(inBuffer, inWidth, inHeight, inFormat);
}
/** Creates a buffered Cairo image from an Android bitmap. */
public BufferedCairoImage(Bitmap bitmap) {
--- a/mobile/android/base/gfx/DisplayPortCalculator.java
+++ b/mobile/android/base/gfx/DisplayPortCalculator.java
@@ -70,17 +70,17 @@ final class DisplayPortCalculator {
PREF_DISPLAYPORT_VB_REVERSE_BUFFER,
PREF_DISPLAYPORT_VB_DANGER_X_BASE,
PREF_DISPLAYPORT_VB_DANGER_Y_BASE,
PREF_DISPLAYPORT_VB_DANGER_X_INCR,
PREF_DISPLAYPORT_VB_DANGER_Y_INCR,
PREF_DISPLAYPORT_PB_VELOCITY_THRESHOLD };
PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() {
- private Map<String, Integer> mValues = new HashMap<String, Integer>();
+ private final Map<String, Integer> mValues = new HashMap<String, Integer>();
@Override public void prefValue(String pref, int value) {
mValues.put(pref, value);
}
@Override public void finish() {
setStrategy(mValues);
}
@@ -119,17 +119,17 @@ final class DisplayPortCalculator {
return false;
}
Log.i(LOGTAG, "Set strategy " + sStrategy.toString());
return true;
}
private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) {
Integer value = (prefs == null ? null : prefs.get(prefName));
- return (float)(value == null || value < 0 ? defaultValue : value) / 1000f;
+ return (value == null || value < 0 ? defaultValue : value) / 1000f;
}
private static abstract class DisplayPortStrategy {
/** Calculates a displayport given a viewport and panning velocity. */
public abstract DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity);
/** Returns true if a checkerboard is about to be visible and we should not throttle drawing. */
public abstract boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort);
/** Notify the strategy of a new recorded draw time. Return false to turn off draw time recording. */
@@ -741,17 +741,17 @@ final class DisplayPortCalculator {
predictedViewport = clampToPageBounds(predictedViewport, metrics);
return !displayPort.contains(predictedViewport);
}
@Override
public boolean drawTimeUpdate(long millis, int pixels) {
// calculate the number of frames it took to draw a viewport-sized area
- float normalizedTime = (float)mPixelArea * (float)millis / (float)pixels;
+ float normalizedTime = (float)mPixelArea * millis / pixels;
int normalizedFrames = (int)FloatMath.ceil(normalizedTime * 60f / 1000f);
// broaden our range on how long it takes to draw if the draw falls outside
// the range. this allows it to grow gradually. this heuristic may need to
// be tweaked into more of a floating window average or something.
if (normalizedFrames <= mMinFramesToDraw) {
mMinFramesToDraw--;
} else if (normalizedFrames > mMaxFramesToDraw) {
mMaxFramesToDraw++;
--- a/mobile/android/base/gfx/GLController.java
+++ b/mobile/android/base/gfx/GLController.java
@@ -83,17 +83,17 @@ public class GLController {
/* This is written by the compositor thread (while the UI thread
* is blocked on it) and read by the UI thread. */
private volatile boolean mCompositorCreated;
private EGL10 mEGL;
private EGLDisplay mEGLDisplay;
private EGLConfig mEGLConfig;
- private EGLPreloadingThread mEGLPreloadingThread;
+ private final EGLPreloadingThread mEGLPreloadingThread;
private EGLSurface mEGLSurfaceForCompositor;
private static final int LOCAL_EGL_OPENGL_ES2_BIT = 4;
private static final int[] CONFIG_SPEC_16BPP = {
EGL10.EGL_RED_SIZE, 5,
EGL10.EGL_GREEN_SIZE, 6,
EGL10.EGL_BLUE_SIZE, 5,
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -28,17 +28,17 @@ import java.util.List;
class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
{
private static final String LOGTAG = "GeckoLayerClient";
private LayerRenderer mLayerRenderer;
private boolean mLayerRendererInitialized;
- private Context mContext;
+ private final Context mContext;
private IntSize mScreenSize;
private IntSize mWindowSize;
private DisplayPortMetrics mDisplayPort;
private boolean mRecordDrawTimes;
private final DrawTimingQueue mDrawTimingQueue;
private VirtualLayer mRootLayer;
@@ -54,17 +54,17 @@ class GeckoLayerClient implements LayerV
private ImmutableViewportMetrics mGeckoViewport;
/*
* The viewport metrics being used to draw the current frame. This is only
* accessed by the compositor thread, and so needs no synchronisation.
*/
private ImmutableViewportMetrics mFrameMetrics;
- private List<DrawListener> mDrawListeners;
+ private final List<DrawListener> mDrawListeners;
/* Used as temporaries by syncViewportInfo */
private final ViewTransform mCurrentViewTransform;
private final RectF mCurrentViewTransformMargins;
/* Used as the return value of progressiveUpdateCallback */
private final ProgressiveUpdateData mProgressiveUpdateData;
private DisplayPortMetrics mProgressiveUpdateDisplayPort;
@@ -89,17 +89,17 @@ class GeckoLayerClient implements LayerV
private LayerView.OnMetricsChangedListener mViewportChangeListener;
private ZoomConstraints mZoomConstraints;
private boolean mGeckoIsReady;
private final PanZoomController mPanZoomController;
private final LayerMarginsAnimator mMarginsAnimator;
- private LayerView mView;
+ private final LayerView mView;
/* This flag is true from the time that browser.js detects a first-paint is about to start,
* to the time that we receive the first-paint composite notification from the compositor.
* Note that there is a small race condition with this; if there are two paints that both
* have the first-paint flag set, and the second paint happens concurrently with the
* composite for the first paint, then this flag may be set to true prematurely. Fixing this
* is possible but risky; see https://bugzilla.mozilla.org/show_bug.cgi?id=797615#c751
*/
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -36,19 +36,19 @@ import android.view.View;
* https://github.com/joehewitt/scrollability/
*/
class JavaPanZoomController
extends GestureDetector.SimpleOnGestureListener
implements PanZoomController, SimpleScaleGestureDetector.SimpleScaleGestureListener, GeckoEventListener
{
private static final String LOGTAG = "GeckoPanZoomController";
- private static String MESSAGE_ZOOM_RECT = "Browser:ZoomToRect";
- private static String MESSAGE_ZOOM_PAGE = "Browser:ZoomToPageWidth";
- private static String MESSAGE_TOUCH_LISTENER = "Tab:HasTouchListener";
+ private static final String MESSAGE_ZOOM_RECT = "Browser:ZoomToRect";
+ private static final String MESSAGE_ZOOM_PAGE = "Browser:ZoomToPageWidth";
+ private static final String MESSAGE_TOUCH_LISTENER = "Tab:HasTouchListener";
// Animation stops if the velocity is below this value when overscrolled or panning.
private static final float STOPPED_THRESHOLD = 4.0f;
// Animation stops is the velocity is below this threshold when flinging.
private static final float FLING_STOPPED_THRESHOLD = 0.1f;
// The distance the user has to pan before we recognize it as such (e.g. to avoid 1-pixel pans
@@ -165,17 +165,17 @@ class JavaPanZoomController
} else {
mMode = AxisLockMode.STICKY;
}
}
}
@Override public void prefValue(String pref, int value) {
if (pref.equals("ui.scrolling.gamepad_dead_zone")) {
- GamepadUtils.overrideDeadZoneThreshold((float)value / 1000f);
+ GamepadUtils.overrideDeadZoneThreshold(value / 1000f);
}
}
@Override public void prefValue(String pref, boolean value) {
if (pref.equals("ui.scrolling.negate_wheel_scrollY")) {
mNegateWheelScrollY = value;
}
}
@@ -655,17 +655,17 @@ class JavaPanZoomController
private float panDistance(MotionEvent move) {
float dx = mX.panDistance(move.getX(0));
float dy = mY.panDistance(move.getY(0));
return FloatMath.sqrt(dx * dx + dy * dy);
}
private void track(float x, float y, long time) {
- float timeDelta = (float)(time - mLastEventTime);
+ float timeDelta = (time - mLastEventTime);
if (FloatUtils.fuzzyEquals(timeDelta, 0)) {
// probably a duplicate event, ignore it. using a zero timeDelta will mess
// up our velocity
return;
}
mLastEventTime = time;
@@ -897,18 +897,18 @@ class JavaPanZoomController
/* The task that performs the bounce animation. */
private class BounceRenderTask extends PanZoomRenderTask {
/*
* The viewport metrics that represent the start and end of the bounce-back animation,
* respectively.
*/
- private ImmutableViewportMetrics mBounceStartMetrics;
- private ImmutableViewportMetrics mBounceEndMetrics;
+ private final ImmutableViewportMetrics mBounceStartMetrics;
+ private final ImmutableViewportMetrics mBounceEndMetrics;
// How long ago this bounce was started in ns.
private long mBounceDuration;
BounceRenderTask(ImmutableViewportMetrics startMetrics, ImmutableViewportMetrics endMetrics) {
super();
mBounceStartMetrics = startMetrics;
mBounceEndMetrics = endMetrics;
}
--- a/mobile/android/base/gfx/LayerMarginsAnimator.java
+++ b/mobile/android/base/gfx/LayerMarginsAnimator.java
@@ -56,17 +56,17 @@ public class LayerMarginsAnimator {
mMaxMargins = new RectF();
mInterpolator = new DecelerateInterpolator();
mTouchTravelDistance = new PointF();
// Listen to the dynamic toolbar pref
mPrefObserverId = PrefsHelper.getPref(PREF_SHOW_MARGINS_THRESHOLD, new PrefsHelper.PrefHandlerBase() {
@Override
public void prefValue(String pref, int value) {
- SHOW_MARGINS_THRESHOLD = (float)value / 100.0f;
+ SHOW_MARGINS_THRESHOLD = value / 100.0f;
}
@Override
public boolean isObserver() {
return true;
}
});
}
@@ -248,18 +248,18 @@ public class LayerMarginsAnimator {
if (action == MotionEvent.ACTION_DOWN && event.getPointerCount() == 1) {
mTouchTravelDistance.set(0.0f, 0.0f);
}
return false;
}
class LayerMarginsAnimationTask extends RenderTask {
- private float mStartLeft, mStartTop, mStartRight, mStartBottom;
- private float mTop, mBottom, mLeft, mRight;
+ private final float mStartLeft, mStartTop, mStartRight, mStartBottom;
+ private final float mTop, mBottom, mLeft, mRight;
private boolean mContinueAnimation;
public LayerMarginsAnimationTask(boolean runAfter, ImmutableViewportMetrics metrics,
float left, float top, float right, float bottom) {
super(runAfter);
mContinueAnimation = true;
this.mStartLeft = metrics.marginLeft;
this.mStartTop = metrics.marginTop;
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -64,20 +64,20 @@ public class LayerRenderer implements Ta
private RenderContext mLastPageContext;
private int mMaxTextureSize;
private int mBackgroundColor;
private int mOverscrollColor;
private long mLastFrameTime;
private final CopyOnWriteArrayList<RenderTask> mTasks;
- private CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
+ private final CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
// Dropped frames display
- private int[] mFrameTimings;
+ private final int[] mFrameTimings;
private int mCurrentFrame, mFrameTimingsSum, mDroppedFrames;
// Render profiling output
private int mFramesRendered;
private float mCompleteFramesRendered;
private boolean mProfileRender;
private long mProfileOutputTime;
@@ -412,19 +412,19 @@ public class LayerRenderer implements Ta
}
}
}
public class Frame {
// The timestamp recording the start of this frame.
private long mFrameStartTime;
// A fixed snapshot of the viewport metrics that this frame is using to render content.
- private ImmutableViewportMetrics mFrameMetrics;
+ private final ImmutableViewportMetrics mFrameMetrics;
// A rendering context for page-positioned layers, and one for screen-positioned layers.
- private RenderContext mPageContext, mScreenContext;
+ private final RenderContext mPageContext, mScreenContext;
// Whether a layer was updated.
private boolean mUpdated;
private final Rect mPageRect;
private final Rect mAbsolutePageRect;
private final PointF mRenderOffset;
public Frame(ImmutableViewportMetrics metrics) {
mFrameMetrics = metrics;
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -45,22 +45,22 @@ import android.view.inputmethod.InputCon
import android.widget.FrameLayout;
/**
* A view rendered by the layer compositor.
*
* Note that LayerView is accessed by Robocop via reflection.
*/
public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener {
- private static String LOGTAG = "GeckoLayerView";
+ private static final String LOGTAG = "GeckoLayerView";
private GeckoLayerClient mLayerClient;
private PanZoomController mPanZoomController;
private LayerMarginsAnimator mMarginsAnimator;
- private GLController mGLController;
+ private final GLController mGLController;
private InputConnectionHandler mInputConnectionHandler;
private LayerRenderer mRenderer;
/* Must be a PAINT_xxx constant */
private int mPaintState;
private int mBackgroundColor;
private FullScreenState mFullScreenState;
private SurfaceView mSurfaceView;
--- a/mobile/android/base/gfx/PluginLayer.java
+++ b/mobile/android/base/gfx/PluginLayer.java
@@ -13,20 +13,20 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.view.SurfaceView;
import android.view.View;
import android.widget.AbsoluteLayout;
public class PluginLayer extends TileLayer {
private static final String LOGTAG = "PluginLayer";
- private View mView;
+ private final View mView;
private SurfaceView mSurfaceView;
- private PluginLayoutParams mLayoutParams;
- private AbsoluteLayout mContainer;
+ private final PluginLayoutParams mLayoutParams;
+ private final AbsoluteLayout mContainer;
private boolean mDestroyed;
private boolean mViewVisible;
private RectF mLastViewport;
private float mLastZoomFactor;
private static final float TEXTURE_MAP[] = {
@@ -118,33 +118,33 @@ public class PluginLayer extends TileLay
public void draw(RenderContext context) {
}
class PluginLayoutParams extends AbsoluteLayout.LayoutParams
{
private static final String LOGTAG = "GeckoApp.PluginLayoutParams";
private RectF mRect;
- private int mMaxDimension;
+ private final int mMaxDimension;
private float mLastResolution;
public PluginLayoutParams(RectF rect, int maxDimension) {
super(0, 0, 0, 0);
mMaxDimension = maxDimension;
reset(rect);
}
private void clampToMaxSize() {
if (width > mMaxDimension || height > mMaxDimension) {
if (width > height) {
- height = Math.round(((float)height/(float)width) * mMaxDimension);
+ height = Math.round(((float)height/ width) * mMaxDimension);
width = mMaxDimension;
} else {
- width = Math.round(((float)width/(float)height) * mMaxDimension);
+ width = Math.round(((float)width/ height) * mMaxDimension);
height = mMaxDimension;
}
}
}
public void reset(RectF rect) {
mRect = rect;
}
--- a/mobile/android/base/gfx/ScrollbarLayer.java
+++ b/mobile/android/base/gfx/ScrollbarLayer.java
@@ -23,17 +23,17 @@ public class ScrollbarLayer extends Tile
// To avoid excessive GC, declare some objects here that would otherwise
// be created and destroyed frequently during draw().
private final RectF mBarRectF;
private final Rect mBarRect;
private final float[] mCoords;
private final RectF mCapRectF;
- private LayerRenderer mRenderer;
+ private final LayerRenderer mRenderer;
private int mProgram;
private int mPositionHandle;
private int mTextureHandle;
private int mSampleHandle;
private int mTMatrixHandle;
private int mOpacityHandle;
// Fragment shader used to draw the scroll-bar with opacity
--- a/mobile/android/base/gfx/SimpleScaleGestureDetector.java
+++ b/mobile/android/base/gfx/SimpleScaleGestureDetector.java
@@ -31,22 +31,22 @@ import java.util.Stack;
* - Starting with three or more fingers down, releasing fingers so that only two are down, and
* then performing a scale gesture is handled correctly.
*
* - It doesn't take pressure into account, which results in smoother scaling.
*/
class SimpleScaleGestureDetector {
private static final String LOGTAG = "GeckoSimpleScaleGestureDetector";
- private SimpleScaleGestureListener mListener;
+ private final SimpleScaleGestureListener mListener;
private long mLastEventTime;
private boolean mScaleResult;
/* Information about all pointers that are down. */
- private LinkedList<PointerInfo> mPointerInfo;
+ private final LinkedList<PointerInfo> mPointerInfo;
/** Creates a new gesture detector with the given listener. */
SimpleScaleGestureDetector(SimpleScaleGestureListener listener) {
mListener = listener;
mPointerInfo = new LinkedList<PointerInfo>();
}
/** Forward touch events to this function. */
--- a/mobile/android/base/gfx/SubdocumentScrollHelper.java
+++ b/mobile/android/base/gfx/SubdocumentScrollHelper.java
@@ -15,20 +15,20 @@ import org.json.JSONObject;
import android.graphics.PointF;
import android.os.Handler;
import android.util.Log;
class SubdocumentScrollHelper implements GeckoEventListener {
private static final String LOGTAG = "GeckoSubdocScroll";
- private static String MESSAGE_PANNING_OVERRIDE = "Panning:Override";
- private static String MESSAGE_CANCEL_OVERRIDE = "Panning:CancelOverride";
- private static String MESSAGE_SCROLL = "Gesture:Scroll";
- private static String MESSAGE_SCROLL_ACK = "Gesture:ScrollAck";
+ private static final String MESSAGE_PANNING_OVERRIDE = "Panning:Override";
+ private static final String MESSAGE_CANCEL_OVERRIDE = "Panning:CancelOverride";
+ private static final String MESSAGE_SCROLL = "Gesture:Scroll";
+ private static final String MESSAGE_SCROLL_ACK = "Gesture:ScrollAck";
private final Handler mUiHandler;
private final EventDispatcher mEventDispatcher;
/* This is the amount of displacement we have accepted but not yet sent to JS; this is
* only valid when mOverrideScrollPending is true. */
private final PointF mPendingDisplacement;
--- a/mobile/android/base/gfx/TextureGenerator.java
+++ b/mobile/android/base/gfx/TextureGenerator.java
@@ -14,17 +14,17 @@ import javax.microedition.khronos.egl.EG
import javax.microedition.khronos.egl.EGLContext;
public class TextureGenerator {
private static final String LOGTAG = "TextureGenerator";
private static final int POOL_SIZE = 5;
private static TextureGenerator sSharedInstance;
- private ArrayBlockingQueue<Integer> mTextureIds;
+ private final ArrayBlockingQueue<Integer> mTextureIds;
private EGLContext mContext;
private TextureGenerator() { mTextureIds = new ArrayBlockingQueue<Integer>(POOL_SIZE); }
public static TextureGenerator get() {
if (sSharedInstance == null)
sSharedInstance = new TextureGenerator();
return sSharedInstance;
--- a/mobile/android/base/gfx/TextureReaper.java
+++ b/mobile/android/base/gfx/TextureReaper.java
@@ -7,17 +7,17 @@ package org.mozilla.gecko.gfx;
import android.opengl.GLES20;
import java.util.ArrayList;
/** Manages a list of dead tiles, so we don't leak resources. */
public class TextureReaper {
private static TextureReaper sSharedInstance;
- private ArrayList<Integer> mDeadTextureIDs;
+ private final ArrayList<Integer> mDeadTextureIDs;
private TextureReaper() { mDeadTextureIDs = new ArrayList<Integer>(); }
public static TextureReaper get() {
if (sSharedInstance == null)
sSharedInstance = new TextureReaper();
return sSharedInstance;
}
--- a/mobile/android/base/health/BrowserHealthRecorder.java
+++ b/mobile/android/base/health/BrowserHealthRecorder.java
@@ -910,17 +910,17 @@ public class BrowserHealthRecorder imple
throw new IllegalArgumentException("Unknown search location: " + location);
}
this.location = location;
this.engineID = engineID;
}
}
- private static ConcurrentLinkedQueue<Search> delayedSearches = new ConcurrentLinkedQueue<>();
+ private static final ConcurrentLinkedQueue<Search> delayedSearches = new ConcurrentLinkedQueue<>();
public static void recordSearchDelayed(String location, String engineID) {
final Search search = new Search(location, engineID);
delayedSearches.add(search);
}
@Override
public void processDelayed() {
--- a/mobile/android/base/home/BookmarksListAdapter.java
+++ b/mobile/android/base/home/BookmarksListAdapter.java
@@ -99,17 +99,17 @@ class BookmarksListAdapter extends Multi
// This is usually implemented by the enclosing fragment/activity.
public static interface OnRefreshFolderListener {
// The folder id to refresh the list with.
public void onRefreshFolder(FolderInfo folderInfo, RefreshType refreshType);
}
// mParentStack holds folder info instances (id + title) that allow
// us to navigate back up the folder hierarchy.
- private LinkedList<FolderInfo> mParentStack;
+ private final LinkedList<FolderInfo> mParentStack;
// Refresh folder listener.
private OnRefreshFolderListener mListener;
public BookmarksListAdapter(Context context, Cursor cursor, List<FolderInfo> parentStack) {
// Initializing with a null cursor.
super(context, cursor, VIEW_TYPES, LAYOUT_TYPES);
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -436,17 +436,17 @@ public class BrowserSearch extends HomeF
final int urlIndex = c.getColumnIndexOrThrow(History.URL);
int searchCount = 0;
do {
final String url = c.getString(urlIndex);
if (searchCount == 0) {
// Prefetch the first item in the list since it's weighted the highest
- GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Session:Prefetch", url.toString()));
+ GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Session:Prefetch", url));
}
// Does the completion match against the whole URL? This will match
// about: pages, as well as user input including "http://...".
if (url.startsWith(searchTerm)) {
return uriSubstringUpToMatchedPath(url, 0,
(searchLength > HTTPS_PREFIX_LENGTH) ? searchLength : HTTPS_PREFIX_LENGTH);
}
--- a/mobile/android/base/home/HomeListView.java
+++ b/mobile/android/base/home/HomeListView.java
@@ -28,17 +28,17 @@ public class HomeListView extends ListVi
// ContextMenuInfo associated with the currently long pressed list item.
private HomeContextMenuInfo mContextMenuInfo;
// On URL open listener
protected OnUrlOpenListener mUrlOpenListener;
// Top divider
- private boolean mShowTopDivider;
+ private final boolean mShowTopDivider;
// ContextMenuInfo maker
private HomeContextMenuInfo.Factory mContextMenuInfoFactory;
public HomeListView(Context context) {
this(context, null);
}
--- a/mobile/android/base/home/HomePager.java
+++ b/mobile/android/base/home/HomePager.java
@@ -40,17 +40,17 @@ public class HomePager extends ViewPager
private Decor mDecor;
private View mTabStrip;
private HomeBanner mHomeBanner;
private int mDefaultPageIndex = -1;
private final OnAddPanelListener mAddPanelListener;
private final HomeConfig mConfig;
- private ConfigLoaderCallbacks mConfigLoaderCallbacks;
+ private final ConfigLoaderCallbacks mConfigLoaderCallbacks;
private String mInitialPanelId;
// Cached original ViewPager background.
private final Drawable mOriginalBackground;
// Telemetry session for current panel.
private TelemetryContract.Session mCurrentPanelSession;
--- a/mobile/android/base/home/PanelGridView.java
+++ b/mobile/android/base/home/PanelGridView.java
@@ -25,17 +25,17 @@ import android.widget.AdapterView;
import android.widget.GridView;
public class PanelGridView extends GridView
implements DatasetBacked, PanelView {
private static final String LOGTAG = "GeckoPanelGridView";
private final ViewConfig viewConfig;
private final PanelViewAdapter adapter;
- private PanelViewItemHandler itemHandler;
+ private final PanelViewItemHandler itemHandler;
private OnItemOpenListener itemOpenListener;
private HomeContextMenuInfo mContextMenuInfo;
private HomeContextMenuInfo.Factory mContextMenuInfoFactory;
public PanelGridView(Context context, ViewConfig viewConfig) {
super(context, null, R.attr.panelGridViewStyle);
this.viewConfig = viewConfig;
--- a/mobile/android/base/home/PanelInfoManager.java
+++ b/mobile/android/base/home/PanelInfoManager.java
@@ -54,17 +54,17 @@ public class PanelInfoManager implements
}
}
}
public interface RequestCallback {
public void onComplete(List<PanelInfo> panelInfos);
}
- private static AtomicInteger sRequestId = new AtomicInteger(0);
+ private static final AtomicInteger sRequestId = new AtomicInteger(0);
// Stores set of pending request callbacks.
private static final SparseArray<RequestCallback> sCallbacks = new SparseArray<RequestCallback>();
/**
* Asynchronously fetches list of available panels from Gecko
* for the given IDs.
*
--- a/mobile/android/base/home/PanelLayout.java
+++ b/mobile/android/base/home/PanelLayout.java
@@ -674,17 +674,17 @@ abstract class PanelLayout extends Frame
}
}
public interface OnItemOpenListener {
public void onItemOpen(String url, String title);
}
private class PanelOnItemOpenListener implements OnItemOpenListener {
- private ViewState mViewState;
+ private final ViewState mViewState;
public PanelOnItemOpenListener(ViewState viewState) {
mViewState = viewState;
}
@Override
public void onItemOpen(String url, String title) {
if (StringUtils.isFilterUrl(url)) {
@@ -697,17 +697,17 @@ abstract class PanelLayout extends Frame
}
mUrlOpenListener.onUrlOpen(url, flags);
}
}
}
private class PanelKeyListener implements View.OnKeyListener {
- private ViewState mViewState;
+ private final ViewState mViewState;
public PanelKeyListener(ViewState viewState) {
mViewState = viewState;
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
--- a/mobile/android/base/home/PinSiteDialog.java
+++ b/mobile/android/base/home/PinSiteDialog.java
@@ -201,17 +201,17 @@ class PinSiteDialog extends DialogFragme
EnumSet.of(FilterFlags.EXCLUDE_PINNED_SITES));
}
public void setOnSiteSelectedListener(OnSiteSelectedListener listener) {
mOnSiteSelectedListener = listener;
}
private static class SearchAdapter extends CursorAdapter {
- private LayoutInflater mInflater;
+ private final LayoutInflater mInflater;
public SearchAdapter(Context context) {
super(context, null, 0);
mInflater = LayoutInflater.from(context);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
--- a/mobile/android/base/home/RemoteTabsPanel.java
+++ b/mobile/android/base/home/RemoteTabsPanel.java
@@ -1,16 +1,18 @@
/* -*- 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.home;
+import java.util.EnumMap;
import java.util.HashMap;
+import java.util.Map;
import org.mozilla.gecko.R;
import org.mozilla.gecko.fxa.AccountLoader;
import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.login.State;
import org.mozilla.gecko.fxa.login.State.Action;
import org.mozilla.gecko.sync.SyncConstants;
@@ -47,17 +49,17 @@ public class RemoteTabsPanel extends Hom
// don't want to detach and re-attach panels unnecessarily, because that
// causes flickering.
private Fragment mCurrentFragment;
// A lazily-populated cache of fragments corresponding to the possible
// system account states. We don't want to re-create panels unnecessarily,
// because that can cause flickering. Be aware that null is a valid key; it
// corresponds to "no Account, neither Firefox nor Legacy Sync."
- private final HashMap<Action, Fragment> mFragmentCache = new HashMap<Action, Fragment>();
+ private final Map<Action, Fragment> mFragmentCache = new EnumMap<>(Action.class);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.home_remote_tabs_panel, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -100,18 +100,18 @@ public class TopSitesPanel extends HomeF
// Time in ms until the Gecko thread is reset to normal priority.
private static final long PRIORITY_RESET_TIMEOUT = 10000;
public static TopSitesPanel newInstance() {
return new TopSitesPanel();
}
- private static boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
- private static boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
+ private static final boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
+ private static final boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
private static void debug(final String message) {
if (logDebug) {
Log.d(LOGTAG, message);
}
}
private static void trace(final String message) {
@@ -401,17 +401,17 @@ public class TopSitesPanel extends HomeF
// Gecko to normal priority.
ThreadUtils.resetGeckoPriority();
}
private static class TopSitesLoader extends SimpleCursorLoader {
// Max number of search results.
private static final int SEARCH_LIMIT = 30;
private static final String TELEMETRY_HISTOGRAM_LOAD_CURSOR = "FENNEC_TOPSITES_LOADER_TIME_MS";
- private int mMaxGridEntries;
+ private final int mMaxGridEntries;
public TopSitesLoader(Context context) {
super(context);
mMaxGridEntries = context.getResources().getInteger(R.integer.number_of_top_sites);
}
@Override
public Cursor loadCursor() {
@@ -696,17 +696,17 @@ public class TopSitesPanel extends HomeF
}
/**
* An AsyncTaskLoader to load the thumbnails from a cursor.
*/
@SuppressWarnings("serial")
static class ThumbnailsLoader extends AsyncTaskLoader<Map<String, ThumbnailInfo>> {
private Map<String, ThumbnailInfo> mThumbnailInfos;
- private ArrayList<String> mUrls;
+ private final ArrayList<String> mUrls;
private static final ArrayList<String> COLUMNS = new ArrayList<String>() {{
add(TILE_IMAGE_URL_COLUMN);
add(TILE_COLOR_COLUMN);
}};
public ThumbnailsLoader(Context context, ArrayList<String> urls) {
super(context);
--- a/mobile/android/base/home/TopSitesThumbnailView.java
+++ b/mobile/android/base/home/TopSitesThumbnailView.java
@@ -27,17 +27,17 @@ public class TopSitesThumbnailView exten
// Default filter color for "Add a bookmark" views.
private static final int DEFAULT_COLOR = 0xFFECF0F3;
// Stroke width for the border.
private final float mStrokeWidth = getResources().getDisplayMetrics().density * 2;
// Paint for drawing the border.
- private static Paint sBorderPaint;
+ private static final Paint sBorderPaint;
// Initializing the static border paint.
static {
sBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
sBorderPaint.setColor(0xFFCFD9E1);
sBorderPaint.setStyle(Paint.Style.STROKE);
}
--- a/mobile/android/base/menu/GeckoMenu.java
+++ b/mobile/android/base/menu/GeckoMenu.java
@@ -83,38 +83,38 @@ public class GeckoMenu extends ListView
// Remove an action-item.
public void removeActionItem(View actionItem);
}
protected static final int NO_ID = 0;
// List of all menu items.
- private List<GeckoMenuItem> mItems;
+ private final List<GeckoMenuItem> mItems;
// Map of "always" action-items in action-bar and their views.
- private Map<GeckoMenuItem, View> mPrimaryActionItems;
+ private final Map<GeckoMenuItem, View> mPrimaryActionItems;
// Map of "ifRoom" action-items in action-bar and their views.
- private Map<GeckoMenuItem, View> mSecondaryActionItems;
+ private final Map<GeckoMenuItem, View> mSecondaryActionItems;
// Reference to a callback for menu events.
private Callback mCallback;
// Reference to menu presenter.
private MenuPresenter mMenuPresenter;
// Reference to "always" action-items bar in action-bar.
private ActionItemBarPresenter mPrimaryActionItemBar;
// Reference to "ifRoom" action-items bar in action-bar.
private final ActionItemBarPresenter mSecondaryActionItemBar;
// Adapter to hold the list of menu items.
- private MenuItemsAdapter mAdapter;
+ private final MenuItemsAdapter mAdapter;
// Show/hide icons in the list.
boolean mShowIcons;
public GeckoMenu(Context context) {
this(context, null);
}
@@ -681,17 +681,17 @@ public class GeckoMenu extends ListView
}
}
// Adapter to bind menu items to the list.
private class MenuItemsAdapter extends BaseAdapter {
private static final int VIEW_TYPE_DEFAULT = 0;
private static final int VIEW_TYPE_ACTION_MODE = 1;
- private List<GeckoMenuItem> mItems;
+ private final List<GeckoMenuItem> mItems;
public MenuItemsAdapter() {
mItems = new ArrayList<GeckoMenuItem>();
}
@Override
public int getCount() {
if (mItems == null)
--- a/mobile/android/base/menu/MenuItemDefault.java
+++ b/mobile/android/base/menu/MenuItemDefault.java
@@ -15,17 +15,17 @@ import android.widget.TextView;
public class MenuItemDefault extends TextView
implements GeckoMenuItem.Layout {
private static final int[] STATE_MORE = new int[] { R.attr.state_more };
private static final int[] STATE_CHECKED = new int[] { android.R.attr.state_checkable, android.R.attr.state_checked };
private static final int[] STATE_UNCHECKED = new int[] { android.R.attr.state_checkable };
private Drawable mIcon;
- private Drawable mState;
+ private final Drawable mState;
private static Rect sIconBounds;
private boolean mCheckable;
private boolean mChecked;
private boolean mHasSubMenu;
private boolean mShowIcon;
public MenuItemDefault(Context context) {
--- a/mobile/android/base/mozglue/ByteBufferInputStream.java
+++ b/mobile/android/base/mozglue/ByteBufferInputStream.java
@@ -7,17 +7,17 @@ package org.mozilla.gecko.mozglue;
import java.io.InputStream;
import java.nio.ByteBuffer;
class ByteBufferInputStream extends InputStream {
protected ByteBuffer mBuf;
// Reference to a native object holding the data backing the ByteBuffer.
- private NativeReference mNativeRef;
+ private final NativeReference mNativeRef;
protected ByteBufferInputStream(ByteBuffer buffer, NativeReference ref) {
mBuf = buffer;
mNativeRef = ref;
}
@Override
public int available() {
--- a/mobile/android/base/mozglue/GeckoLoader.java.in
+++ b/mobile/android/base/mozglue/GeckoLoader.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* -*- 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.mozglue;
import java.io.File;
@@ -221,26 +221,26 @@ public final class GeckoLoader {
String forced_ondemand = System.getenv("MOZ_LINKER_ONDEMAND");
if (forced_ondemand == null) {
if ("HTC".equals(android.os.Build.MANUFACTURER) &&
"HTC Vision".equals(android.os.Build.MODEL)) {
putenv("MOZ_LINKER_ONDEMAND=0");
}
}
-#ifdef MOZ_LINKER_EXTRACT
+//#ifdef MOZ_LINKER_EXTRACT
putenv("MOZ_LINKER_EXTRACT=1");
// Ensure that the cache dir is world-writable
File cacheDir = new File(linkerCache);
if (cacheDir.isDirectory()) {
cacheDir.setWritable(true, false);
cacheDir.setExecutable(true, false);
cacheDir.setReadable(true, false);
}
-#endif
+//#endif
}
@RobocopTarget
public static void loadSQLiteLibs(final Context context, final String apkName) {
synchronized (sLibLoadingLock) {
if (sSQLiteLibsLoaded) {
return;
}
--- a/mobile/android/base/overlays/ui/SendTabList.java
+++ b/mobile/android/base/overlays/ui/SendTabList.java
@@ -50,17 +50,17 @@ public class SendTabList extends ListVie
// from a secondary menu.
public static final int MAXIMUM_INLINE_ELEMENTS = 2;
private SendTabDeviceListArrayAdapter clientListAdapter;
// Listener to fire when a share target is selected (either directly or via the prompt)
private SendTabTargetSelectedListener listener;
- private State currentState = LOADING;
+ private final State currentState = LOADING;
/**
* Enum defining the states this view may occupy.
*/
public enum State {
// State when no sync targets exist (a generic "Send to Firefox Sync" button which launches
// an activity to set it up)
NONE,
--- a/mobile/android/base/preferences/AndroidImport.java
+++ b/mobile/android/base/preferences/AndroidImport.java
@@ -17,24 +17,24 @@ import android.content.OperationApplicat
import android.database.Cursor;
import android.os.RemoteException;
import android.provider.Browser;
import android.util.Log;
import java.util.ArrayList;
class AndroidImport implements Runnable {
- static final private String LOGTAG = "AndroidImport";
- private Context mContext;
- private Runnable mOnDoneRunnable;
- private ArrayList<ContentProviderOperation> mOperations;
- private ContentResolver mCr;
- private LocalBrowserDB mDB;
- private boolean mImportBookmarks;
- private boolean mImportHistory;
+ private static final String LOGTAG = "AndroidImport";
+ private final Context mContext;
+ private final Runnable mOnDoneRunnable;
+ private final ArrayList<ContentProviderOperation> mOperations;
+ private final ContentResolver mCr;
+ private final LocalBrowserDB mDB;
+ private final boolean mImportBookmarks;
+ private final boolean mImportHistory;
public AndroidImport(Context context, Runnable onDoneRunnable,
boolean doBookmarks, boolean doHistory) {
mContext = context;
mOnDoneRunnable = onDoneRunnable;
mOperations = new ArrayList<ContentProviderOperation>();
mCr = mContext.getContentResolver();
mDB = new LocalBrowserDB(GeckoProfile.get(context).getName());
--- a/mobile/android/base/preferences/AndroidImportPreference.java
+++ b/mobile/android/base/preferences/AndroidImportPreference.java
@@ -11,19 +11,19 @@ import org.mozilla.gecko.util.ThreadUtil
import java.util.Set;
import android.app.ProgressDialog;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
class AndroidImportPreference extends MultiPrefMultiChoicePreference {
- static final private String LOGTAG = "AndroidImport";
+ private static final String LOGTAG = "AndroidImport";
private static final String PREF_KEY_PREFIX = "import_android.data.";
- private Context mContext;
+ private final Context mContext;
public AndroidImportPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
@Override
protected void onDialogClosed(boolean positiveResult) {
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -6,16 +6,17 @@
package org.mozilla.gecko.preferences;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import android.os.Build;
import org.json.JSONObject;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.BrowserLocaleManager;
import org.mozilla.gecko.DataReportingNotification;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoActivityStatus;
@@ -31,16 +32,17 @@ import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
import org.mozilla.gecko.RestrictedProfiles;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.TelemetryContract.Method;
import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.background.healthreport.HealthReportConstants;
import org.mozilla.gecko.db.BrowserContract.SuggestedSites;
+import org.mozilla.gecko.updater.UpdateServiceHelper;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.widget.FloatingHintEditText;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
@@ -320,17 +322,17 @@ OnSharedPreferenceChangeListener
updateTitle(getString(R.string.pref_header_customize));
}
if (onIsMultiPane()) {
// So that Android doesn't put the fragment title (or nothing at
// all) in the action bar.
updateActionBarTitle(R.string.settings_title);
- if (android.os.Build.VERSION.SDK_INT < 13) {
+ if (Build.VERSION.SDK_INT < 13) {
// Affected by Bug 1015209 -- no detach/attach.
// If we try rejigging fragments, we'll crash, so don't
// enable locale switching at all.
localeSwitchingIsEnabled = false;
}
}
}
@@ -1023,17 +1025,17 @@ OnSharedPreferenceChangeListener
}
public interface PrefHandler {
public void setupPref(Context context, Preference pref);
public void onChange(Context context, Preference pref, Object newValue);
}
@SuppressWarnings("serial")
- private Map<String, PrefHandler> handlers = new HashMap<String, PrefHandler>() {{
+ private final Map<String, PrefHandler> handlers = new HashMap<String, PrefHandler>() {{
put(ClearOnShutdownPref.PREF, new ClearOnShutdownPref());
}};
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String prefName = preference.getKey();
Log.i(LOGTAG, "Changed " + prefName + " = " + newValue);
@@ -1051,27 +1053,27 @@ OnSharedPreferenceChangeListener
// Even though this is a list preference, we don't want to handle it
// below, so we return here.
return onLocaleSelected(BrowserLocaleManager.getLanguageTag(lastLocale), (String) newValue);
}
if (PREFS_MENU_CHAR_ENCODING.equals(prefName)) {
setCharEncodingState(((String) newValue).equals("true"));
} else if (PREFS_UPDATER_AUTODOWNLOAD.equals(prefName)) {
- org.mozilla.gecko.updater.UpdateServiceHelper.registerForUpdates(this, (String) newValue);
+ UpdateServiceHelper.registerForUpdates(this, (String) newValue);
} else if (PREFS_HEALTHREPORT_UPLOAD_ENABLED.equals(prefName)) {
// The healthreport pref only lives in Android, so we do not persist
// to Gecko, but we do broadcast intent to the health report
// background uploader service, which will start or stop the
// repeated background upload attempts.
- broadcastHealthReportUploadPref(this, ((Boolean) newValue).booleanValue());
+ broadcastHealthReportUploadPref(this, (Boolean) newValue);
} else if (PREFS_GEO_REPORTING.equals(prefName)) {
- broadcastStumblerPref(this, ((Boolean) newValue).booleanValue());
+ broadcastStumblerPref(this, (Boolean) newValue);
// Translate boolean value to int for geo reporting pref.
- newValue = ((Boolean) newValue) ? 1 : 0;
+ newValue = (Boolean) newValue ? 1 : 0;
} else if (handlers.containsKey(prefName)) {
PrefHandler handler = handlers.get(prefName);
handler.onChange(this, preference, newValue);
}
// Send Gecko-side pref changes to Gecko
if (isGeckoPref(prefName)) {
PrefsHelper.setPref(prefName, newValue);
--- a/mobile/android/base/preferences/LinkPreference.java
+++ b/mobile/android/base/preferences/LinkPreference.java
@@ -7,17 +7,17 @@ package org.mozilla.gecko.preferences;
import org.mozilla.gecko.Tabs;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
class LinkPreference extends Preference {
- private String mUrl;
+ private final String mUrl;
public LinkPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mUrl = attrs.getAttributeValue(null, "url");
}
public LinkPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mUrl = attrs.getAttributeValue(null, "url");
--- a/mobile/android/base/preferences/PanelsPreference.java
+++ b/mobile/android/base/preferences/PanelsPreference.java
@@ -40,17 +40,17 @@ public class PanelsPreference extends Cu
private static final int INDEX_MOVE_UP_BUTTON = 0;
private static final int INDEX_MOVE_DOWN_BUTTON = 1;
private String LABEL_HIDE;
private String LABEL_SHOW;
private View preferenceView;
protected boolean mIsHidden;
- private boolean mIsRemovable;
+ private final boolean mIsRemovable;
private boolean mAnimate;
private static final int ANIMATION_DURATION_MS = 400;
// State for reordering.
private int mPositionState = -1;
private final int mIndex;
--- a/mobile/android/base/preferences/SyncPreference.java
+++ b/mobile/android/base/preferences/SyncPreference.java
@@ -16,17 +16,17 @@ import org.mozilla.gecko.util.HardwareUt
import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
class SyncPreference extends Preference {
private static final boolean DEFAULT_TO_FXA = true;
- private Context mContext;
+ private final Context mContext;
public SyncPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
private void openSync11Settings() {
// Show Sync setup if no accounts exist; otherwise, show account settings.
--- a/mobile/android/base/prompts/ColorPickerInput.java
+++ b/mobile/android/base/prompts/ColorPickerInput.java
@@ -13,18 +13,18 @@ import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
public class ColorPickerInput extends PromptInput {
public static final String INPUT_TYPE = "color";
public static final String LOGTAG = "GeckoColorPickerInput";
- private boolean mShowAdvancedButton = true;
- private int mInitialColor;
+ private final boolean mShowAdvancedButton = true;
+ private final int mInitialColor;
public ColorPickerInput(JSONObject obj) {
super(obj);
String init = obj.optString("value");
mInitialColor = Color.rgb(Integer.parseInt(init.substring(1,3), 16),
Integer.parseInt(init.substring(3,5), 16),
Integer.parseInt(init.substring(5,7), 16));
}
@@ -49,11 +49,11 @@ public class ColorPickerInput extends Pr
@Override
public boolean getScrollable() {
return true;
}
@Override
public boolean canApplyInputStyle() {
- return false;
+ return false;
}
}
--- a/mobile/android/base/prompts/IconGridInput.java
+++ b/mobile/android/base/prompts/IconGridInput.java
@@ -35,17 +35,17 @@ public class IconGridInput extends Promp
public static final String LOGTAG = "GeckoIconGridInput";
private ArrayAdapter<IconGridItem> mAdapter; // An adapter holding a list of items to show in the grid
private static int mColumnWidth = -1; // The maximum width of columns
private static int mMaxColumns = -1; // The maximum number of columns to show
private static int mIconSize = -1; // Size of icons in the grid
private int mSelected; // Current selection
- private JSONArray mArray;
+ private final JSONArray mArray;
public IconGridInput(JSONObject obj) {
super(obj);
mArray = obj.optJSONArray("items");
}
@Override
public View getView(Context context) throws UnsupportedOperationException {
@@ -98,17 +98,17 @@ public class IconGridInput extends Promp
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mSelected = position;
notifyListeners(Integer.toString(position));
}
@Override
public Object getValue() {
- return new Integer(mSelected);
+ return mSelected;
}
@Override
public boolean getScrollable() {
return true;
}
private class IconGridAdapter extends ArrayAdapter<IconGridItem> {
--- a/mobile/android/base/prompts/PromptInput.java
+++ b/mobile/android/base/prompts/PromptInput.java
@@ -127,17 +127,17 @@ public class PromptInput {
public Object getValue() {
EditText edit = (EditText)mView;
return edit.getText();
}
}
public static class CheckboxInput extends PromptInput {
public static final String INPUT_TYPE = "checkbox";
- private boolean mChecked;
+ private final boolean mChecked;
public CheckboxInput(JSONObject obj) {
super(obj);
mChecked = obj.optBoolean("checked");
}
public View getView(Context context) throws UnsupportedOperationException {
CheckBox checkbox = new CheckBox(context);
@@ -306,17 +306,17 @@ public class PromptInput {
return container;
}
return spinner;
}
@Override
public Object getValue() {
- return new Integer(spinner.getSelectedItemPosition());
+ return spinner.getSelectedItemPosition();
}
}
public static class LabelInput extends PromptInput {
public static final String INPUT_TYPE = "label";
public LabelInput(JSONObject obj) {
super(obj);
}
--- a/mobile/android/base/sqlite/ByteBufferInputStream.java
+++ b/mobile/android/base/sqlite/ByteBufferInputStream.java
@@ -9,17 +9,17 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
/*
* Helper class to make the ByteBuffers returned by SQLite BLOB
* easier to use.
*/
public class ByteBufferInputStream extends InputStream {
- private ByteBuffer mByteBuffer;
+ private final ByteBuffer mByteBuffer;
public ByteBufferInputStream(ByteBuffer aByteBuffer) {
mByteBuffer = aByteBuffer;
}
@Override
public synchronized int read() throws IOException {
if (!mByteBuffer.hasRemaining()) {
--- a/mobile/android/base/sqlite/SQLiteBridge.java
+++ b/mobile/android/base/sqlite/SQLiteBridge.java
@@ -21,17 +21,17 @@ import java.util.Map.Entry;
* This class allows using the mozsqlite3 library included with Firefox
* to read SQLite databases, instead of the Android SQLiteDataBase API,
* which might use whatever outdated DB is present on the Android system.
*/
public class SQLiteBridge {
private static final String LOGTAG = "SQLiteBridge";
// Path to the database. If this database was not opened with openDatabase, we reopen it every query.
- private String mDb;
+ private final String mDb;
// Pointer to the database if it was opened with openDatabase. 0 implies closed.
protected volatile long mDbPointer;
// Values remembered after a query.
private long[] mQueryResults;
private boolean mTransactionSuccess;
--- a/mobile/android/base/sync/CommandProcessor.java
+++ b/mobile/android/base/sync/CommandProcessor.java
@@ -37,17 +37,17 @@ import android.net.Uri;
* during an activity completely unrelated to a sync (such as
* <code>SendTabActivity</code>.)</li>
* </ol>
* To provide a processor for both these time frames, we maintain a static
* long-lived singleton.
*/
public class CommandProcessor {
private static final String LOG_TAG = "Command";
- private static AtomicInteger currentId = new AtomicInteger();
+ private static final AtomicInteger currentId = new AtomicInteger();
protected ConcurrentHashMap<String, CommandRunner> commands = new ConcurrentHashMap<String, CommandRunner>();
private final static CommandProcessor processor = new CommandProcessor();
/**
* Get the global singleton command processor.
*
* @return the singleton processor.
--- a/mobile/android/base/sync/GlobalSession.java
+++ b/mobile/android/base/sync/GlobalSession.java
@@ -5,16 +5,17 @@
package org.mozilla.gecko.sync;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
@@ -169,17 +170,17 @@ public class GlobalSession implements Ht
@Override
public void executeCommand(final GlobalSession session, List<String> args) {
CommandProcessor.displayURI(args, session.getContext());
}
});
}
protected void prepareStages() {
- HashMap<Stage, GlobalSyncStage> stages = new HashMap<Stage, GlobalSyncStage>();
+ Map<Stage, GlobalSyncStage> stages = new EnumMap<Stage, GlobalSyncStage>(Stage.class);
stages.put(Stage.checkPreconditions, new CheckPreconditionsStage());
stages.put(Stage.ensureClusterURL, new EnsureClusterURLStage(nodeAssignmentCallback));
stages.put(Stage.fetchInfoCollections, new FetchInfoCollectionsStage());
stages.put(Stage.fetchMetaGlobal, new FetchMetaGlobalStage());
stages.put(Stage.ensureKeysStage, new EnsureCrypto5KeysStage());
stages.put(Stage.syncClientsEngine, new SyncClientsEngineStage());
--- a/mobile/android/base/sync/JSONRecordFetcher.java
+++ b/mobile/android/base/sync/JSONRecordFetcher.java
@@ -82,17 +82,17 @@ public class JSONRecordFetcher {
} catch (Exception e) {
delegate.handleError(e);
}
}
private class LatchedJSONRecordFetchDelegate implements JSONRecordFetchDelegate {
public ExtendedJSONObject body = null;
public Exception exception = null;
- private CountDownLatch latch;
+ private final CountDownLatch latch;
public LatchedJSONRecordFetchDelegate(CountDownLatch latch) {
this.latch = latch;
}
@Override
public void handleFailure(SyncStorageResponse response) {
this.exception = new HTTPFailureException(response);
--- a/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java
+++ b/mobile/android/base/sync/SharedPreferencesClientsDataDelegate.java
@@ -70,17 +70,17 @@ public class SharedPreferencesClientsDat
long now = System.currentTimeMillis();
setClientName(clientName, now);
}
return clientName;
}
@Override
public synchronized void setClientsCount(int clientsCount) {
- sharedPreferences.edit().putLong(SyncConfiguration.PREF_NUM_CLIENTS, (long) clientsCount).commit();
+ sharedPreferences.edit().putLong(SyncConfiguration.PREF_NUM_CLIENTS, clientsCount).commit();
}
@Override
public boolean isLocalGUID(String guid) {
return getAccountGUID().equals(guid);
}
@Override
--- a/mobile/android/base/sync/SyncConfiguration.java
+++ b/mobile/android/base/sync/SyncConfiguration.java
@@ -21,17 +21,17 @@ import org.mozilla.gecko.sync.stage.Glob
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class SyncConfiguration {
public class EditorBranch implements Editor {
- private String prefix;
+ private final String prefix;
private Editor editor;
public EditorBranch(SyncConfiguration config, String prefix) {
if (!prefix.endsWith(".")) {
throw new IllegalArgumentException("No trailing period in prefix.");
}
this.prefix = prefix;
this.editor = config.getEditor();
@@ -100,18 +100,18 @@ public class SyncConfiguration {
/**
* A wrapper around a portion of the SharedPreferences space.
*
* @author rnewman
*
*/
public class ConfigurationBranch implements SharedPreferences {
- private SyncConfiguration config;
- private String prefix; // Including trailing period.
+ private final SyncConfiguration config;
+ private final String prefix; // Including trailing period.
public ConfigurationBranch(SyncConfiguration syncConfiguration,
String prefix) {
if (!prefix.endsWith(".")) {
throw new IllegalArgumentException("No trailing period in prefix.");
}
this.config = syncConfiguration;
this.prefix = prefix;
--- a/mobile/android/base/sync/SyncConstants.java.in
+++ b/mobile/android/base/sync/SyncConstants.java.in
@@ -1,9 +1,9 @@
-#filter substitution
+//#filter substitution
/* 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.sync;
import org.mozilla.gecko.background.common.GlobalConstants;
--- a/mobile/android/base/sync/Utils.java
+++ b/mobile/android/base/sync/Utils.java
@@ -35,17 +35,17 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
public class Utils {
private static final String LOG_TAG = "Utils";
- private static SecureRandom sharedSecureRandom = new SecureRandom();
+ private static final SecureRandom sharedSecureRandom = new SecureRandom();
// See <http://developer.android.com/reference/android/content/Context.html#getSharedPreferences%28java.lang.String,%20int%29>
public static final int SHARED_PREFERENCES_MODE = 0;
public static String generateGuid() {
byte[] encodedBytes = Base64.encodeBase64(generateRandomBytes(9), false);
return new String(encodedBytes).replace("+", "-").replace("/", "_");
}
@@ -195,17 +195,17 @@ public class Utils {
return (long)(decimal * 1000);
}
public static long decimalSecondsToMilliseconds(Long decimal) {
return decimal * 1000;
}
public static long decimalSecondsToMilliseconds(Integer decimal) {
- return (long)(decimal * 1000);
+ return (decimal * 1000);
}
public static byte[] sha256(byte[] in)
throws NoSuchAlgorithmException {
MessageDigest sha1 = MessageDigest.getInstance("SHA-256");
return sha1.digest(in);
}
--- a/mobile/android/base/sync/config/ConfigurationMigrator.java
+++ b/mobile/android/base/sync/config/ConfigurationMigrator.java
@@ -234,17 +234,17 @@ public class ConfigurationMigrator {
}
if (clientName != null) {
Logger.debug(LOG_TAG, "Migrated client name.");
accountManager.setUserData(account, V1_PREF_CLIENT_NAME, clientName);
count += 1;
}
if (numClients > -1) {
Logger.debug(LOG_TAG, "Migrated clients count.");
- accountManager.setUserData(account, V1_PREF_NUM_CLIENTS, new Long(numClients).toString());
+ accountManager.setUserData(account, V1_PREF_NUM_CLIENTS, Long.toString(numClients));
count += 1;
}
return count;
}
/**
* Extract version 0 per-Android account user data and write to version 1 per-Sync account shared prefs.
*
--- a/mobile/android/base/sync/crypto/HKDF.java
+++ b/mobile/android/base/sync/crypto/HKDF.java
@@ -51,17 +51,17 @@ public class HKDF {
* Output: OKM (output keyring material).
*/
public static byte[] hkdfExpand(byte[] prk, byte[] info, int len) throws NoSuchAlgorithmException, InvalidKeyException {
Mac hmacHasher = makeHMACHasher(prk);
byte[] T = {};
byte[] Tn = {};
- int iterations = (int) Math.ceil(((double)len) / ((double)BLOCKSIZE));
+ int iterations = (int) Math.ceil(((double)len) / (BLOCKSIZE));
for (int i = 0; i < iterations; i++) {
Tn = digestBytes(Utils.concatAll(Tn, info, Utils.hex2Byte(Integer.toHexString(i + 1))),
hmacHasher);
T = Utils.concatAll(T, Tn);
}
byte[] result = new byte[len];
System.arraycopy(T, 0, result, 0, len);
--- a/mobile/android/base/sync/jpake/JPakeClient.java
+++ b/mobile/android/base/sync/jpake/JPakeClient.java
@@ -33,67 +33,67 @@ import org.mozilla.gecko.sync.jpake.stag
import org.mozilla.gecko.sync.jpake.stage.VerifyPairingStage;
import org.mozilla.gecko.sync.setup.Constants;
import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
import ch.boye.httpclientandroidlib.entity.StringEntity;
public class JPakeClient {
- private static String LOG_TAG = "JPakeClient";
+ private static final String LOG_TAG = "JPakeClient";
// J-PAKE constants.
- public final static int REQUEST_TIMEOUT = 60 * 1000; // 1 min
- public final static int KEYEXCHANGE_VERSION = 3;
- public final static String JPAKE_VERIFY_VALUE = "0123456789ABCDEF";
+ public static final int REQUEST_TIMEOUT = 60 * 1000; // 1 min
+ public static final int KEYEXCHANGE_VERSION = 3;
+ public static final String JPAKE_VERIFY_VALUE = "0123456789ABCDEF";
- private final static String JPAKE_SIGNERID_SENDER = "sender";
- private final static String JPAKE_SIGNERID_RECEIVER = "receiver";
- private final static int JPAKE_LENGTH_SECRET = 8;
- private final static int JPAKE_LENGTH_CLIENTID = 256;
+ private static final String JPAKE_SIGNERID_SENDER = "sender";
+ private static final String JPAKE_SIGNERID_RECEIVER = "receiver";
+ private static final int JPAKE_LENGTH_SECRET = 8;
+ private static final int JPAKE_LENGTH_CLIENTID = 256;
- private final static int MAX_TRIES = 10;
- private final static int MAX_TRIES_FIRST_MSG = 300;
- private final static int MAX_TRIES_LAST_MSG = 300;
+ private static final int MAX_TRIES = 10;
+ private static final int MAX_TRIES_FIRST_MSG = 300;
+ private static final int MAX_TRIES_LAST_MSG = 300;
// J-PAKE session values.
- public String clientId;
- public String secret;
+ public String clientId;
+ public String secret;
- public String myEtag;
- public String mySignerId;
- public String theirEtag;
- public String theirSignerId;
- public String jpakeServer;
+ public String myEtag;
+ public String mySignerId;
+ public String theirEtag;
+ public String theirSignerId;
+ public String jpakeServer;
// J-PAKE state.
- public boolean paired = false;
- public boolean finished = false;
+ public boolean paired;
+ public boolean finished;
// J-PAKE values.
- public int jpakePollInterval;
- public int jpakeMaxTries;
- public String channel;
- public volatile String channelUrl;
+ public int jpakePollInterval;
+ public int jpakeMaxTries;
+ public String channel;
+ public volatile String channelUrl;
// J-PAKE session data.
- public KeyBundle myKeyBundle;
- public JSONObject jCreds;
+ public KeyBundle myKeyBundle;
+ public JSONObject jCreds;
- public ExtendedJSONObject jOutgoing;
- public ExtendedJSONObject jIncoming;
+ public ExtendedJSONObject jOutgoing;
+ public ExtendedJSONObject jIncoming;
- public JPakeParty jParty;
- public JPakeNumGenerator numGen;
+ public JPakeParty jParty;
+ public JPakeNumGenerator numGen;
- public int pollTries = 0;
+ public int pollTries;
// UI controller.
- private SetupSyncActivity controllerActivity;
- private Queue<JPakeStage> stages;
+ private final SetupSyncActivity controllerActivity;
+ private Queue<JPakeStage> stages;
public JPakeClient(SetupSyncActivity activity) {
controllerActivity = activity;
jpakeServer = "https://setup.services.mozilla.com/";
jpakePollInterval = 1 * 1000; // 1 second
jpakeMaxTries = MAX_TRIES;
if (!jpakeServer.endsWith("/")) {
--- a/mobile/android/base/sync/jpake/stage/GetRequestStage.java
+++ b/mobile/android/base/sync/jpake/stage/GetRequestStage.java
@@ -23,17 +23,17 @@ import ch.boye.httpclientandroidlib.Head
import ch.boye.httpclientandroidlib.HttpResponse;
import ch.boye.httpclientandroidlib.client.ClientProtocolException;
import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
import ch.boye.httpclientandroidlib.message.BasicHeader;
public class GetRequestStage extends JPakeStage {
- private Timer timerScheduler = new Timer();
+ private final Timer timerScheduler = new Timer();
private int pollTries;
private GetStepTimerTask getStepTimerTask;
private interface GetRequestStageDelegate {
public void handleSuccess(HttpResponse response);
public void handleFailure(String error);
public void handleError(Exception e);
}
@@ -183,17 +183,17 @@ public class GetRequestStage extends JPa
return httpResource;
}
/**
* TimerTask for use with delayed GET requests.
*
*/
public class GetStepTimerTask extends TimerTask {
- private Resource request;
+ private final Resource request;
public GetStepTimerTask(Resource request) {
this.request = request;
}
@Override
public void run() {
request.get();
--- a/mobile/android/base/sync/middleware/Crypto5MiddlewareRepository.java
+++ b/mobile/android/base/sync/middleware/Crypto5MiddlewareRepository.java
@@ -21,18 +21,18 @@ import android.content.Context;
* @author rnewman
*
*/
public class Crypto5MiddlewareRepository extends MiddlewareRepository {
public RecordFactory recordFactory = new IdentityRecordFactory();
public class Crypto5MiddlewareRepositorySessionCreationDelegate extends MiddlewareRepository.SessionCreationDelegate {
- private Crypto5MiddlewareRepository repository;
- private RepositorySessionCreationDelegate outerDelegate;
+ private final Crypto5MiddlewareRepository repository;
+ private final RepositorySessionCreationDelegate outerDelegate;
public Crypto5MiddlewareRepositorySessionCreationDelegate(Crypto5MiddlewareRepository repository, RepositorySessionCreationDelegate outerDelegate) {
this.repository = repository;
this.outerDelegate = outerDelegate;
}
public void onSessionCreateFailed(Exception ex) {
this.outerDelegate.onSessionCreateFailed(ex);
}
@@ -48,17 +48,17 @@ public class Crypto5MiddlewareRepository
this.outerDelegate.onSessionCreateFailed(ex);
return;
}
this.outerDelegate.onSessionCreated(cryptoSession);
}
}
public KeyBundle keyBundle;
- private Repository inner;
+ private final Repository inner;
public Crypto5MiddlewareRepository(Repository inner, KeyBundle keys) {
super();
this.inner = inner;
this.keyBundle = keys;
}
@Override
public void createSession(RepositorySessionCreationDelegate delegate, Context context) {
--- a/mobile/android/base/sync/middleware/Crypto5MiddlewareRepositorySession.java
+++ b/mobile/android/base/sync/middleware/Crypto5MiddlewareRepositorySession.java
@@ -53,29 +53,29 @@ import org.mozilla.gecko.sync.repositori
| Local RepositorySession instance |
+------------------------------------+
* @author rnewman
*
*/
public class Crypto5MiddlewareRepositorySession extends MiddlewareRepositorySession {
- private KeyBundle keyBundle;
- private RecordFactory recordFactory;
+ private final KeyBundle keyBundle;
+ private final RecordFactory recordFactory;
public Crypto5MiddlewareRepositorySession(RepositorySession session, Crypto5MiddlewareRepository repository, RecordFactory recordFactory) {
super(session, repository);
this.keyBundle = repository.keyBundle;
this.recordFactory = recordFactory;
}
public class DecryptingTransformingFetchDelegate implements RepositorySessionFetchRecordsDelegate {
- private RepositorySessionFetchRecordsDelegate next;
- private KeyBundle keyBundle;
- private RecordFactory recordFactory;
+ private final RepositorySessionFetchRecordsDelegate next;
+ private final KeyBundle keyBundle;
+ private final RecordFactory recordFactory;
DecryptingTransformingFetchDelegate(RepositorySessionFetchRecordsDelegate next, KeyBundle bundle, RecordFactory recordFactory) {
this.next = next;
this.keyBundle = bundle;
this.recordFactory = recordFactory;
}
@Override
--- a/mobile/android/base/sync/middleware/MiddlewareRepositorySession.java
+++ b/mobile/android/base/sync/middleware/MiddlewareRepositorySession.java
@@ -27,18 +27,18 @@ public abstract class MiddlewareReposito
@Override
public void wipe(RepositorySessionWipeDelegate delegate) {
inner.wipe(delegate);
}
public class MiddlewareRepositorySessionBeginDelegate implements RepositorySessionBeginDelegate {
- private MiddlewareRepositorySession outerSession;
- private RepositorySessionBeginDelegate next;
+ private final MiddlewareRepositorySession outerSession;
+ private final RepositorySessionBeginDelegate next;
public MiddlewareRepositorySessionBeginDelegate(MiddlewareRepositorySession outerSession, RepositorySessionBeginDelegate next) {
this.outerSession = outerSession;
this.next = next;
}
@Override
public void onBeginFailed(Exception ex) {
--- a/mobile/android/base/sync/net/BaseResource.java
+++ b/mobile/android/base/sync/net/BaseResource.java
@@ -179,17 +179,17 @@ public class BaseResource implements Res
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
final String userAgent = delegate.getUserAgent();
if (userAgent != null) {
HttpProtocolParams.setUserAgent(params, userAgent);
}
delegate.addHeaders(request, client);
}
- private static Object connManagerMonitor = new Object();
+ private static final Object connManagerMonitor = new Object();
private static ClientConnectionManager connManager;
// Call within a synchronized block on connManagerMonitor.
private static ClientConnectionManager enableTLSConnectionManager() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, new SecureRandom());
SSLSocketFactory sf = new TLSSocketFactory(sslContext);
SchemeRegistry schemeRegistry = new SchemeRegistry();
--- a/mobile/android/base/sync/repositories/HashSetStoreTracker.java
+++ b/mobile/android/base/sync/repositories/HashSetStoreTracker.java
@@ -10,17 +10,17 @@ import java.util.Iterator;
import org.mozilla.gecko.sync.repositories.domain.Record;
public class HashSetStoreTracker implements StoreTracker {
// Guarded by `this`.
// Used to store GUIDs that were not locally modified but
// have been modified by a call to `store`, and thus
// should not be returned by a subsequent fetch.
- private HashSet<String> guids;
+ private final HashSet<String> guids;
public HashSetStoreTracker() {
guids = new HashSet<String>();
}
@Override
public String toString() {
return "#<Tracker: " + guids.size() + " guids tracked.>";
--- a/mobile/android/base/sync/repositories/Server11RepositorySession.java
+++ b/mobile/android/base/sync/repositories/Server11RepositorySession.java
@@ -90,17 +90,17 @@ public class Server11RepositorySession e
normalizedTimestamp = System.currentTimeMillis();
}
return normalizedTimestamp;
}
/**
* Used to track outstanding requests, so that we can abort them as needed.
*/
- private Set<SyncStorageCollectionRequest> pending = Collections.synchronizedSet(new HashSet<SyncStorageCollectionRequest>());
+ private final Set<SyncStorageCollectionRequest> pending = Collections.synchronizedSet(new HashSet<SyncStorageCollectionRequest>());
@Override
public void abort() {
super.abort();
for (SyncStorageCollectionRequest request : pending) {
request.abort();
}
pending.clear();
@@ -110,17 +110,17 @@ public class Server11RepositorySession e
* Convert HTTP request delegate callbacks into fetch callbacks within the
* context of this RepositorySession.
*
* @author rnewman
*
*/
public class RequestFetchDelegateAdapter extends WBOCollectionRequestDelegate {
RepositorySessionFetchRecordsDelegate delegate;
- private DelayedWorkTracker workTracker = new DelayedWorkTracker();
+ private final DelayedWorkTracker workTracker = new DelayedWorkTracker();
// So that we can clean up.
private SyncStorageCollectionRequest request;
public void setRequest(SyncStorageCollectionRequest request) {
this.request = request;
}
private void removeRequestFromPending() {
@@ -422,19 +422,19 @@ public class Server11RepositorySession e
* store callbacks within the context of this RepositorySession.
*
* @author rnewman
*
*/
protected class RecordUploadRunnable implements Runnable, SyncStorageRequestDelegate {
public final String LOG_TAG = "RecordUploadRunnable";
- private ArrayList<byte[]> outgoing;
+ private final ArrayList<byte[]> outgoing;
private ArrayList<String> outgoingGuids;
- private long byteCount;
+ private final long byteCount;
public RecordUploadRunnable(RepositorySessionStoreDelegate storeDelegate,
ArrayList<byte[]> outgoing,
ArrayList<String> outgoingGuids,
long byteCount) {
Logger.debug(LOG_TAG, "Preparing record upload for " +
outgoing.size() + " records (" +
byteCount + " bytes).");
@@ -551,17 +551,17 @@ public class Server11RepositorySession e
outstream.write(recordSeparator);
outstream.write(outgoing.get(i));
}
outstream.write(recordsEnd);
}
}
public class ByteArraysEntity extends EntityTemplate {
- private long count;
+ private final long count;
public ByteArraysEntity(ArrayList<byte[]> arrays, long totalBytes) {
super(new ByteArraysContentProducer(arrays));
this.count = totalBytes;
this.setContentType("application/json");
// charset is set in BaseResource.
}
@Override
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java
@@ -82,17 +82,17 @@ public class AndroidBrowserBookmarksData
@Override
public void wipe() {
Uri uri = getUri();
Logger.info(LOG_TAG, "wiping (except for special guids): " + uri);
context.getContentResolver().delete(uri, EXCLUDE_SPECIAL_GUIDS_WHERE_CLAUSE, null);
}
- private String[] GUID_AND_ID = new String[] { BrowserContract.Bookmarks.GUID,
+ private final String[] GUID_AND_ID = new String[] { BrowserContract.Bookmarks.GUID,
BrowserContract.Bookmarks._ID };
protected Cursor getGuidsIDsForFolders() throws NullCursorException {
// Exclude items that we don't want to sync (pinned items, reading list,
// tags, the places root), in case they've ended up in the DB.
String where = BOOKMARK_IS_FOLDER + " AND " + GUID_SHOULD_TRACK;
return queryHelper.safeQuery(".getGuidsIDsForFolders", GUID_AND_ID, where, null, null);
}
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
@@ -37,18 +37,18 @@ import android.net.Uri;
public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepositorySession
implements BookmarksInsertionManager.BookmarkInserter {
public static final int DEFAULT_DELETION_FLUSH_THRESHOLD = 50;
public static final int DEFAULT_INSERTION_FLUSH_THRESHOLD = 50;
// TODO: synchronization for these.
- private HashMap<String, Long> parentGuidToIDMap = new HashMap<String, Long>();
- private HashMap<Long, String> parentIDToGuidMap = new HashMap<Long, String>();
+ private final HashMap<String, Long> parentGuidToIDMap = new HashMap<String, Long>();
+ private final HashMap<Long, String> parentIDToGuidMap = new HashMap<Long, String>();
/**
* Some notes on reparenting/reordering.
*
* Fennec stores new items with a high-negative position, because it doesn't care.
* On the other hand, it also doesn't give us any help managing positions.
*
* We can process records and folders in any order, though we'll usually see folders
@@ -95,21 +95,21 @@ public class AndroidBrowserBookmarksRepo
* we're left with lonely records at the end.
*
* As we modify local folders, perhaps by moving children out of their purview, we
* must bump their modification time so as to cause them to be uploaded on the next
* stage of syncing. The same applies to simple reordering.
*/
// TODO: can we guarantee serial access to these?
- private HashMap<String, ArrayList<String>> missingParentToChildren = new HashMap<String, ArrayList<String>>();
- private HashMap<String, JSONArray> parentToChildArray = new HashMap<String, JSONArray>();
+ private final HashMap<String, ArrayList<String>> missingParentToChildren = new HashMap<String, ArrayList<String>>();
+ private final HashMap<String, JSONArray> parentToChildArray = new HashMap<String, JSONArray>();
private int needsReparenting = 0;
- private AndroidBrowserBookmarksDataAccessor dataAccessor;
+ private final AndroidBrowserBookmarksDataAccessor dataAccessor;
protected BookmarksDeletionManager deletionManager;
protected BookmarksInsertionManager insertionManager;
/**
* An array of known-special GUIDs.
*/
public static String[] SPECIAL_GUIDS = new String[] {
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserHistoryDataAccessor.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserHistoryDataAccessor.java
@@ -18,17 +18,17 @@ import org.mozilla.gecko.sync.repositori
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
public class AndroidBrowserHistoryDataAccessor extends
AndroidBrowserRepositoryDataAccessor {
- private AndroidBrowserHistoryDataExtender dataExtender;
+ private final AndroidBrowserHistoryDataExtender dataExtender;
public AndroidBrowserHistoryDataAccessor(Context context) {
super(context);
dataExtender = new AndroidBrowserHistoryDataExtender(context);
}
public AndroidBrowserHistoryDataExtender getHistoryDataExtender() {
return dataExtender;
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepository.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepository.java
@@ -22,18 +22,18 @@ public abstract class AndroidBrowserRepo
public void clean(boolean success, RepositorySessionCleanDelegate delegate, Context context) {
// Only clean deleted records if success
if (success) {
new CleanThread(delegate, context).start();
}
}
class CleanThread extends Thread {
- private RepositorySessionCleanDelegate delegate;
- private Context context;
+ private final RepositorySessionCleanDelegate delegate;
+ private final Context context;
public CleanThread(RepositorySessionCleanDelegate delegate, Context context) {
if (context == null) {
throw new IllegalArgumentException("context is null");
}
this.delegate = delegate;
this.context = context;
}
@@ -51,18 +51,18 @@ public abstract class AndroidBrowserRepo
delegate.onCleaned(AndroidBrowserRepository.this);
}
}
protected abstract AndroidBrowserRepositoryDataAccessor getDataAccessor(Context context);
protected abstract void sessionCreator(RepositorySessionCreationDelegate delegate, Context context);
class CreateSessionThread extends Thread {
- private RepositorySessionCreationDelegate delegate;
- private Context context;
+ private final RepositorySessionCreationDelegate delegate;
+ private final Context context;
public CreateSessionThread(RepositorySessionCreationDelegate delegate, Context context) {
if (context == null) {
throw new IllegalArgumentException("context is null.");
}
this.delegate = delegate;
this.context = context;
}
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
@@ -195,18 +195,18 @@ public abstract class AndroidBrowserRepo
@Override
public void guidsSince(long timestamp, RepositorySessionGuidsSinceDelegate delegate) {
GuidsSinceRunnable command = new GuidsSinceRunnable(timestamp, delegate);
delegateQueue.execute(command);
}
class GuidsSinceRunnable implements Runnable {
- private RepositorySessionGuidsSinceDelegate delegate;
- private long timestamp;
+ private final RepositorySessionGuidsSinceDelegate delegate;
+ private final long timestamp;
public GuidsSinceRunnable(long timestamp,
RepositorySessionGuidsSinceDelegate delegate) {
this.timestamp = timestamp;
this.delegate = delegate;
}
@Override
@@ -295,19 +295,19 @@ public abstract class AndroidBrowserRepo
} finally {
Logger.trace(LOG_TAG, "Closing cursor after fetch.");
cursor.close();
}
}
}
public class FetchRunnable extends FetchingRunnable {
- private String[] guids;
- private long end;
- private RecordFilter filter;
+ private final String[] guids;
+ private final long end;
+ private final RecordFilter filter;
public FetchRunnable(String[] guids,
long end,
RecordFilter filter,
RepositorySessionFetchRecordsDelegate delegate) {
super(delegate);
this.guids = guids;
this.end = end;
@@ -344,19 +344,19 @@ public abstract class AndroidBrowserRepo
}
Logger.debug(LOG_TAG, "Running fetchSince(" + timestamp + ").");
FetchSinceRunnable command = new FetchSinceRunnable(timestamp, now(), this.storeTracker.getFilter(), delegate);
delegateQueue.execute(command);
}
class FetchSinceRunnable extends FetchingRunnable {
- private long since;
- private long end;
- private RecordFilter filter;
+ private final long since;
+ private final long end;
+ private final RecordFilter filter;
public FetchSinceRunnable(long since,
long end,
RecordFilter filter,
RepositorySessionFetchRecordsDelegate delegate) {
super(delegate);
this.since = since;
this.end = end;
--- a/mobile/android/base/sync/repositories/android/FormHistoryRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/FormHistoryRepositorySession.java
@@ -39,18 +39,18 @@ public class FormHistoryRepositorySessio
StoreTrackingRepositorySession {
public static String LOG_TAG = "FormHistoryRepoSess";
/**
* Number of records to insert in one batch.
*/
public static final int INSERT_ITEM_THRESHOLD = 200;
- private static Uri FORM_HISTORY_CONTENT_URI = BrowserContractHelpers.FORM_HISTORY_CONTENT_URI;
- private static Uri DELETED_FORM_HISTORY_CONTENT_URI = BrowserContractHelpers.DELETED_FORM_HISTORY_CONTENT_URI;
+ private static final Uri FORM_HISTORY_CONTENT_URI = BrowserContractHelpers.FORM_HISTORY_CONTENT_URI;
+ private static final Uri DELETED_FORM_HISTORY_CONTENT_URI = BrowserContractHelpers.DELETED_FORM_HISTORY_CONTENT_URI;
public static class FormHistoryRepository extends Repository {
@Override
public void createSession(RepositorySessionCreationDelegate delegate,
Context context) {
try {
final FormHistoryRepositorySession session = new FormHistoryRepositorySession(this, context);
--- a/mobile/android/base/sync/repositories/android/PasswordsRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/PasswordsRepositorySession.java
@@ -44,21 +44,21 @@ public class PasswordsRepositorySession
Context context) {
PasswordsRepositorySession session = new PasswordsRepositorySession(PasswordsRepository.this, context);
final RepositorySessionCreationDelegate deferredCreationDelegate = delegate.deferredCreationDelegate();
deferredCreationDelegate.onSessionCreated(session);
}
}
private static final String LOG_TAG = "PasswordsRepoSession";
- private static String COLLECTION = "passwords";
+ private static final String COLLECTION = "passwords";
- private RepoUtils.QueryHelper passwordsHelper;
- private RepoUtils.QueryHelper deletedPasswordsHelper;
- private ContentProviderClient passwordsProvider;
+ private final RepoUtils.QueryHelper passwordsHelper;
+ private final RepoUtils.QueryHelper deletedPasswordsHelper;
+ private final ContentProviderClient passwordsProvider;
private final Context context;
public PasswordsRepositorySession(Repository repository, Context context) {
super(repository);
this.context = context;
this.passwordsHelper = new QueryHelper(context, BrowserContractHelpers.PASSWORDS_CONTENT_URI, LOG_TAG);
this.deletedPasswordsHelper = new QueryHelper(context, BrowserContractHelpers.DELETED_PASSWORDS_CONTENT_URI, LOG_TAG);
--- a/mobile/android/base/sync/repositories/delegates/DeferredRepositorySessionBeginDelegate.java
+++ b/mobile/android/base/sync/repositories/delegates/DeferredRepositorySessionBeginDelegate.java
@@ -4,18 +4,18 @@
package org.mozilla.gecko.sync.repositories.delegates;
import java.util.concurrent.ExecutorService;
import org.mozilla.gecko.sync.repositories.RepositorySession;
public class DeferredRepositorySessionBeginDelegate implements RepositorySessionBeginDelegate {
- private RepositorySessionBeginDelegate inner;
- private ExecutorService executor;
+ private final RepositorySessionBeginDelegate inner;
+ private final ExecutorService executor;
public DeferredRepositorySessionBeginDelegate(final RepositorySessionBeginDelegate inner, final ExecutorService executor) {
this.inner = inner;
this.executor = executor;
}
@Override
public void onBeginSucceeded(final RepositorySession session) {
executor.execute(new Runnable() {
--- a/mobile/android/base/sync/repositories/delegates/DeferredRepositorySessionFetchRecordsDelegate.java
+++ b/mobile/android/base/sync/repositories/delegates/DeferredRepositorySessionFetchRecordsDelegate.java
@@ -4,18 +4,18 @@
package org.mozilla.gecko.sync.repositories.delegates;
import java.util.concurrent.ExecutorService;
import org.mozilla.gecko.sync.repositories.domain.Record;
public class DeferredRepositorySessionFetchRecordsDelegate implements RepositorySessionFetchRecordsDelegate {
- private RepositorySessionFetchRecordsDelegate inner;
- private ExecutorService executor;
+ private final RepositorySessionFetchRecordsDelegate inner;
+ private final ExecutorService executor;
public DeferredRepositorySessionFetchRecordsDelegate(final RepositorySessionFetchRecordsDelegate inner, final ExecutorService executor) {
this.inner = inner;
this.executor = executor;
}
@Override
public void onFetchedRecord(final Record record) {
executor.execute(new Runnable() {
--- a/mobile/android/base/sync/setup/SyncAuthenticatorService.java
+++ b/mobile/android/base/sync/setup/SyncAuthenticatorService.java
@@ -128,17 +128,17 @@ public class SyncAuthenticatorService ex
result.putString(Constants.OPTION_SYNCKEY, syncKey);
// Password.
result.putString(AccountManager.KEY_AUTHTOKEN, password);
return result;
}
private static class SyncAccountAuthenticator extends AbstractAccountAuthenticator {
- private Context mContext;
+ private final Context mContext;
public SyncAccountAuthenticator(Context context) {
super(context);
mContext = context;
}
@Override
public Bundle addAccount(AccountAuthenticatorResponse response,
String accountType, String authTokenType, String[] requiredFeatures,
--- a/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java
+++ b/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java
@@ -19,17 +19,17 @@ import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
public class ClientRecordArrayAdapter extends ArrayAdapter<ClientRecord> {
public static final String LOG_TAG = "ClientRecArrayAdapter";
private boolean[] checkedItems;
- private SendTabActivity sendTabActivity;
+ private final SendTabActivity sendTabActivity;
public ClientRecordArrayAdapter(Context context,
int textViewResourceId) {
super(context, textViewResourceId, new ArrayList<ClientRecord>());
this.checkedItems = new boolean[0];
this.sendTabActivity = (SendTabActivity) context;
}
--- a/mobile/android/base/sync/setup/auth/AccountAuthenticator.java
+++ b/mobile/android/base/sync/setup/auth/AccountAuthenticator.java
@@ -10,17 +10,17 @@ import java.util.Queue;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.sync.ThreadPool;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.sync.setup.activities.AccountActivity;
public class AccountAuthenticator {
private final String LOG_TAG = "AccountAuthenticator";
- private AccountActivity activityCallback;
+ private final AccountActivity activityCallback;
private Queue<AuthenticatorStage> stages;
// Values for authentication.
public String password;
public String username;
public String authServer;
public String nodeServer;
--- a/mobile/android/base/sync/stage/FetchMetaGlobalStage.java
+++ b/mobile/android/base/sync/stage/FetchMetaGlobalStage.java
@@ -13,17 +13,17 @@ import org.mozilla.gecko.sync.delegates.
import org.mozilla.gecko.sync.net.SyncStorageResponse;
public class FetchMetaGlobalStage extends AbstractNonRepositorySyncStage {
private static final String LOG_TAG = "FetchMetaGlobalStage";
private static final String META_COLLECTION = "meta";
public class StageMetaGlobalDelegate implements MetaGlobalDelegate {
- private GlobalSession session;
+ private final GlobalSession session;
public StageMetaGlobalDelegate(GlobalSession session) {
this.session = session;
}
@Override
public void handleSuccess(MetaGlobal global, SyncStorageResponse response) {
Logger.trace(LOG_TAG, "Persisting fetched meta/global and last modified.");
PersistedMetaGlobal pmg = session.config.persistedMetaGlobal();
--- a/mobile/android/base/sync/stage/SafeConstrainedServer11Repository.java
+++ b/mobile/android/base/sync/stage/SafeConstrainedServer11Repository.java
@@ -26,17 +26,17 @@ import android.content.Context;
* You must pass an {@link InfoCounts} instance, which will be interrogated
* in the event of a first sync.
*
* "First sync" means that our sync timestamp is not greater than zero.
*/
public class SafeConstrainedServer11Repository extends ConstrainedServer11Repository {
// This can be lazily evaluated if we need it.
- private JSONRecordFetcher countFetcher;
+ private final JSONRecordFetcher countFetcher;
public SafeConstrainedServer11Repository(String collection,
String storageURL,
AuthHeaderProvider authHeaderProvider,
InfoCollections infoCollections,
long limit,
String sort,
JSONRecordFetcher countFetcher)
@@ -56,17 +56,17 @@ public class SafeConstrainedServer11Repo
public class CountCheckingServer11RepositorySession extends Server11RepositorySession {
private static final String LOG_TAG = "CountCheckingServer11RepositorySession";
/**
* The session will report no data available if this is a first sync
* and the server has more data available than this limit.
*/
- private long fetchLimit;
+ private final long fetchLimit;
public CountCheckingServer11RepositorySession(Repository repository, long fetchLimit) {
super(repository);
this.fetchLimit = fetchLimit;
}
@Override
public boolean shouldSkip() {
--- a/mobile/android/base/sync/syncadapter/SyncAdapter.java
+++ b/mobile/android/base/sync/syncadapter/SyncAdapter.java
@@ -193,17 +193,17 @@ public class SyncAdapter extends Abstrac
*/
@Override
public void requestBackoff(final long backoff) {
if (this.backoffHandler == null) {
throw new IllegalStateException("No backoff handler: requesting backoff outside run()?");
}
if (backoff > 0) {
// Fuzz the backoff time (up to 25% more) to prevent client lock-stepping; agrees with desktop.
- final long fuzzedBackoff = backoff + Math.round((double) backoff * 0.25d * Math.random());
+ final long fuzzedBackoff = backoff + Math.round(backoff * 0.25d * Math.random());
this.backoffHandler.extendEarliestNextRequest(System.currentTimeMillis() + fuzzedBackoff);
}
}
@Override
public boolean shouldBackOffStorage() {
if (thisSyncIsForced) {
/*
--- a/mobile/android/base/sync/synchronizer/ConcurrentRecordConsumer.java
+++ b/mobile/android/base/sync/synchronizer/ConcurrentRecordConsumer.java
@@ -24,17 +24,17 @@ class ConcurrentRecordConsumer extends R
*/
protected boolean allRecordsQueued = false;
private long counter = 0;
public ConcurrentRecordConsumer(RecordsConsumerDelegate delegate) {
this.delegate = delegate;
}
- private Object monitor = new Object();
+ private final Object monitor = new Object();
@Override
public void doNotify() {
synchronized (monitor) {
monitor.notify();
}
}
@Override
@@ -49,17 +49,17 @@ class ConcurrentRecordConsumer extends R
@Override
public void halt() {
synchronized (monitor) {
this.stopImmediately = true;
monitor.notify();
}
}
- private Object countMonitor = new Object();
+ private final Object countMonitor = new Object();
@Override
public void stored() {
Logger.trace(LOG_TAG, "Record stored. Notifying.");
synchronized (countMonitor) {
counter++;
}
}
--- a/mobile/android/base/sync/synchronizer/RecordsChannel.java
+++ b/mobile/android/base/sync/synchronizer/RecordsChannel.java
@@ -64,17 +64,17 @@ public class RecordsChannel implements
RepositorySessionFetchRecordsDelegate,
RepositorySessionStoreDelegate,
RecordsConsumerDelegate,
RepositorySessionBeginDelegate {
private static final String LOG_TAG = "RecordsChannel";
public RepositorySession source;
public RepositorySession sink;
- private RecordsChannelDelegate delegate;
+ private final RecordsChannelDelegate delegate;
private long fetchEnd = -1;
protected final AtomicInteger numFetched = new AtomicInteger();
protected final AtomicInteger numFetchFailed = new AtomicInteger();
protected final AtomicInteger numStored = new AtomicInteger();
protected final AtomicInteger numStoreFailed = new AtomicInteger();
public RecordsChannel(RepositorySession source, RepositorySession sink, RecordsChannelDelegate delegate) {
@@ -89,17 +89,17 @@ public class RecordsChannel implements
* When we tell it to stop, it'll stop. We do that when the fetch
* is completed.
* When it stops, we tell the sink that there are no more records,
* and wait for the sink to tell us that storing is done.
* Then we notify our delegate of completion.
*/
private RecordConsumer consumer;
private boolean waitingForQueueDone = false;
- private ConcurrentLinkedQueue<Record> toProcess = new ConcurrentLinkedQueue<Record>();
+ private final ConcurrentLinkedQueue<Record> toProcess = new ConcurrentLinkedQueue<Record>();
@Override
public ConcurrentLinkedQueue<Record> getQueue() {
return toProcess;
}
protected boolean isReady() {
return source.isActive() && sink.isActive();
--- a/mobile/android/base/sync/synchronizer/SerialRecordConsumer.java
+++ b/mobile/android/base/sync/synchronizer/SerialRecordConsumer.java
@@ -16,17 +16,17 @@ class SerialRecordConsumer extends Recor
private static final String LOG_TAG = "SerialRecordConsumer";
protected boolean stopEventually = false;
private volatile long counter = 0;
public SerialRecordConsumer(RecordsConsumerDelegate delegate) {
this.delegate = delegate;
}
- private Object monitor = new Object();
+ private final Object monitor = new Object();
@Override
public void doNotify() {
synchronized (monitor) {
monitor.notify();
}
}
@Override
@@ -43,17 +43,17 @@ class SerialRecordConsumer extends Recor
Logger.debug(LOG_TAG, "Halting.");
synchronized (monitor) {
this.stopEventually = true;
this.stopImmediately = true;
monitor.notify();
}
}
- private Object storeSerializer = new Object();
+ private final Object storeSerializer = new Object();
@Override
public void stored() {
Logger.debug(LOG_TAG, "Record stored. Notifying.");
synchronized (storeSerializer) {
Logger.debug(LOG_TAG, "stored() took storeSerializer.");
counter++;
storeSerializer.notify();
Logger.debug(LOG_TAG, "stored() dropped storeSerializer.");
--- a/mobile/android/base/tabs/PrivateTabsPanel.java
+++ b/mobile/android/base/tabs/PrivateTabsPanel.java
@@ -22,17 +22,17 @@ import android.widget.FrameLayout;
/**
* A container that wraps the private tabs {@link android.widget.AdapterView} and empty
* {@link android.view.View} to manage both of their visibility states by changing the visibility of
* this container as calling {@link android.widget.AdapterView#setVisibility} does not affect the
* empty View's visibility.
*/
class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
private TabsPanel tabsPanel;
- private TabsLayout tabsLayout;
+ private final TabsLayout tabsLayout;
public PrivateTabsPanel(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.private_tabs_panel, this);
tabsLayout = (TabsLayout) findViewById(R.id.private_tabs_tray);
final View emptyView = findViewById(R.id.private_tabs_empty);
--- a/mobile/android/base/tabs/TabsGridLayout.java
+++ b/mobile/android/base/tabs/TabsGridLayout.java
@@ -28,22 +28,22 @@ import android.widget.Button;
* Expected to replace TabsListLayout once complete.
*/
class TabsGridLayout extends GridView
implements TabsLayout,
Tabs.OnTabsChangedListener {
private static final String LOGTAG = "Gecko" + TabsGridLayout.class.getSimpleName();
- private Context mContext;
+ private final Context mContext;
private TabsPanel mTabsPanel;
final private boolean mIsPrivate;
- private TabsLayoutAdapter mTabsAdapter;
+ private final TabsLayoutAdapter mTabsAdapter;
public TabsGridLayout(Context context, AttributeSet attrs) {
super(context, attrs, R.attr.tabGridLayoutViewStyle);
mContext = context;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabsTray);
mIsPrivate = (a.getInt(R.styleable.TabsTray_tabs, 0x0) == 1);
a.recycle();
--- a/mobile/android/base/tabs/TabsLayoutAdapter.java
+++ b/mobile/android/base/tabs/TabsLayoutAdapter.java
@@ -15,19 +15,19 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.ArrayList;
// Adapter to bind tabs into a list
public class TabsLayoutAdapter extends BaseAdapter {
public static final String LOGTAG = "Gecko" + TabsLayoutAdapter.class.getSimpleName();
- private Context mContext;
+ private final Context mContext;
private ArrayList<Tab> mTabs;
- private LayoutInflater mInflater;
+ private final LayoutInflater mInflater;
public TabsLayoutAdapter (Context context) {
mContext = context;
mInflater = LayoutInflater.from(mContext);
}
final void setTabs (ArrayList<Tab> tabs) {
mTabs = tabs;
--- a/mobile/android/base/tabs/TabsListLayout.java
+++ b/mobile/android/base/tabs/TabsListLayout.java
@@ -31,28 +31,28 @@ import android.view.ViewGroup;
import android.view.ViewConfiguration;
import android.widget.Button;
class TabsListLayout extends TwoWayView
implements TabsLayout,
Tabs.OnTabsChangedListener {
private static final String LOGTAG = "Gecko" + TabsListLayout.class.getSimpleName();
- private Context mContext;
+ private final Context mContext;
private TabsPanel mTabsPanel;
final private boolean mIsPrivate;
- private TabsLayoutAdapter mTabsAdapter;
+ private final TabsLayoutAdapter mTabsAdapter;
- private List<View> mPendingClosedTabs;
+ private final List<View> mPendingClosedTabs;
private int mCloseAnimationCount;
private int mCloseAllAnimationCount;
- private TabSwipeGestureListener mSwipeListener;
+ private final TabSwipeGestureListener mSwipeListener;
// Time to animate non-flinged tabs of screen, in milliseconds
private static final int ANIMATION_DURATION = 250;
// Time between starting successive tab animations in closeAllTabs.
private static final int ANIMATION_CASCADE_DELAY = 75;
private int mOriginalSize;
@@ -82,17 +82,17 @@ class TabsListLayout extends TwoWayView
TabsLayoutItemView item = (TabsLayoutItemView) view;
item.setThumbnail(null);
item.setCloseVisibile(true);
}
});
}
private class TabsListLayoutAdapter extends TabsLayoutAdapter {
- private Button.OnClickListener mCloseOnClickListener;
+ private final Button.OnClickListener mCloseOnClickListener;
public TabsListLayoutAdapter (Context context) {
super(context);
mCloseOnClickListener = new Button.OnClickListener() {
@Override
public void onClick(View v) {
// The view here is the close button, which has a reference
// to the parent TabsLayoutItemView in it's tag, hence the getTag() call
@@ -404,20 +404,20 @@ class TabsListLayout extends TwoWayView
animator.start();
}
private class TabSwipeGestureListener implements View.OnTouchListener {
// same value the stock browser uses for after drag animation velocity in pixels/sec
// http://androidxref.com/4.0.4/xref/packages/apps/Browser/src/com/android/browser/NavTabScroller.java#61
private static final float MIN_VELOCITY = 750;
- private int mSwipeThreshold;
- private int mMinFlingVelocity;
+ private final int mSwipeThreshold;
+ private final int mMinFlingVelocity;
- private int mMaxFlingVelocity;
+ private final int mMaxFlingVelocity;
private VelocityTracker mVelocityTracker;
private int mListWidth = 1;
private int mListHeight = 1;
private View mSwipeView;
private Runnable mPendingCheckForTap;
--- a/mobile/android/base/tabs/TabsPanel.java
+++ b/mobile/android/base/tabs/TabsPanel.java
@@ -74,39 +74,39 @@ public class TabsPanel extends LinearLay
return new TabsListLayout(context, attrs);
}
}
public static interface TabsLayoutChangeListener {
public void onTabsLayoutChange(int width, int height);
}
- private Context mContext;
+ private final Context mContext;
private final GeckoApp mActivity;
private final LightweightTheme mTheme;
private RelativeLayout mHeader;
private PanelViewContainer mPanelsContainer;
private PanelView mPanel;
private PanelView mPanelNormal;
private PanelView mPanelPrivate;
private PanelView mPanelRemote;
private RelativeLayout mFooter;
private TabsLayoutChangeListener mLayoutChangeListener;
- private AppStateListener mAppStateListener;
+ private final AppStateListener mAppStateListener;
private IconTabWidget mTabWidget;
private static ImageButton mMenuButton;
private static ImageButton mAddTab;
private Panel mCurrentPanel;
private boolean mIsSideBar;
private boolean mVisible;
private boolean mHeaderVisible;
- private GeckoPopupMenu mPopupMenu;
+ private final GeckoPopupMenu mPopupMenu;
public TabsPanel(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mActivity = (GeckoApp) context;
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
--- a/mobile/android/base/tests/AboutHomeTest.java
+++ b/mobile/android/base/tests/AboutHomeTest.java
@@ -30,17 +30,17 @@ abstract class AboutHomeTest extends Pix
protected enum AboutHomeTabs {
RECENT_TABS,
HISTORY,
TOP_SITES,
BOOKMARKS,
READING_LIST
};
- private ArrayList<String> aboutHomeTabs = new ArrayList<String>() {{
+ private final ArrayList<String> aboutHomeTabs = new ArrayList<String>() {{
add("TOP_SITES");
add("BOOKMARKS");
add("READING_LIST");
}};
@Override
public void setUp() throws Exception {
--- a/mobile/android/base/tests/DatabaseHelper.java
+++ b/mobile/android/base/tests/DatabaseHelper.java
@@ -9,18 +9,18 @@ import org.mozilla.gecko.db.BrowserDB;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
class DatabaseHelper {
protected enum BrowserDataType {BOOKMARKS, HISTORY};
- private Activity mActivity;
- private Assert mAsserter;
+ private final Activity mActivity;
+ private final Assert mAsserter;
public DatabaseHelper(Activity activity, Assert asserter) {
mActivity = activity;
mAsserter = asserter;
}
/**
* This method can be used to check if an URL is present in the bookmarks database
*/
@@ -87,17 +87,17 @@ class DatabaseHelper {
protected void deleteHistoryItem(String url) {
final ContentResolver resolver = mActivity.getContentResolver();
BrowserDB.removeHistoryEntry(resolver, url);
}
// About the same implementation as getFolderIdFromGuid from LocalBrowserDB because it is declared private and we can't use reflections to access it
protected long getFolderIdFromGuid(String guid) {
ContentResolver resolver = mActivity.getContentResolver();
- long folderId = Long.valueOf(-1);
+ long folderId = -1L;
Uri bookmarksUri = buildUri(BrowserDataType.BOOKMARKS);
Cursor c = null;
try {
c = resolver.query(bookmarksUri,
new String[] { "_id" },
"guid = ?",
new String[] { guid },
null);
--- a/mobile/android/base/tests/MotionEventReplayer.java
+++ b/mobile/android/base/tests/MotionEventReplayer.java
@@ -71,21 +71,21 @@ class MotionEventReplayer {
}
if (value.startsWith("0x")) {
return Integer.parseInt(value.substring(2), 16);
}
return Integer.parseInt(value);
}
private float scaleX(float value) {
- return value * (float)mSurfaceWidth / (float)CAPTURE_WINDOW_WIDTH;
+ return value * mSurfaceWidth / CAPTURE_WINDOW_WIDTH;
}
private float scaleY(float value) {
- return value * (float)mSurfaceHeight / (float)CAPTURE_WINDOW_HEIGHT;
+ return value * mSurfaceHeight / CAPTURE_WINDOW_HEIGHT;
}
public void replayEvents(InputStream eventDescriptions)
throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
// As an example, a line in the input stream might look like:
//
// MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=424.41055, y[0]=825.2412,
--- a/mobile/android/base/tests/SessionTest.java
+++ b/mobile/android/base/tests/SessionTest.java
@@ -40,18 +40,18 @@ public abstract class SessionTest extend
}
public T[] getItems() {
return mItems;
}
}
protected class PageInfo {
- private String url;
- private String title;
+ private final String url;
+ private final String title;
public PageInfo(String key) {
if (key.startsWith("about:")) {
url = key;
} else {
url = getPage(key);
}
title = key;
--- a/mobile/android/base/tests/helpers/AssertionHelper.java
+++ b/mobile/android/base/tests/helpers/AssertionHelper.java
@@ -94,19 +94,19 @@ public final class AssertionHelper {
sAsserter.ok(expected == actual, message, DIAG_STRING);
}
public static void fAssertTrue(final String message, final boolean actual) {
sAsserter.ok(actual, message, DIAG_STRING);
}
public static void fAssertIsPixel(final String message, final int actual, final int r, final int g, final int b) {
- sAsserter.ispixel(actual, r, g, b, message);
+ sAsserter.ispixel(actual, r, g, b, message);
}
public static void fAssertIsNotPixel(final String message, final int actual, final int r, final int g, final int b) {
- sAsserter.isnotpixel(actual, r, g, b, message);
+ sAsserter.isnotpixel(actual, r, g, b, message);
}
public static void fFail(final String message) {
sAsserter.ok(false, message, DIAG_STRING);
}
}
--- a/mobile/android/base/tests/testBookmark.java
+++ b/mobile/android/base/tests/testBookmark.java
@@ -1,14 +1,14 @@
package org.mozilla.gecko.tests;
public class testBookmark extends AboutHomeTest {
private static String BOOKMARK_URL;
- private static int WAIT_FOR_BOOKMARKED_TIMEOUT = 10000;
+ private static final int WAIT_FOR_BOOKMARKED_TIMEOUT = 10000;
public void testBookmark() {
BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
runAboutHomeTest();
runMenuTest();
}
public void runMenuTest() {
--- a/mobile/android/base/tests/testNewTab.java
+++ b/mobile/android/base/tests/testNewTab.java
@@ -7,17 +7,17 @@ import android.app.Activity;
import android.view.View;
import com.jayway.android.robotium.solo.Condition;
/* A simple test that creates 2 new tabs and checks that the tab count increases. */
public class testNewTab extends BaseTest {
private Element tabCount = null;
private Element tabs = null;
- private Element closeTab = null;
+ private final Element closeTab = null;
private int tabCountInt = 0;
public void testNewTab() {
String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
String url2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
blockForGeckoReady();
--- a/mobile/android/base/tests/testReadingListProvider.java
+++ b/mobile/android/base/tests/testReadingListProvider.java
@@ -46,17 +46,17 @@ public class testReadingListProvider ext
private boolean mContentProviderUpdateTested = false;
/**
* Factory function that makes new ReadingListProvider instances.
* <p>
* We want a fresh provider each test, so this should be invoked in
* <code>setUp</code> before each individual test.
*/
- private static Callable<ContentProvider> sProviderFactory = new Callable<ContentProvider>() {
+ private static final Callable<ContentProvider> sProviderFactory = new Callable<ContentProvider>() {
@Override
public ContentProvider call() {
return new ReadingListProvider();
}
};
@Override
public void setUp() throws Exception {
--- a/mobile/android/base/tests/testSearchHistoryProvider.java
+++ b/mobile/android/base/tests/testSearchHistoryProvider.java
@@ -78,17 +78,17 @@ public class testSearchHistoryProvider e
private static final String DB_NAME = "searchhistory.db";
/**
* Boilerplate alert.
* <p/>
* Make sure this method is present and that it returns a new
* instance of your class.
*/
- private static Callable<ContentProvider> sProviderFactory =
+ private static final Callable<ContentProvider> sProviderFactory =
new Callable<ContentProvider>() {
@Override
public ContentProvider call() {
return new SearchHistoryProvider();
}
};
@Override
--- a/mobile/android/base/tests/testThumbnails.java
+++ b/mobile/android/base/tests/testThumbnails.java
@@ -57,18 +57,18 @@ public class testThumbnails extends Base
// drop thumbnails
BrowserDB.removeThumbnails(resolver);
// check that the thumbnail is now null
thumbnailData = BrowserDB.getThumbnailForUrl(resolver, site1Url);
mAsserter.ok(thumbnailData == null || thumbnailData.length == 0, "Checking for thumbnail data", "Thumbnail data found");
}
private class ThumbnailTest implements BooleanTest {
- private String mTitle;
- private int mColor;
+ private final String mTitle;
+ private final int mColor;
public ThumbnailTest(String title, int color) {
mTitle = title;
mColor = color;
}
@Override
public boolean test() {
--- a/mobile/android/base/toolbar/PageActionLayout.java
+++ b/mobile/android/base/toolbar/PageActionLayout.java
@@ -298,22 +298,22 @@ public class PageActionLayout extends Li
}
private static interface OnPageActionClickListeners {
public void onClick(String id);
public boolean onLongClick(String id);
}
private static class PageAction {
- private OnPageActionClickListeners mOnPageActionClickListeners;
+ private final OnPageActionClickListeners mOnPageActionClickListeners;
private Drawable mDrawable;
- private String mTitle;
- private String mId;
- private int key;
- private boolean mImportant;
+ private final String mTitle;
+ private final String mId;
+ private final int key;
+ private final boolean mImportant;
public PageAction(String id,
String title,
Drawable image,
OnPageActionClickListeners onPageActionClickListeners,
boolean important) {
mId = id;
mTitle = title;
--- a/mobile/android/base/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/toolbar/ToolbarDisplayLayout.java
@@ -92,39 +92,39 @@ public class ToolbarDisplayLayout extend
}
private final BrowserApp mActivity;
private UIMode mUiMode;
private boolean mIsAttached;
- private ThemedTextView mTitle;
- private int mTitlePadding;
+ private final ThemedTextView mTitle;
+ private final int mTitlePadding;
private ToolbarPrefs mPrefs;
private OnTitleChangeListener mTitleChangeListener;
- private ImageButton mSiteSecurity;
+ private final ImageButton mSiteSecurity;
private boolean mSiteSecurityVisible;
// To de-bounce sets.
private Bitmap mLastFavicon;
- private ImageButton mFavicon;
+ private final ImageButton mFavicon;
private int mFaviconSize;
- private ImageButton mStop;
+ private final ImageButton mStop;
private OnStopListener mStopListener;
- private PageActionLayout mPageActionLayout;
+ private final PageActionLayout mPageActionLayout;
private AlphaAnimation mLockFadeIn;
private TranslateAnimation mTitleSlideLeft;
private TranslateAnimation mTitleSlideRight;
- private SiteIdentityPopup mSiteIdentityPopup;
+ private final SiteIdentityPopup mSiteIdentityPopup;
private SecurityMode mSecurityMode;
private PropertyAnimator mForwardAnim;
private final ForegroundColorSpan mUrlColor;
private final ForegroundColorSpan mBlockedColor;
private final ForegroundColorSpan mDomainColor;
private final ForegroundColorSpan mPrivateDomainColor;
--- a/mobile/android/base/updater/UpdateService.java
+++ b/mobile/android/base/updater/UpdateService.java
@@ -388,20 +388,20 @@ public class UpdateService extends Inten
if (downloadFile != null)
notificationIntent.putExtra(UpdateServiceHelper.EXTRA_PACKAGE_PATH_NAME, downloadFile.getAbsolutePath());
PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent deleteIntent = PendingIntent.getService(this, 0, cancelIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(getResources().getString(R.string.updater_downloading_title))
- .setContentText(mApplyImmediately ? "" : getResources().getString(R.string.updater_downloading_select))
- .setSmallIcon(android.R.drawable.stat_sys_download)
- .setContentIntent(contentIntent)
- .setDeleteIntent(deleteIntent);
+ .setContentText(mApplyImmediately ? "" : getResources().getString(R.string.updater_downloading_select))
+ .setSmallIcon(android.R.drawable.stat_sys_download)
+ .setContentIntent(contentIntent)
+ .setDeleteIntent(deleteIntent);
mBuilder.setProgress(100, 0, true);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
private void showDownloadFailure() {
Notification notification = new Notification(R.drawable.ic_status_logo, null, System.currentTimeMillis());
@@ -475,20 +475,20 @@ public class UpdateService extends Inten
int bytesRead = 0;
int lastNotify = 0;
while ((len = input.read(buf, 0, BUFSIZE)) > 0 && !mCancelDownload) {
output.write(buf, 0, len);
bytesRead += len;
// Updating the notification takes time so only do it every 1MB
- if(bytesRead - lastNotify > 1048576) {
- mBuilder.setProgress(length, bytesRead, false);
- mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
- lastNotify = bytesRead;
+ if (bytesRead - lastNotify > 1048576) {
+ mBuilder.setProgress(length, bytesRead, false);
+ mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
+ lastNotify = bytesRead;
}
}
mNotificationManager.cancel(NOTIFICATION_ID);
// if the download was canceled by the user
// delete the update package
if (mCancelDownload) {
--- a/mobile/android/base/util/ActivityResultHandlerMap.java
+++ b/mobile/android/base/util/ActivityResultHandlerMap.java
@@ -2,17 +2,17 @@
* 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.util;
import android.util.SparseArray;
public final class ActivityResultHandlerMap {
- private SparseArray<ActivityResultHandler> mMap = new SparseArray<ActivityResultHandler>();
+ private final SparseArray<ActivityResultHandler> mMap = new SparseArray<ActivityResultHandler>();
private int mCounter;
public synchronized int put(ActivityResultHandler handler) {
mMap.put(mCounter, handler);
return mCounter++;
}
public synchronized ActivityResultHandler getAndRemove(int i) {
--- a/mobile/android/base/util/INIParser.java
+++ b/mobile/android/base/util/INIParser.java
@@ -11,17 +11,17 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
public final class INIParser extends INISection {
// default file to read and write to
- private File mFile;
+ private final File mFile;
// List of sections in the current iniFile. null if the file has not been parsed yet
private Hashtable<String, INISection> mSections;
// create a parser. The file will not be read until you attempt to
// access sections or properties inside it. At that point its read synchronously
public INIParser(File iniFile) {
super("");
--- a/mobile/android/base/util/NativeJSContainer.java
+++ b/mobile/android/base/util/NativeJSContainer.java
@@ -13,17 +13,17 @@ import org.mozilla.gecko.mozglue.JNITarg
*
* A container must only be used on the thread it is attached to. To use it on another
* thread, call {@link #clone()} to make a copy, and use the copy on the other thread.
* When a copy is first used, it becomes attached to the thread using it.
*/
@JNITarget
public final class NativeJSContainer extends NativeJSObject
{
- private long mNativeObject;
+ private final long mNativeObject;
private NativeJSContainer(long nativeObject) {
mNativeObject = nativeObject;
}
/**
* Make a copy of this container for use by another thread. When the copy is first used,
* it becomes attached to the thread using it.
--- a/mobile/android/base/util/UIAsyncTask.java
+++ b/mobile/android/base/util/UIAsyncTask.java
@@ -67,17 +67,17 @@ public abstract class UIAsyncTask<Param,
if (sHandler == null) {
sHandler = new Handler(Looper.getMainLooper());
}
return sHandler;
}
private final class BackgroundTaskRunnable implements Runnable {
- private Param mParam;
+ private final Param mParam;
public BackgroundTaskRunnable(Param param) {
mParam = param;
}
@Override
public void run() {
final Result result = doInBackground(mParam);
--- a/mobile/android/base/webapp/InstallListener.java
+++ b/mobile/android/base/webapp/InstallListener.java
@@ -5,39 +5,40 @@
package org.mozilla.gecko.webapp;
import java.io.File;
import java.io.IOException;
import org.json.JSONException;
import org.json.JSONObject;
+import org.mozilla.gecko.Assert;
import org.mozilla.gecko.GeckoThread;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import android.util.Log;
public class InstallListener extends BroadcastReceiver {
- private static String LOGTAG = "GeckoWebappInstallListener";
- private JSONObject mData;
- private String mManifestUrl;
+ private static final String LOGTAG = "GeckoWebappInstallListener";
+ private final JSONObject mData;
+ private final String mManifestUrl;
private boolean mReceived;
- private File mApkFile;
+ private final File mApkFile;
public InstallListener(String manifestUrl, JSONObject data, File apkFile) {
mData = data;
mApkFile = apkFile;
mManifestUrl = manifestUrl;
- assert mManifestUrl != null;
- assert mApkFile != null && mApkFile.exists();
+ Assert.isNotNull(mManifestUrl);
+ Assert.isTrue(mApkFile != null && mApkFile.exists());
}
public boolean isReceived() {
return mReceived;
}
@Override
public void onReceive(Context context, Intent intent) {
--- a/mobile/android/base/webapp/UninstallListener.java
+++ b/mobile/android/base/webapp/UninstallListener.java
@@ -29,17 +29,17 @@ import android.content.pm.PackageManager
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.ArrayList;
public class UninstallListener extends BroadcastReceiver {
- private static String LOGTAG = "GeckoWebappUninstallListener";
+ private static final String LOGTAG = "GeckoWebappUninstallListener";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
Log.i(LOGTAG, "Package is being replaced; ignoring removal intent");
return;
}
@@ -131,17 +131,17 @@ public class UninstallListener extends B
}
if (uninstalledPackages.size() > 0) {
doUninstall(context, uninstalledPackages);
}
}
public static class DelayedStartupTask implements Runnable {
- private GeckoApp mApp;
+ private final GeckoApp mApp;
public DelayedStartupTask(GeckoApp app) {
mApp = app;
}
@Override
public void run() {
ThreadUtils.assertOnBackgroundThread();
--- a/mobile/android/base/widget/ArrowPopup.java
+++ b/mobile/android/base/widget/ArrowPopup.java
@@ -23,17 +23,17 @@ import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
public abstract class ArrowPopup extends PopupWindow {
View mAnchor;
ImageView mArrow;
int mArrowWidth;
- private int mYOffset;
+ private final int mYOffset;
protected LinearLayout mContent;
protected boolean mInflated;
protected final Context mContext;
public ArrowPopup(Context context) {
super(context);
--- a/mobile/android/base/widget/ButtonToast.java
+++ b/mobile/android/base/widget/ButtonToast.java
@@ -160,15 +160,15 @@ public class ButtonToast {
mView.setVisibility(View.GONE);
}
public void onPropertyAnimationStart() { }
});
animator.start();
}
}
- private Runnable mHideRunnable = new Runnable() {
+ private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide(false, ReasonHidden.TIMEOUT);
}
};
}
--- a/mobile/android/base/widget/DateTimePicker.java
+++ b/mobile/android/base/widget/DateTimePicker.java
@@ -53,19 +53,19 @@ public class DateTimePicker extends Fram
boolean mWeekEnabled;
boolean mDayEnabled = true;
boolean mHourEnabled = true;
boolean mMinuteEnabled = true;
boolean mIs12HourMode;
private boolean mCalendarEnabled;
// Size of the screen in inches;
- private int mScreenWidth;
- private int mScreenHeight;
- private OnValueChangeListener mOnChangeListener;
+ private final int mScreenWidth;
+ private final int mScreenHeight;
+ private final OnValueChangeListener mOnChangeListener;
private final LinearLayout mPickers;
private final LinearLayout mDateSpinners;
private final LinearLayout mTimeSpinners;
final NumberPicker mDaySpinner;
final NumberPicker mMonthSpinner;
final NumberPicker mWeekSpinner;
final NumberPicker mYearSpinner;
@@ -84,17 +84,17 @@ public class DateTimePicker extends Fram
private String[] mShortMonths;
private String[] mShortAMPMs;
private int mNumberOfMonths;
Calendar mTempDate;
Calendar mCurrentDate;
private Calendar mMinDate;
private Calendar mMaxDate;
- private PickersState mState;
+ private final PickersState mState;
public static enum PickersState { DATE, MONTH, WEEK, TIME, DATETIME };
public class OnValueChangeListener implements NumberPicker.OnValueChangeListener {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
updateInputState();
mTempDate.setTimeInMillis(mCurrentDate.getTimeInMillis());
--- a/mobile/android/base/widget/Divider.java
+++ b/mobile/android/base/widget/Divider.java
@@ -11,17 +11,17 @@ import android.widget.LinearLayout.Layou
public class Divider extends View {
public static enum Orientation { HORIZONTAL, VERTICAL };
// Orientation of the divider.
private Orientation mOrientation;
// Density of the device.
- private int mDensity;
+ private final int mDensity;
public Divider(Context context, AttributeSet attrs) {
super(context, attrs);
mDensity = (int) context.getResources().getDisplayMetrics().density;
setOrientation(Orientation.HORIZONTAL);
}
--- a/mobile/android/base/widget/DoorHanger.java
+++ b/mobile/android/base/widget/DoorHanger.java
@@ -37,17 +37,17 @@ import java.util.List;
public class DoorHanger extends LinearLayout {
private static final String LOGTAG = "GeckoDoorHanger";
private static int sInputPadding = -1;
private static int sSpinnerTextColor = -1;
private static int sSpinnerTextSize = -1;
- private static LayoutParams sButtonParams;
+ private static final LayoutParams sButtonParams;
static {
sButtonParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
}
private final TextView mTextView;
private final ImageView mIcon;
private final LinearLayout mChoicesLayout;
@@ -55,17 +55,17 @@ public class DoorHanger extends LinearLa
private final View mDivider;
// The tab associated with this notification.
private final int mTabId;
// Value used to identify the notification.
private final String mValue;
- private Resources mResources;
+ private final Resources mResources;
private List<PromptInput> mInputs;
private CheckBox mCheckBox;
private int mPersistence;
private boolean mPersistWhileVisible;
private long mTimeout;
--- a/mobile/android/base/widget/EllipsisTextView.java
+++ b/mobile/android/base/widget/EllipsisTextView.java
@@ -13,17 +13,17 @@ import android.util.AttributeSet;
import android.widget.TextView;
/**
* Text view that correctly handles maxLines and ellipsizing for Android < 2.3.
*/
public class EllipsisTextView extends TextView {
private final String ellipsis;
- private int maxLines;
+ private final int maxLines;
private CharSequence originalText;
public EllipsisTextView(Context context) {
this(context, null);
}
public EllipsisTextView(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.textViewStyle);
--- a/mobile/android/base/widget/FadedTextView.java
+++ b/mobile/android/base/widget/FadedTextView.java
@@ -82,17 +82,17 @@ public class FadedTextView extends Theme
private static class FadedTextGradient extends LinearGradient {
private final int mWidth;
private final int mColor;
public FadedTextGradient(int width, int fadeWidth, int color) {
super(0, 0, width, 0,
new int[] { color, color, 0x0 },
- new float[] { 0, ((float) (width - fadeWidth) / (float) width), 1.0f },
+ new float[] { 0, ((float) (width - fadeWidth) / width), 1.0f },
Shader.TileMode.CLAMP);
mWidth = width;
mColor = color;
}
public int getWidth() {
return mWidth;
--- a/mobile/android/base/widget/FaviconView.java
+++ b/mobile/android/base/widget/FaviconView.java
@@ -40,20 +40,20 @@ public class FaviconView extends ImageVi
// Dominant color of the favicon.
private int mDominantColor;
// Stroke width for the border.
private static float sStrokeWidth;
// Paint for drawing the stroke.
- private static Paint sStrokePaint;
+ private static final Paint sStrokePaint;
// Paint for drawing the background.
- private static Paint sBackgroundPaint;
+ private static final Paint sBackgroundPaint;
// Size of the stroke rectangle.
private final RectF mStrokeRect;
// Size of the background rectangle.
private final RectF mBackgroundRect;
// Initializing the static paints.
--- a/mobile/android/base/widget/GeckoActionProvider.java
+++ b/mobile/android/base/widget/GeckoActionProvider.java
@@ -22,17 +22,17 @@ import android.view.SubMenu;
import android.view.View;
import android.view.View.OnClickListener;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.HashMap;
public class GeckoActionProvider {
- private static int MAX_HISTORY_SIZE = 2;
+ private static final int MAX_HISTORY_SIZE = 2;
/**
* A listener to know when a target was selected.
* When setting a provider, the activity can listen to this,
* to close the menu.
*/
public interface OnTargetSelectedListener {
public void onTargetSelected();
@@ -46,17 +46,17 @@ public class GeckoActionProvider {
// History file.
String mHistoryFileName = DEFAULT_HISTORY_FILE_NAME;
OnTargetSelectedListener mOnTargetListener;
private final Callbacks mCallbacks = new Callbacks();
- private static HashMap<String, GeckoActionProvider> mProviders = new HashMap<String, GeckoActionProvider>();
+ private static final HashMap<String, GeckoActionProvider> mProviders = new HashMap<String, GeckoActionProvider>();
private static String getFilenameFromMimeType(String mimeType) {
String[] mime = mimeType.split("/");
// All text mimetypes use the default provider
if ("text".equals(mime[0])) {
return DEFAULT_HISTORY_FILE_NAME;
}
--- a/mobile/android/base/widget/GeckoSwipeRefreshLayout.java
+++ b/mobile/android/base/widget/GeckoSwipeRefreshLayout.java
@@ -69,20 +69,20 @@ public class GeckoSwipeRefreshLayout ext
int mFrom;
int mMediumAnimationDuration;
float mFromPercentage;
float mCurrPercentage;
int mCurrentTargetOffsetTop;
private OnRefreshListener mListener;
private MotionEvent mDownEvent;
private boolean mRefreshing;
- private int mTouchSlop;
+ private final int mTouchSlop;
private float mDistanceToTriggerSync = -1;
private float mPrevY;
- private int mProgressBarHeight;
+ private final int mProgressBarHeight;
// Target is returning to its start offset because it was cancelled or a
// refresh was triggered.
boolean mReturningToStart;
final DecelerateInterpolator mDecelerateInterpolator;
private final AccelerateInterpolator mAccelerateInterpolator;
private static final int[] LAYOUT_ATTRS = new int[] {
android.R.attr.enabled
@@ -522,19 +522,19 @@ public class GeckoSwipeRefreshLayout ext
private long mFinishTime;
private boolean mRunning;
// Colors used when rendering the animation,
private int mColor1;
private int mColor2;
private int mColor3;
private int mColor4;
- private View mParent;
+ private final View mParent;
- private Rect mBounds = new Rect();
+ private final Rect mBounds = new Rect();
public SwipeProgressBar(View parent) {
mParent = parent;
mColor1 = COLOR1;
mColor2 = COLOR2;
mColor3 = COLOR3;
mColor4 = COLOR4;
}
--- a/mobile/android/base/widget/GeckoViewFlipper.java
+++ b/mobile/android/base/widget/GeckoViewFlipper.java
@@ -13,17 +13,17 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ViewFlipper;
/* This extends the normal ViewFlipper only to fix bug 956075 on < 3.0 devices.
* i.e. It ignores touch events on the ViewFlipper when its hidden. */
public class GeckoViewFlipper extends ViewFlipper {
- private Rect mRect = new Rect();
+ private final Rect mRect = new Rect();
public GeckoViewFlipper(Context context) {
super(context);
}
public GeckoViewFlipper(Context context, AttributeSet attrs) {
super(context, attrs);
}
--- a/mobile/android/base/widget/SwipeDismissListViewTouchListener.java
+++ b/mobile/android/base/widget/SwipeDismissListViewTouchListener.java
@@ -71,24 +71,24 @@ import org.mozilla.gecko.R;
*
* <p>For a generalized {@link android.view.View.OnTouchListener} that makes any view dismissable,
* see {@link SwipeDismissTouchListener}.</p>
*
* @see SwipeDismissTouchListener
*/
public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
// Cached ViewConfiguration and system-wide constant values
- private int mSlop;
- private int mMinFlingVelocity;
- private int mMaxFlingVelocity;
- private long mAnimationTime;
+ private final int mSlop;
+ private final int mMinFlingVelocity;
+ private final int mMaxFlingVelocity;
+ private final long mAnimationTime;
// Fixed properties
- private ListView mListView;
- private OnDismissCallback mCallback;
+ private final ListView mListView;
+ private final OnDismissCallback mCallback;
private int mViewWidth = 1; // 1 and not 0 to prevent dividing by zero
// Transient properties
private float mDownX;
private boolean mSwiping;
private VelocityTracker mVelocityTracker;
private int mDownPosition;
private View mDownView;
--- a/mobile/android/base/widget/TabThumbnailWrapper.java
+++ b/mobile/android/base/widget/TabThumbnailWrapper.java
@@ -23,17 +23,17 @@ public class TabThumbnailWrapper extends
}
@Override
public int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (mRecording) {
mergeDrawableStates(drawableState, STATE_RECORDING);
- }
+ }
return drawableState;
}
public void setRecording(boolean recording) {
if (mRecording != recording) {
mRecording = recording;
refreshDrawableState();
}
--- a/mobile/android/base/widget/ThemedEditText.java.in
+++ b/mobile/android/base/widget/ThemedEditText.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX EditText
-#define BASE_TYPE android.widget.EditText
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX EditText
+//#define BASE_TYPE android.widget.EditText
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedImageButton.java.in
+++ b/mobile/android/base/widget/ThemedImageButton.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX ImageButton
-#define BASE_TYPE android.widget.ImageButton
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX ImageButton
+//#define BASE_TYPE android.widget.ImageButton
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedImageView.java.in
+++ b/mobile/android/base/widget/ThemedImageView.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX ImageView
-#define BASE_TYPE android.widget.ImageView
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX ImageView
+//#define BASE_TYPE android.widget.ImageView
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedLinearLayout.java.in
+++ b/mobile/android/base/widget/ThemedLinearLayout.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX LinearLayout
-#define BASE_TYPE android.widget.LinearLayout
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX LinearLayout
+//#define BASE_TYPE android.widget.LinearLayout
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedRelativeLayout.java.in
+++ b/mobile/android/base/widget/ThemedRelativeLayout.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX RelativeLayout
-#define BASE_TYPE android.widget.RelativeLayout
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX RelativeLayout
+//#define BASE_TYPE android.widget.RelativeLayout
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedTextSwitcher.java.in
+++ b/mobile/android/base/widget/ThemedTextSwitcher.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX TextSwitcher
-#define BASE_TYPE android.widget.TextSwitcher
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX TextSwitcher
+//#define BASE_TYPE android.widget.TextSwitcher
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedTextView.java.in
+++ b/mobile/android/base/widget/ThemedTextView.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX TextView
-#define BASE_TYPE android.widget.TextView
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX TextView
+//#define BASE_TYPE android.widget.TextView
+//#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedView.java.in
+++ b/mobile/android/base/widget/ThemedView.java.in
@@ -1,4 +1,4 @@
-#filter substitution
-#define VIEW_NAME_SUFFIX View
-#define BASE_TYPE android.view.View
-#include ThemedView.java.frag
+//#filter substitution
+//#define VIEW_NAME_SUFFIX View
+//#define BASE_TYPE android.view.View
+//#include ThemedView.java.frag
--- a/mobile/android/search/java/org/mozilla/search/providers/SearchEngine.java
+++ b/mobile/android/search/java/org/mozilla/search/providers/SearchEngine.java
@@ -47,17 +47,17 @@ public class SearchEngine {
// head of a web page. The actual CSS is inserted at `%s`.
private static final String STYLE_INJECTION_SCRIPT =
"javascript:(function(){" +
"var tag=document.createElement('style');" +
"tag.type='text/css';" +
"document.getElementsByTagName('head')[0].appendChild(tag);" +
"tag.innerText='%s'})();";
- private String identifier;
+ private final String identifier;
private String shortName;
private String iconURL;
// Ordered list of preferred results URIs.
private final List<Uri> resultsUris = new ArrayList<Uri>();
private Uri suggestUri;
/**
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/datahandling/DataStorageManager.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/datahandling/DataStorageManager.java
@@ -62,17 +62,17 @@ public class DataStorageManager {
private final File mReportsDir;
private final File mStatsFile;
private final StorageIsEmptyTracker mTracker;
private static DataStorageManager sInstance;
private ReportBatch mCurrentReportsSendBuffer;
private ReportBatchIterator mReportBatchIterator;
- private ReportFileList mFileList;
+ private final ReportFileList mFileList;
private Timer mFlushMemoryBuffersToDiskTimer;
static final String SEP_REPORT_COUNT = "-r";
static final String SEP_WIFI_COUNT = "-w";
static final String SEP_CELL_COUNT = "-c";
static final String SEP_TIME_MS = "-t";
static final String FILENAME_PREFIX = "reports";
static final String MEMORY_BUFFER_NAME = "in memory send buffer";
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/WifiScanner.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/WifiScanner.java
@@ -43,17 +43,17 @@ public class WifiScanner extends Broadca
private static final String LOG_TAG = AppGlobals.LOG_PREFIX + WifiScanner.class.getSimpleName();
private static final long WIFI_MIN_UPDATE_TIME = 5000; // milliseconds
private boolean mStarted;
private final Context mContext;
private WifiLock mWifiLock;
private Timer mWifiScanTimer;
private final Set<String> mAPs = Collections.synchronizedSet(new HashSet<String>());
- private AtomicInteger mVisibleAPs = new AtomicInteger();
+ private final AtomicInteger mVisibleAPs = new AtomicInteger();
/* Testing */
public static boolean sIsTestMode;
public List<ScanResult> mTestModeFakeScanResults = new ArrayList<ScanResult>();
public Set<String> getAccessPoints(android.test.AndroidTestCase restrictedAccessor) { return mAPs; }
/* ------- */
public WifiScanner(Context c) {
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/uploadthread/AsyncUploader.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/uploadthread/AsyncUploader.java
@@ -23,17 +23,17 @@ import org.mozilla.mozstumbler.service.u
* Uploads on a separate thread. ONLY DataStorageManager is thread-safe, do not call
* preferences, do not call any code that isn't thread-safe. You will cause suffering.
* An exception is made for AppGlobals.isDebug, a false reading is of no consequence. */
public class AsyncUploader extends AsyncTask<Void, Void, SyncSummary> {
private static final String LOG_TAG = AppGlobals.LOG_PREFIX + AsyncUploader.class.getSimpleName();
private final UploadSettings mSettings;
private final Object mListenerLock = new Object();
private AsyncUploaderListener mListener;
- private static AtomicBoolean sIsUploading = new AtomicBoolean();
+ private static final AtomicBoolean sIsUploading = new AtomicBoolean();
private String mNickname;
public interface AsyncUploaderListener {
public void onUploadComplete(SyncSummary result);
public void onUploadProgress();
}
public static class UploadSettings {
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/utils/PersistentIntentService.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/utils/PersistentIntentService.java
@@ -23,17 +23,17 @@ import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
/* This code is copied from android IntentService, with stopSelf commented out. */
public abstract class PersistentIntentService extends Service {
private volatile Looper mServiceLooper;
private volatile ServiceHandler mServiceHandler;
- private String mName;
+ private final String mName;
private boolean mRedelivery;
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
@Override
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -708,28 +708,30 @@ var LoginManagerContent = {
var didFillForm = false;
if (selectedLogin && autofillForm && !isFormDisabled) {
// Fill the form
if (usernameField) {
// Don't modify the username field if it's disabled or readOnly so we preserve its case.
let disabledOrReadOnly = usernameField.disabled || usernameField.readOnly;
+ let userNameDiffers = selectedLogin.username != usernameField.value;
// Don't replace the username if it differs only in case, and the user triggered
// this autocomplete. We assume that if it was user-triggered the entered text
// is desired.
- let userEnteredDifferentCase = userTriggered &&
- (usernameField.value != selectedLogin.username &&
- usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase());
+ let userEnteredDifferentCase = userTriggered && userNameDiffers &&
+ usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase();
- if (!disabledOrReadOnly && !userEnteredDifferentCase) {
+ if (!disabledOrReadOnly && !userEnteredDifferentCase && userNameDiffers) {
usernameField.setUserInput(selectedLogin.username);
}
}
- passwordField.setUserInput(selectedLogin.password);
+ if (passwordField.value != selectedLogin.password) {
+ passwordField.setUserInput(selectedLogin.password);
+ }
didFillForm = true;
} else if (selectedLogin && !autofillForm) {
// For when autofillForm is false, but we still have the information
// to fill a form, we notify observers.
didntFillReason = "noAutofillForms";
Services.obs.notifyObservers(form, "passwordmgr-found-form", didntFillReason);
log("autofillForms=false but form can be filled; notified observers");
} else if (selectedLogin && isFormDisabled) {
--- a/toolkit/components/passwordmgr/test/mochitest.ini
+++ b/toolkit/components/passwordmgr/test/mochitest.ini
@@ -56,16 +56,17 @@ skip-if = true
[test_bug_391514.html]
[test_bug_427033.html]
[test_bug_444968.html]
[test_bug_627616.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug_654348.html]
[test_bug_776171.html]
[test_input_events.html]
+[test_input_events_for_identical_values.html]
[test_master_password.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_master_password_cleanup.html]
skip-if = toolkit == 'android'
[test_notifications.html]
skip-if = toolkit == 'android'
[test_notifications_popup.html]
skip-if = os == "linux" || toolkit == 'android' # bug 934057
new file mode 100644
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/test_input_events_for_identical_values.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for input events in Login Manager when username/password are filled in already</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="text/javascript" src="pwmgr_common.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="onNewEvent(event)">
+Login Manager test: input events should fire.
+
+<script>
+commonInit();
+SimpleTest.waitForExplicitFinish();
+
+/** Test for Login Manager: form fill when form is already filled, should not get input events. **/
+
+var onloadFired = false;
+
+function onNewEvent(e) {
+ console.error("Got " + e.type + " event.");
+ if (e.type == "load") {
+ onloadFired = true;
+ $_(1, "uname").focus();
+ sendKey("Tab");
+ } else {
+ ok(false, "Got an input event for " + e.target.name + " field, which shouldn't happen.");
+ }
+}
+
+SimpleTest.registerCleanupFunction(function cleanup() {
+ $_(1, "uname").removeAttribute("oninput");
+ $_(1, "pword").removeAttribute("onfocus");
+ $_(1, "pword").removeAttribute("oninput");
+ document.body.removeAttribute("onload");
+});
+</script>
+
+<p id="display"></p>
+
+<div id="content">
+
+ <form id="form1" action="formtest.js">
+ <p>This is form 1.</p>
+ <input type="text" name="uname" oninput="onNewEvent(event)" value="testuser">
+ <input type="password" name="pword" oninput="onNewEvent(event)" onfocus="setTimeout(function() { SimpleTest.finish() }, 1000);" value="testpass">
+
+ <button type="submit">Submit</button>
+ <button type="reset"> Reset </button>
+ </form>
+
+</div>
+<pre id="test"></pre>
+</body>
+</html>
--- a/toolkit/content/aboutSupport.xhtml
+++ b/toolkit/content/aboutSupport.xhtml
@@ -25,20 +25,19 @@
src="chrome://global/content/aboutSupport.js"/>
<script type="application/javascript;version=1.7"
src="chrome://global/content/resetProfile.js"/>
</head>
<body dir="&locale.dir;">
<div id="reset-box">
- <h3>&resetProfile.title;</h3>
- <p>&resetProfile.description;</p>
+ <h3>&refreshProfile.title;</h3>
<button id="reset-box-button">
- &resetProfile.button.label2;
+ &refreshProfile.button.label;
</button>
</div>
<h1>
&aboutSupport.pageTitle;
</h1>
<div class="page-subtitle">
--- a/toolkit/content/resetProfile.js
+++ b/toolkit/content/resetProfile.js
@@ -9,31 +9,12 @@
// Proceed with caution:
if (!("Cu" in window)) {
window.Cu = Components.utils;
}
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ResetProfile.jsm");
-// based on onImportItemsPageShow from migration.js
-function populateResetPane(aContainerID) {
- let resetProfileItems = document.getElementById(aContainerID);
- try {
- let dataTypes = ResetProfile.getMigratedData();
- for (let dataType of dataTypes) {
- let label = document.createElement("label");
- label.setAttribute("value", dataType);
- resetProfileItems.appendChild(label);
- }
- } catch (ex) {
- Cu.reportError(ex);
- }
-}
-
-function onResetProfileLoad() {
- populateResetPane("migratedItems");
-}
-
function onResetProfileAccepted() {
let retVals = window.arguments[0];
retVals.reset = true;
}
--- a/toolkit/content/resetProfile.xul
+++ b/toolkit/content/resetProfile.xul
@@ -11,27 +11,25 @@
%resetProfileDTD;
]>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://global/content/resetProfile.css"?>
<dialog id="resetProfileDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- title="&resetProfile.dialog.title;"
+ title="&refreshProfile.dialog.title;"
buttons="accept,cancel"
defaultButton="cancel"
- buttonlabelaccept="&resetProfile.dialog.button.label;"
+ buttonlabelaccept="&refreshProfile.dialog.button.label;"
ondialogaccept="return onResetProfileAccepted();"
- ondialogcancel="window.close();"
- onload="onResetProfileLoad();">
+ ondialogcancel="window.close();">
<script type="application/javascript" src="chrome://global/content/resetProfile.js"/>
- <description>&resetProfile.dialog.description;</description>
+ <description value="&refreshProfile.dialog.description1;"></description>
+ <label value="&refreshProfile.dialog.description2;"/>
- <label value="&resetProfile.dialog.items2.label;"/>
<vbox id="migratedItems">
+ <label class="migratedLabel" value="&refreshProfile.dialog.items.label1;"/>
+ <label class="migratedLabel" value="&refreshProfile.dialog.items.label2;"/>
</vbox>
-
- <label id="resetProfileFooter" value="&resetProfile.dialog.footer.label;"/>
-
</dialog>
--- a/toolkit/content/resetProfileProgress.xul
+++ b/toolkit/content/resetProfileProgress.xul
@@ -11,14 +11,15 @@
%resetProfileDTD;
]>
<?xml-stylesheet href="chrome://global/content/resetProfile.css"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<window id="resetProfileProgressDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- title="&resetProfile.dialog.title;">
+ title="&refreshProfile.dialog.title;"
+ style="min-width: 300px;">
<vbox>
- <description>&resetProfile.cleaning.description;</description>
+ <description>&refreshProfile.cleaning.description;</description>
<progressmeter mode="undetermined"/>
</vbox>
</window>
--- a/toolkit/locales/en-US/chrome/global/resetProfile.dtd
+++ b/toolkit/locales/en-US/chrome/global/resetProfile.dtd
@@ -1,15 +1,15 @@
<!-- 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/. -->
-<!ENTITY resetProfile.dialog.title "Reset &brandShortName;">
-<!ENTITY resetProfile.dialog.description "Are you sure you want to reset &brandShortName; to its initial state?">
-<!ENTITY resetProfile.dialog.items2.label "&brandShortName; will try to preserve your:">
-<!ENTITY resetProfile.dialog.footer.label "&brandShortName; will restart and everything else will be removed.">
-<!ENTITY resetProfile.dialog.button.label "Reset &brandShortName;">
+<!ENTITY refreshProfile.dialog.title "Refresh &brandShortName;">
+<!ENTITY refreshProfile.dialog.description1 "Start fresh to fix problems and restore performance.">
+<!ENTITY refreshProfile.dialog.description2 "This will:">
+<!ENTITY refreshProfile.dialog.items.label1 "Remove your add-ons and customizations">
+<!ENTITY refreshProfile.dialog.items.label2 "Restore your browser settings to their defaults">
+<!ENTITY refreshProfile.dialog.button.label "Refresh &brandShortName;">
-<!ENTITY resetProfile.title "Reset &brandShortName; to its default state">
-<!ENTITY resetProfile.description "If you're having major problems which you can't resolve, start fresh with only your essential information.">
-<!ENTITY resetProfile.button.label2 "Reset &brandShortName;…">
+<!ENTITY refreshProfile.title "Give &brandShortName; a tune up">
+<!ENTITY refreshProfile.button.label "Refresh &brandShortName;…">
-<!ENTITY resetProfile.cleaning.description "Please wait while &brandShortName; cleans up your old data…">
+<!ENTITY refreshProfile.cleaning.description "Almost done…">
--- a/toolkit/locales/en-US/chrome/global/resetProfile.properties
+++ b/toolkit/locales/en-US/chrome/global/resetProfile.properties
@@ -2,11 +2,11 @@
# 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/.
# LOCALIZATION NOTE: These strings are used for profile reset.
# LOCALIZATION NOTE (resetUnusedProfile.message): %S is brandShortName.
resetUnusedProfile.message=It looks like you haven't started %S in a while. Do you want to clean it up for a fresh, like-new experience? And by the way, welcome back!
-# LOCALIZATION NOTE (resetProfile.resetButton.label): %S is brandShortName.
-resetProfile.resetButton.label=Reset %S…
-resetProfile.resetButton.accesskey=e
+# LOCALIZATION NOTE (refreshProfile.resetButton.label): %S is brandShortName.
+refreshProfile.resetButton.label=Refresh %S…
+refreshProfile.resetButton.accesskey=e
--- a/toolkit/themes/windows/global/aboutSupport.css
+++ b/toolkit/themes/windows/global/aboutSupport.css
@@ -97,17 +97,16 @@ td {
}
#reset-box > h3 {
margin-top: 0;
}
#reset-box > button {
display: block;
- margin: auto;
}
.block {
display: block;
}
.hidden {
display: none;