Пример #1
1
  @Implementation
  public void setTo(Configuration o) {
    // commented out lines are coming in a newer version of Android SDK

    realConfiguration.fontScale = o.fontScale;
    realConfiguration.mcc = o.mcc;
    realConfiguration.mnc = o.mnc;
    if (o.locale != null) {
      realConfiguration.locale = (Locale) o.locale.clone();
      // realConfiguration.textLayoutDirection = o.textLayoutDirection;
    }
    // realConfiguration.userSetLocale = o.userSetLocale;
    realConfiguration.touchscreen = o.touchscreen;
    realConfiguration.keyboard = o.keyboard;
    realConfiguration.keyboardHidden = o.keyboardHidden;
    realConfiguration.hardKeyboardHidden = o.hardKeyboardHidden;
    realConfiguration.navigation = o.navigation;
    realConfiguration.navigationHidden = o.navigationHidden;
    realConfiguration.orientation = o.orientation;
    realConfiguration.screenLayout = o.screenLayout;
    realConfiguration.uiMode = o.uiMode;
    realConfiguration.screenWidthDp = o.screenWidthDp;
    realConfiguration.screenHeightDp = o.screenHeightDp;
    realConfiguration.smallestScreenWidthDp = o.smallestScreenWidthDp;
    // realConfiguration.compatScreenWidthDp = o.compatScreenWidthDp;
    // realConfiguration.compatScreenHeightDp = o.compatScreenHeightDp;
    // realConfiguration.compatSmallestScreenWidthDp = o.compatSmallestScreenWidthDp;
    // realConfiguration.seq = o.seq;
  }
 private void handleToggleLargeTextPreferenceClick() {
   try {
     mCurConfig.fontScale = mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE : 1;
     ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
   } catch (RemoteException re) {
     /* ignore */
   }
 }
 public void writeFontSizePreference(Object objValue) {
   try {
     mCurConfig.fontScale = Float.parseFloat(objValue.toString());
     ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
   } catch (RemoteException e) {
     Log.w(TAG, "Unable to save font size");
   }
 }
 private void handleToggleLargeTextPreferenceClick() {
   float updateFontScale =
       Settings.System.getFloat(getContentResolver(), Settings.System.FONT_SCALE_EXTRALARGE, -1);
   try {
     if (updateFontScale == -1) {
       if (sIsScreenLarge) {
         mCurConfig.fontScale =
             mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE_TABLET : 1;
       } else {
         mCurConfig.fontScale =
             mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE_PHONE : 1;
       }
       ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
     } else {
       mCurConfig.fontScale = mToggleLargeTextPreference.isChecked() ? updateFontScale : 1;
       ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
     }
   } catch (RemoteException re) {
     /* ignore */
   }
 }