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

Commit 87fb39b3 authored by Gianmarco Reverberi's avatar Gianmarco Reverberi Committed by David van Tonder
Browse files

QS: change location sensors mode in quick settings [1/2]

Clicking on the location tile now opens a detail view
where we can either enable/disable location or
switch through the location modes.
Added a new icon for battery saving mode.
Added a switch in notification drawer settings
to enable this.

Change-Id: Icfc2e75aeafde32b1975040d0ea757aaeb34c120
parent e6f1d4e5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1777,6 +1777,11 @@ public final class Settings {
         */
        public static final int ADVANCED_SETTINGS_DEFAULT = 0;

        /**
         * @hide
         */
        public static final String QS_LOCATION_ADVANCED = "qs_location_advanced";

        /**
         * @deprecated Use {@link android.provider.Settings.Global#AIRPLANE_MODE_ON} instead
         */
+28 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2014 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="64dp"
        android:height="64dp"
        android:viewportWidth="48.0"
        android:viewportHeight="48.0">

    <path
        android:fillColor="#4DFFFFFF"
        android:pathData="M24.0,4.0c-7.7,0.0 -14.0,6.3 -14.0,14.0c0.0,10.5 14.0,26.0 14.0,26.0s14.0,-15.5 14.0,-26.0C38.0,10.3 31.7,4.0 24.0,4.0zM24.0,23.0c-2.8,0.0 -5.0,-2.2 -5.0,-5.0s2.2,-5.0 5.0,-5.0c2.8,0.0 5.0,2.2 5.0,5.0S26.8,23.0 24.0,23.0z"/>
    <path
        android:pathData="M24.0,4.0c-7.7,0.0 -14.0,6.3 -14.0,14.0c0.0,10.5 14.0,26.0 14.0,26.0l0.0,-21.0 c-2.8,0.0 -5.0,-2.2 -5.0,-5.0s2.2,-5.0 5.0,-5.0l0.0,-9.0z"
        android:fillColor="#FFFFFFFF"/>
</vector>
+75 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2014 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.
-->
<com.android.systemui.qs.tiles.LocationDetailView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="16dp"
    android:paddingStart="16dp"
    android:paddingEnd="16dp"
    android:orientation="vertical" >

    <TextView
        android:id="@android:id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="@style/TextAppearance.QS.DataUsage"
        android:text="@string/quick_settings_location_detail_menu_title" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:orientation="vertical" >

        <RadioGroup
            android:id="@+id/radiogroup_location"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        <RadioButton android:id="@+id/radio_high_accuracy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:paddingLeft="16dp"
            android:paddingRight="8dp"
            android:paddingBottom="8dp"
            android:textSize="20sp"
            android:text="@string/quick_settings_location_detail_mode_high_accuracy_title" />
        <RadioButton android:id="@+id/radio_battery_saving"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:paddingLeft="16dp"
            android:paddingRight="8dp"
            android:paddingBottom="8dp"
            android:textSize="20sp"
            android:text="@string/quick_settings_location_detail_mode_battery_saving_title" />
        <RadioButton android:id="@+id/radio_sensors_only"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:paddingLeft="16dp"
            android:paddingRight="8dp"
            android:paddingBottom="8dp"
            android:textSize="20sp"
            android:text="@string/quick_settings_location_detail_mode_sensors_only_title" />
        </RadioGroup>
    </LinearLayout>

</com.android.systemui.qs.tiles.LocationDetailView>
+31 −0
Original line number Diff line number Diff line
@@ -39,6 +39,13 @@
    <!-- Content description of the roaming tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_roaming_on">Roaming on.</string>

    <!-- Content description of the location tile in quick settings when on, battery saving mode (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_battery_saving">Location reporting: battery saving mode.</string>
    <!-- Content description of the location tile in quick settings when on, sensors only mode (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_gps_only">Location reporting: sensors only mode.</string>
    <!-- Content description of the location tile in quick settings when on, high accuracy mode (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_high_accuracy">Location reporting: high accuracy mode.</string>

    <!-- Content description of the superuser tile -->
    <string name="accessibility_su_active">Superuser session active</string>

@@ -54,6 +61,30 @@
    <string name="quick_settings_dds_sub">Card <xliff:g id="number">%d</xliff:g> data</string>
    <string name="quick_settings_data_off">Data off</string>

    <!-- QuickSettings: Location (On, low-power) [CHAR LIMIT=NONE] -->
    <string name="quick_settings_location_battery_saving_label">Battery saving</string>
    <!-- QuickSettings: Location (On, gps-only) [CHAR LIMIT=NONE] -->
    <string name="quick_settings_location_gps_only_label">GPS only</string>
    <!-- QuickSettings: Location (On, high-accuracy) [CHAR LIMIT=NONE] -->
    <string name="quick_settings_location_high_accuracy_label">High accuracy</string>

    <!-- QuickSettings: Location detail panel title [CHAR LIMIT=NONE] -->
    <string name="quick_settings_location_detail_title">Location</string>
    <!-- QuickSettings: Location detail panel menu title [CHAR LIMIT=NONE] -->
    <string name="quick_settings_location_detail_menu_title">Select mode:</string>
    <!-- [CHAR LIMIT=30] Location detail panel, high accuracy location mode -->
    <string name="quick_settings_location_detail_mode_high_accuracy_title">High accuracy</string>
    <!-- [CHAR LIMIT=30] Location detail panel, battery saving location mode -->
    <string name="quick_settings_location_detail_mode_battery_saving_title">Battery saving</string>
    <!-- [CHAR LIMIT=30] Location detail panel, device only location mode -->
    <string name="quick_settings_location_detail_mode_sensors_only_title">Device only</string>
    <!-- [CHAR LIMIT=130] Location detail panel, description for high accuracy mode -->
    <string name="quick_settings_location_detail_mode_high_accuracy_description">Use GPS, Wi\u2011Fi, and cellular networks to determine location </string>
    <!-- [CHAR LIMIT=130] Location detail panel, description for battery saving mode -->
    <string name="quick_settings_location_detail_mode_battery_saving_description">Use Wi\u2011Fi and cellular networks to determine location</string>
    <!-- [CHAR LIMIT=130] Location detail panel, description for sensors only mode -->
    <string name="quick_settings_location_detail_mode_sensors_only_description">Use GPS to determine your location</string>

    <!-- Task Manager -->
    <string name="tasklistview_title">Task Manager</string>
    <string name="message_switch_fail">Can not switch to this task, because it has no interface.</string>
+106 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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
 */

package com.android.systemui.qs.tiles;

import android.content.Context;
import android.provider.Settings;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

import com.android.systemui.R;
import com.android.systemui.statusbar.policy.LocationController;

/**
 * Layout for the location detail in quick settings.
 */
public class LocationDetailView extends LinearLayout {

    private RadioGroup mRadioGroup;
    private RadioButton mHighAccuracy;
    private RadioButton mBatterySaving;
    private RadioButton mSensorsOnly;

    //private Context mContext;
    private LocationController mController;

    public LocationDetailView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mRadioGroup = (RadioGroup) findViewById(R.id.radiogroup_location);
        mHighAccuracy = (RadioButton) findViewById(R.id.radio_high_accuracy);
        mBatterySaving = (RadioButton) findViewById(R.id.radio_battery_saving);
        mSensorsOnly = (RadioButton) findViewById(R.id.radio_sensors_only);
        
        mRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                onRadioButtonClicked(checkedId);
            }
        });
    }

    public void setLocationController(LocationController controller) {
        mController = controller;
    }

    public void onRadioButtonClicked(int checkedId) {
        switch(checkedId) {
            case R.id.radio_high_accuracy:
                mController.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
                break;
            case R.id.radio_battery_saving:
                mController.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
                break;
            case R.id.radio_sensors_only:
                mController.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
                break;
            default: break;
        }
    }

    public void setLocationMode(int mode) {
        boolean enabled = mode != Settings.Secure.LOCATION_MODE_OFF;

        switch(mode) {
            case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
                mRadioGroup.check(mHighAccuracy.getId());
                break;
            case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
                mRadioGroup.check(mBatterySaving.getId());
                break;
            case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
                mRadioGroup.check(mSensorsOnly.getId());
                break;
            default: break;
        }

        mHighAccuracy.setEnabled(enabled);
        mBatterySaving.setEnabled(enabled);
        mSensorsOnly.setEnabled(enabled);
    }
}
Loading