Fix formatting and unused imports

This commit is contained in:
Ensar Sarajčić 2023-08-04 16:39:57 +02:00
parent 04a173501d
commit c50dc814ac
16 changed files with 61 additions and 50 deletions

View file

@ -5,25 +5,25 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
open class SimpleActivity : BaseSimpleActivity() {
override fun getAppIconIDs() = arrayListOf(
R.mipmap.ic_launcher_red,
R.mipmap.ic_launcher_pink,
R.mipmap.ic_launcher_purple,
R.mipmap.ic_launcher_deep_purple,
R.mipmap.ic_launcher_indigo,
R.mipmap.ic_launcher_blue,
R.mipmap.ic_launcher_light_blue,
R.mipmap.ic_launcher_cyan,
R.mipmap.ic_launcher_teal,
R.mipmap.ic_launcher_green,
R.mipmap.ic_launcher_light_green,
R.mipmap.ic_launcher_lime,
R.mipmap.ic_launcher_yellow,
R.mipmap.ic_launcher_amber,
R.mipmap.ic_launcher,
R.mipmap.ic_launcher_deep_orange,
R.mipmap.ic_launcher_brown,
R.mipmap.ic_launcher_blue_grey,
R.mipmap.ic_launcher_grey_black
R.mipmap.ic_launcher_red,
R.mipmap.ic_launcher_pink,
R.mipmap.ic_launcher_purple,
R.mipmap.ic_launcher_deep_purple,
R.mipmap.ic_launcher_indigo,
R.mipmap.ic_launcher_blue,
R.mipmap.ic_launcher_light_blue,
R.mipmap.ic_launcher_cyan,
R.mipmap.ic_launcher_teal,
R.mipmap.ic_launcher_green,
R.mipmap.ic_launcher_light_green,
R.mipmap.ic_launcher_lime,
R.mipmap.ic_launcher_yellow,
R.mipmap.ic_launcher_amber,
R.mipmap.ic_launcher,
R.mipmap.ic_launcher_deep_orange,
R.mipmap.ic_launcher_brown,
R.mipmap.ic_launcher_blue_grey,
R.mipmap.ic_launcher_grey_black
)
override fun getAppLauncherName() = getString(R.string.app_launcher_name)

View file

@ -13,6 +13,7 @@ class SplashActivity : BaseSplashActivity() {
startActivity(this)
}
}
intent?.action == STOPWATCH_TOGGLE_ACTION -> {
Intent(this, MainActivity::class.java).apply {
putExtra(OPEN_TAB, TAB_STOPWATCH)
@ -20,6 +21,7 @@ class SplashActivity : BaseSplashActivity() {
startActivity(this)
}
}
intent.extras?.containsKey(OPEN_TAB) == true -> {
Intent(this, MainActivity::class.java).apply {
putExtra(OPEN_TAB, intent.getIntExtra(OPEN_TAB, TAB_CLOCK))
@ -27,6 +29,7 @@ class SplashActivity : BaseSplashActivity() {
startActivity(this)
}
}
else -> startActivity(Intent(this, MainActivity::class.java))
}
finish()

View file

@ -143,8 +143,11 @@ class TimerAdapter(
val state = timer.state
val resetPossible = state is TimerState.Running || state is TimerState.Paused || state is TimerState.Finished
timerReset.beInvisibleIf(!resetPossible)
val drawableId =
if (state is TimerState.Running) com.simplemobiletools.commons.R.drawable.ic_pause_vector else com.simplemobiletools.commons.R.drawable.ic_play_vector
val drawableId = if (state is TimerState.Running) {
com.simplemobiletools.commons.R.drawable.ic_pause_vector
} else {
com.simplemobiletools.commons.R.drawable.ic_play_vector
}
timerPlayPause.setImageDrawable(simpleActivity.resources.getColoredDrawableWithColor(drawableId, textColor))
}
}

View file

