Browse Source

Cleaning up unused code

master
anthony restaino 8 years ago
parent
commit
54026bf6cc
  1. 1
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 11
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 1
      app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java
  4. 22
      app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java
  5. 1
      app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java
  6. 1
      app/src/main/java/acr/browser/lightning/favicon/FaviconModel.java
  7. 1
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  8. 2
      app/src/main/java/acr/browser/lightning/reading/Converter.java
  9. 2
      app/src/main/java/acr/browser/lightning/search/SuggestionsManager.java
  10. 10
      app/src/main/java/acr/browser/lightning/utils/DrawableUtils.java
  11. 1
      app/src/main/java/acr/browser/lightning/utils/FileUtils.java
  12. 2
      app/src/main/java/acr/browser/lightning/utils/ThemeUtils.java
  13. 94
      app/src/main/java/acr/browser/lightning/utils/UrlUtils.java

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

@ -22,7 +22,6 @@ import android.media.MediaPlayer; @@ -22,7 +22,6 @@ import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.support.annotation.ColorInt;

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

@ -528,17 +528,6 @@ public class TabsManager { @@ -528,17 +528,6 @@ public class TabsManager {
});
}
/**
* Return the {@link WebView} associated to the current tab,
* or null if there is no current tab.
*
* @return a {@link WebView} or null if there is no current tab.
*/
@Nullable
public synchronized WebView getCurrentWebView() {
return mCurrentTab != null ? mCurrentTab.getWebView() : null;
}
/**
* Returns the index of the current tab.
*

1
app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java

@ -20,7 +20,6 @@ import javax.inject.Inject; @@ -20,7 +20,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
@Singleton
@WorkerThread

22
app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java

@ -75,16 +75,11 @@ public class BrowserDialog { @@ -75,16 +75,11 @@ public class BrowserDialog {
public abstract void onClick();
}
public static void show(@NonNull Activity activity, @NonNull Item item, @Nullable Item... items) {
show(activity, null, item, items);
}
public static void show(@NonNull Activity activity, @StringRes int title, @NonNull Item item, @Nullable Item... items) {
show(activity, activity.getString(title), item, items);
public static void show(@NonNull Activity activity, @StringRes int title, @NonNull Item... items) {
show(activity, activity.getString(title), items);
}
public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item item, @Nullable Item... items) {
public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item... items) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
View layout = LayoutInflater.from(activity).inflate(R.layout.list_dialog, null);
@ -96,14 +91,9 @@ public class BrowserDialog { @@ -96,14 +91,9 @@ public class BrowserDialog {
android.R.layout.simple_list_item_1);
final List<Item> itemList = new ArrayList<>(1);
if (item.isConditionMet()) {
itemList.add(item);
}
if (items != null) {
for (Item it : items) {
if (it.isConditionMet()) {
itemList.add(it);
}
for (Item it : items) {
if (it.isConditionMet()) {
itemList.add(it);
}
}

1
app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java

@ -14,7 +14,6 @@ import android.webkit.URLUtil; @@ -14,7 +14,6 @@ import android.webkit.URLUtil;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.dialog.BrowserDialog;
import acr.browser.lightning.preference.PreferenceManager;

1
app/src/main/java/acr/browser/lightning/favicon/FaviconModel.java

@ -20,7 +20,6 @@ import java.io.IOException; @@ -20,7 +20,6 @@ import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.utils.Utils;
/**

1
app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java

@ -36,7 +36,6 @@ import javax.inject.Inject; @@ -36,7 +36,6 @@ import javax.inject.Inject;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.database.BookmarkLocalSync;
import acr.browser.lightning.database.BookmarkLocalSync.Source;
import acr.browser.lightning.database.BookmarkManager;

2
app/src/main/java/acr/browser/lightning/reading/Converter.java

@ -25,8 +25,6 @@ import java.io.UnsupportedEncodingException; @@ -25,8 +25,6 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Locale;
import acr.browser.lightning.constant.Constants;
/**
* This class is not thread safe. Use one new instance every time due to
* encoding variable.

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

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package acr.browser.lightning.search;
import android.app.Application;
import android.content.Context;
import android.support.annotation.NonNull;
import com.anthonycr.bonsai.Single;
@ -10,7 +9,6 @@ import com.anthonycr.bonsai.SingleSubscriber; @@ -10,7 +9,6 @@ import com.anthonycr.bonsai.SingleSubscriber;
import java.util.List;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.database.HistoryItem;
class SuggestionsManager {

10
app/src/main/java/acr/browser/lightning/utils/DrawableUtils.java

@ -78,16 +78,6 @@ public class DrawableUtils { @@ -78,16 +78,6 @@ public class DrawableUtils {
(startB + (int) (fraction * (endB - startB)));
}
public static Drawable resolveDrawableAttribute(@NonNull Context context, @AttrRes int res) {
int[] attribute = new int[]{res};
int indexOfAttrTextSize = 0;
TypedValue typedValue = new TypedValue();
TypedArray a = context.obtainStyledAttributes(typedValue.data, attribute);
Drawable drawable = a.getDrawable(indexOfAttrTextSize);
a.recycle();
return drawable;
}
public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(drawable);

1
app/src/main/java/acr/browser/lightning/utils/FileUtils.java

@ -19,7 +19,6 @@ import java.io.InputStreamReader; @@ -19,7 +19,6 @@ import java.io.InputStreamReader;
import java.io.PrintStream;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants;
/**
* A utility class containing helpful methods

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

@ -12,8 +12,6 @@ import android.graphics.PorterDuffColorFilter; @@ -12,8 +12,6 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;

94
app/src/main/java/acr/browser/lightning/utils/UrlUtils.java

@ -33,44 +33,18 @@ import acr.browser.lightning.constant.StartPage; @@ -33,44 +33,18 @@ import acr.browser.lightning.constant.StartPage;
*/
public class UrlUtils {
private static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
"(?i)" + // switch on case insensitive matching
'(' + // begin group for schema
"(?:http|https|file)://" +
"|(?:inline|data|about|javascript):" +
"|(?:.*:.*@)" +
')' +
"(.*)");
"(?i)" + // switch on case insensitive matching
'(' + // begin group for schema
"(?:http|https|file)://" +
"|(?:inline|data|about|javascript):" +
"|(?:.*:.*@)" +
')' +
"(.*)");
// Google search
public final static String QUERY_PLACE_HOLDER = "%s";
// Regular expression to strip http:// and optionally
// the trailing slash
private static final Pattern STRIP_URL_PATTERN =
Pattern.compile("^http://(.*?)/?$");
private UrlUtils() { /* cannot be instantiated */ }
/**
* Strips the provided url of preceding "http://" and any trailing "/". Does not
* strip "https://". If the provided string cannot be stripped, the original string
* is returned.
* <p/>
* TODO: Put this in TextUtils to be used by other packages doing something similar.
*
* @param url a url to strip, like "http://www.google.com/"
* @return a stripped url like "www.google.com", or the original string if it could
* not be stripped
*/
@Nullable
public static String stripUrl(@Nullable String url) {
if (url == null) return null;
Matcher m = STRIP_URL_PATTERN.matcher(url);
if (m.matches()) {
return m.group(1);
} else {
return url;
}
}
/**
* Attempts to determine whether user input is a URL or search
* terms. Anything with a space is passed to search if canBeSearch is true.
@ -106,65 +80,19 @@ public class UrlUtils { @@ -106,65 +80,19 @@ public class UrlUtils {
}
if (canBeSearch) {
return URLUtil.composeSearchUrl(inUrl,
searchUrl, QUERY_PLACE_HOLDER);
searchUrl, QUERY_PLACE_HOLDER);
}
return "";
}
/* package */
@NonNull
static String fixUrl(@NonNull String inUrl) {
// FIXME: Converting the url to lower case
// duplicates functionality in smartUrlFilter().
// However, changing all current callers of fixUrl to
// call smartUrlFilter in addition may have unwanted
// consequences, and is deferred for now.
int colon = inUrl.indexOf(':');
boolean allLower = true;
for (int index = 0; index < colon; index++) {
char ch = inUrl.charAt(index);
if (!Character.isLetter(ch)) {
break;
}
allLower &= Character.isLowerCase(ch);
if (index == colon - 1 && !allLower) {
inUrl = inUrl.substring(0, colon).toLowerCase()
+ inUrl.substring(colon);
}
}
if (inUrl.startsWith("http://") || inUrl.startsWith("https://"))
return inUrl;
if (inUrl.startsWith("http:") ||
inUrl.startsWith("https:")) {
if (inUrl.startsWith("http:/") || inUrl.startsWith("https:/")) {
inUrl = inUrl.replaceFirst("/", "//");
} else inUrl = inUrl.replaceFirst(":", "://");
}
return inUrl;
}
// Returns the filtered URL. Cannot return null, but can return an empty string
/* package */
@Nullable
static String filteredUrl(@Nullable String inUrl) {
if (inUrl == null) {
return "";
}
if (inUrl.startsWith("content:")
|| inUrl.startsWith("browser:")) {
return "";
}
return inUrl;
}
/**
* Returns whether the given url is the bookmarks/history page or a normal website
*/
public static boolean isSpecialUrl(@Nullable String url) {
return url != null && url.startsWith(Constants.FILE) &&
(url.endsWith(BookmarkPage.FILENAME) ||
url.endsWith(HistoryPage.FILENAME) ||
url.endsWith(StartPage.FILENAME));
(url.endsWith(BookmarkPage.FILENAME) ||
url.endsWith(HistoryPage.FILENAME) ||
url.endsWith(StartPage.FILENAME));
}
/**

Loading…
Cancel
Save