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

Commit 35f68aa9 authored by Isaac Katzenelson's avatar Isaac Katzenelson
Browse files

Lock alert orientation for un-docked phones.

Bug: 7368087

Lock the rotation to the default for phones.
LEt device rotate if it was docked or it is sw600

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

        <receiver android:name="AlarmReceiver"
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License"); 
** you may not use this file except in compliance with the License. 
** You may obtain a copy of the License at 
**
**     http://www.apache.org/licenses/LICENSE-2.0 
**
** Unless required by applicable law or agreed to in writing, software 
** distributed under the License is distributed on an "AS IS" BASIS, 
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
** See the License for the specific language governing permissions and 
** limitations under the License.
*/
-->

<!-- These resources are around just to allow their values to be customized
     for different hardware and product builds. -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <bool name="config_rotateAlarmAlert">true</bool>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <bool name="config_requiresScreenSaver">true</bool>
    <bool name="config_dockAppEnabled">true</bool>
    <bool name="config_rotateAlarmAlert">false</bool>
</resources>
+15 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
@@ -58,6 +59,7 @@ 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,6 +134,14 @@ public class AlarmAlertFullScreen extends Activity implements GlowPadView.OnTrig

        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;
        }

        // Register to get the alarm killed/snooze/dismiss intent.
        IntentFilter filter = new IntentFilter(Alarms.ALARM_KILLED);
        filter.addAction(Alarms.ALARM_SNOOZE_ACTION);
@@ -298,6 +308,11 @@ public class AlarmAlertFullScreen extends Activity implements GlowPadView.OnTrig
            mGlowPadView.setTargetDescriptionsResourceId(R.array.dismiss_descriptions);
            mGlowPadView.setDirectionDescriptionsResourceId(R.array.dismiss_direction_descriptions);
        }
        // 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