aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java35
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java14
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java12
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java1
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java99
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java3
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java9
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java4
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java5
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java8
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java21
12 files changed, 149 insertions, 70 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 282c8e8fa..03d9defa0 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.latin.Constants;
-
/**
* This class handles key detection.
*/
@@ -41,13 +39,15 @@ public class KeyDetector {
* @param keyHysteresisDistanceForSlidingModifier the same parameter for sliding input that
* starts from a modifier key such as shift and symbols key.
*/
- public KeyDetector(float keyHysteresisDistance, float keyHysteresisDistanceForSlidingModifier) {
+ public KeyDetector(final float keyHysteresisDistance,
+ final float keyHysteresisDistanceForSlidingModifier) {
mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance);
mKeyHysteresisDistanceForSlidingModifierSquared = (int)(
keyHysteresisDistanceForSlidingModifier * keyHysteresisDistanceForSlidingModifier);
}
- public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
+ public void setKeyboard(final Keyboard keyboard, final float correctionX,
+ final float correctionY) {
if (keyboard == null) {
throw new NullPointerException();
}
@@ -56,24 +56,21 @@ public class KeyDetector {
mKeyboard = keyboard;
}
- public int getKeyHysteresisDistanceSquared(boolean isSlidingFromModifier) {
+ public int getKeyHysteresisDistanceSquared(final boolean isSlidingFromModifier) {
return isSlidingFromModifier
? mKeyHysteresisDistanceForSlidingModifierSquared : mKeyHysteresisDistanceSquared;
}
- public int getTouchX(int x) {
+ public int getTouchX(final int x) {
return x + mCorrectionX;
}
// TODO: Remove vertical correction.
- public int getTouchY(int y) {
+ public int getTouchY(final int y) {
return y + mCorrectionY;
}
public Keyboard getKeyboard() {
- if (mKeyboard == null) {
- throw new IllegalStateException("keyboard isn't set");
- }
return mKeyboard;
}
@@ -88,7 +85,7 @@ public class KeyDetector {
* @param y The y-coordinate of a touch point
* @return the key that the touch point hits.
*/
- public Key detectHitKey(int x, int y) {
+ public Key detectHitKey(final int x, final int y) {
final int touchX = getTouchX(x);
final int touchY = getTouchY(y);
@@ -113,20 +110,4 @@ public class KeyDetector {
}
return primaryKey;
}
-
- public static String printableCode(Key key) {
- return key != null ? Constants.printableCode(key.getCode()) : "none";
- }
-
- public static String printableCodes(int[] codes) {
- final StringBuilder sb = new StringBuilder();
- boolean addDelimiter = false;
- for (final int code : codes) {
- if (code == Constants.NOT_A_CODE) break;
- if (addDelimiter) sb.append(", ");
- sb.append(Constants.printableCode(code));
- addDelimiter = true;
- }
- return "[" + sb + "]";
- }
}
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
index 4a80279ca..abff202b7 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
@@ -33,13 +33,17 @@ public final class MoreKeysDetector extends KeyDetector {
}
@Override
- public Key detectHitKey(int x, int y) {
+ public Key detectHitKey(final int x, final int y) {
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard == null) {
+ return null;
+ }
final int touchX = getTouchX(x);
final int touchY = getTouchY(y);
Key nearestKey = null;
int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
- for (final Key key : getKeyboard().getKeys()) {
+ for (final Key key : keyboard.getKeys()) {
final int dist = key.squaredDistanceToEdge(touchX, touchY);
if (dist < nearestDist) {
nearestKey = key;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index befc4e6fa..59cf64d4b 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -257,12 +257,15 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
public static void setKeyDetector(final KeyDetector keyDetector) {
+ final Keyboard keyboard = keyDetector.getKeyboard();
+ if (keyboard == null) {
+ return;
+ }
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
tracker.setKeyDetectorInner(keyDetector);
}
- final Keyboard keyboard = keyDetector.getKeyboard();
sGestureEnabler.setPasswordMode(keyboard.mId.passwordInput());
}
@@ -301,7 +304,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final boolean ignoreModifierKey = mIsInDraggingFinger && key.isModifier();
if (DEBUG_LISTENER) {
Log.d(TAG, String.format("[%d] onPress : %s%s%s%s", mPointerId,
- KeyDetector.printableCode(key),
+ (key == null ? "none" : Constants.printableCode(key.getCode())),
ignoreModifierKey ? " ignoreModifier" : "",
key.isEnabled() ? "" : " disabled",
repeatCount > 0 ? " repeatCount=" + repeatCount : ""));
@@ -402,11 +405,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private void setKeyDetectorInner(final KeyDetector keyDetector) {
final Keyboard keyboard = keyDetector.getKeyboard();
+ if (keyboard == null) {
+ return;
+ }
if (keyDetector == mKeyDetector && keyboard == mKeyboard) {
return;
}
mKeyDetector = keyDetector;
- mKeyboard = keyDetector.getKeyboard();
+ mKeyboard = keyboard;
// Mark that keyboard layout has been changed.
mKeyboardLayoutHasBeenChanged = true;
final int keyWidth = mKeyboard.mMostCommonKeyWidth;
@@ -1235,7 +1241,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private void printTouchEvent(final String title, final int x, final int y,
final long eventTime) {
final Key key = mKeyDetector.detectHitKey(x, y);
- final String code = KeyDetector.printableCode(key);
+ final String code = (key == null ? "none" : Constants.printableCode(key.getCode()));
Log.d(TAG, String.format("[%d]%s%s %4d %4d %5d %s", mPointerId,
(mIsTrackingForActionDisabled ? "-" : " "), title, x, y, eventTime, code));
}
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index d6ac71fe2..d1ff714fc 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -252,6 +252,18 @@ public final class Constants {
}
}
+ public static String printableCodes(final int[] codes) {
+ final StringBuilder sb = new StringBuilder();
+ boolean addDelimiter = false;
+ for (final int code : codes) {
+ if (code == NOT_A_CODE) break;
+ if (addDelimiter) sb.append(", ");
+ sb.append(printableCode(code));
+ addDelimiter = true;
+ }
+ return "[" + sb + "]";
+ }
+
public static final int MAX_INT_BIT_COUNT = 32;
/**
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
index 259c1372e..138a626a0 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
@@ -512,7 +512,6 @@ public class DictionaryFacilitatorForSuggest {
}
}
- @UsedForTesting
public void clearUserHistoryDictionary() {
if (mUserHistoryDictionary == null) {
return;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 75ba24d75..5d90e10a0 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -25,6 +25,9 @@ import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnDismissListener;
+import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -531,18 +534,33 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private void refreshPersonalizationDictionarySession() {
+ final Suggest suggest = mInputLogic.mSuggest;
+ final boolean shouldKeepUserHistoryDictionaries;
+ final boolean shouldKeepPersonalizationDictionaries;
if (mSettings.getCurrent().mUsePersonalizedDicts) {
- if (mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes()) {
- final DictionaryFacilitatorForSuggest dictionaryFacilitator =
- (mInputLogic.mSuggest == null) ?
- null : mInputLogic.mSuggest.mDictionaryFacilitator;
- PersonalizationDictionarySessionRegistrar.init(this, dictionaryFacilitator);
- } else {
- PersonalizationDictionarySessionRegistrar.close(this);
- }
+ shouldKeepUserHistoryDictionaries = true;
+ // TODO: Eliminate this restriction
+ shouldKeepPersonalizationDictionaries =
+ mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes();
} else {
- PersonalizationHelper.removeAllPersonalizedDictionaries(this);
+ shouldKeepUserHistoryDictionaries = false;
+ shouldKeepPersonalizationDictionaries = false;
+ }
+ if (!shouldKeepUserHistoryDictionaries) {
+ // Remove user history dictionaries.
+ PersonalizationHelper.removeAllUserHistoryDictionaries(this);
+ if (suggest != null) {
+ suggest.mDictionaryFacilitator.clearUserHistoryDictionary();
+ }
+ }
+ if (!shouldKeepPersonalizationDictionaries) {
+ // Remove personalization dictionaries.
+ PersonalizationHelper.removeAllPersonalizationDictionaries(this);
PersonalizationDictionarySessionRegistrar.resetAll(this);
+ } else {
+ final DictionaryFacilitatorForSuggest dictionaryFacilitator =
+ (suggest == null) ? null : suggest.mDictionaryFacilitator;
+ PersonalizationDictionarySessionRegistrar.init(this, dictionaryFacilitator);
}
}
@@ -775,9 +793,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Note: the following does a round-trip IPC on the main thread: be careful
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
- final Suggest suggest = mInputLogic.mSuggest;
+ Suggest suggest = mInputLogic.mSuggest;
if (null != suggest && null != currentLocale && !currentLocale.equals(suggest.mLocale)) {
initSuggest();
+ suggest = mInputLogic.mSuggest;
}
// Sometimes, while rotating, for some reason the framework tells the app we are not
@@ -802,6 +821,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (isDifferentTextField ||
!currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
loadSettings();
+ suggest = mInputLogic.mSuggest;
}
if (isDifferentTextField) {
mainKeyboardView.closing();
@@ -1163,27 +1183,48 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void showImportantNoticeContents() {
final Context context = this;
- final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ final OnShowListener onShowListener = new OnShowListener() {
@Override
- public void onClick(final DialogInterface di, final int position) {
- di.dismiss();
+ public void onShow(final DialogInterface dialog) {
ImportantNoticeUtils.updateLastImportantNoticeVersion(context);
- if (position == DialogInterface.BUTTON_POSITIVE) {
- setNeutralSuggestionStrip();
- return;
- }
+ onShowImportantNoticeDialog(
+ ImportantNoticeUtils.getCurrentImportantNoticeVersion(context));
+ }
+ };
+ final OnClickListener onClickListener = new OnClickListener() {
+ @Override
+ public void onClick(final DialogInterface dialog, final int position) {
if (position == DialogInterface.BUTTON_NEGATIVE) {
launchSettings();
- return;
}
}
};
- final AlertDialog.Builder builder =
- new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_DARK);
- builder.setMessage(R.string.important_notice_contents)
- .setPositiveButton(android.R.string.ok, listener)
- .setNegativeButton(R.string.go_to_settings, listener);
- showOptionDialog(builder.create(), true /* cancelable */);
+ final OnDismissListener onDismissListener = new OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ setNeutralSuggestionStrip();
+ }
+ };
+ final String importantNoticeContents = ImportantNoticeUtils.getImportantNoticeContents(
+ context);
+ final AlertDialog.Builder builder = new AlertDialog.Builder(
+ context, AlertDialog.THEME_HOLO_DARK);
+ builder.setMessage(importantNoticeContents)
+ .setPositiveButton(android.R.string.ok, null /* listener */)
+ .setNegativeButton(R.string.go_to_settings, onClickListener);
+ final AlertDialog importantNoticeDialog = builder.create();
+ importantNoticeDialog.setOnShowListener(onShowListener);
+ importantNoticeDialog.setOnDismissListener(onDismissListener);
+ showOptionDialog(importantNoticeDialog);
+ }
+
+ private void onShowImportantNoticeDialog(final int importantNoticeVersion) {
+ if (importantNoticeVersion ==
+ ImportantNoticeUtils.VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS) {
+ mSettings.writeUsePersonalizationDictionary(true /* enabled */);
+ loadSettings();
+ initSuggest();
+ }
}
public void displaySettingsDialog() {
@@ -1637,7 +1678,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
getString(R.string.language_selection_title),
getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)),
};
- final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ final OnClickListener listener = new OnClickListener() {
@Override
public void onClick(DialogInterface di, int position) {
di.dismiss();
@@ -1658,18 +1699,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
};
final AlertDialog.Builder builder =
new AlertDialog.Builder(this).setItems(items, listener).setTitle(title);
- showOptionDialog(builder.create(), true /*cancelable */);
+ showOptionDialog(builder.create());
}
// TODO: Move this method out of {@link LatinIME}.
- private void showOptionDialog(final AlertDialog dialog, final boolean cancelable) {
+ private void showOptionDialog(final AlertDialog dialog) {
final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
if (windowToken == null) {
return;
}
- dialog.setCancelable(cancelable);
- dialog.setCanceledOnTouchOutside(cancelable);
+ dialog.setCancelable(true /* cancelable */);
+ dialog.setCanceledOnTouchOutside(true /* cancelable */);
final Window window = dialog.getWindow();
final WindowManager.LayoutParams lp = window.getAttributes();
diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
index 315bd8e58..71e120c5f 100644
--- a/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
@@ -173,6 +173,9 @@ public class Ver2DictDecoder extends AbstractDictDecoder {
@Override
public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException {
final DictionaryHeader header = mBinaryDictionary.getHeader();
+ if (header == null) {
+ throw new IOException("Cannot read the dictionary header.");
+ }
if (header.mFormatOptions.mVersion != FormatSpec.VERSION2) {
throw new UnsupportedFormatException("File header has a wrong version : "
+ header.mFormatOptions.mVersion);
diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
index df64bcec1..5ae2fb6f8 100644
--- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
+++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
@@ -93,13 +93,16 @@ public class PersonalizationHelper {
}
}
- public static void removeAllPersonalizedDictionaries(final Context context) {
- removeAllDictionaries(context, sLangUserHistoryDictCache,
- UserHistoryDictionary.NAME);
+ public static void removeAllPersonalizationDictionaries(final Context context) {
removeAllDictionaries(context, sLangPersonalizationDictCache,
PersonalizationDictionary.NAME);
}
+ public static void removeAllUserHistoryDictionaries(final Context context) {
+ removeAllDictionaries(context, sLangUserHistoryDictCache,
+ UserHistoryDictionary.NAME);
+ }
+
private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries(
final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap,
final String dictNamePrefix) {
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index b51c765f0..f09f386a2 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -421,6 +421,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return mPrefs.getStringSet(PREF_CORPUS_HANDLES_FOR_PERSONALIZATION, emptySet);
}
+ public void writeUsePersonalizationDictionary(final boolean enabled) {
+ mPrefs.edit().putBoolean(PREF_USE_PERSONALIZED_DICTS, enabled).apply();
+ }
+
public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) {
prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply();
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
index e77c55069..8ea712835 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
@@ -504,12 +504,13 @@ final class SuggestionStripLayoutHelper {
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}
- public void layoutImportantNotice(final View importantNoticeStrip, final int stripWidth) {
+ public void layoutImportantNotice(final View importantNoticeStrip, final int stripWidth,
+ final String importantNoticeTitle) {
final TextView titleView = (TextView)importantNoticeStrip.findViewById(
R.id.important_notice_title);
final int width = stripWidth - titleView.getPaddingLeft() - titleView.getPaddingRight();
titleView.setTextColor(mColorAutoCorrect);
- final CharSequence importantNoticeTitle = titleView.getText();
+ titleView.setText(importantNoticeTitle);
titleView.setTextScaleX(1.0f); // Reset textScaleX.
final float titleScaleX = getTextScaleX(
importantNoticeTitle, width, titleView.getPaint());
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 1f80c4cca..2966a8bba 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.v4.view.ViewCompat;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.GestureDetector;
@@ -236,7 +237,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
if (width <= 0) {
return false;
}
- mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, width);
+ final String importantNoticeTitle = ImportantNoticeUtils.getImportantNoticeTitle(
+ getContext());
+ if (TextUtils.isEmpty(importantNoticeTitle)) {
+ return false;
+ }
+ mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, width, importantNoticeTitle);
mStripVisibilityGroup.showImportantNoticeStrip();
mImportantNoticeStrip.setOnClickListener(this);
return true;
diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
index 50a942382..dd418b8cf 100644
--- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
@@ -32,6 +32,7 @@ public final class ImportantNoticeUtils {
// displayed to users.
private static final String PREFERENCE_NAME = "important_notice";
private static final String KEY_IMPORTANT_NOTICE_VERSION = "important_notice_version";
+ public static final int VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS = 2;
// Copy of the hidden {@link Settings.Secure#USER_SETUP_COMPLETE} settings key.
// The value is zero until each multiuser completes system setup wizard.
@@ -59,7 +60,7 @@ public final class ImportantNoticeUtils {
return context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
}
- private static int getCurrentImportantNoticeVersion(final Context context) {
+ public static int getCurrentImportantNoticeVersion(final Context context) {
return context.getResources().getInteger(R.integer.config_important_notice_version);
}
@@ -83,4 +84,22 @@ public final class ImportantNoticeUtils {
.putInt(KEY_IMPORTANT_NOTICE_VERSION, getCurrentImportantNoticeVersion(context))
.apply();
}
+
+ public static String getImportantNoticeTitle(final Context context) {
+ switch (getCurrentImportantNoticeVersion(context)) {
+ case VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS:
+ return context.getString(R.string.important_notice_title);
+ default:
+ return null;
+ }
+ }
+
+ public static String getImportantNoticeContents(final Context context) {
+ switch (getCurrentImportantNoticeVersion(context)) {
+ case VERSION_TO_ENABLE_PERSONALIZED_SUGGESTIONS:
+ return context.getString(R.string.important_notice_contents);
+ default:
+ return null;
+ }
+ }
}