Cleaning up unused code
This commit is contained in:
parent
fa7673b3d1
commit
54026bf6cc
@ -22,7 +22,6 @@ import android.media.MediaPlayer;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
@ -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.
|
* Returns the index of the current tab.
|
||||||
*
|
*
|
||||||
|
@ -20,7 +20,6 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
@ -75,16 +75,11 @@ public class BrowserDialog {
|
|||||||
public abstract void onClick();
|
public abstract void onClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void show(@NonNull Activity activity, @StringRes int title, @NonNull Item... items) {
|
||||||
public static void show(@NonNull Activity activity, @NonNull Item item, @Nullable Item... items) {
|
show(activity, activity.getString(title), items);
|
||||||
show(activity, null, item, items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void show(@NonNull Activity activity, @StringRes int title, @NonNull Item item, @Nullable Item... items) {
|
public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item... items) {
|
||||||
show(activity, activity.getString(title), item, items);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item item, @Nullable Item... items) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
|
||||||
View layout = LayoutInflater.from(activity).inflate(R.layout.list_dialog, null);
|
View layout = LayoutInflater.from(activity).inflate(R.layout.list_dialog, null);
|
||||||
@ -96,14 +91,9 @@ public class BrowserDialog {
|
|||||||
android.R.layout.simple_list_item_1);
|
android.R.layout.simple_list_item_1);
|
||||||
|
|
||||||
final List<Item> itemList = new ArrayList<>(1);
|
final List<Item> itemList = new ArrayList<>(1);
|
||||||
if (item.isConditionMet()) {
|
for (Item it : items) {
|
||||||
itemList.add(item);
|
if (it.isConditionMet()) {
|
||||||
}
|
itemList.add(it);
|
||||||
if (items != null) {
|
|
||||||
for (Item it : items) {
|
|
||||||
if (it.isConditionMet()) {
|
|
||||||
itemList.add(it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import android.webkit.URLUtil;
|
|||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.constant.Constants;
|
|
||||||
import acr.browser.lightning.dialog.BrowserDialog;
|
import acr.browser.lightning.dialog.BrowserDialog;
|
||||||
import acr.browser.lightning.preference.PreferenceManager;
|
import acr.browser.lightning.preference.PreferenceManager;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
|
||||||
import acr.browser.lightning.utils.Utils;
|
import acr.browser.lightning.utils.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,6 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.constant.Constants;
|
|
||||||
import acr.browser.lightning.database.BookmarkLocalSync;
|
import acr.browser.lightning.database.BookmarkLocalSync;
|
||||||
import acr.browser.lightning.database.BookmarkLocalSync.Source;
|
import acr.browser.lightning.database.BookmarkLocalSync.Source;
|
||||||
import acr.browser.lightning.database.BookmarkManager;
|
import acr.browser.lightning.database.BookmarkManager;
|
||||||
|
@ -25,8 +25,6 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import acr.browser.lightning.constant.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is not thread safe. Use one new instance every time due to
|
* This class is not thread safe. Use one new instance every time due to
|
||||||
* encoding variable.
|
* encoding variable.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package acr.browser.lightning.search;
|
package acr.browser.lightning.search;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.anthonycr.bonsai.Single;
|
import com.anthonycr.bonsai.Single;
|
||||||
@ -10,7 +9,6 @@ import com.anthonycr.bonsai.SingleSubscriber;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
|
||||||
import acr.browser.lightning.database.HistoryItem;
|
import acr.browser.lightning.database.HistoryItem;
|
||||||
|
|
||||||
class SuggestionsManager {
|
class SuggestionsManager {
|
||||||
|
@ -78,16 +78,6 @@ public class DrawableUtils {
|
|||||||
(startB + (int) (fraction * (endB - startB)));
|
(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) {
|
public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
view.setBackground(drawable);
|
view.setBackground(drawable);
|
||||||
|
@ -19,7 +19,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.constant.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility class containing helpful methods
|
* A utility class containing helpful methods
|
||||||
|
@ -12,8 +12,6 @@ import android.graphics.PorterDuffColorFilter;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Build.VERSION;
|
|
||||||
import android.os.Build.VERSION_CODES;
|
|
||||||
import android.support.annotation.AttrRes;
|
import android.support.annotation.AttrRes;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
@ -33,44 +33,18 @@ import acr.browser.lightning.constant.StartPage;
|
|||||||
*/
|
*/
|
||||||
public class UrlUtils {
|
public class UrlUtils {
|
||||||
private static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
|
private static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
|
||||||
"(?i)" + // switch on case insensitive matching
|
"(?i)" + // switch on case insensitive matching
|
||||||
'(' + // begin group for schema
|
'(' + // begin group for schema
|
||||||
"(?:http|https|file)://" +
|
"(?:http|https|file)://" +
|
||||||
"|(?:inline|data|about|javascript):" +
|
"|(?:inline|data|about|javascript):" +
|
||||||
"|(?:.*:.*@)" +
|
"|(?:.*:.*@)" +
|
||||||
')' +
|
')' +
|
||||||
"(.*)");
|
"(.*)");
|
||||||
// Google search
|
// Google search
|
||||||
public final static String QUERY_PLACE_HOLDER = "%s";
|
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 */ }
|
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
|
* Attempts to determine whether user input is a URL or search
|
||||||
* terms. Anything with a space is passed to search if canBeSearch is true.
|
* terms. Anything with a space is passed to search if canBeSearch is true.
|
||||||
@ -106,65 +80,19 @@ public class UrlUtils {
|
|||||||
}
|
}
|
||||||
if (canBeSearch) {
|
if (canBeSearch) {
|
||||||
return URLUtil.composeSearchUrl(inUrl,
|
return URLUtil.composeSearchUrl(inUrl,
|
||||||
searchUrl, QUERY_PLACE_HOLDER);
|
searchUrl, QUERY_PLACE_HOLDER);
|
||||||
}
|
}
|
||||||
return "";
|
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
|
* Returns whether the given url is the bookmarks/history page or a normal website
|
||||||
*/
|
*/
|
||||||
public static boolean isSpecialUrl(@Nullable String url) {
|
public static boolean isSpecialUrl(@Nullable String url) {
|
||||||
return url != null && url.startsWith(Constants.FILE) &&
|
return url != null && url.startsWith(Constants.FILE) &&
|
||||||
(url.endsWith(BookmarkPage.FILENAME) ||
|
(url.endsWith(BookmarkPage.FILENAME) ||
|
||||||
url.endsWith(HistoryPage.FILENAME) ||
|
url.endsWith(HistoryPage.FILENAME) ||
|
||||||
url.endsWith(StartPage.FILENAME));
|
url.endsWith(StartPage.FILENAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user