[Panlingual] Adds a filter of application for per apps locale change.

- Settings -> System -> app language -> app languages
   Use this filter to only show apps allowed to change the locale.
 - Settings -> Apps -> all apps -> any one of app -> language
   Use this filter to only show the language preference of app allowed to change the locale.
Bug: 210935436
Test: atest pass.
Test: local test.
Change-Id: I2f8a0815dae68392e11882ad9e1e4945492efdba
This commit is contained in:
tom hsu
2022-01-04 18:08:28 +08:00
committed by Tom Hsu
parent 0bcd9d1b20
commit 33f2096fea
8 changed files with 356 additions and 18 deletions

View File

@@ -20,20 +20,23 @@ import android.content.Context;
import android.util.FeatureFlagUtils;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.AppLocaleUtil;
/**
* A controller to update current locale information of application.
*/
public class AppLocalePreferenceController extends AppInfoPreferenceControllerBase {
private static final String TAG = AppLocalePreferenceController.class.getSimpleName();
public AppLocalePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION)
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
boolean isFeatureOn = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION);
return isFeatureOn && canDisplayLocaleUi() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
@@ -45,4 +48,8 @@ public class AppLocalePreferenceController extends AppInfoPreferenceControllerBa
public CharSequence getSummary() {
return AppLocaleDetails.getSummary(mContext, mParent.getAppEntry().info.packageName);
}
boolean canDisplayLocaleUi() {
return AppLocaleUtil.canDisplayLocaleUi(mContext, mParent.getAppEntry());
}
}