Skip to content

Commit 87d3f47

Browse files
committed
EE animations rework
included restricted settings information in notification dialog
1 parent 3c4dbb5 commit 87d3f47

File tree

17 files changed

+358
-184
lines changed

17 files changed

+358
-184
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdk = 34
1414
targetSdk = 34
1515
versionCode = 1
16-
versionName = "1.4.1"
16+
versionName = "1.4.2"
1717

1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
ndk {

app/src/main/java/com/frank/glyphify/AppUpdater.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class AppUpdater(private val context: Context, workerParams: WorkerParameters):
5454
}
5555

5656
if(update) {
57-
Log.d("DEBUG", "UPDATE AVAILABLE")
5857
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(downloadUrl))
5958
val pendingIntent = PendingIntent.getActivity(context, 0, browserIntent,
6059
PendingIntent.FLAG_IMMUTABLE)

app/src/main/java/com/frank/glyphify/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ object Constants {
1717
val PHONE2_MODEL_ID = listOf("A065", "AIN065")
1818
const val PHONE2A_MODEL_ID = "A142"
1919

20+
const val EE_ANIMATIONS_NUM = 3
2021
val DIMMING_VALUES = listOf(1000, 2500, 4000, -1)
2122
}

app/src/main/java/com/frank/glyphify/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.graphics.Color
1010
import android.graphics.drawable.ColorDrawable
1111
import android.os.Build
1212
import android.os.Bundle
13+
import android.os.Environment
1314
import androidx.appcompat.app.AppCompatActivity
1415
import androidx.core.content.ContextCompat
1516
import androidx.navigation.findNavController
@@ -20,8 +21,10 @@ import com.frank.glyphify.Constants.PHONE2A_MODEL_ID
2021
import com.frank.glyphify.Constants.PHONE2_MODEL_ID
2122
import com.frank.glyphify.databinding.ActivityMainBinding
2223
import com.frank.glyphify.glyph.batteryindicator.BatteryIndicatorService
24+
import com.frank.glyphify.glyph.visualizer.GlyphVisualizer
2325
import com.frank.glyphify.ui.dialogs.Dialog.supportMe
2426
import com.google.android.material.bottomnavigation.BottomNavigationView
27+
import java.io.File
2528
import kotlin.random.Random
2629

2730

@@ -113,5 +116,4 @@ class MainActivity : AppCompatActivity() {
113116
startService(intent)
114117
}
115118
}
116-
117119
}

app/src/main/java/com/frank/glyphify/Util.kt

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@ import org.json.JSONObject
1414
import java.math.BigInteger
1515

