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

Commit b3ae3463 authored by Gabriele M's avatar Gabriele M
Browse files

SystemUI: Add separate pref screen for the status bar tuner

Keep the status bar preferences separate and allow to start them
directly without loading the main tuner fragment.

Change-Id: Ie1a0d9395b7bc01d585616a1976adeda3c457a0d
parent 629bff9e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -39,6 +39,20 @@

    <application>

        <activity-alias
            android:name=".tuner.StatusBarTuner"
            android:targetActivity=".tuner.TunerActivity"
            android:icon="@drawable/tuner"
            android:theme="@style/TunerSettings"
            android:label="@string/status_bar"
            android:process=":tuner"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.settings.action.STATUS_BAR_TUNER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".tuner.NavBarTuner"
            android:targetActivity=".tuner.TunerActivity"
+92 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sysui="http://schemas.android.com/apk/res-auto"
    android:key="status_bar"
    android:title="@string/status_bar">

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="rotate"
        android:title="@string/status_bar_settings_auto_rotation" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="headset"
        android:title="@string/headset" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="managed_profile"
        android:title="@string/status_bar_work" />

    <!-- ime -->
    <!-- sync_failing -->
    <!-- sync_active -->

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="cast"
        android:title="@string/quick_settings_cast_title" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="hotspot"
        android:title="@string/quick_settings_hotspot_label" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="bluetooth"
        android:title="@string/quick_settings_bluetooth_label" />

    <!-- nfc -->
    <!-- tty -->
    <!-- speakerphone -->

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="zen"
        android:title="@string/quick_settings_dnd_label" />

    <!-- mute -->

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="volume"
        android:title="@*android:string/volume_unknown" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="wifi"
        android:title="@string/quick_settings_wifi_label" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="ethernet"
        android:title="@string/status_bar_ethernet" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="mobile"
        android:title="@string/quick_settings_cellular_detail_title" />

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="airplane"
        android:title="@string/status_bar_airplane" />

    <!-- other weird signal stuff -->

    <com.android.systemui.tuner.StatusBarSwitch
        android:key="alarm_clock"
        android:title="@string/status_bar_alarm" />

    <!-- secure -->

    <com.android.systemui.tuner.ClockPreference
        android:title="@string/tuner_time"
        android:summary="%s"
        android:entries="@array/clock_options" />

</PreferenceScreen>
+3 −75
Original line number Diff line number Diff line
@@ -18,82 +18,10 @@
    xmlns:sysui="http://schemas.android.com/apk/res-auto"
    android:title="@string/system_ui_tuner">

    <PreferenceScreen
    <Preference
        android:key="status_bar"
        android:title="@string/status_bar" >

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="rotate"
            android:title="@string/status_bar_settings_auto_rotation" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="headset"
            android:title="@string/headset" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="managed_profile"
            android:title="@string/status_bar_work" />

        <!-- ime -->
        <!-- sync_failing -->
        <!-- sync_active -->

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="cast"
            android:title="@string/quick_settings_cast_title" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="hotspot"
            android:title="@string/quick_settings_hotspot_label" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="bluetooth"
            android:title="@string/quick_settings_bluetooth_label" />

        <!-- nfc -->
        <!-- tty -->
        <!-- speakerphone -->

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="zen"
            android:title="@string/quick_settings_dnd_label" />

        <!-- mute -->

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="volume"
            android:title="@*android:string/volume_unknown" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="wifi"
            android:title="@string/quick_settings_wifi_label" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="ethernet"
            android:title="@string/status_bar_ethernet" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="mobile"
            android:title="@string/quick_settings_cellular_detail_title" />

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="airplane"
            android:title="@string/status_bar_airplane" />

        <!-- other weird signal stuff -->

        <com.android.systemui.tuner.StatusBarSwitch
            android:key="alarm_clock"
            android:title="@string/status_bar_alarm" />

        <!-- secure -->

        <com.android.systemui.tuner.ClockPreference
            android:title="@string/tuner_time"
            android:summary="%s"
            android:entries="@array/clock_options" />

    </PreferenceScreen>
        android:title="@string/status_bar"
        android:fragment="com.android.systemui.tuner.StatusBarTuner" />

    <PreferenceScreen
        android:key="volume_and_do_not_disturb"
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The LineageOS 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.tuner;

import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
import android.view.MenuItem;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.R;

public class StatusBarTuner extends PreferenceFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setHasOptionsMenu(true);
        getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        addPreferencesFromResource(R.xml.status_bar_prefs);
    }

    @Override
    public void onResume() {
        super.onResume();
        MetricsLogger.visibility(getContext(), MetricsEvent.TUNER, true);
    }

    @Override
    public void onPause() {
        super.onPause();
        MetricsLogger.visibility(getContext(), MetricsEvent.TUNER, false);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            getActivity().onBackPressed();
            return true;
        }
        return false;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ public class TunerActivity extends SettingsDrawerActivity implements
                fragment = new NavBarTuner();
            } else if ("com.android.settings.action.POWER_NOTIF_CONTROLS".equals(action)) {
                fragment = new PowerNotificationControlsFragment();
            } else if ("com.android.settings.action.STATUS_BAR_TUNER".equals(action)) {
                fragment = new StatusBarTuner();
            } else {
                fragment = new TunerFragment();
            }