@ -8,11 +8,7 @@ import com.simplemobiletools.clock.fragments.AlarmFragment
import com.simplemobiletools.clock.fragments.ClockFragment
import com.simplemobiletools.clock.fragments.StopwatchFragment
import com.simplemobiletools.clock.fragments.TimerFragment
import com.simplemobiletools.clock.helpers.TABS_COUNT
import com.simplemobiletools.clock.helpers.TAB_ALARM
import com.simplemobiletools.clock.helpers.TAB_CLOCK
import com.simplemobiletools.clock.helpers.TAB_TIMER
import com.simplemobiletools.clock.helpers.TAB_STOPWATCH
import com.simplemobiletools.clock.helpers.*
import com.simplemobiletools.commons.models.AlarmSound
class ViewPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {

View file

@ -3,7 +3,6 @@ package com.simplemobiletools.clock.dialogs
import android.media.AudioManager
import android.media.RingtoneManager
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.databinding.DialogEditTimerBinding
import com.simplemobiletools.clock.extensions.*

View file

@ -490,7 +490,11 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
.setDefaults(Notification.DEFAULT_LIGHTS)
.setAutoCancel(true)
.setChannelId(channelId)
.addAction(com.simplemobiletools.commons.R.drawable.ic_snooze_vector, getString(com.simplemobiletools.commons.R.string.snooze), getSnoozePendingIntent(alarm))
.addAction(
com.simplemobiletools.commons.R.drawable.ic_snooze_vector,
getString(com.simplemobiletools.commons.R.string.snooze),
getSnoozePendingIntent(alarm)
)
.addAction(com.simplemobiletools.commons.R.drawable.ic_cross_vector, getString(com.simplemobiletools.commons.R.string.dismiss), dismissIntent)
.setDeleteIntent(dismissIntent)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)

View file

@ -3,5 +3,5 @@ package com.simplemobiletools.clock.extensions
import android.util.Log
import com.simplemobiletools.clock.BuildConfig
fun <A> A.log(tag: String) = apply { if (BuildConfig.DEBUG) Log.wtf(tag, this.toString()) }
fun <A> A.log(tag: String) = apply { if (BuildConfig.DEBUG) Log.wtf(tag, this.toString()) }
fun <A> A.log(first: String, tag: String) = apply { if (BuildConfig.DEBUG) Log.wtf(tag, first) }

View file

@ -2,7 +2,8 @@ package com.simplemobiletools.clock.extensions
import android.text.format.DateFormat
import com.simplemobiletools.commons.extensions.getFormattedDuration
import java.util.*
import java.util.Calendar
import java.util.Locale
import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt
@ -21,10 +22,12 @@ fun Long.formatStopwatchTime(useLongerMSFormat: Boolean): String {
val format = "%02d:%02d:%02d.$MSFormat"
String.format(format, hours, minutes, seconds, ms)
}
minutes > 0 -> {
val format = "%02d:%02d.$MSFormat"
String.format(format, minutes, seconds, ms)
}
else -> {
val format = "%d.$MSFormat"
String.format(format, seconds, ms)

View file

@ -198,9 +198,9 @@ public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
}
final Map<String, TypeAdapter<?>> labelToDelegate
= new LinkedHashMap<String, TypeAdapter<?>>();
= new LinkedHashMap<String, TypeAdapter<?>>();
final Map<Class<?>, TypeAdapter<?>> subtypeToDelegate
= new LinkedHashMap<Class<?>, TypeAdapter<?>>();
= new LinkedHashMap<Class<?>, TypeAdapter<?>>();
for (Map.Entry<String, Class<?>> entry : labelToSubtype.entrySet()) {
TypeAdapter<?> delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue()));
labelToDelegate.put(entry.getKey(), delegate);
@ -220,14 +220,14 @@ public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
if (labelJsonElement == null) {
throw new JsonParseException("cannot deserialize " + baseType
+ " because it does not define a field named " + typeFieldName);
+ " because it does not define a field named " + typeFieldName);
}
String label = labelJsonElement.getAsString();
@SuppressWarnings("unchecked") // registration requires that subtype extends T
TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label);
TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label);
if (delegate == null) {
throw new JsonParseException("cannot deserialize " + baseType + " subtype named "
+ label + "; did you forget to register a subtype?");
+ label + "; did you forget to register a subtype?");
}
return delegate.fromJsonTree(jsonElement);
}
@ -237,10 +237,10 @@ public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
Class<?> srcType = value.getClass();
String label = subtypeToLabel.get(srcType);
@SuppressWarnings("unchecked") // registration requires that subtype extends T
TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType);
TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType);
if (delegate == null) {
throw new JsonParseException("cannot serialize " + srcType.getName()
+ "; did you forget to register a subtype?");
+ "; did you forget to register a subtype?");
}
JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject();
@ -253,7 +253,7 @@ public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
if (jsonObject.has(typeFieldName)) {
throw new JsonParseException("cannot serialize " + srcType.getName()
+ " because it already defines a field named " + typeFieldName);
+ " because it already defines a field named " + typeFieldName);
}
clone.add(typeFieldName, new JsonPrimitive(label));