1616
object Util {
17-
fun loadPreferences(context: Context, numZones: Int): MutableList<Triple<Int, List<BigInteger>, Boolean>> {
17+
fun loadPreferences(context: Context, numZones: Int): MutableList<Triple<Int, List<BigInteger>, Int>> {
1818
val sharedPref: SharedPreferences =
1919
context.getSharedPreferences("settings", Context.MODE_PRIVATE)
2020
val jsonString = sharedPref.getString("contactsMapping", null)
21-
val glyphsMapping = MutableList(numZones) { Triple(-1, emptyList<BigInteger>(), false) }
21+
val glyphsMapping = MutableList(numZones) { Triple(-1, emptyList<BigInteger>(), 0) }
2222

2323
if (jsonString != null) {
2424
val mapping = JSONObject(jsonString)
2525
for (i in 0 until numZones) {
2626
if (mapping.has(i.toString())) {
2727
val jsonArray = mapping.getJSONArray(i.toString())
2828
val glyphId = jsonArray.getInt(0)
29-
val pulse = jsonArray.getBoolean(2)
29+
30+
var pulse: Int
31+
try {
32+
pulse = jsonArray.getInt(2)
33+
}
34+
catch (e: Exception) {
35+
pulse = if (jsonArray.getBoolean(2)) 1 else 0
36+
}
3037

3138
var mappingIdsJsonArray = JSONArray()
3239
try {
@@ -46,47 +53,6 @@ object Util {
4653
return glyphsMapping
4754
}
4855

49-
/**
50-
* Used to pass from a simplified glyph addressing to the Nothing's glyph addressing
51-
* @param index: simplified index for glyph zones
52-
* @return list of ints containing the actual glyph zones
53-
* */
54-
fun getGlyphMapping(index: Int): List<Int> {
55-
var glyphIndexes: List<Int>
56-
when(index) {
57-
2 -> {
58-
if(Common.is20111()) {
59-
glyphIndexes = (Glyph.Code_20111.C1..Glyph.Code_20111.C4).toList()
60-
}
61-
else if(Common.is23111()) {
62-
glyphIndexes = (Glyph.Code_23111.C_1..Glyph.Code_23111.C_24).toList()
63-
}
64-
else glyphIndexes = listOf(index)
65-
}
66-
3 -> {
67-
if(Common.is20111()) {
68-
glyphIndexes = (Glyph.Code_20111.D1_1..Glyph.Code_20111.D1_8).toList()
69-
}
70-
else if(Common.is22111()) {
71-
glyphIndexes = (Glyph.Code_22111.C1_1..Glyph.Code_22111.C1_16).toList()
72-
}
73-
else glyphIndexes = listOf(index)
74-
}
75-
4 -> {
76-
if(Common.is20111()) {
77-
glyphIndexes = listOf(Glyph.Code_20111.E1)
78-
}
79-
else glyphIndexes = listOf(index)
80-
}
81-
9 -> {
82-
glyphIndexes = (Glyph.Code_22111.D1_1..Glyph.Code_22111.D1_8).toList()
83-
}
84-
else -> glyphIndexes = listOf(index)
85-
}
86-
87-
return glyphIndexes
88-
}
89-
9056
fun resizeDrawable(resources: Resources, drawable: Drawable, width: Int, height: Int): Drawable {
9157
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
9258
val canvas = Canvas(bitmap)

app/src/main/java/com/frank/glyphify/glyph/composer/Glyphifier.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.net.Uri
77
import android.os.Build
88
import android.os.Environment
99
import android.provider.MediaStore
10+
import android.util.Log
1011
import androidx.work.Worker
1112
import androidx.work.WorkerParameters
1213
import androidx.work.workDataOf
@@ -399,20 +400,26 @@ class Glyphifier(private val context: Context, workerParams: WorkerParameters):
399400

400401
// insert 15 copies of element 3 between elements 3 and 4
401402
for (i in 0 until 15) {
402-
expandedList.add(4, element3)
403+
expandedList.add(3, element3)
403404
}
404405

405406
// adjust the index for element 9 after the previous insertions
406407
val newElement9Index = 9 + 15
407408

408409
// insert 7 copies of element 9 between elements 9 and 10
409410
for (i in 0 until 7) {
410-
expandedList.add(newElement9Index + 1, element9)
411+
expandedList.add(newElement9Index, element9)
411412
}
412413

414+
// swap last element with 24th for dot glyph
415+
val temp = expandedList[32]
416+
expandedList[32] = expandedList[24]
417+
expandedList[24] = temp
418+
413419
expandedZones.add(Pair(timestamp, expandedList))
414420
}
415421

422+
Log.d("DEBUG", expandedZones.toString())
416423
return expandedZones
417424
}
418425

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.frank.glyphify.glyph.extendedessential
2+
3+
import com.nothing.ketchum.Common
4+
import com.nothing.ketchum.GlyphFrame
5+
6+
object Animations {
7+
8+
fun pulseAnimation(frame: GlyphFrame.Builder, glyphs: List<Int>, time: Long, intensity: Int,
9+
stepSize: Int, perStepDelay: Long): GlyphFrame.Builder {
10+
11+
var dynamicFrame = frame
12+
val light = maxOf(intensity - stepSize * (time / perStepDelay).toInt(), 0)
13+
for(glyph in glyphs) {
14+
dynamicFrame = dynamicFrame.buildChannel(glyph, light)
15+
}
16+
return dynamicFrame
17+
}
18+
19+
fun knightRiderAnimation(frame: GlyphFrame.Builder, glyphs: List<Int>, time: Long, intensity: Int,
20+
perStepDelay: Long): GlyphFrame.Builder {
21+
22+
val variableGlyphZones = MutableList(2) { mutableListOf<Int>() }
23+
if(Common.is22111()) { // phone2 has 2 variable glyphs
24+
val (zone1, zone2) = glyphs.partition { it <= 18 }
25+
variableGlyphZones[0] = zone1.toMutableList()
26+
variableGlyphZones[1] = zone2.toMutableList()
27+
}
28+
// (1) and (2a) only have one variable glyph zone
29+
else variableGlyphZones[0] = glyphs.toMutableList()
30+
31+
var dynamicFrame = frame
32+
var polarGlyphIndex: Int
33+
var revertAnim: Boolean
34+
val baseIntensity = 0
35+
36+
for(variableZone in variableGlyphZones) {
37+
val animDuration = variableZone.size * perStepDelay * 2
38+
if(animDuration == 0L) continue
39+
40+
val elapsedTick = ((time / (perStepDelay * 2)) % variableZone.size).toInt()
41+
42+
if((time / animDuration) % 2L == 0L) {
43+
revertAnim = false
44+
polarGlyphIndex = variableZone[0] + elapsedTick
45+
}
46+
else {
47+
revertAnim = true
48+
polarGlyphIndex = variableZone[0] + (variableZone.size - 1) - elapsedTick
49+
}
50+
51+
for(glyph in variableZone) {
52+
dynamicFrame = dynamicFrame.buildChannel(glyph, baseIntensity)
53+
}
54+
55+
var currIntensity = intensity
56+
if(!revertAnim) {
57+
for (i in polarGlyphIndex downTo maxOf(polarGlyphIndex - 2, variableZone[0])) {
58+
dynamicFrame.buildChannel(i, currIntensity)
59+
currIntensity -= intensity / 2
60+
currIntensity.coerceAtLeast(baseIntensity)
61+
}
62+
}
63+
else {
64+
for (i in polarGlyphIndex .. minOf(polarGlyphIndex + 2, variableZone.last())) {
65+
dynamicFrame.buildChannel(i, currIntensity)
66+
currIntensity -= intensity / 2
67+
currIntensity.coerceAtLeast(baseIntensity)
68+
}
69+
}
70+
71+
}
72+
73+
return dynamicFrame
74+
}
75+
}

0 commit comments

Comments
 (0)