|
|
@ -634,7 +634,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void initializePreferences() { |
|
|
|
private void initializePreferences() { |
|
|
|
if (mPreferences == null) { |
|
|
|
if (mPreferences == null) { |
|
|
|
mPreferences = PreferenceManager.getInstance(); |
|
|
|
mPreferences = PreferenceManager.getInstance(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1012,7 +1012,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* @param id |
|
|
|
* @param id |
|
|
|
* which id in the list was chosen |
|
|
|
* which id in the list was chosen |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public synchronized void editBookmark(final int id) { |
|
|
|
private synchronized void editBookmark(final int id) { |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); |
|
|
|
homePicker.setTitle(getResources().getString(R.string.title_edit_bookmark)); |
|
|
|
homePicker.setTitle(getResources().getString(R.string.title_edit_bookmark)); |
|
|
|
final EditText getTitle = new EditText(mActivity); |
|
|
|
final EditText getTitle = new EditText(mActivity); |
|
|
@ -1287,7 +1287,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
public void clearHistory() { |
|
|
|
private void clearHistory() { |
|
|
|
this.deleteDatabase(HistoryDatabase.DATABASE_NAME); |
|
|
|
this.deleteDatabase(HistoryDatabase.DATABASE_NAME); |
|
|
|
WebViewDatabase m = WebViewDatabase.getInstance(this); |
|
|
|
WebViewDatabase m = WebViewDatabase.getInstance(this); |
|
|
|
m.clearFormData(); |
|
|
|
m.clearFormData(); |
|
|
@ -1307,7 +1307,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NewApi") |
|
|
|
@SuppressLint("NewApi") |
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
public void clearCookies() { |
|
|
|
private void clearCookies() { |
|
|
|
// TODO Break out web storage deletion into its own option/action
|
|
|
|
// TODO Break out web storage deletion into its own option/action
|
|
|
|
// TODO clear web storage for all sites that are visited in Incognito mode
|
|
|
|
// TODO clear web storage for all sites that are visited in Incognito mode
|
|
|
|
WebStorage storage = WebStorage.getInstance(); |
|
|
|
WebStorage storage = WebStorage.getInstance(); |
|
|
@ -1413,7 +1413,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* searches the web for the query fixing any and all problems with the input |
|
|
|
* searches the web for the query fixing any and all problems with the input |
|
|
|
* checks if it is a search, url, etc. |
|
|
|
* checks if it is a search, url, etc. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void searchTheWeb(String query) { |
|
|
|
private void searchTheWeb(String query) { |
|
|
|
if (query.equals("")) { |
|
|
|
if (query.equals("")) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1556,8 +1556,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
|
|
|
|
|
|
|
|
int finalColor; // Lighten up the dark color if it is
|
|
|
|
int finalColor; // Lighten up the dark color if it is
|
|
|
|
// too dark
|
|
|
|
// too dark
|
|
|
|
if (isColorTooDark(color)) { |
|
|
|
if (Utils.isColorTooDark(color)) { |
|
|
|
finalColor = mixTwoColors( |
|
|
|
finalColor = Utils.mixTwoColors( |
|
|
|
mActivity.getResources().getColor(R.color.primary_color), |
|
|
|
mActivity.getResources().getColor(R.color.primary_color), |
|
|
|
color, 0.25f); |
|
|
|
color, 0.25f); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -1586,35 +1586,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isColorTooDark(int color) { |
|
|
|
|
|
|
|
final byte RED_CHANNEL = 16; |
|
|
|
|
|
|
|
final byte GREEN_CHANNEL = 8; |
|
|
|
|
|
|
|
//final byte BLUE_CHANNEL = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int r = ((int) ((float) (color >> RED_CHANNEL & 0xff) * 0.3f)) & 0xff; |
|
|
|
|
|
|
|
int g = ((int) ((float) (color >> GREEN_CHANNEL & 0xff) * 0.59)) & 0xff; |
|
|
|
|
|
|
|
int b = ((int) ((float) (color & 0xff) * 0.11)) & 0xff; |
|
|
|
|
|
|
|
int gr = (r + g + b) & 0xff; |
|
|
|
|
|
|
|
int gray = gr + (gr << GREEN_CHANNEL) + (gr << RED_CHANNEL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return gray < 0x727272; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int mixTwoColors(int color1, int color2, float amount) { |
|
|
|
|
|
|
|
final byte ALPHA_CHANNEL = 24; |
|
|
|
|
|
|
|
final byte RED_CHANNEL = 16; |
|
|
|
|
|
|
|
final byte GREEN_CHANNEL = 8; |
|
|
|
|
|
|
|
//final byte BLUE_CHANNEL = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final float inverseAmount = 1.0f - amount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int r = ((int) (((float) (color1 >> RED_CHANNEL & 0xff) * amount) + ((float) (color2 >> RED_CHANNEL & 0xff) * inverseAmount))) & 0xff; |
|
|
|
|
|
|
|
int g = ((int) (((float) (color1 >> GREEN_CHANNEL & 0xff) * amount) + ((float) (color2 >> GREEN_CHANNEL & 0xff) * inverseAmount))) & 0xff; |
|
|
|
|
|
|
|
int b = ((int) (((float) (color1 & 0xff) * amount) + ((float) (color2 & 0xff) * inverseAmount))) & 0xff; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0xff << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> { |
|
|
|
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> { |
|
|
|
|
|
|
|
|
|
|
|
final Context context; |
|
|
|
final Context context; |
|
|
@ -1758,7 +1729,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static String getDomainName(String url) throws URISyntaxException { |
|
|
|
private static String getDomainName(String url) throws URISyntaxException { |
|
|
|
URI uri = new URI(url); |
|
|
|
URI uri = new URI(url); |
|
|
|
String domain = uri.getHost(); |
|
|
|
String domain = uri.getHost(); |
|
|
|
if (domain == null) { |
|
|
|
if (domain == null) { |
|
|
@ -1843,11 +1814,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isSystemBrowserAvailable() { |
|
|
|
private boolean isSystemBrowserAvailable() { |
|
|
|
return mSystemBrowser; |
|
|
|
return mSystemBrowser; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean getSystemBrowser() { |
|
|
|
private boolean getSystemBrowser() { |
|
|
|
Cursor c = null; |
|
|
|
Cursor c = null; |
|
|
|
String[] columns = new String[] { "url", "title" }; |
|
|
|
String[] columns = new String[] { "url", "title" }; |
|
|
|
boolean browserFlag; |
|
|
|
boolean browserFlag; |
|
|
@ -2194,7 +2165,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* @param enabled |
|
|
|
* @param enabled |
|
|
|
* whether to enable fullscreen or not |
|
|
|
* whether to enable fullscreen or not |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setFullscreen(boolean enabled) { |
|
|
|
private void setFullscreen(boolean enabled) { |
|
|
|
Window win = getWindow(); |
|
|
|
Window win = getWindow(); |
|
|
|
WindowManager.LayoutParams winParams = win.getAttributes(); |
|
|
|
WindowManager.LayoutParams winParams = win.getAttributes(); |
|
|
|
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; |
|
|
|
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; |
|
|
@ -2559,7 +2530,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* and that it should display the stop icon to indicate to the user that |
|
|
|
* and that it should display the stop icon to indicate to the user that |
|
|
|
* pressing it stops the page from loading |
|
|
|
* pressing it stops the page from loading |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setIsLoading() { |
|
|
|
private void setIsLoading() { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
mIcon = mDeleteIcon; |
|
|
|
mIcon = mDeleteIcon; |
|
|
|
mSearch.setCompoundDrawables(null, null, mDeleteIcon, null); |
|
|
|
mSearch.setCompoundDrawables(null, null, mDeleteIcon, null); |
|
|
@ -2570,7 +2541,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* This tells the search bar that the page is finished loading and it should |
|
|
|
* This tells the search bar that the page is finished loading and it should |
|
|
|
* display the refresh icon |
|
|
|
* display the refresh icon |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setIsFinishedLoading() { |
|
|
|
private void setIsFinishedLoading() { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
mIcon = mRefreshIcon; |
|
|
|
mIcon = mRefreshIcon; |
|
|
|
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); |
|
|
|
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); |
|
|
@ -2583,7 +2554,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
* |
|
|
|
* |
|
|
|
* See setIsFinishedLoading and setIsLoading for displaying the correct icon |
|
|
|
* See setIsFinishedLoading and setIsLoading for displaying the correct icon |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void refreshOrStop() { |
|
|
|
private void refreshOrStop() { |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView.getProgress() < 100) { |
|
|
|
if (mCurrentView.getProgress() < 100) { |
|
|
|
mCurrentView.stopLoading(); |
|
|
|
mCurrentView.stopLoading(); |
|
|
@ -2598,7 +2569,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll |
|
|
|
finish(); |
|
|
|
finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class SortIgnoreCase implements Comparator<HistoryItem> { |
|
|
|
private class SortIgnoreCase implements Comparator<HistoryItem> { |
|
|
|
|
|
|
|
|
|
|
|
public int compare(HistoryItem o1, HistoryItem o2) { |
|
|
|
public int compare(HistoryItem o1, HistoryItem o2) { |
|
|
|
return o1.getTitle().toLowerCase(Locale.getDefault()) |
|
|
|
return o1.getTitle().toLowerCase(Locale.getDefault()) |
|
|
|