Bug 1236431 - (Pre) ToolbarDisplayLayout: Address lint warnings and clean up code. r=mcomella
MozReview-Commit-ID: JkD7uqRMQhQ
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -22,29 +22,26 @@ import org.mozilla.gecko.animation.Prope
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation;
import org.mozilla.gecko.util.ColorUtils;
import org.mozilla.gecko.util.StringUtils;
import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
import org.mozilla.gecko.widget.themed.ThemedTextView;
import android.content.Context;
-import android.content.res.Resources;
import android.os.SystemClock;
+import android.support.annotation.Nullable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageButton;
/**
* {@code ToolbarDisplayLayout} is the UI for when the toolbar is in
* display state. It's used to display the state of the currently selected
* tab. It should always be updated through a single entry point
* (updateFromTab) and should never track any tab events or gecko messages
@@ -79,21 +76,21 @@ public class ToolbarDisplayLayout extend
}
private enum UIMode {
PROGRESS,
DISPLAY
}
interface OnStopListener {
- public Tab onStop();
+ Tab onStop();
}
interface OnTitleChangeListener {
- public void onTitleChange(CharSequence title);
+ void onTitleChange(CharSequence title);
}
private final BrowserApp mActivity;
private UIMode mUiMode;
private boolean mIsAttached;
@@ -110,23 +107,23 @@ public class ToolbarDisplayLayout extend
private final PageActionLayout mPageActionLayout;
private final SiteIdentityPopup mSiteIdentityPopup;
private int mSecurityImageLevel;
// Security level constants, which map to the icons / levels defined in:
// http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/resources/drawable/site_security_level.xml
// Default level (unverified pages) - globe icon:
- private final int LEVEL_DEFAULT_GLOBE = 0;
+ private static final int LEVEL_DEFAULT_GLOBE = 0;
// Levels for displaying Mixed Content state icons.
- private final int LEVEL_WARNING_MINOR = 3;
- private final int LEVEL_LOCK_DISABLED = 4;
+ private static final int LEVEL_WARNING_MINOR = 3;
+ private static final int LEVEL_LOCK_DISABLED = 4;
// Levels for displaying Tracking Protection state icons.
- private final int LEVEL_SHIELD_ENABLED = 5;
- private final int LEVEL_SHIELD_DISABLED = 6;
+ private static final int LEVEL_SHIELD_ENABLED = 5;
+ private static final int LEVEL_SHIELD_DISABLED = 6;
private final ForegroundColorSpan mUrlColor;
private final ForegroundColorSpan mBlockedColor;
private final ForegroundColorSpan mDomainColor;
private final ForegroundColorSpan mPrivateDomainColor;
public ToolbarDisplayLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -153,16 +150,18 @@ public class ToolbarDisplayLayout extend
mSiteIdentityPopup.setOnVisibilityChangeListener(mActivity);
mStop = (ImageButton) findViewById(R.id.stop);
mPageActionLayout = (PageActionLayout) findViewById(R.id.page_action_layout);
}
@Override
public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+
mIsAttached = true;
mSiteSecurity.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
mSiteIdentityPopup.show();
}
});
@@ -349,23 +348,23 @@ public class ToolbarDisplayLayout extend
mSecurityImageLevel = imageLevel;
mSiteSecurity.setImageLevel(mSecurityImageLevel);
updatePageActions();
}
mTrackingProtectionEnabled = trackingMode == TrackingMode.TRACKING_CONTENT_BLOCKED;
}
- private void updateProgress(Tab tab) {
+ private void updateProgress(@Nullable Tab tab) {
final boolean shouldShowThrobber = (tab != null &&
tab.getState() == Tab.STATE_LOADING);
updateUiMode(shouldShowThrobber ? UIMode.PROGRESS : UIMode.DISPLAY);
- if (Tab.STATE_SUCCESS == tab.getState() && mTrackingProtectionEnabled) {
+ if (tab != null && Tab.STATE_SUCCESS == tab.getState() && mTrackingProtectionEnabled) {
mActivity.showTrackingProtectionPromptIfApplicable();
}
}
private void updateUiMode(UIMode uiMode) {
if (mUiMode == uiMode) {
return;
}