Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 025bca16 authored by Sam Blitzstein's avatar Sam Blitzstein
Browse files

Allow tablets to freely rotate the alarm alert activity.

Tablets were switching to their defualt orientation due to the
nosensor orientation set in the manifest, and were then being changed
to unspecified once the activity was created. Doing it the opposite,
so phones and tablets start as unspecified and only phones are
then designated as "nosensor" during onCreate() allows us to get
the desired behavior.

Bug: 8728671
Change-Id: I29ac593ccbb65953fa35dad38110accc9c531594
parent ce9b1067
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@
                android:launchMode="singleInstance"
                android:taskAffinity=""
                android:showOnLockScreen="true"
                android:screenOrientation="nosensor"
                android:configChanges="orientation|screenSize|keyboardHidden|keyboard|navigation"/>

        <activity android:name="ScreensaverActivity"
+10 −14
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ public class AlarmAlertFullScreen extends Activity implements GlowPadView.OnTrig
    private int mVolumeBehavior;
    boolean mFullscreenStyle;
    private GlowPadView mGlowPadView;
    private boolean mIsDocked = false;

    // Parameters for the GlowPadView "ping" animation; see triggerPing().
    private static final int PING_MESSAGE_WHAT = 101;
@@ -132,16 +131,18 @@ public class AlarmAlertFullScreen extends Activity implements GlowPadView.OnTrig
                    | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        }

        updateLayout();

        // Check the docking status , if the device is docked , do not limit rotation
        IntentFilter ifilter = new IntentFilter(Intent.ACTION_DOCK_EVENT);
        Intent dockStatus = registerReceiver(null, ifilter);
        if (dockStatus != null) {
            mIsDocked = dockStatus.getIntExtra(Intent.EXTRA_DOCK_STATE, -1)
                    != Intent.EXTRA_DOCK_STATE_UNDOCKED;
        // In order to allow tablets to freely rotate and phones to stick
        // with "nosensor" (use default device orientation) we have to have
        // the manifest start with an orientation of unspecified" and only limit
        // to "nosensor" for phones. Otherwise we get behavior like in b/8728671
        // where tablets start off in their default orientation and then are
        // able to freely rotate.
        if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
        }

        updateLayout();

        // Register to get the alarm killed/snooze/dismiss intent.
        IntentFilter filter = new IntentFilter(Alarms.ALARM_KILLED);
        filter.addAction(Alarms.ALARM_SNOOZE_ACTION);
@@ -311,11 +312,6 @@ public class AlarmAlertFullScreen extends Activity implements GlowPadView.OnTrig
            mGlowPadView.setDirectionDescriptionsResourceId(R.array.dismiss_direction_descriptions);
        }
        mPingEnabled = true;
        // The activity is locked to the default orientation as a default set in the manifest
        // Override this settings if the device is docked or config set it differently
        if (getResources().getBoolean(R.bool.config_rotateAlarmAlert) || mIsDocked) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }
    }

    @Override