@@ -9,6 +9,7 @@ import android.graphics.Canvas
9
9
import android.graphics.Color
10
10
import android.graphics.Paint
11
11
import androidx.core.graphics.ColorUtils
12
+ import otang.pulse.lib.util.PulseConfig
12
13
import kotlin.math.log10
13
14
14
15
class SolidLineRenderer (context : Context , view : VisualizerView , colorController : ColorController ) :
@@ -99,8 +100,7 @@ class SolidLineRenderer(context: Context, view: VisualizerView, colorController:
99
100
}
100
101
barUnit = barWidth + (barUnit - barWidth) * units / (units - 1 )
101
102
mPaint.strokeWidth = barWidth
102
- mPaint.strokeCap =
103
- if (mRounded) Paint .Cap .ROUND else Paint .Cap .BUTT
103
+ mPaint.strokeCap = if (mRounded) Paint .Cap .ROUND else Paint .Cap .BUTT
104
104
for (i in 0 until mUnits) {
105
105
mFFTPoints[i * 4 + 2 ] = i * barUnit + barWidth / 2
106
106
mFFTPoints[i * 4 ] = mFFTPoints[i * 4 + 2 ]
@@ -129,13 +129,12 @@ class SolidLineRenderer(context: Context, view: VisualizerView, colorController:
129
129
}
130
130
barUnit = barHeight + (barUnit - barHeight) * units / (units - 1 )
131
131
mPaint.strokeWidth = barHeight
132
- mPaint.strokeCap =
133
- if (mRounded) Paint .Cap .ROUND else Paint .Cap .BUTT
132
+ mPaint.strokeCap = if (mRounded) Paint .Cap .ROUND else Paint .Cap .BUTT
134
133
for (i in 0 until mUnits) {
135
134
mFFTPoints[i * 4 + 3 ] = i * barUnit + barHeight / 2
136
135
mFFTPoints[i * 4 + 1 ] = mFFTPoints[i * 4 + 3 ]
137
136
mFFTPoints[i * 4 ] = (if (mLeftInLandscape) 0 else startPoint) as Float
138
- mFFTPoints[i * 4 + 2 ] = (if (mLeftInLandscape) 0 else startPoint) as Float
137
+ mFFTPoints[i * 4 + 2 ] = (startPoint)
139
138
}
140
139
}
141
140
@@ -191,25 +190,21 @@ class SolidLineRenderer(context: Context, view: VisualizerView, colorController:
191
190
if (mVertical) {
192
191
if (mLeftInLandscape || mGravity == GRAVITY_TOP ) {
193
192
mValueAnimators!! [i]!! .setFloatValues(
194
- mFFTPoints[i * 4 ],
195
- (dbValue * fudgeFactor).toFloat()
193
+ mFFTPoints[i * 4 ], (dbValue * fudgeFactor).toFloat()
196
194
)
197
195
} else if (mGravity == GRAVITY_BOTTOM || mGravity == GRAVITY_CENTER ) {
198
196
mValueAnimators!! [i]!! .setFloatValues(
199
- mFFTPoints[i * 4 ],
200
- mFFTPoints[2 ] - dbValue * fudgeFactor
197
+ mFFTPoints[i * 4 ], mFFTPoints[2 ] - dbValue * fudgeFactor
201
198
)
202
199
}
203
200
} else {
204
201
if (mGravity == GRAVITY_BOTTOM || mGravity == GRAVITY_CENTER ) {
205
202
mValueAnimators!! [i]!! .setFloatValues(
206
- mFFTPoints[i * 4 + 1 ],
207
- mFFTPoints[3 ] - dbValue * fudgeFactor
203
+ mFFTPoints[i * 4 + 1 ], mFFTPoints[3 ] - dbValue * fudgeFactor
208
204
)
209
205
} else if (mGravity == GRAVITY_TOP ) {
210
206
mValueAnimators!! [i]!! .setFloatValues(
211
- mFFTPoints[i * 4 + 1 ],
212
- mFFTPoints[3 ] + dbValue * fudgeFactor
207
+ mFFTPoints[i * 4 + 1 ], mFFTPoints[3 ] + dbValue * fudgeFactor
213
208
)
214
209
}
215
210
}
@@ -237,28 +232,22 @@ class SolidLineRenderer(context: Context, view: VisualizerView, colorController:
237
232
if (mVertical) {
238
233
if (mLeftInLandscape || mGravity == GRAVITY_TOP ) {
239
234
mValueAnimators!! [i]!! .setFloatValues(
240
- mFFTPoints[i * 4 ],
241
- (dbValue * fudgeFactor).toFloat()
235
+ mFFTPoints[i * 4 ], (dbValue * fudgeFactor).toFloat()
242
236
)
243
237
} else if (mGravity == GRAVITY_BOTTOM || mGravity == GRAVITY_CENTER ) {
244
238
mValueAnimators!! [i]!! .setFloatValues(
245
- mFFTPoints[i * 4 ],
246
- mFFTPoints[2 ] - dbValue * fudgeFactor
239
+ mFFTPoints[i * 4 ], mFFTPoints[2 ] - dbValue * fudgeFactor
247
240
)
248
241
}
249
242
} else {
250
243
if (mGravity == GRAVITY_BOTTOM || mGravity == GRAVITY_CENTER ) {
251
- mValueAnimators!! [i]!!
252
- .setFloatValues(
253
- mFFTPoints[i * 4 + 1 ],
254
- mFFTPoints[3 ] - dbValue * fudgeFactor
255
- )
244
+ mValueAnimators!! [i]!! .setFloatValues(
245
+ mFFTPoints[i * 4 + 1 ], mFFTPoints[3 ] - dbValue * fudgeFactor
246
+ )
256
247
} else if (mGravity == GRAVITY_TOP ) {
257
- mValueAnimators!! [i]!!
258
- .setFloatValues(
259
- mFFTPoints[i * 4 + 1 ],
260
- mFFTPoints[3 ] + dbValue * fudgeFactor
261
- )
248
+ mValueAnimators!! [i]!! .setFloatValues(
249
+ mFFTPoints[i * 4 + 1 ], mFFTPoints[3 ] + dbValue * fudgeFactor
250
+ )
262
251
}
263
252
}
264
253
mValueAnimators!! [i]!! .start()
@@ -337,7 +326,9 @@ class SolidLineRenderer(context: Context, view: VisualizerView, colorController:
337
326
}
338
327
339
328
override fun onSharedPreferenceChanged (prefs : SharedPreferences , keys : String? ) {
340
- updateSettings()
329
+ if (keys == PulseConfig .PREF_PULSE_SOLID_FUDGE || keys == PulseConfig .PREF_PULSE_LINE_COUNT || keys == PulseConfig .PREF_PULSE_ROUNDED || keys == PulseConfig .PREF_PULSE_SOLID_OVACITY || keys == PulseConfig .PREF_PULSE_GRAVITY || keys == PulseConfig .PREF_PULSE_CENTER_MIRRORED || keys == PulseConfig .PREF_PULSE_LEFT || keys == PulseConfig .PREF_PULSE_VERTICAL_MIRROR || keys == PulseConfig .PREF_PULSE_SMOOTH ) {
330
+ updateSettings()
331
+ }
341
332
}
342
333
343
334
companion object {
0 commit comments