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

Commit e2c4a01e authored by stofstik's avatar stofstik Committed by Luca Stefani
Browse files

SystemUI: Add tile to show volume panel

Change-Id: Ic583c24e304d1edc903127237fc9eb5c7eeb7e4d
JIRA: CYAN-6721
parent f6ded640
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2015 The CyanogenMod Project
    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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="64dp"
        android:height="64dp"
        android:viewportWidth="24"
        android:viewportHeight="24">

    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M3,10v4c0,0.55,0.45,1,1,1h3l3.29,3.29c0.63,0.63,1.71,0.18,1.71-0.71V6.41c0-0.89-1.08-1.34-1.71-0.71L7,9H4 C3.45,9,3,9.45,3,10z M16.5,12c0-1.77-1.02-3.29-2.5-4.03v8.05C15.48,15.29,16.5,13.77,16.5,12z M14,4.45v0.2 c0,0.38,0.25,0.71,0.6,0.85C17.18,6.53,19,9.06,19,12s-1.82,5.47-4.4,6.5c-0.36,0.14-0.6,0.47-0.6,0.85v0.2 c0,0.63,0.63,1.07,1.21,0.85C18.6,19.11,21,15.84,21,12s-2.4-7.11-5.79-8.4C14.63,3.37,14,3.82,14,4.45z"/>
</vector>
+3 −0
Original line number Diff line number Diff line
@@ -59,4 +59,7 @@
    <string name="accessibility_quick_settings_sync_on">Sync on.</string>
    <string name="accessibility_quick_settings_sync_changed_off">Sync turned off.</string>
    <string name="accessibility_quick_settings_sync_changed_on">Sync turned on.</string>

    <!-- Volume panel QS tile -->
    <string name="quick_settings_volume_panel_label">Volume panel</string>
</resources>
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@

    <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
    <string name="quick_settings_tiles_stock" translatable="false">
        wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,caffeine,heads_up,sync
        wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,caffeine,heads_up,sync,volume_panel
    </string>

    <!-- The tiles to display in QuickSettings -->
+7 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.qs.tiles.RotationLockTile;
import com.android.systemui.qs.tiles.SyncTile;
import com.android.systemui.qs.tiles.UiModeNightTile;
import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.VolumeTile;
import com.android.systemui.qs.tiles.WifiTile;
import com.android.systemui.qs.tiles.WorkModeTile;
import com.android.systemui.util.leak.GarbageMonitor;
@@ -82,6 +83,7 @@ public class QSFactoryImpl implements QSFactory {
    private final Provider<CaffeineTile> mCaffeineTileProvider;
    private final Provider<HeadsUpTile> mHeadsUpTileProvider;
    private final Provider<SyncTile> mSyncTileProvider;
    private final Provider<VolumeTile> mVolumeTileProvider;

    private QSTileHost mHost;

@@ -107,7 +109,8 @@ public class QSFactoryImpl implements QSFactory {
            Provider<UiModeNightTile> uiModeNightTileProvider,
            Provider<CaffeineTile> caffeineTileProvider,
            Provider<HeadsUpTile> headsUpTileProvider,
            Provider<SyncTile> syncTileProvider) {
            Provider<SyncTile> syncTileProvider,
            Provider<VolumeTile> volumeTileProvider) {
        mWifiTileProvider = wifiTileProvider;
        mBluetoothTileProvider = bluetoothTileProvider;
        mCellularTileProvider = cellularTileProvider;
@@ -130,6 +133,7 @@ public class QSFactoryImpl implements QSFactory {
        mCaffeineTileProvider = caffeineTileProvider;
        mHeadsUpTileProvider = headsUpTileProvider;
        mSyncTileProvider = syncTileProvider;
        mVolumeTileProvider = volumeTileProvider;
    }

    public void setHost(QSTileHost host) {
@@ -190,6 +194,8 @@ public class QSFactoryImpl implements QSFactory {
                return mHeadsUpTileProvider.get();
            case "sync":
                return mSyncTileProvider.get();
            case "volume_panel":
                return mVolumeTileProvider.get();
        }

        // Intent tiles.
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The CyanogenMod Project
 * 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.qs.tiles;

import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.service.quicksettings.Tile;

import com.android.systemui.plugins.qs.QSTile.BooleanState;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.R;

import org.lineageos.internal.logging.LineageMetricsLogger;

import javax.inject.Inject;

public class VolumeTile extends QSTileImpl<BooleanState> {

    private static final Intent SOUND_SETTINGS = new Intent("android.settings.SOUND_SETTINGS");

    @Inject
    public VolumeTile(QSHost host) {
        super(host);
    }

    @Override
    protected void handleClick() {
        AudioManager am = mContext.getSystemService(AudioManager.class);
        am.adjustVolume(AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
    }

    @Override
    public Intent getLongClickIntent() {
        return SOUND_SETTINGS;
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.label = mContext.getString(R.string.quick_settings_volume_panel_label);
        state.icon = ResourceIcon.get(R.drawable.ic_qs_volume_panel); // TODO needs own icon
        state.state = Tile.STATE_ACTIVE;
    }

    @Override
    public CharSequence getTileLabel() {
        return mContext.getString(R.string.quick_settings_volume_panel_label);
    }

    @Override
    public int getMetricsCategory() {
        return LineageMetricsLogger.TILE_VOLUME;
    }

    @Override
    public BooleanState newTileState() {
        return new BooleanState();
    }

    @Override
    public void handleSetListening(boolean listening) {
        // Do nothing
    }
}