Added option to disable history sync with Google

This commit is contained in:
Anthony Restaino 2014-08-19 19:31:53 -04:00
parent 52fcf8fdc0
commit ff56ca1d31
5 changed files with 160 additions and 97 deletions

View File

@ -13,11 +13,11 @@
android:id="@+id/r1" android:id="@+id/r1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -65,11 +65,11 @@
android:id="@+id/r2" android:id="@+id/r2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:id="@+id/textView3" android:id="@+id/textView3"
@ -101,11 +101,11 @@
android:id="@+id/rClearHistoryExit" android:id="@+id/rClearHistoryExit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -136,11 +136,11 @@
android:id="@+id/rClearCookiesExit" android:id="@+id/rClearCookiesExit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -171,11 +171,11 @@
android:id="@+id/r3" android:id="@+id/r3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -223,11 +223,11 @@
android:id="@+id/r4" android:id="@+id/r4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:id="@+id/textView5" android:id="@+id/textView5"
@ -258,11 +258,11 @@
android:id="@+id/r5" android:id="@+id/r5"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:id="@+id/textView6" android:id="@+id/textView6"
@ -294,11 +294,11 @@
android:id="@+id/r6" android:id="@+id/r6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -345,11 +345,11 @@
android:id="@+id/r7" android:id="@+id/r7"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -396,11 +396,11 @@
android:id="@+id/rIncognitoCookies" android:id="@+id/rIncognitoCookies"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -437,11 +437,11 @@
android:id="@+id/r11" android:id="@+id/r11"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -488,11 +488,11 @@
android:id="@+id/r12" android:id="@+id/r12"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -539,11 +539,11 @@
android:id="@+id/r13" android:id="@+id/r13"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -574,11 +574,11 @@
android:id="@+id/r14" android:id="@+id/r14"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -609,11 +609,11 @@
android:id="@+id/rGoogleSuggestions" android:id="@+id/rGoogleSuggestions"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" > android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -648,6 +648,56 @@
android:layout_centerVertical="true" /> android:layout_centerVertical="true" />
</RelativeLayout> </RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#cdcdcd" />
<RelativeLayout
android:id="@+id/rBrowserHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="30dp"
android:text="@string/sync_history"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/isBrowserAvailable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
</LinearLayout>
<CheckBox
android:id="@+id/cbBrowserHistory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
@ -659,10 +709,10 @@
android:id="@+id/rClearCache" android:id="@+id/rClearCache"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp" android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" > android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -682,13 +732,13 @@
android:background="#cdcdcd" /> android:background="#cdcdcd" />
<RelativeLayout <RelativeLayout
android:id="@+id/r8" android:id="@+id/rClearHistory"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp" android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" > android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -711,10 +761,10 @@
android:id="@+id/r15" android:id="@+id/r15"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp" android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" > android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -737,10 +787,10 @@
android:id="@+id/r9" android:id="@+id/r9"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp" android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" > android:paddingTop="10dp" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -778,10 +828,10 @@
android:id="@+id/r10" android:id="@+id/r10"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:minHeight="60dp" android:minHeight="60dp"
android:paddingTop="10dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:background="?android:attr/listChoiceBackgroundIndicator" > android:paddingTop="10dp" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -178,4 +178,5 @@
<string name="name_grayscale">Grayscale</string> <string name="name_grayscale">Grayscale</string>
<string name="name_inverted_grayscale">Inverted Grayscale</string> <string name="name_inverted_grayscale">Inverted Grayscale</string>
<string name="name_normal">Normal</string> <string name="name_normal">Normal</string>
<string name="sync_history">Sync history with Google</string>
</resources> </resources>

View File