View file

@ -6,10 +6,10 @@ import com.google.gson.TypeAdapterFactory
import com.simplemobiletools.clock.models.TimerState
val timerStates = valueOf<TimerState>()
.registerSubtype(TimerState.Idle::class.java)
.registerSubtype(TimerState.Running::class.java)
.registerSubtype(TimerState.Paused::class.java)
.registerSubtype(TimerState.Finished::class.java)
.registerSubtype(TimerState.Idle::class.java)
.registerSubtype(TimerState.Running::class.java)
.registerSubtype(TimerState.Paused::class.java)
.registerSubtype(TimerState.Finished::class.java)
inline fun <reified T : Any> valueOf(): RuntimeTypeAdapterFactory<T> = RuntimeTypeAdapterFactory.of(T::class.java)

View file

@ -3,7 +3,9 @@ package com.simplemobiletools.clock.helpers
import com.simplemobiletools.clock.extensions.isBitSet
import com.simplemobiletools.clock.models.MyTimeZone
import com.simplemobiletools.commons.extensions.addBit
import java.util.*
import java.util.Calendar
import java.util.Date
import java.util.TimeZone
import kotlin.math.pow
// shared preferences

View file

@ -12,7 +12,6 @@ import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.commons.extensions.getIntValue
import com.simplemobiletools.commons.extensions.getStringValue
import com.simplemobiletools.commons.helpers.*
import java.util.*
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
private val ALARMS_TABLE_NAME = "contacts" // wrong table name, ignore it
@ -41,8 +40,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
override fun onCreate(db: SQLiteDatabase) {
db.execSQL("CREATE TABLE IF NOT EXISTS $ALARMS_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_TIME_IN_MINUTES INTEGER, $COL_DAYS INTEGER, " +
"$COL_IS_ENABLED INTEGER, $COL_VIBRATE INTEGER, $COL_SOUND_TITLE TEXT, $COL_SOUND_URI TEXT, $COL_LABEL TEXT)")
db.execSQL(
"CREATE TABLE IF NOT EXISTS $ALARMS_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_TIME_IN_MINUTES INTEGER, $COL_DAYS INTEGER, " +
"$COL_IS_ENABLED INTEGER, $COL_VIBRATE INTEGER, $COL_SOUND_TITLE TEXT, $COL_SOUND_URI TEXT, $COL_LABEL TEXT)"
)
insertInitialAlarms(db)
}

View file

@ -16,11 +16,13 @@ data class Lap(val id: Int, var lapTime: Long, var totalTime: Long) : Comparable
id > other.id -> 1
else -> -1
}
sorting and SORT_BY_LAP_TIME != 0 -> when {
lapTime == other.lapTime -> 0
lapTime > other.lapTime -> 1
else -> -1
}
else -> when {
totalTime == other.totalTime -> 0
totalTime > other.totalTime -> 1

View file

@ -1,6 +1,5 @@
package com.simplemobiletools.clock.receivers
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
@ -18,7 +17,6 @@ import com.simplemobiletools.clock.helpers.ALARM_ID
import com.simplemobiletools.clock.helpers.ALARM_NOTIFICATION_CHANNEL_ID
import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID
import com.simplemobiletools.clock.helpers.EARLY_ALARM_NOTIF_ID
import com.simplemobiletools.commons.extensions.canUseFullScreenIntent
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.helpers.isOreoPlus

View file

@ -18,7 +18,7 @@ import com.simplemobiletools.commons.helpers.isOreoPlus
class EarlyAlarmDismissalReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
override fun onReceive(context: Context, intent: Intent) {
val alarmId = intent.getIntExtra(ALARM_ID, -1)
if (alarmId == -1) {
return

View file

@ -13,6 +13,6 @@ class HideTimerReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val timerId = intent.getIntExtra(TIMER_ID, INVALID_TIMER_ID)
context.hideTimerNotification(timerId)
EventBus.getDefault().post(TimerEvent.Reset(timerId, ))
EventBus.getDefault().post(TimerEvent.Reset(timerId))
}
}