Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9015233 authored by Sandeep Siddhartha's avatar Sandeep Siddhartha
Browse files

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
parent 1e10d29b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,5 +46,5 @@ public final class ProductionFlags {
    /**
     * When {@code true}, personal dictionary sync feature is ready to be enabled.
     */
    public static final boolean ENABLE_PERSONAL_DICTIONARY_SYNC = false;
    public static final boolean ENABLE_PERSONAL_DICTIONARY_SYNC = ENABLE_ACCOUNT_SIGN_IN && false;
}
+0 −55
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.inputmethod.latin.sync;

import android.content.Context;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy;

public class BeanstalkManager {
    private static final Object sLock = new Object();

    @GuardedBy("sLock")
    private static BeanstalkManager sInstance;

    /**
     * @return the singleton instance of {@link BeanstalkManager}.
     */
    @Nonnull
    public static BeanstalkManager getInstance(Context context) {
        synchronized(sLock) {
            if (sInstance == null) {
                sInstance = new BeanstalkManager(context.getApplicationContext());
            }
        }
        return sInstance;
    }

    private BeanstalkManager(final Context context) {
        // Intentional private constructor for singleton.
    }

    public void onCreate() {
    }

    public void requestSync() {
    }

    public void onDestroy() {
    }
}
 No newline at end of file
+5 −3
Original line number Diff line number Diff line
@@ -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>
+11 −2
Original line number Diff line number Diff line
@@ -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>
+0 −3
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ import com.android.inputmethod.latin.settings.SettingsActivity;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.sync.BeanstalkManager;
import com.android.inputmethod.latin.touchinputconsumer.GestureConsumer;
import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils;
@@ -561,7 +560,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        AudioAndHapticFeedbackManager.init(this);
        AccessibilityUtils.init(this);
        mStatsUtilsManager.onCreate(this /* context */);
        BeanstalkManager.getInstance(this /* context */).onCreate();
        super.onCreate();

        mHandler.onCreate();
@@ -709,7 +707,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        unregisterReceiver(mDictionaryPackInstallReceiver);
        unregisterReceiver(mDictionaryDumpBroadcastReceiver);
        mStatsUtilsManager.onDestroy();
        BeanstalkManager.getInstance(this /* context */).onDestroy();
        super.onDestroy();
    }

Loading