のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

Quick Settings 自動回転

     57     @Override
     58     protected void handleUpdateState(BooleanState state, Object arg) {
     59         if (mController == null) return;
     60         final boolean rotationLocked = mController.isRotationLocked();
     61         state.visible = mController.isRotationLockAffordanceVisible();
     62         final Resources res = mContext.getResources();
     63         state.value = rotationLocked;
     64         if (rotationLocked) {
     65             final boolean portrait = res.getConfiguration().orientation
     66                     != Configuration.ORIENTATION_LANDSCAPE;
     67             final int label = portrait 
                            ? R.string
                              .quick_settings_rotation_locked_portrait_label <====

     68                     : R.string
                              .quick_settings_rotation_locked_landscape_label; <====

     69             final int icon = portrait ? R.drawable.ic_qs_rotation_portrait
     70                     : R.drawable.ic_qs_rotation_landscape;
     71             state.label = mContext.getString(label);
     72             state.icon = mContext.getDrawable(icon);
     73         } else {
     74             state.label = mContext.getString(R.string
                              .quick_settings_rotation_unlocked_label); <====

     75             state.icon = res.getDrawable(R.drawable.ic_qs_rotation_unlocked);
     76         }
     77         state.contentDescription = getAccessibilityString(
     78                 R.string.accessibility_rotation_lock_on_portrait,
     79                 R.string.accessibility_rotation_lock_on_landscape,
     80                 R.string.accessibility_rotation_lock_off);
     81     }