diff options
Diffstat (limited to 'java/src')
4 files changed, 17 insertions, 102 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java index 48361bf8c..39dcddb95 100644 --- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java @@ -132,7 +132,7 @@ public final class AccountsSettingsFragment extends SubScreenFragment { @Override protected Void doInBackground(Void... params) { - if (ManagedProfileUtils.getInstance().hasManagedWorkProfile(mFragment.getActivity())) { + if (ManagedProfileUtils.getInstance().hasWorkProfile(mFragment.getActivity())) { mFragment.removeSyncPreferences(); } else { mFragment.enableSyncPreferences(); diff --git a/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java index f7c5f6760..62834cd2a 100644 --- a/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/CorrectionSettingsFragment.java @@ -49,7 +49,7 @@ import java.util.TreeSet; */ public final class CorrectionSettingsFragment extends SubScreenFragment { private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false; - private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTIGS = + private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS || Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2; @@ -61,8 +61,6 @@ public final class CorrectionSettingsFragment extends SubScreenFragment { final Context context = getActivity(); final PackageManager pm = context.getPackageManager(); - ensureConsistencyOfAutoCorrectionSettings(); - final Preference dictionaryLink = findPreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY); final Intent intent = dictionaryLink.getIntent(); intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName()); @@ -74,7 +72,7 @@ public final class CorrectionSettingsFragment extends SubScreenFragment { final Preference editPersonalDictionary = findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY); final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent(); - final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTIGS ? null + final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null : pm.resolveActivity( editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY); if (ri == null) { @@ -82,19 +80,6 @@ public final class CorrectionSettingsFragment extends SubScreenFragment { } } - @Override - public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { - ensureConsistencyOfAutoCorrectionSettings(); - } - - private void ensureConsistencyOfAutoCorrectionSettings() { - final TwoStatePreference autoCorrectionPref = (TwoStatePreference) - findPreference(Settings.PREF_AUTO_CORRECTION); - if (!autoCorrectionPref.isChecked()) { - setPreferenceEnabled(Settings.PREF_BIGRAM_PREDICTIONS, false); - } - } - private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) { final Activity activity = getActivity(); final TreeSet<String> localeList = UserDictionaryList.getUserDictionaryLocalesSet(activity); diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index b98c53af4..f5455e3db 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -16,10 +16,12 @@ package com.android.inputmethod.latin.settings; +import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceScreen; +import android.provider.Settings.Secure; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -68,13 +70,23 @@ public final class SettingsFragment extends InputMethodSettingsFragment { @Override public boolean onOptionsItemSelected(final MenuItem item) { + final Activity activity = getActivity(); + final int setupStatus = Secure.getInt( + activity.getContentResolver(), + "user_setup_complete", + 0 /* default */); + if (setupStatus == 0) { + // If setup is not complete, it's not safe to launch Help or other activities + // because they might go to the Play Store. See b/19866981. + return true; + } final int itemId = item.getItemId(); if (itemId == MENU_HELP_AND_FEEDBACK) { - FeedbackUtils.showHelpAndFeedbackForm(getActivity()); + FeedbackUtils.showHelpAndFeedbackForm(activity); return true; } if (itemId == MENU_ABOUT) { - final Intent aboutIntent = FeedbackUtils.getAboutKeyboardIntent(getActivity()); + final Intent aboutIntent = FeedbackUtils.getAboutKeyboardIntent(activity); if (aboutIntent != null) { startActivity(aboutIntent); return true; diff --git a/java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java b/java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java deleted file mode 100644 index 1bd8f314c..000000000 --- a/java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.utils; - -import android.annotation.TargetApi; -import android.content.Context; -import android.os.Build; -import android.os.UserHandle; -import android.os.UserManager; -import android.util.Log; - -import com.android.inputmethod.annotations.UsedForTesting; - -import java.util.List; - -/** - * Utility for determining if the device has managed profiles. - */ -public class ManagedProfileUtils { - private static final boolean DEBUG = false; - private static final String TAG = ManagedProfileUtils.class.getSimpleName(); - - private static ManagedProfileUtils INSTANCE = new ManagedProfileUtils(); - private static ManagedProfileUtils sTestInstance; - - private ManagedProfileUtils() { - // This utility class is not publicly instantiable. - } - - @UsedForTesting - public static void setTestInstance(final ManagedProfileUtils testInstance) { - sTestInstance = testInstance; - } - - public static ManagedProfileUtils getInstance() { - return sTestInstance == null ? INSTANCE : sTestInstance; - } - - /** - * Note that {@link UserManager#getUserProfiles} has been introduced - * in API level 21 (Build.VERSION_CODES.LOLLIPOP). - */ - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public boolean hasManagedWorkProfile(final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - return false; - } - - final UserManager userManagerService = - (UserManager) context.getSystemService(Context.USER_SERVICE); - if (userManagerService != null) { - if (DEBUG) { - Log.d(TAG, "Detecting managed profile..."); - } - final List<UserHandle> userProfiles = userManagerService.getUserProfiles(); - if (userProfiles.size() > 1) { - if (DEBUG) { - Log.d(TAG, "More than one user profile => Managed profile exists."); - } - return true; - } - } - if (DEBUG) { - Log.d(TAG, "Managed profile not detected."); - } - return false; - } -} |