Set up a sync preference and policy for syncing [2]

- Adds a preference for enabling sync, which controls the sync behavior
- Make the ProductionFlags depend on appropriate flags to guarantee that
  we don't mess things when flipping some flags
- Preferences now control the "syncable" property of the provider
  thereby controlling the policy and when this entry shows up in
  system settings.

Bug: 17464069
Change-Id: I1d58351188518c1ae9f1f9e147b5ea15d32a3427
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 6aea637..ed05e91 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -56,9 +56,11 @@
     <!--  Option for enabling or disabling the split keyboard layout. [CHAR LIMIT=65]-->
     <string name="enable_split_keyboard">Enable split keyboard</string>
 
-    <string name="sync_now_title" translatable="false">Sync Now</string>
-    <string name="sync_now_summary" translatable="false">Sync your personal dictionary</string>
-    <string name="sync_now_summary_disabled_signed_out" translatable="false">Select an account to enable sync</string>
+    <!-- TODO: Enable translation for user-visible strings -->
+    <string name="cloud_sync_title" translatable="false">Enable sync</string>
+    <string name="cloud_sync_summary" translatable="false">Sync your personal dictionary across devices</string>
+    <string name="cloud_sync_summary_disabled_signed_out" translatable="false">Select an account to enable sync</string>
+    <string name="sync_now_title" translatable="false">[DEBUG] Sync Now</string>
 
     <!-- Option name for including other IMEs in the language switch list [CHAR LIMIT=30] -->
     <string name="include_other_imes_in_language_switch_list">Switch to other input methods</string>
diff --git a/java/res/xml/prefs_screen_accounts.xml b/java/res/xml/prefs_screen_accounts.xml
index 003a37f..41642bf 100644
--- a/java/res/xml/prefs_screen_accounts.xml
+++ b/java/res/xml/prefs_screen_accounts.xml
@@ -28,7 +28,15 @@
         android:title="@string/switch_accounts"
         android:summary="@string/no_accounts_selected" />
 
-    <!-- title will be set programmatically to embed application name -->
+    <!-- Summary will be set programmatically to reflect the account status -->
+    <CheckBoxPreference
+        android:key="pref_enable_cloud_sync"
+        android:title="@string/cloud_sync_title"
+        android:defaultValue="false"
+        android:persistent="true"
+        android:disableDependentsState="false" />
+
+    <!-- Title will be set programmatically to embed application name -->
     <CheckBoxPreference
         android:key="pref_enable_metrics_logging"
         android:summary="@string/enable_metrics_logging_summary"
@@ -38,5 +46,6 @@
     <!-- This preference (acts like a button) enables the user to initiate an one time sync. -->
     <Preference android:key="pref_beanstalk"
         android:persistent="false"
-        android:title="@string/sync_now_title" />
+        android:title="@string/sync_now_title"
+        android:dependency="pref_enable_cloud_sync" />
 </PreferenceScreen>