Browse Source

added some missing nullable annotation additions, switched to compat implementations of some methods, fixed some lint warnings

master
Anthony Restaino 9 years ago
parent
commit
d59aeef3a9
  1. 8
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 2
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 2
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java
  4. 13
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
  5. 14
      app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java
  6. 14
      app/src/main/java/acr/browser/lightning/search/RetrieveSuggestionsTask.java
  7. 2
      app/src/main/java/acr/browser/lightning/search/SuggestionsResult.java
  8. 2
      app/src/main/java/acr/browser/lightning/utils/KeyboardHelper.java
  9. 2
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  10. 2
      app/src/main/java/acr/browser/lightning/view/LightningViewTitle.java
  11. 2
      app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

8
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -313,7 +313,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
setNavigationDrawerWidth(); setNavigationDrawerWidth();
mDrawerLayout.setDrawerListener(new DrawerLocker()); mDrawerLayout.addDrawerListener(new DrawerLocker());
mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme); mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
@ -541,12 +541,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
@Override @Override
public void onDrawerSlide(View v, float arg) { public void onDrawerSlide(View v, float arg) {}
}
@Override @Override
public void onDrawerStateChanged(int arg) { public void onDrawerStateChanged(int arg) {}
}
} }

2
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -54,7 +54,7 @@ public class TabsManager {
@Nullable private TabNumberChangedListener mTabNumberListener; @Nullable private TabNumberChangedListener mTabNumberListener;
private boolean mIsInitialized = false; private boolean mIsInitialized = false;
private List<Runnable> mPostInitializationWorkList = new ArrayList<>(); private final List<Runnable> mPostInitializationWorkList = new ArrayList<>();
@Inject PreferenceManager mPreferenceManager; @Inject PreferenceManager mPreferenceManager;
@Inject BookmarkManager mBookmarkManager; @Inject BookmarkManager mBookmarkManager;

2
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -30,7 +30,7 @@ public class BrowserPresenter {
private static final String TAG = BrowserPresenter.class.getSimpleName(); private static final String TAG = BrowserPresenter.class.getSimpleName();
private TabsManager mTabsModel; @NonNull private final TabsManager mTabsModel;
@Inject PreferenceManager mPreferences; @Inject PreferenceManager mPreferences;
@Inject Bus mEventBus; @Inject Bus mEventBus;

13
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -19,6 +19,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.LayoutManager; import android.support.v7.widget.RecyclerView.LayoutManager;
@ -316,11 +317,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
final Bitmap favicon = web.getFavicon(); final Bitmap favicon = web.getFavicon();
if (web.isForegroundTab()) { if (web.isForegroundTab()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { TextViewCompat.setTextAppearance(holder.txtTitle, R.style.boldText);
holder.txtTitle.setTextAppearance(R.style.boldText);
} else {
holder.txtTitle.setTextAppearance(getContext(), R.style.boldText);
}
Drawable foregroundDrawable; Drawable foregroundDrawable;
if (!mDrawerTabs) { if (!mDrawerTabs) {
foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap); foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap);
@ -340,11 +337,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} }
holder.favicon.setImageBitmap(favicon); holder.favicon.setImageBitmap(favicon);
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { TextViewCompat.setTextAppearance(holder.txtTitle, R.style.normalText);
holder.txtTitle.setTextAppearance(R.style.normalText);
} else {
holder.txtTitle.setTextAppearance(getContext(), R.style.normalText);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
holder.layout.setBackground(mBackgroundTabDrawable); holder.layout.setBackground(mBackgroundTabDrawable);
} else { } else {

14
app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java

@ -63,7 +63,7 @@ public class PreferenceManager {
public static final String INITIAL_CHECK_FOR_I2P = "checkForI2P"; public static final String INITIAL_CHECK_FOR_I2P = "checkForI2P";
} }
private final SharedPreferences mPrefs; @NonNull private final SharedPreferences mPrefs;
private static final String PREFERENCES = "settings"; private static final String PREFERENCES = "settings";
@ -255,7 +255,7 @@ public class PreferenceManager {
return mPrefs.getBoolean(Name.DO_NOT_TRACK, false); return mPrefs.getBoolean(Name.DO_NOT_TRACK, false);
} }
public boolean getRemoveIdentifyingHeadersEnabled(){ public boolean getRemoveIdentifyingHeadersEnabled() {
return mPrefs.getBoolean(Name.IDENTIFYING_HEADERS, false); return mPrefs.getBoolean(Name.IDENTIFYING_HEADERS, false);
} }
@ -271,7 +271,7 @@ public class PreferenceManager {
mPrefs.edit().putString(name, value).apply(); mPrefs.edit().putString(name, value).apply();
} }
public void setRemoveIdentifyingHeadersEnabled(boolean enabled){ public void setRemoveIdentifyingHeadersEnabled(boolean enabled) {
putBoolean(Name.IDENTIFYING_HEADERS, enabled); putBoolean(Name.IDENTIFYING_HEADERS, enabled);
} }
@ -331,7 +331,7 @@ public class PreferenceManager {
putBoolean(Name.COOKIES, enable); putBoolean(Name.COOKIES, enable);
} }
public void setDownloadDirectory(String directory) { public void setDownloadDirectory(@NonNull String directory) {
putString(Name.DOWNLOAD_DIRECTORY, directory); putString(Name.DOWNLOAD_DIRECTORY, directory);
} }
@ -351,7 +351,7 @@ public class PreferenceManager {
putBoolean(Name.HIDE_STATUS_BAR, enable); putBoolean(Name.HIDE_STATUS_BAR, enable);
} }
public void setHomepage(String homepage) { public void setHomepage(@NonNull String homepage) {
putString(Name.HOMEPAGE, homepage); putString(Name.HOMEPAGE, homepage);
} }
@ -438,7 +438,7 @@ public class PreferenceManager {
putInt(Name.PROXY_CHOICE, choice); putInt(Name.PROXY_CHOICE, choice);
} }
public void setProxyHost(String proxyHost) { public void setProxyHost(@NonNull String proxyHost) {
putString(Name.USE_PROXY_HOST, proxyHost); putString(Name.USE_PROXY_HOST, proxyHost);
} }
@ -450,7 +450,7 @@ public class PreferenceManager {
putInt(Name.USER_AGENT, choice); putInt(Name.USER_AGENT, choice);
} }
public void setUserAgentString(String agent) { public void setUserAgentString(@Nullable String agent) {
putString(Name.USER_AGENT_STRING, agent); putString(Name.USER_AGENT_STRING, agent);
} }

