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

Commit 42a0bc8f authored by stofstik's avatar stofstik Committed by Bruno Martins
Browse files

SystemUI: Add tile to show volume panel

Change-Id: Ic583c24e304d1edc903127237fc9eb5c7eeb7e4d
JIRA: CYAN-6721
parent fdcf5bb5
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
@@ -37,4 +37,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
@@ -123,7 +123,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,work,cast,night,caffeine,heads_up,sync
        wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,caffeine,heads_up,sync,volume_panel
    </string>

    <!-- The tiles to display in QuickSettings -->
+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.qs.tiles.NightDisplayTile;
import com.android.systemui.qs.tiles.RotationLockTile;
import com.android.systemui.qs.tiles.SyncTile;
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.qs.QSTileHost;
@@ -109,6 +110,8 @@ public class QSFactoryImpl implements QSFactory {
                return new HeadsUpTile(mHost);
            case "sync":
                return new SyncTile(mHost);
            case "volume_panel":
                return new VolumeTile(mHost);
        }

        // Intent tiles.
+77 −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;

public class VolumeTile extends QSTileImpl<BooleanState> {

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

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