Fix cannot add language
Fix: 227972634 Test: manual Change-Id: I3382879e51238be55687072eeb07bb553dafc952
This commit is contained in:
@@ -17,11 +17,8 @@
|
|||||||
package com.android.settings.localepicker;
|
package com.android.settings.localepicker;
|
||||||
|
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.app.LocaleManager;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.LocaleList;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.android.internal.app.LocalePickerWithRegion;
|
import com.android.internal.app.LocalePickerWithRegion;
|
||||||
@@ -34,7 +31,6 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
implements LocalePickerWithRegion.LocaleSelectedListener {
|
implements LocalePickerWithRegion.LocaleSelectedListener {
|
||||||
|
|
||||||
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
||||||
private static final String TAG = "Calvin";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -51,25 +47,6 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppDefaultLocale(String languageTag) {
|
|
||||||
if (languageTag.isEmpty()) {
|
|
||||||
Log.w(TAG, "[setAppDefaultLocale] No language tag.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setAppDefaultLocale(LocaleList.forLanguageTags(languageTag));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets per app's default language to system. */
|
|
||||||
public void setAppDefaultLocale(LocaleList localeList) {
|
|
||||||
LocaleManager mLocaleManager = getSystemService(LocaleManager.class);
|
|
||||||
if (mLocaleManager == null) {
|
|
||||||
Log.w(TAG, "LocaleManager is null, and cannot set the app locale up.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mLocaleManager.setApplicationLocales("com.android.vending", localeList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
@@ -81,16 +58,9 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
|
public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
|
||||||
/*final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
|
intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
|
||||||
setResult(RESULT_OK, intent);*/
|
setResult(RESULT_OK, intent);
|
||||||
if(locale != null) {
|
|
||||||
Log.d("Calvin", "onLocaleSelected " + locale.getLocale().toLanguageTag());
|
|
||||||
setAppDefaultLocale(locale.getLocale().toLanguageTag());
|
|
||||||
} else {
|
|
||||||
Log.d("Calvin", "onLocaleSelected null");
|
|
||||||
setAppDefaultLocale("");
|
|
||||||
}
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user