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

Commit e9468390 authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: port compass tile to cm-12.0



Change-Id: Ia1bf264ceb64b153f066c86ab6d2bad3d068b2ee
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 88f00b6a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class QSConstants {
    public static final String TILE_PERFORMANCE = "performance";
    public static final String TILE_ADB_NETWORK = "adb_network";
    public static final String TILE_NFC = "nfc";
    public static final String TILE_COMPASS = "compass";

    // Order matters
    protected static final ArrayList<String> TILES_DEFAULT = new ArrayList<String>();
@@ -70,5 +71,6 @@ public class QSConstants {
        TILES_AVAILABLE.add(TILE_PERFORMANCE);
        TILES_AVAILABLE.add(TILE_ADB_NETWORK);
        TILES_AVAILABLE.add(TILE_NFC);
        TILES_AVAILABLE.add(TILE_COMPASS);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.internal.util.cm;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
@@ -78,6 +80,9 @@ public class QSUtils {
                    case QSConstants.TILE_NFC:
                        removeTile = !deviceSupportsNfc(context);
                        break;
                    case QSConstants.TILE_COMPASS:
                        removeTile = !deviceSupportsCompass(context);
                        break;
                }
                if (removeTile) {
                    iterator.remove();
@@ -131,4 +136,10 @@ public class QSUtils {
        }
        return false;
    }

    public static boolean deviceSupportsCompass(Context context) {
        SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        return sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null
                && sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null;
    }
}
+15 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="64dp"
    android:height="64dp"
    android:viewportWidth="48"
    android:viewportHeight="48">

    <path
        android:fillColor="#4DFFFFFF"
        android:pathData="M42,39.2L8.8,6L6,8.8l9.8,9.8l-1.5,3.7c-0.4,1-0.4,2.2,0,3.3l7.8,19.1c0.7,1.7,3.1,1.7,3.8,0l4.6-11.3
l8.6,8.6L42,39.2Z
M24,28c-2.2,0-4-1.8-4-4c0-0.4,0.1-0.7,0.1-1l4.9,4.9C24.7,27.9,24.4,28,24,28z
M33.8,25.3L19.1,10.7l3-7.4
c0.7-1.7,3.1-1.7,3.8,0l7.8,19.1C34.1,23.3,34.1,24.4,33.8,25.3z" />
</vector>
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="48dp"
    android:height="48dp"
    android:viewportWidth="48"
    android:viewportHeight="48">

    <path
        android:fillColor="#FFFFFF"
        android:pathData="M25.9,3.3l7.8,19.1c0.4,1,0.4,2.2,0,3.3l-7.8,19.1c-0.7,1.7-3.1,1.7-3.8,0l-7.8-19.1c-0.4-1-0.4-2.2,0-3.3
l7.8-19.1C22.8,1.6,25.2,1.6,25.9,3.3Z
M24,20c-2.2,0-4,1.8-4,4s1.8,4,4,4s4-1.8,4-4S26.2,20,24,20z
M26,14v-4c0-1.1-0.9-2-2-2 s-2,0.9-2,2v4c0,1.1,0.9,2,2,2S26,15.1,26,14z" />
</vector>
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
@@ -32,4 +32,16 @@
        <item>@drawable/ic_qs_perf_profile_bal</item>
        <item>@drawable/ic_qs_perf_profile_perf</item>
    </string-array>

    <!-- Cardinal directions for the compass tile -->
    <string-array name="cardinal_directions">
        <item>N</item>  <!-- North -->
        <item>NE</item> <!-- North east -->
        <item>E</item>  <!-- East -->
        <item>SE</item> <!-- South east -->
        <item>S</item>  <!-- South -->
        <item>SW</item> <!-- South west -->
        <item>W</item>  <!-- West -->
        <item>NW</item> <!-- North west -->
    </string-array>
</resources>
Loading