@ -29,18 +29,12 @@ public class AdvancedSettingsActivity extends Activity {
// mPreferences variables // mPreferences variables
private static final int API = android.os.Build.VERSION.SDK_INT; private static final int API = android.os.Build.VERSION.SDK_INT;
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditPrefs; private SharedPreferences.Editor mEditPrefs;
private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11, cbIncognitoCookies, private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11, cbIncognitoCookies,
cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit; cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
private Context mContext; private Context mContext;
private boolean mSystemBrowser; private boolean mSystemBrowser;
private Handler messageHandler; private Handler messageHandler;
@Override @Override
@ -88,7 +82,7 @@ public class AdvancedSettingsActivity extends Activity {
r5 = (RelativeLayout) findViewById(R.id.r5); r5 = (RelativeLayout) findViewById(R.id.r5);
r6 = (RelativeLayout) findViewById(R.id.r6); r6 = (RelativeLayout) findViewById(R.id.r6);
r7 = (RelativeLayout) findViewById(R.id.r7); r7 = (RelativeLayout) findViewById(R.id.r7);
r8 = (RelativeLayout) findViewById(R.id.r8); r8 = (RelativeLayout) findViewById(R.id.rClearHistory);
r9 = (RelativeLayout) findViewById(R.id.r9); r9 = (RelativeLayout) findViewById(R.id.r9);
r10 = (RelativeLayout) findViewById(R.id.r10); r10 = (RelativeLayout) findViewById(R.id.r10);
r11 = (RelativeLayout) findViewById(R.id.r11); r11 = (RelativeLayout) findViewById(R.id.r11);
@ -178,11 +172,38 @@ public class AdvancedSettingsActivity extends Activity {
cbSearchSuggestions(cbSearchSuggestions); cbSearchSuggestions(cbSearchSuggestions);
TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable); TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable);
TextView syncHistory = (TextView) findViewById(R.id.isBrowserAvailable);
RelativeLayout layoutSyncHistory = (RelativeLayout) findViewById(R.id.rBrowserHistory);
final CheckBox cbSyncHistory = (CheckBox) findViewById(R.id.cbBrowserHistory);
layoutSyncHistory.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
cbSyncHistory.setChecked(!cbSyncHistory.isChecked());
}
});
cbSyncHistory.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.SYNC_HISTORY, isChecked).apply();
}
});
if (!mSystemBrowser) { if (!mSystemBrowser) {
cbSyncHistory.setChecked(false);
cbSyncHistory.setEnabled(false);
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable)); importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
syncHistory.setText(getResources().getString(R.string.stock_browser_unavailable));
} else { } else {
cbSyncHistory.setEnabled(true);
cbSyncHistory.setChecked(mPreferences
.getBoolean(PreferenceConstants.SYNC_HISTORY, true));
importBookmarks.setText(getResources().getString(R.string.stock_browser_available)); importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
syncHistory.setText(getResources().getString(R.string.stock_browser_available));
} }
messageHandler = new MessageHandler(mContext); messageHandler = new MessageHandler(mContext);

View File

@ -1734,7 +1734,8 @@ public class BrowserActivity extends Activity implements BrowserController {
Runnable update = new Runnable() { Runnable update = new Runnable() {
@Override @Override
public void run() { public void run() {
if (isSystemBrowserAvailable()) { if (isSystemBrowserAvailable()
&& mPreferences.getBoolean(PreferenceConstants.SYNC_HISTORY, true)) {
try { try {
Browser.updateVisitedHistory(getContentResolver(), url, true); Browser.updateVisitedHistory(getContentResolver(), url, true);
} catch (NullPointerException ignored) { } catch (NullPointerException ignored) {
@ -1775,26 +1776,15 @@ public class BrowserActivity extends Activity implements BrowserController {
} }
} }
}; };
if (url != null) { if (url != null && !url.startsWith(Constants.FILE)) {
if (!url.startsWith(Constants.FILE)) { new Thread(update).start();
new Thread(update).start();
}
} }
} }
/**
* 1, 2, 3, testing... is there a system browser that has some nice
* bookmarks for us?
*/
public boolean isSystemBrowserAvailable() { public boolean isSystemBrowserAvailable() {
return mSystemBrowser; return mSystemBrowser;
} }
/**
* 1, 2, 3, testing... is there a system browser that has some nice
* bookmarks for us? helper method for isSystemBrowserAvailable
*/
public boolean getSystemBrowser() { public boolean getSystemBrowser() {
Cursor c = null; Cursor c = null;
String[] columns = new String[] { "url", "title" }; String[] columns = new String[] { "url", "title" };

View File

@ -39,6 +39,7 @@ public final class PreferenceConstants {
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit"; public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
public static final String SAVE_URL = "saveUrl"; public static final String SAVE_URL = "saveUrl";
public static final String RENDERING_MODE = "renderMode"; public static final String RENDERING_MODE = "renderMode";
public static final String SYNC_HISTORY = "syncHistory";
public static final String USE_PROXY = "useProxy"; public static final String USE_PROXY = "useProxy";
public static final String USE_PROXY_HOST = "useProxyHost"; public static final String USE_PROXY_HOST = "useProxyHost";