14
app/src/main/java/acr/browser/lightning/search/RetrieveSuggestionsTask.java

@ -33,7 +33,7 @@ import acr.browser.lightning.R;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
public class RetrieveSuggestionsTask extends AsyncTask<Void, Void, List<HistoryItem>> { class RetrieveSuggestionsTask extends AsyncTask<Void, Void, List<HistoryItem>> {
private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName(); private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName();
@ -42,12 +42,12 @@ public class RetrieveSuggestionsTask extends AsyncTask<Void, Void, List<HistoryI
private static final String ENCODING = "ISO-8859-1"; private static final String ENCODING = "ISO-8859-1";
private static final long INTERVAL_DAY = 86400000; private static final long INTERVAL_DAY = 86400000;
private static final String DEFAULT_LANGUAGE = "en"; private static final String DEFAULT_LANGUAGE = "en";
private static XmlPullParser sXpp; @Nullable private static XmlPullParser sXpp;
private static String sLanguage; @Nullable private static String sLanguage;
private WeakReference<SuggestionsResult> mResultCallback; @NonNull private final WeakReference<SuggestionsResult> mResultCallback;
private Application mApplication; @NonNull private final Application mApplication;
private String mSearchSubtitle; @NonNull private final String mSearchSubtitle;
private String mQuery; @NonNull private String mQuery;
public RetrieveSuggestionsTask(@NonNull String query, public RetrieveSuggestionsTask(@NonNull String query,
@NonNull SuggestionsResult callback, @NonNull SuggestionsResult callback,

2
app/src/main/java/acr/browser/lightning/search/SuggestionsResult.java

@ -6,7 +6,7 @@ import java.util.List;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
public interface SuggestionsResult { interface SuggestionsResult {
/** /**
* Called when the search suggestions have * Called when the search suggestions have

2
app/src/main/java/acr/browser/lightning/utils/KeyboardHelper.java

@ -19,7 +19,7 @@ public class KeyboardHelper {
void keyboardVisibilityChanged(boolean visible); void keyboardVisibilityChanged(boolean visible);
} }
@NonNull private View mView; @NonNull private final View mView;
private int mLastRight = -1; private int mLastRight = -1;
private int mLastBottom = -1; private int mLastBottom = -1;

2
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -40,7 +40,6 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.BookmarkPage; import acr.browser.lightning.constant.BookmarkPage;
import acr.browser.lightning.constant.Constants; import acr.browser.lightning.constant.Constants;
@ -57,7 +56,6 @@ import acr.browser.lightning.react.Schedulers;
import acr.browser.lightning.react.Subscriber; import acr.browser.lightning.react.Subscriber;
import acr.browser.lightning.react.OnSubscribe; import acr.browser.lightning.react.OnSubscribe;
import acr.browser.lightning.utils.ProxyUtils; import acr.browser.lightning.utils.ProxyUtils;
import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.utils.UrlUtils; import acr.browser.lightning.utils.UrlUtils;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;

2
app/src/main/java/acr/browser/lightning/view/LightningViewTitle.java

@ -21,7 +21,7 @@ class LightningViewTitle {
@Nullable private Bitmap mFavicon = null; @Nullable private Bitmap mFavicon = null;
@NonNull private String mTitle; @NonNull private String mTitle;
@NonNull Context mContext; @NonNull private final Context mContext;
public LightningViewTitle(@NonNull Context context) { public LightningViewTitle(@NonNull Context context) {
mContext = context; mContext = context;

2
app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

@ -25,8 +25,6 @@ import android.webkit.WebViewClient;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.squareup.otto.Bus;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;

Loading…
Cancel
Save