Fix bug where default folder name doesn't change when locale changes.

Bug: 78611156
Change-Id: I25c67fc5ebc3edc2d6090f0da0e37bf2e4c07cbf
This commit is contained in:
Jon Miranda
2018-07-11 14:16:23 -07:00
parent 90218c4435
commit aeb4dd026c
3 changed files with 19 additions and 14 deletions
+7
View File
@@ -16,6 +16,7 @@
package com.android.launcher3;
import static android.content.pm.ActivityInfo.CONFIG_LOCALE;
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
@@ -85,6 +86,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.FolderIconPreviewVerifier;
import com.android.launcher3.keyboard.CustomActionsPopup;
@@ -349,6 +351,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
public void onConfigurationChanged(Configuration newConfig) {
int diff = newConfig.diff(mOldConfig);
if ((diff & CONFIG_LOCALE) != 0) {
Folder.setLocaleDependentFields(getResources(), true /* force */);
}
if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0) {
mUserEventDispatcher = null;
initDeviceProfile(mDeviceProfile.inv);
+12 -7
View File
@@ -25,6 +25,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.text.InputType;
@@ -191,14 +192,9 @@ public class Folder extends AbstractFloatingView implements DragSource,
public Folder(Context context, AttributeSet attrs) {
super(context, attrs);
setAlwaysDrawnWithCacheEnabled(false);
Resources res = getResources();
if (sDefaultFolderName == null) {
sDefaultFolderName = res.getString(R.string.folder_name);
}
if (sHintText == null) {
sHintText = res.getString(R.string.folder_hint_text);
}
setLocaleDependentFields(getResources(), false /* force */);
mLauncher = Launcher.getLauncher(context);
// We need this view to be focusable in touch mode so that when text editing of the folder
// name is complete, we have something to focus on, thus hiding the cursor and giving
@@ -1473,4 +1469,13 @@ public class Folder extends AbstractFloatingView implements DragSource,
}
return false;
}
public static void setLocaleDependentFields(Resources res, boolean force) {
if (sDefaultFolderName == null || force) {
sDefaultFolderName = res.getString(R.string.folder_name);
}
if (sHintText == null || force) {
sHintText = res.getString(R.string.folder_hint_text);
}
}
}
@@ -77,7 +77,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
@Thunk Launcher mLauncher;
@Thunk Folder mFolder;
private FolderInfo mInfo;
@Thunk static boolean sStaticValuesDirty = true;
private CheckLongPressHelper mLongPressHelper;
private StylusEventHelper mStylusEventHelper;
@@ -185,12 +184,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
return icon;
}
@Override
protected Parcelable onSaveInstanceState() {
sStaticValuesDirty = true;
return super.onSaveInstanceState();
}
public Folder getFolder() {
return mFolder;
}