use of android.content.res.Configuration in project android_frameworks_base by ResurrectionRemix.
the class ActivityThread method createNewConfigAndUpdateIfNotNull.
/**
* Creates a new Configuration only if override would modify base. Otherwise returns base.
* @param base The base configuration.
* @param override The update to apply to the base configuration. Can be null.
* @return A Configuration representing base with override applied.
*/
private static Configuration createNewConfigAndUpdateIfNotNull(@NonNull Configuration base, @Nullable Configuration override) {
if (override == null) {
return base;
}
Configuration newConfig = new Configuration(base);
newConfig.updateFrom(override);
return newConfig;
}
use of android.content.res.Configuration in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PreviewSeekBarPreferenceFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View root = super.onCreateView(inflater, container, savedInstanceState);
final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
listContainer.removeAllViews();
final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
listContainer.addView(content);
mLabel = (TextView) content.findViewById(R.id.current_label);
// The maximum SeekBar value always needs to be non-zero. If there's
// only one available value, we'll handle this by disabling the
// seek bar.
final int max = Math.max(1, mEntries.length - 1);
final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
seekBar.setLabels(mEntries);
seekBar.setMax(max);
seekBar.setProgress(mInitialIndex);
seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
mSmaller = content.findViewById(R.id.smaller);
mSmaller.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final int progress = seekBar.getProgress();
if (progress > 0) {
seekBar.setProgress(progress - 1, true);
}
}
});
mLarger = content.findViewById(R.id.larger);
mLarger.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final int progress = seekBar.getProgress();
if (progress < seekBar.getMax()) {
seekBar.setProgress(progress + 1, true);
}
}
});
if (mEntries.length == 1) {
// The larger and smaller buttons will be disabled when we call
// setPreviewLayer() later in this method.
seekBar.setEnabled(false);
}
final Context context = getContext();
final Configuration origConfig = context.getResources().getConfiguration();
final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
Configuration[] configurations = new Configuration[mEntries.length];
for (int i = 0; i < mEntries.length; ++i) {
configurations[i] = createConfig(origConfig, i);
}
mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
mPreviewPager.setAdapter(mPreviewPagerAdapter);
mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
if (mPreviewSampleResIds.length > 1) {
mPageIndicator.setViewPager(mPreviewPager);
mPageIndicator.setVisibility(View.VISIBLE);
mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
} else {
mPageIndicator.setVisibility(View.GONE);
}
setPreviewLayer(mInitialIndex, false);
return root;
}
use of android.content.res.Configuration in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InputMethodAndSubtypeEnabler method onCreate.
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
final Configuration config = getResources().getConfiguration();
mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
// Input method id should be available from an Intent when this preference is launched as a
// single Activity (see InputMethodAndSubtypeEnablerActivity). It should be available
// from a preference argument when the preference is launched as a part of the other
// Activity (like a right pane of 2-pane Settings app)
final String targetImi = getStringExtraFromIntentOrArguments(android.provider.Settings.EXTRA_INPUT_METHOD_ID);
mInputMethodInfoList = mImm.getInputMethodList();
mCollator = Collator.getInstance();
final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
final int imiCount = mInputMethodInfoList.size();
for (int index = 0; index < imiCount; ++index) {
final InputMethodInfo imi = mInputMethodInfoList.get(index);
// Add subtype preferences of this IME when it is specified or no IME is specified.
if (imi.getId().equals(targetImi) || TextUtils.isEmpty(targetImi)) {
addInputMethodSubtypePreferences(imi, root);
}
}
setPreferenceScreen(root);
}
use of android.content.res.Configuration in project android_frameworks_base by ResurrectionRemix.
the class Am method runGetConfig.
private void runGetConfig() throws Exception {
int days = 14;
String option = nextOption();
if (option != null) {
if (!option.equals("--days")) {
throw new IllegalArgumentException("unrecognized option " + option);
}
days = Integer.parseInt(nextArgRequired());
if (days <= 0) {
throw new IllegalArgumentException("--days must be a positive integer");
}
}
try {
Configuration config = mAm.getConfiguration();
if (config == null) {
System.err.println("Activity manager has no configuration");
return;
}
System.out.println("config: " + Configuration.resourceQualifierString(config));
System.out.println("abi: " + TextUtils.join(",", Build.SUPPORTED_ABIS));
final List<Configuration> recentConfigs = getRecentConfigurations(days);
final int recentConfigSize = recentConfigs.size();
if (recentConfigSize > 0) {
System.out.println("recentConfigs:");
}
for (int i = 0; i < recentConfigSize; i++) {
System.out.println(" config: " + Configuration.resourceQualifierString(recentConfigs.get(i)));
}
} catch (RemoteException e) {
}
}
use of android.content.res.Configuration in project android_frameworks_base by ResurrectionRemix.
the class Am method runSupportsMultiwindow.
private void runSupportsMultiwindow() throws Exception {
// system resources does not contain all the device configuration, construct it manually.
Configuration config = mAm.getConfiguration();
if (config == null) {
throw new AndroidException("Activity manager has no configuration");
}
final DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
Resources res = new Resources(AssetManager.getSystem(), metrics, config);
System.out.println(res.getBoolean(com.android.internal.R.bool.config_supportsMultiWindow));
}
Aggregations