ParanoidGlyph: Improve volume indicator function

* phone1 requires https://gerrit.aospa.co/c/AOSPA/android_kernel_nothing_sm7325/+/39114
 * phone1 will now be "inverted" and fill up from the bottom, will be "fixed" again with https://gerrit.aospa.co/c/AOSPA/android_kernel_nothing_sm7325/+/39116

Co-authored-by: Abhay Singh Gill <abhaygill017@gmail.com>
Change-Id: I8b39df3f28e656c960e58eb2f99fd0045aa076a6
This commit is contained in:
Fabian Leutenegger
2024-03-02 15:47:52 +05:30
committed by Wiktor Rudzki
parent 35e24ba438
commit 1ffd57dbb1
5 changed files with 40 additions and 44 deletions

View File

@@ -46,15 +46,6 @@
<integer name="glyph_settings_notifs_essential_led" translatable="false">1</integer>
<!-- Volume Animation -->
<integer-array name="glyph_settings_volume_levels" translatable="false">
<item>8</item>
<item>15</item>
<item>14</item>
<item>10</item>
<item>12</item>
<item>9</item>
<item>11</item>
<item>13</item>
</integer-array>
<integer name="glyph_settings_volume_levels_num" translatable="false">8</integer>
</resources>

View File

@@ -52,23 +52,6 @@
<integer name="glyph_settings_notifs_essential_led" translatable="false">24</integer>
<!-- Volume Animation -->
<integer-array name="glyph_settings_volume_levels" translatable="false">
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
<item>20</item>
<item>26</item>
<item>27</item>
</integer-array>
<integer name="glyph_settings_volume_levels_num" translatable="false">16</integer>
</resources>

View File

@@ -33,7 +33,6 @@
<integer name="glyph_settings_notifs_essential_led" translatable="false"></integer>
<!-- Volume Animation -->
<integer-array name="glyph_settings_volume_levels" translatable="false">
</integer-array>
<integer name="glyph_settings_volume_levels_num" translatable="false"></integer>
</resources>

View File

@@ -176,19 +176,30 @@ public final class AnimationManager {
StatusManager.setVolumeLedActive(true);
StatusManager.setAnimationActive(true);
int[] volumeArray = ResourceUtils.getIntArray("glyph_settings_volume_levels");
int[] volumeArray = new int[ResourceUtils.getInteger("glyph_settings_volume_levels_num")];
int amount = (int) (Math.floor((volumeLevel / 100D) * (volumeArray.length - 1)) + 1);
int last = StatusManager.getVolumeLedLast();
try {
if (checkInterruption("volume")) throw new InterruptedException();
for (int i = 0; i < volumeArray.length; i++) {
if (checkInterruption("volume")) throw new InterruptedException();
if ( i <= amount - 1 && volumeLevel > 0) {
FileUtils.writeSingleLed(volumeArray[i], Constants.getBrightness());
} else {
FileUtils.writeSingleLed(volumeArray[i], 0);
if (volumeLevel == 0) {
if (checkInterruption("volume")) throw new InterruptedException();
StatusManager.setVolumeLedLast(0);
updateLedFrame(new int[volumeArray.length]);
break;
} else if ( i <= amount - 1 && volumeLevel > 0) {
if (checkInterruption("volume")) throw new InterruptedException();
StatusManager.setVolumeLedLast(i);
volumeArray[i] = Constants.getBrightness();
if (last == 0) {
updateLedFrame(volumeArray);
Thread.sleep(15);
}
}
Thread.sleep(15);
}
if (last != 0) {
if (checkInterruption("volume")) throw new InterruptedException();
updateLedFrame(volumeArray);
}
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start <= 1800) {
@@ -196,22 +207,25 @@ public final class AnimationManager {
}
for (int i = volumeArray.length - 1; i >= 0; i--) {
if (checkInterruption("volume")) throw new InterruptedException();
FileUtils.writeSingleLed(volumeArray[i], 0);
Thread.sleep(15);
if (volumeArray[i] != 0) {
StatusManager.setVolumeLedLast(i);
volumeArray[i] = 0;
updateLedFrame(volumeArray);
Thread.sleep(15);
}
}
long start2 = System.currentTimeMillis();
while (System.currentTimeMillis() - start2 <= 800) {
while (System.currentTimeMillis() - start2 <= 730) {
if (checkInterruption("volume")) throw new InterruptedException();
}
} catch (InterruptedException e) {
if (DEBUG) Log.d(TAG, "Exception while playing animation, interrupted | name: volume");
if (!StatusManager.isAllLedActive() && !StatusManager.isVolumeLedUpdate()) {
for (int i : volumeArray) {
FileUtils.writeSingleLed(i, 0);
}
updateLedFrame(new int[volumeArray.length]);
}
} finally {
if (!StatusManager.isVolumeLedUpdate()) {
StatusManager.setVolumeLedLast(0);
StatusManager.setAnimationActive(false);
StatusManager.setVolumeLedActive(false);
}

View File

@@ -26,6 +26,7 @@ public final class StatusManager {
private static boolean callLedActive = false;
private static boolean essentialLedActive = false;
private static boolean volumeLedActive = false;
private static int volumeLedLast = 0;
private static boolean volumeLedUpdate = false;
private static boolean callLedEnabled = false;
@@ -70,6 +71,14 @@ public final class StatusManager {
volumeLedActive = status;
}
public static int getVolumeLedLast() {
return volumeLedLast;
}
public static void setVolumeLedLast(int last) {
volumeLedLast = last;
}
public static boolean isVolumeLedUpdate() {
return volumeLedUpdate;
}