Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
2762f12151 | |||
a873c71918 | |||
e8f3c110a8 | |||
72bf3b04a7 | |||
ca6fb75dfd | |||
59dc5de21a | |||
ec40a277d7 | |||
507b7f2318 | |||
1a709a9406 | |||
770ba0cd13 | |||
6a92225edf | |||
ce801d4a7d | |||
25da807bd5 | |||
63212d13b1 | |||
79ad9b2500 | |||
9c0aa0a9ef | |||
b9197ddf2e | |||
d1362f7d81 | |||
a8c7d115ae | |||
a5a753e198 | |||
39ede20518 | |||
5527e6e405 | |||
565ed11f53 | |||
4bd8653d32 | |||
d121119ca9 | |||
e82a34bcc7 | |||
8867a1fbbd | |||
7265883d6c | |||
7a4fc6ff58 | |||
9f61215caa | |||
7ccf7eb8f6 | |||
704448a848 | |||
fa366b3d45 | |||
e58fef66aa | |||
c120bad9c6 |
BIN
.idea/caches/build_file_checksums.ser
generated
16
.idea/codeStyles/Project.xml
generated
@ -1,6 +1,22 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
|
2
.idea/modules.xml
generated
@ -2,7 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Another Widget.iml" filepath="$PROJECT_DIR$/Another Widget.iml" group="Another Widget" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Another_Widget.iml" filepath="$PROJECT_DIR$/.idea/modules/Another_Widget.iml" group="Another_Widget" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" group="Another Widget/app" />
|
||||
</modules>
|
||||
</component>
|
||||
|
@ -18,8 +18,8 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 101
|
||||
versionName "2.0.12"
|
||||
versionCode 105
|
||||
versionName "2.0.13"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -59,13 +59,13 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.13'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
// UI
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.2.0-alpha06'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
||||
implementation 'androidx.browser:browser:1.2.0'
|
||||
implementation 'net.idik:slimadapter:2.1.2'
|
||||
implementation 'com.google.android:flexbox:2.0.1'
|
||||
@ -75,18 +75,18 @@ dependencies {
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.4"
|
||||
implementation "androidx.work:work-runtime-ktx:2.4.0"
|
||||
|
||||
// EventBus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
||||
// Navigation
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.0-alpha05'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
||||
|
||||
// Other
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
implementation 'joda-time:joda-time:2.10.3'
|
||||
implementation 'me.everything:providers-android:1.0.1'
|
||||
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'
|
||||
|
||||
@ -96,34 +96,30 @@ dependencies {
|
||||
|
||||
// Fitness
|
||||
implementation 'com.google.android.gms:play-services-fitness:18.0.0'
|
||||
implementation 'com.google.android.gms:play-services-auth:18.0.0'
|
||||
implementation 'com.google.android.gms:play-services-auth:18.1.0'
|
||||
|
||||
//Weather
|
||||
implementation 'com.github.KwabenBerko:OpenWeatherMap-Android-Library:2.0.2'
|
||||
implementation 'com.google.android.gms:play-services-location:17.0.0'
|
||||
implementation 'com.google.android.gms:play-services-location:17.1.0'
|
||||
|
||||
// Billing
|
||||
implementation 'com.android.billingclient:billing:2.2.0'
|
||||
implementation 'com.android.billingclient:billing-ktx:2.2.0'
|
||||
implementation 'com.android.billingclient:billing:3.0.1'
|
||||
implementation 'com.android.billingclient:billing-ktx:3.0.1'
|
||||
|
||||
// KTX
|
||||
implementation "androidx.core:core-ktx:1.2.0"
|
||||
implementation "androidx.core:core-ktx:1.3.2"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
|
||||
implementation "androidx.palette:palette-ktx:1.0.0"
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
|
||||
// Add the Firebase SDK for Crashlytics.
|
||||
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
|
||||
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
|
||||
|
||||
// Preferences
|
||||
implementation 'com.chibatching.kotpref:kotpref:2.10.0'
|
||||
implementation 'com.chibatching.kotpref:kotpref:2.11.0'
|
||||
implementation 'com.chibatching.kotpref:livedata-support:2.10.0'
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
|
||||
// Permissions
|
||||
implementation 'com.karumi:dexter:6.1.0'
|
||||
|
||||
// Billing
|
||||
implementation 'com.android.billingclient:billing:2.2.0'
|
||||
implementation 'com.android.billingclient:billing-ktx:2.2.0'
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ typealias DialogCallback = () -> Unit
|
||||
|
||||
class MaterialBottomSheetDialog(
|
||||
context: Context,
|
||||
private val title: String? = "",
|
||||
private val message: String? = ""
|
||||
private val title: String? = null,
|
||||
private val message: String? = null
|
||||
) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) {
|
||||
|
||||
private var positiveButtonLabel: String? = null
|
||||
@ -36,7 +36,7 @@ class MaterialBottomSheetDialog(
|
||||
val view = View.inflate(context, R.layout.bottom_sheet_dialog, null)
|
||||
|
||||
// Header
|
||||
view.message.isVisible = title != null
|
||||
view.title.isVisible = title != null
|
||||
view.title.text = title ?: ""
|
||||
|
||||
view.message.isVisible = message != null
|
||||
|
@ -5,12 +5,14 @@ import android.provider.CalendarContract
|
||||
import android.util.Log
|
||||
import com.chibatching.kotpref.bulk
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.applyFilters
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmResults
|
||||
import java.util.*
|
||||
import kotlin.Comparator
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class EventRepository(val context: Context) {
|
||||
@ -68,7 +70,7 @@ class EventRepository(val context: Context) {
|
||||
val events = getEvents()
|
||||
if (events.isNotEmpty()) {
|
||||
val newNextEvent = events.first()
|
||||
Preferences.nextEventId = newNextEvent!!.eventID
|
||||
Preferences.nextEventId = newNextEvent.eventID
|
||||
newNextEvent
|
||||
} else {
|
||||
resetNextEventData()
|
||||
@ -96,9 +98,9 @@ class EventRepository(val context: Context) {
|
||||
if (eventList.isNotEmpty()) {
|
||||
val index = eventList.indexOfFirst { it.eventID == Preferences.nextEventId }
|
||||
if (index > -1 && index < eventList.size - 1) {
|
||||
Preferences.nextEventId = eventList[index + 1]!!.eventID
|
||||
Preferences.nextEventId = eventList[index + 1].eventID
|
||||
} else {
|
||||
Preferences.nextEventId = eventList.first()!!.eventID
|
||||
Preferences.nextEventId = eventList.first().eventID
|
||||
}
|
||||
} else {
|
||||
resetNextEventData()
|
||||
@ -112,9 +114,9 @@ class EventRepository(val context: Context) {
|
||||
if (eventList.isNotEmpty()) {
|
||||
val index = eventList.indexOfFirst { it.eventID == Preferences.nextEventId }
|
||||
if (index > 0) {
|
||||
Preferences.nextEventId = eventList[index - 1]!!.eventID
|
||||
Preferences.nextEventId = eventList[index - 1].eventID
|
||||
} else {
|
||||
Preferences.nextEventId = eventList.last()!!.eventID
|
||||
Preferences.nextEventId = eventList.last().eventID
|
||||
}
|
||||
} else {
|
||||
resetNextEventData()
|
||||
@ -130,8 +132,7 @@ class EventRepository(val context: Context) {
|
||||
.where(Event::class.java)
|
||||
.greaterThan("endDate", now)
|
||||
.findAll()
|
||||
.filter { (Preferences.showDeclinedEvents || it.selfAttendeeStatus != CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED) }
|
||||
.filter { (Preferences.calendarAllDay || !it.allDay) }
|
||||
.applyFilters()
|
||||
}
|
||||
|
||||
private fun getEvents(): List<Event> {
|
||||
@ -156,8 +157,7 @@ class EventRepository(val context: Context) {
|
||||
.greaterThan("endDate", now)
|
||||
.lessThanOrEqualTo("startDate", limit.timeInMillis)
|
||||
.findAll()
|
||||
.filter { (Preferences.showDeclinedEvents || it.selfAttendeeStatus != CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED) }
|
||||
.filter { (Preferences.calendarAllDay || !it.allDay) }
|
||||
.applyFilters()
|
||||
}
|
||||
|
||||
fun getEventsCount(): Int = getEvents().size
|
||||
|
@ -15,6 +15,13 @@ object Constants {
|
||||
LARGE(3)
|
||||
}
|
||||
|
||||
enum class SecondRowTopMargin(val value: Int) {
|
||||
NONE(0),
|
||||
SMALL(1),
|
||||
MEDIUM(2),
|
||||
LARGE(3)
|
||||
}
|
||||
|
||||
enum class GlanceProviderId(val id: String) {
|
||||
PLAYING_SONG("PLAYING_SONG"),
|
||||
NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"),
|
||||
|
@ -31,6 +31,7 @@ object Preferences : KotprefModel() {
|
||||
var customLocationAdd by stringPref(key = "PREF_CUSTOM_LOCATION_ADD", default = "")
|
||||
var dateFormat by stringPref(default = "")
|
||||
var isDateCapitalize by booleanPref(default = true)
|
||||
var isDateUppercase by booleanPref(default = false)
|
||||
var weatherRefreshPeriod by intPref(key = "PREF_WEATHER_REFRESH_PERIOD", default = 1)
|
||||
var showUntil by intPref(key = "PREF_SHOW_UNTIL", default = 1)
|
||||
var calendarAppName by stringPref(key = "PREF_CALENDAR_APP_NAME", default = "")
|
||||
@ -55,6 +56,20 @@ object Preferences : KotprefModel() {
|
||||
|
||||
var clockTextColor by stringPref(default = "#FFFFFF")
|
||||
var clockTextAlpha by stringPref(default = "FF")
|
||||
|
||||
var textGlobalColorDark by stringPref(default = "#FFFFFF")
|
||||
var textGlobalAlphaDark by stringPref(default = "FF")
|
||||
|
||||
var textSecondaryColorDark by stringPref(default = "#FFFFFF")
|
||||
var textSecondaryAlphaDark by stringPref(default = "FF")
|
||||
|
||||
var backgroundCardColorDark by stringPref(default = "#000000")
|
||||
var backgroundCardAlphaDark by stringPref(default = "00")
|
||||
|
||||
var clockTextColorDark by stringPref(default = "#FFFFFF")
|
||||
var clockTextAlphaDark by stringPref(default = "FF")
|
||||
|
||||
|
||||
var showAMPMIndicator by booleanPref(default = true)
|
||||
|
||||
var weatherIconPack by intPref(default = Constants.WeatherIconPack.DEFAULT.value)
|
||||
@ -64,12 +79,17 @@ object Preferences : KotprefModel() {
|
||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
||||
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 90f)
|
||||
var clockBottomMargin by intPref(default = Constants.ClockBottomMargin.MEDIUM.value)
|
||||
var secondRowTopMargin by intPref(default = Constants.SecondRowTopMargin.NONE.value)
|
||||
var showClock by booleanPref(key = "PREF_SHOW_CLOCK", default = false)
|
||||
var clockAppName by stringPref(key = "PREF_CLOCK_APP_NAME", default = "")
|
||||
var clockAppPackage by stringPref(key = "PREF_CLOCK_APP_PACKAGE", default = "")
|
||||
var textShadow by intPref(key = "PREF_TEXT_SHADOW", default = 1)
|
||||
var textShadowDark by intPref(default = 1)
|
||||
var showDiffTime by booleanPref(key = "PREF_SHOW_DIFF_TIME", default = true)
|
||||
var showDeclinedEvents by booleanPref(key = "PREF_SHOW_DECLINED_EVENTS", default = false)
|
||||
var showInvitedEvents by booleanPref(default = false)
|
||||
var showAcceptedEvents by booleanPref(default = true)
|
||||
var showOnlyBusyEvents by booleanPref(default = false)
|
||||
var secondRowInformation by intPref(key = "PREF_SECOND_ROW_INFORMATION", default = 0)
|
||||
var customFont by intPref(key = "PREF_CUSTOM_FONT", default = Constants.CUSTOM_FONT_PRODUCT_SANS)
|
||||
var customFontFile by stringPref(key = "PREF_CUSTOM_FONT_FILE")
|
||||
|
@ -12,8 +12,7 @@ object AlarmHelper {
|
||||
val alarm = nextAlarmClock
|
||||
return if (
|
||||
alarm != null
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis > 10 * 60 * 1000
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis < 12 * 60 * 60 * 1000
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis > 5 * 60 * 1000
|
||||
) {
|
||||
"%s %s".format(
|
||||
SimpleDateFormat("EEE", Locale.getDefault()).format(alarm.triggerTime),
|
||||
|
@ -104,13 +104,12 @@ object BitmapHelper {
|
||||
}
|
||||
|
||||
fun drawableToBitmap(drawable: Drawable): Bitmap? {
|
||||
var bitmap: Bitmap? = null
|
||||
if (drawable is BitmapDrawable) {
|
||||
if (drawable.bitmap != null) {
|
||||
return drawable.bitmap
|
||||
}
|
||||
}
|
||||
bitmap = if (drawable.intrinsicWidth <= 0 || drawable.intrinsicHeight <= 0) {
|
||||
val bitmap: Bitmap = if (drawable.intrinsicWidth <= 0 || drawable.intrinsicHeight <= 0) {
|
||||
Bitmap.createBitmap(
|
||||
1,
|
||||
1,
|
||||
|
@ -69,4 +69,15 @@ object CalendarHelper {
|
||||
fun removeEventUpdatesAndroidN(context: Context) {
|
||||
EventListenerJob.remove(context)
|
||||
}
|
||||
|
||||
fun List<Event>.applyFilters() : List<Event> {
|
||||
return this
|
||||
.asSequence()
|
||||
.filter { (Preferences.showDeclinedEvents || it.selfAttendeeStatus != CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED) }
|
||||
.filter { (Preferences.showAcceptedEvents || it.selfAttendeeStatus != CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED) }
|
||||
.filter { (Preferences.showInvitedEvents || it.selfAttendeeStatus != CalendarContract.Attendees.ATTENDEE_STATUS_INVITED) }
|
||||
.filter { (Preferences.calendarAllDay || !it.allDay) }
|
||||
.filter { (!Preferences.showOnlyBusyEvents || it.availability != CalendarContract.EventsEntity.AVAILABILITY_FREE) }
|
||||
.toList()
|
||||
}
|
||||
}
|
@ -7,97 +7,97 @@ import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
object ColorHelper {
|
||||
fun getFontColor(): Int {
|
||||
fun getFontColor(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor("#%s%s".format(Preferences.textGlobalAlpha, Preferences.textGlobalColor.replace("#", "")))
|
||||
Color.parseColor("#%s%s".format(if (!isDark) Preferences.textGlobalAlpha else Preferences.textGlobalAlphaDark, (if (!isDark) Preferences.textGlobalColor else Preferences.textGlobalColorDark).replace("#", "")))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#FFFFFFFF")
|
||||
}
|
||||
}
|
||||
|
||||
fun getFontColorAlpha(): Int {
|
||||
fun getFontColorAlpha(isDark: Boolean): Int {
|
||||
return try {
|
||||
Preferences.textGlobalAlpha.toIntValue().toDouble() * 255 / 100
|
||||
(if (!isDark) Preferences.textGlobalAlpha else Preferences.textGlobalAlphaDark).toIntValue().toDouble() * 255 / 100
|
||||
} catch (e: Exception) {
|
||||
"FF".toIntValue().toDouble() * 255 / 100
|
||||
}.roundToInt()
|
||||
}
|
||||
|
||||
fun getFontColorRgb(): Int {
|
||||
fun getFontColorRgb(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor(Preferences.textGlobalColor)
|
||||
Color.parseColor((if (!isDark) Preferences.textGlobalColor else Preferences.textGlobalColorDark))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#000000")
|
||||
}
|
||||
}
|
||||
|
||||
fun getSecondaryFontColor(): Int {
|
||||
fun getSecondaryFontColor(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor("#%s%s".format(Preferences.textSecondaryAlpha, Preferences.textSecondaryColor.replace("#", "")))
|
||||
Color.parseColor("#%s%s".format((if (!isDark) Preferences.textSecondaryAlpha else Preferences.textSecondaryAlphaDark), (if (!isDark) Preferences.textSecondaryColor else Preferences.textSecondaryColorDark).replace("#", "")))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#FFFFFFFF")
|
||||
}
|
||||
}
|
||||
|
||||
fun getSecondaryFontColorAlpha(): Int {
|
||||
fun getSecondaryFontColorAlpha(isDark: Boolean): Int {
|
||||
return try {
|
||||
Preferences.textSecondaryAlpha.toIntValue().toDouble() * 255 / 100
|
||||
(if (!isDark) Preferences.textSecondaryAlpha else Preferences.textSecondaryAlphaDark).toIntValue().toDouble() * 255 / 100
|
||||
} catch (e: Exception) {
|
||||
"FF".toIntValue().toDouble() * 255 / 100
|
||||
}.roundToInt()
|
||||
}
|
||||
|
||||
fun getSecondaryFontColorRgb(): Int {
|
||||
fun getSecondaryFontColorRgb(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor(Preferences.textSecondaryColor)
|
||||
Color.parseColor((if (!isDark) Preferences.textSecondaryColor else Preferences.textSecondaryColorDark))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#000000")
|
||||
}
|
||||
}
|
||||
|
||||
fun getClockFontColor(): Int {
|
||||
fun getClockFontColor(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor("#%s%s".format(Preferences.clockTextAlpha, Preferences.clockTextColor.replace("#", "")))
|
||||
Color.parseColor("#%s%s".format((if (!isDark) Preferences.clockTextAlpha else Preferences.clockTextAlphaDark), (if (!isDark) Preferences.clockTextColor else Preferences.clockTextColorDark).replace("#", "")))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#FFFFFFFF")
|
||||
}
|
||||
}
|
||||
|
||||
fun getClockFontColorAlpha(): Int {
|
||||
fun getClockFontColorAlpha(isDark: Boolean): Int {
|
||||
return try {
|
||||
Preferences.clockTextAlpha.toIntValue().toDouble() * 255 / 100
|
||||
(if (!isDark) Preferences.clockTextAlpha else Preferences.clockTextAlphaDark).toIntValue().toDouble() * 255 / 100
|
||||
} catch (e: Exception) {
|
||||
"FF".toIntValue().toDouble() * 255 / 100
|
||||
}.roundToInt()
|
||||
}
|
||||
|
||||
fun getClockFontColorRgb(): Int {
|
||||
fun getClockFontColorRgb(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor(Preferences.clockTextColor)
|
||||
Color.parseColor((if (!isDark) Preferences.clockTextColor else Preferences.clockTextColorDark))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#000000")
|
||||
}
|
||||
}
|
||||
|
||||
fun getBackgroundColor(): Int {
|
||||
fun getBackgroundColor(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor("#%s%s".format(Preferences.backgroundCardAlpha, Preferences.backgroundCardColor.replace("#", "")))
|
||||
Color.parseColor("#%s%s".format((if (!isDark) Preferences.backgroundCardAlpha else Preferences.backgroundCardAlphaDark), (if (!isDark) Preferences.backgroundCardColor else Preferences.backgroundCardColorDark).replace("#", "")))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#00000000")
|
||||
}
|
||||
}
|
||||
|
||||
fun getBackgroundAlpha(): Int {
|
||||
fun getBackgroundAlpha(isDark: Boolean): Int {
|
||||
return try {
|
||||
Preferences.backgroundCardAlpha.toIntValue().toDouble() * 255 / 100
|
||||
(if (!isDark) Preferences.backgroundCardAlpha else Preferences.backgroundCardAlphaDark).toIntValue().toDouble() * 255 / 100
|
||||
} catch (e: Exception) {
|
||||
"00".toIntValue().toDouble() * 255 / 100
|
||||
}.roundToInt()
|
||||
}
|
||||
|
||||
fun getBackgroundColorRgb(): Int {
|
||||
fun getBackgroundColorRgb(isDark: Boolean): Int {
|
||||
return try {
|
||||
Color.parseColor(Preferences.backgroundCardColor)
|
||||
Color.parseColor((if (!isDark) Preferences.backgroundCardColor else Preferences.backgroundCardColorDark))
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#000000")
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateUtils
|
||||
import android.util.Log
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.utils.getCapWordString
|
||||
import java.lang.Exception
|
||||
@ -17,7 +16,11 @@ object DateHelper {
|
||||
} catch (e: Exception) {
|
||||
getDefaultDateText(context, date)
|
||||
}
|
||||
if (Preferences.isDateCapitalize) text.getCapWordString() else text
|
||||
when {
|
||||
Preferences.isDateUppercase -> text.toUpperCase(Locale.getDefault())
|
||||
Preferences.isDateCapitalize -> text.getCapWordString()
|
||||
else -> text
|
||||
}
|
||||
} else {
|
||||
val flags: Int =
|
||||
DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_NO_YEAR or DateUtils.FORMAT_ABBREV_MONTH
|
||||
@ -25,17 +28,20 @@ object DateHelper {
|
||||
SimpleDateFormat("EEEE", Locale.getDefault()).format(date.time),
|
||||
DateUtils.formatDateTime(context, date.timeInMillis, flags)
|
||||
)
|
||||
if (Preferences.isDateCapitalize) text.getCapWordString() else text
|
||||
when {
|
||||
Preferences.isDateUppercase -> text.toUpperCase(Locale.getDefault())
|
||||
Preferences.isDateCapitalize -> text.getCapWordString()
|
||||
else -> text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getDefaultDateText(context: Context, date: Calendar): String {
|
||||
val flags: Int =
|
||||
DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_NO_YEAR or DateUtils.FORMAT_ABBREV_MONTH
|
||||
val text = "%s, %s".format(
|
||||
return "%s, %s".format(
|
||||
SimpleDateFormat("EEEE", Locale.getDefault()).format(date.time),
|
||||
DateUtils.formatDateTime(context, date.timeInMillis, flags)
|
||||
)
|
||||
return if (Preferences.isDateCapitalize) text.getCapWordString() else text
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ import android.media.session.MediaSessionManager
|
||||
import android.media.session.PlaybackState
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.chibatching.kotpref.Kotpref
|
||||
import com.chibatching.kotpref.blockingBulk
|
||||
import com.chibatching.kotpref.bulk
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.receivers.MusicNotificationListener
|
||||
@ -28,6 +30,7 @@ object MediaPlayerHelper {
|
||||
}
|
||||
|
||||
fun updatePlayingMediaInfo(context: Context) {
|
||||
Kotpref.init(context)
|
||||
if (NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.packageName)) {
|
||||
val list = try {
|
||||
(context.getSystemService(Context.MEDIA_SESSION_SERVICE) as MediaSessionManager).getActiveSessions(
|
||||
@ -65,20 +68,21 @@ object MediaPlayerHelper {
|
||||
}
|
||||
|
||||
if (!isSomeonePlaying) {
|
||||
removeMediaInfo()
|
||||
removeMediaInfo(context)
|
||||
}
|
||||
|
||||
} else {
|
||||
removeMediaInfo()
|
||||
removeMediaInfo(context)
|
||||
}
|
||||
} else {
|
||||
removeMediaInfo()
|
||||
removeMediaInfo(context)
|
||||
}
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
|
||||
private fun removeMediaInfo() {
|
||||
Preferences.bulk {
|
||||
private fun removeMediaInfo(context: Context) {
|
||||
Kotpref.init(context)
|
||||
Preferences.blockingBulk {
|
||||
remove(Preferences::mediaPlayerTitle)
|
||||
remove(Preferences::mediaPlayerArtist)
|
||||
remove(Preferences::mediaPlayerAlbum)
|
||||
|
@ -17,7 +17,8 @@ open class Event(
|
||||
var calendarID: Int = 0,
|
||||
var allDay: Boolean = false,
|
||||
var address: String = "",
|
||||
var selfAttendeeStatus: Int = CalendarContract.Attendees.ATTENDEE_STATUS_NONE
|
||||
var selfAttendeeStatus: Int = CalendarContract.Attendees.ATTENDEE_STATUS_NONE,
|
||||
var availability: Int = CalendarContract.EventsEntity.AVAILABILITY_BUSY
|
||||
) : RealmObject() {
|
||||
override fun toString(): String {
|
||||
return "Event:\nEVENT ID: " + eventID + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) + "\nCAL ID: " + calendarID + "\nADDRESS: " + address
|
||||
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.chibatching.kotpref.Kotpref
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
||||
import com.google.android.gms.fitness.Fitness
|
||||
@ -35,15 +36,16 @@ class ActivityDetectionReceiver : BroadcastReceiver() {
|
||||
}
|
||||
} else {
|
||||
if (intent.action == Intent.ACTION_BOOT_COMPLETED || intent.action == Intent.ACTION_MY_PACKAGE_REPLACED && Preferences.showDailySteps && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || context.checkGrantedPermission(Manifest.permission.ACTIVITY_RECOGNITION)) {
|
||||
resetDailySteps()
|
||||
resetDailySteps(context)
|
||||
registerFence(context)
|
||||
} else {
|
||||
resetDailySteps()
|
||||
resetDailySteps(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetDailySteps() {
|
||||
private fun resetDailySteps(context: Context) {
|
||||
Kotpref.init(context)
|
||||
Preferences.googleFitSteps = -1
|
||||
}
|
||||
|
||||
@ -54,6 +56,7 @@ class ActivityDetectionReceiver : BroadcastReceiver() {
|
||||
.build()
|
||||
|
||||
fun registerFence(context: Context) {
|
||||
Kotpref.init(context)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || context.checkGrantedPermission(
|
||||
Manifest.permission.ACTIVITY_RECOGNITION)) {
|
||||
val transitions = mutableListOf<ActivityTransition>()
|
||||
@ -116,6 +119,7 @@ class ActivityDetectionReceiver : BroadcastReceiver() {
|
||||
}
|
||||
|
||||
fun requestDailySteps(context: Context) {
|
||||
Kotpref.init(context)
|
||||
|
||||
val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(context)
|
||||
if (account != null && GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS)) {
|
||||
|
@ -52,7 +52,7 @@ class BatteryListenerJob : JobService() {
|
||||
}
|
||||
}
|
||||
|
||||
fun remove(context: Context) {
|
||||
private fun remove(context: Context) {
|
||||
val js = context.getSystemService(JobScheduler::class.java)
|
||||
js?.cancel(chargingJobId)
|
||||
js?.cancel(notChargingJobId)
|
||||
|
@ -3,11 +3,13 @@ package com.tommasoberlose.anotherwidget.services
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.CalendarContract
|
||||
import android.util.Log
|
||||
import androidx.core.app.JobIntentService
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.applyFilters
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||
@ -22,7 +24,7 @@ import kotlin.collections.ArrayList
|
||||
class UpdateCalendarJob : JobIntentService() {
|
||||
|
||||
companion object {
|
||||
val jobId = 1200
|
||||
private const val jobId = 1200
|
||||
|
||||
fun enqueueWork(context: Context, work: Intent) {
|
||||
enqueueWork(context, UpdateCalendarJob::class.java, jobId, work)
|
||||
@ -83,7 +85,8 @@ class UpdateCalendarJob : JobIntentService() {
|
||||
calendarID = e.calendarId.toInt(),
|
||||
allDay = e.allDay,
|
||||
address = e.eventLocation ?: "",
|
||||
selfAttendeeStatus = e.selfAttendeeStatus.toInt()
|
||||
selfAttendeeStatus = e.selfAttendeeStatus.toInt(),
|
||||
availability = e.availability
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -92,17 +95,27 @@ class UpdateCalendarJob : JobIntentService() {
|
||||
}
|
||||
}
|
||||
|
||||
if (eventList.isEmpty()) {
|
||||
val filteredEventList = eventList
|
||||
.applyFilters()
|
||||
|
||||
if (filteredEventList.isEmpty()) {
|
||||
eventRepository.resetNextEventData()
|
||||
eventRepository.clearEvents()
|
||||
} else {
|
||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
||||
if (event.allDay && event1.allDay) {
|
||||
event.startDate.compareTo(event1.startDate)
|
||||
} else if (event.allDay) {
|
||||
1
|
||||
} else if (event1.allDay) {
|
||||
-1
|
||||
val date = Calendar.getInstance().apply { timeInMillis = event.startDate }
|
||||
val date1 = Calendar.getInstance().apply { timeInMillis = event1.startDate }
|
||||
|
||||
if (date.get(Calendar.DAY_OF_YEAR) == date1.get(Calendar.DAY_OF_YEAR) && date.get(Calendar.YEAR) == date1.get(Calendar.YEAR)) {
|
||||
if (event.allDay && event1.allDay) {
|
||||
event1.startDate.compareTo(event.startDate)
|
||||
} else if (event.allDay) {
|
||||
-1
|
||||
} else if (event1.allDay) {
|
||||
1
|
||||
} else {
|
||||
event1.startDate.compareTo(event.startDate)
|
||||
}
|
||||
} else {
|
||||
event1.startDate.compareTo(event.startDate)
|
||||
}
|
||||
@ -111,9 +124,7 @@ class UpdateCalendarJob : JobIntentService() {
|
||||
eventRepository.saveEvents(
|
||||
eventList
|
||||
)
|
||||
eventRepository.saveNextEventData(
|
||||
eventList[0]
|
||||
)
|
||||
eventRepository.saveNextEventData(filteredEventList.first())
|
||||
}
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
|
||||
|
@ -6,12 +6,14 @@ import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chibatching.kotpref.blockingBulk
|
||||
import com.chibatching.kotpref.bulk
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomDateBinding
|
||||
@ -90,10 +92,14 @@ class CustomDateActivity : AppCompatActivity() {
|
||||
"__"
|
||||
}
|
||||
|
||||
if (Preferences.isDateCapitalize) {
|
||||
if (viewModel.isDateCapitalize.value == true) {
|
||||
text = text.getCapWordString()
|
||||
}
|
||||
|
||||
if (viewModel.isDateUppercase.value == true) {
|
||||
text = text.toUpperCase(Locale.getDefault())
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
action_save.isVisible = text != ERROR_STRING
|
||||
loader.visibility = View.INVISIBLE
|
||||
@ -105,8 +111,30 @@ class CustomDateActivity : AppCompatActivity() {
|
||||
|
||||
viewModel.isDateCapitalize.observe(this, Observer {
|
||||
viewModel.dateInput.value = viewModel.dateInput.value
|
||||
binding.isdCapitalizeEnabled = it
|
||||
updateCapitalizeUi()
|
||||
})
|
||||
|
||||
viewModel.isDateUppercase.observe(this, Observer {
|
||||
viewModel.dateInput.value = viewModel.dateInput.value
|
||||
updateCapitalizeUi()
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateCapitalizeUi() {
|
||||
when {
|
||||
viewModel.isDateUppercase.value == true -> {
|
||||
action_capitalize.setImageDrawable(ContextCompat.getDrawable(this@CustomDateActivity, R.drawable.round_publish))
|
||||
action_capitalize.alpha = 1f
|
||||
}
|
||||
viewModel.isDateCapitalize.value == true -> {
|
||||
action_capitalize.setImageDrawable(ContextCompat.getDrawable(this@CustomDateActivity, R.drawable.ic_capitalize))
|
||||
action_capitalize.alpha = 1f
|
||||
}
|
||||
else -> {
|
||||
action_capitalize.setImageDrawable(ContextCompat.getDrawable(this@CustomDateActivity, R.drawable.round_publish))
|
||||
action_capitalize.alpha = 0.3f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupListener() {
|
||||
@ -115,12 +143,29 @@ class CustomDateActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
action_save.setOnClickListener {
|
||||
Preferences.dateFormat = viewModel.dateInput.value ?: ""
|
||||
Preferences.blockingBulk {
|
||||
dateFormat = viewModel.dateInput.value ?: ""
|
||||
isDateCapitalize = viewModel.isDateCapitalize.value ?: true
|
||||
isDateUppercase = viewModel.isDateUppercase.value ?: false
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
||||
action_capitalize.setOnClickListener {
|
||||
Preferences.isDateCapitalize = !Preferences.isDateCapitalize
|
||||
when {
|
||||
viewModel.isDateUppercase.value == true -> {
|
||||
viewModel.isDateCapitalize.value = false
|
||||
viewModel.isDateUppercase.value = false
|
||||
}
|
||||
viewModel.isDateCapitalize.value == true -> {
|
||||
viewModel.isDateCapitalize.value = false
|
||||
viewModel.isDateUppercase.value = true
|
||||
}
|
||||
else -> {
|
||||
viewModel.isDateCapitalize.value = true
|
||||
viewModel.isDateUppercase.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
action_capitalize.setOnLongClickListener {
|
||||
|
@ -28,6 +28,7 @@ import com.karumi.dexter.MultiplePermissionsReport
|
||||
import com.karumi.dexter.PermissionToken
|
||||
import com.karumi.dexter.listener.PermissionRequest
|
||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
|
||||
import com.tommasoberlose.anotherwidget.databinding.ActivityChooseApplicationBinding
|
||||
import com.tommasoberlose.anotherwidget.databinding.ActivityCustomLocationBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
@ -62,7 +63,11 @@ class CustomLocationActivity : AppCompatActivity() {
|
||||
injector
|
||||
.text(R.id.text, getString(R.string.custom_location_gps))
|
||||
.clicked(R.id.text) {
|
||||
requirePermission()
|
||||
MaterialBottomSheetDialog(this, message = getString(R.string.background_location_warning))
|
||||
.setPositiveButton(getString(android.R.string.ok)) {
|
||||
requirePermission()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}
|
||||
.register<Address>(R.layout.custom_location_item) { item, injector ->
|
||||
|
@ -4,7 +4,7 @@ import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.provider.CalendarContract
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -31,10 +31,8 @@ import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.DateHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.IntentHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.CustomDateActivity
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.isDefaultSet
|
||||
import com.tommasoberlose.anotherwidget.utils.toast
|
||||
@ -42,7 +40,6 @@ import kotlinx.android.synthetic.main.fragment_calendar_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_calendar_settings.scrollView
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
import kotlin.Comparator
|
||||
|
||||
class CalendarTabFragment : Fragment() {
|
||||
@ -77,7 +74,7 @@ class CalendarTabFragment : Fragment() {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
show_all_day_toggle.isChecked = Preferences.calendarAllDay
|
||||
show_declined_events_toggle.isChecked = Preferences.showDeclinedEvents
|
||||
show_only_busy_events_toggle.isChecked = Preferences.showOnlyBusyEvents
|
||||
show_diff_time_toggle.isChecked = Preferences.showDiffTime
|
||||
show_multiple_events_toggle.isChecked = Preferences.showNextEvent
|
||||
|
||||
@ -113,12 +110,6 @@ class CalendarTabFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.showDeclinedEvents.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
show_declined_events_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.secondRowInformation.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
second_row_info_label?.text = getString(SettingsStringHelper.getSecondRowInfoString(it))
|
||||
@ -258,18 +249,58 @@ class CalendarTabFragment : Fragment() {
|
||||
show_all_day_toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (Preferences.showEvents) {
|
||||
Preferences.calendarAllDay = isChecked
|
||||
updateCalendar()
|
||||
}
|
||||
}
|
||||
|
||||
action_show_declined_events.setOnClickListener {
|
||||
action_change_attendee_filter.setOnClickListener {
|
||||
if (Preferences.showEvents) {
|
||||
show_declined_events_toggle.isChecked = !show_declined_events_toggle.isChecked
|
||||
val selectedValues = emptyList<Int>().toMutableList()
|
||||
if (Preferences.showDeclinedEvents) {
|
||||
selectedValues.add(CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED)
|
||||
}
|
||||
if (Preferences.showInvitedEvents) {
|
||||
selectedValues.add(CalendarContract.Attendees.ATTENDEE_STATUS_INVITED)
|
||||
}
|
||||
if (Preferences.showAcceptedEvents) {
|
||||
selectedValues.add(CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED)
|
||||
}
|
||||
|
||||
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.settings_attendee_status_title), isMultiSelection = true)
|
||||
.setSelectedValues(selectedValues)
|
||||
|
||||
dialog.addItem(
|
||||
getString(R.string.attendee_status_invited),
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_INVITED
|
||||
)
|
||||
dialog.addItem(
|
||||
getString(R.string.attendee_status_accepted),
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED
|
||||
)
|
||||
dialog.addItem(
|
||||
getString(R.string.attendee_status_declined),
|
||||
CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED
|
||||
)
|
||||
|
||||
dialog.addOnMultipleSelectItemListener { values ->
|
||||
Preferences.showDeclinedEvents = values.contains(CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED)
|
||||
Preferences.showAcceptedEvents = values.contains(CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED)
|
||||
Preferences.showInvitedEvents = values.contains(CalendarContract.Attendees.ATTENDEE_STATUS_INVITED)
|
||||
updateCalendar()
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
show_declined_events_toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
action_show_only_busy_events.setOnClickListener {
|
||||
if (Preferences.showEvents) {
|
||||
Preferences.showDeclinedEvents = isChecked
|
||||
show_only_busy_events_toggle.isChecked = !show_only_busy_events_toggle.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
show_only_busy_events_toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (Preferences.showEvents) {
|
||||
Preferences.showOnlyBusyEvents = isChecked
|
||||
updateCalendar()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import com.tommasoberlose.anotherwidget.helpers.IntentHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.utils.isDarkTheme
|
||||
import com.tommasoberlose.anotherwidget.utils.isDefaultSet
|
||||
import kotlinx.android.synthetic.main.fragment_clock_settings.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -95,6 +96,7 @@ class ClockTabFragment : Fragment() {
|
||||
) {
|
||||
binding.isClockVisible = Preferences.showClock
|
||||
binding.is24Format = DateFormat.is24HourFormat(requireContext())
|
||||
binding.isDarkModeEnabled = activity?.isDarkTheme() == true
|
||||
|
||||
viewModel.showBigClockWarning.observe(viewLifecycleOwner, Observer {
|
||||
large_clock_warning?.isVisible = it
|
||||
@ -127,7 +129,18 @@ class ClockTabFragment : Fragment() {
|
||||
clock_text_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
clock_text_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.clockTextColorDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.clockTextAlphaDark == "00") {
|
||||
clock_text_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
clock_text_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -138,7 +151,18 @@ class ClockTabFragment : Fragment() {
|
||||
clock_text_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
clock_text_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.clockTextAlphaDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.clockTextAlphaDark == "00") {
|
||||
clock_text_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
clock_text_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -217,16 +241,25 @@ class ClockTabFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_font_color_title),
|
||||
getSelected = ColorHelper::getClockFontColorRgb,
|
||||
getSelected = { ColorHelper.getClockFontColorRgb(activity?.isDarkTheme() == true) },
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.clockTextColor =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.clockTextColorDark =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
} else {
|
||||
Preferences.clockTextColor =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
}
|
||||
},
|
||||
showAlphaSelector = true,
|
||||
alpha = Preferences.clockTextAlpha.toIntValue(),
|
||||
alpha = if (activity?.isDarkTheme() == true) Preferences.clockTextAlphaDark.toIntValue() else Preferences.clockTextAlpha.toIntValue(),
|
||||
onAlphaChangeListener = { alpha ->
|
||||
Preferences.clockTextAlpha = alpha.toHexValue()
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.clockTextAlphaDark = alpha.toHexValue()
|
||||
} else {
|
||||
Preferences.clockTextAlpha = alpha.toHexValue()
|
||||
}
|
||||
}
|
||||
).show()
|
||||
}
|
||||
|
@ -12,10 +12,12 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.chibatching.kotpref.blockingBulk
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentGeneralSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.global.RequestCode
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
|
||||
@ -26,7 +28,10 @@ import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.CustomDateActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.utils.isDarkTheme
|
||||
import kotlinx.android.synthetic.main.fragment_clock_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_general_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_general_settings.scrollView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@ -60,6 +65,7 @@ class GeneralTabFragment : Fragment() {
|
||||
|
||||
binding.lifecycleOwner = this
|
||||
binding.viewModel = viewModel
|
||||
binding.isDarkModeEnabled = activity?.isDarkTheme() == true
|
||||
|
||||
return binding.root
|
||||
}
|
||||
@ -102,7 +108,18 @@ class GeneralTabFragment : Fragment() {
|
||||
font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textGlobalColorDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.textGlobalAlphaDark == "00") {
|
||||
font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -113,7 +130,18 @@ class GeneralTabFragment : Fragment() {
|
||||
font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textGlobalAlphaDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.textGlobalAlphaDark == "00") {
|
||||
font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -124,7 +152,18 @@ class GeneralTabFragment : Fragment() {
|
||||
secondary_font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
secondary_font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textSecondaryColorDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.textSecondaryAlphaDark == "00") {
|
||||
secondary_font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
secondary_font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -135,7 +174,29 @@ class GeneralTabFragment : Fragment() {
|
||||
secondary_font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
secondary_font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textSecondaryAlphaDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.textSecondaryAlphaDark == "00") {
|
||||
secondary_font_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
secondary_font_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getSecondaryFontColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.secondRowTopMargin.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
second_row_top_margin_label?.text = when (it) {
|
||||
Constants.SecondRowTopMargin.NONE.value -> getString(R.string.settings_clock_bottom_margin_subtitle_none)
|
||||
Constants.SecondRowTopMargin.SMALL.value -> getString(R.string.settings_clock_bottom_margin_subtitle_small)
|
||||
Constants.SecondRowTopMargin.LARGE.value -> getString(R.string.settings_clock_bottom_margin_subtitle_large)
|
||||
else -> getString(R.string.settings_clock_bottom_margin_subtitle_medium)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -146,7 +207,18 @@ class GeneralTabFragment : Fragment() {
|
||||
background_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
background_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.backgroundCardColorDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.backgroundCardAlphaDark == "00") {
|
||||
background_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
background_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -157,14 +229,37 @@ class GeneralTabFragment : Fragment() {
|
||||
background_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
background_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor())).toUpperCase()
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.backgroundCardAlphaDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.backgroundCardAlphaDark == "00") {
|
||||
background_color_label?.text = getString(R.string.transparent)
|
||||
} else {
|
||||
background_color_label?.text =
|
||||
"#%s".format(Integer.toHexString(ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true))).toUpperCase()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textShadow.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
text_shadow_label?.text = getString(SettingsStringHelper.getTextShadowString(it))
|
||||
if (activity?.isDarkTheme() != true) {
|
||||
text_shadow_label?.text =
|
||||
getString(SettingsStringHelper.getTextShadowString(it))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.textShadowDark.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
text_shadow_label?.text =
|
||||
getString(SettingsStringHelper.getTextShadowString(it))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -213,15 +308,23 @@ class GeneralTabFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_font_color_title),
|
||||
getSelected = ColorHelper::getFontColorRgb,
|
||||
getSelected = { ColorHelper.getFontColorRgb(activity?.isDarkTheme() == true) },
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.textGlobalColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.textGlobalColorDark = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
} else {
|
||||
Preferences.textGlobalColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
}
|
||||
},
|
||||
showAlphaSelector = true,
|
||||
alpha = Preferences.textGlobalAlpha.toIntValue(),
|
||||
alpha = if (activity?.isDarkTheme() == true) Preferences.textGlobalAlphaDark.toIntValue() else Preferences.textGlobalAlpha.toIntValue(),
|
||||
onAlphaChangeListener = { alpha ->
|
||||
Preferences.textGlobalAlpha = alpha.toHexValue()
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.textGlobalAlphaDark = alpha.toHexValue()
|
||||
} else {
|
||||
Preferences.textGlobalAlpha = alpha.toHexValue()
|
||||
}
|
||||
}
|
||||
).show()
|
||||
}
|
||||
@ -230,19 +333,55 @@ class GeneralTabFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_secondary_font_color_title),
|
||||
getSelected = ColorHelper::getSecondaryFontColorRgb,
|
||||
getSelected = { ColorHelper.getSecondaryFontColorRgb(activity?.isDarkTheme() == true) },
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.textSecondaryColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.textSecondaryColorDark =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
} else {
|
||||
Preferences.textSecondaryColor =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
}
|
||||
},
|
||||
showAlphaSelector = true,
|
||||
alpha = Preferences.textSecondaryAlpha.toIntValue(),
|
||||
alpha = if (activity?.isDarkTheme() == true) Preferences.textSecondaryAlphaDark.toIntValue() else Preferences.textSecondaryAlpha.toIntValue(),
|
||||
onAlphaChangeListener = { alpha ->
|
||||
Preferences.textSecondaryAlpha = alpha.toHexValue()
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.textSecondaryAlphaDark = alpha.toHexValue()
|
||||
} else {
|
||||
Preferences.textSecondaryAlpha = alpha.toHexValue()
|
||||
}
|
||||
}
|
||||
).show()
|
||||
}
|
||||
|
||||
action_second_row_top_margin_size.setOnClickListener {
|
||||
BottomSheetMenu<Int>(
|
||||
requireContext(),
|
||||
header = getString(R.string.settings_secondary_row_top_margin_title)
|
||||
).setSelectedValue(Preferences.secondRowTopMargin)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_none),
|
||||
Constants.SecondRowTopMargin.NONE.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_small),
|
||||
Constants.SecondRowTopMargin.SMALL.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_medium),
|
||||
Constants.SecondRowTopMargin.MEDIUM.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_large),
|
||||
Constants.SecondRowTopMargin.LARGE.value
|
||||
)
|
||||
.addOnSelectItemListener { value ->
|
||||
Preferences.secondRowTopMargin = value
|
||||
}.show()
|
||||
}
|
||||
|
||||
action_date_format.setOnClickListener {
|
||||
val now = Calendar.getInstance()
|
||||
val dialog = BottomSheetMenu<String>(requireContext(), header = getString(R.string.settings_date_format_title)).setSelectedValue(Preferences.dateFormat)
|
||||
@ -254,10 +393,20 @@ class GeneralTabFragment : Fragment() {
|
||||
dialog.addItem(getString(R.string.custom_date_format), "-")
|
||||
|
||||
dialog.addOnSelectItemListener { value ->
|
||||
if (value == "-") {
|
||||
startActivity(Intent(requireContext(), CustomDateActivity::class.java))
|
||||
} else {
|
||||
Preferences.dateFormat = value
|
||||
when (value) {
|
||||
"-" -> {
|
||||
startActivity(Intent(requireContext(), CustomDateActivity::class.java))
|
||||
}
|
||||
"" -> {
|
||||
Preferences.blockingBulk {
|
||||
isDateCapitalize = false
|
||||
isDateUppercase = false
|
||||
}
|
||||
Preferences.dateFormat = value
|
||||
}
|
||||
else -> {
|
||||
Preferences.dateFormat = value
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
@ -266,26 +415,40 @@ class GeneralTabFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_background_color_title),
|
||||
getSelected = { ColorHelper.getBackgroundColorRgb() },
|
||||
getSelected = { ColorHelper.getBackgroundColorRgb(activity?.isDarkTheme() == true) },
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.backgroundCardColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.backgroundCardColorDark =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
} else {
|
||||
Preferences.backgroundCardColor =
|
||||
"#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
}
|
||||
},
|
||||
showAlphaSelector = true,
|
||||
alpha = Preferences.backgroundCardAlpha.toIntValue(),
|
||||
alpha = if (activity?.isDarkTheme() == true) Preferences.backgroundCardAlphaDark.toIntValue() else Preferences.backgroundCardAlpha.toIntValue(),
|
||||
onAlphaChangeListener = { alpha ->
|
||||
Preferences.backgroundCardAlpha = alpha.toHexValue()
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.backgroundCardAlphaDark = alpha.toHexValue()
|
||||
} else {
|
||||
Preferences.backgroundCardAlpha = alpha.toHexValue()
|
||||
}
|
||||
}
|
||||
).show()
|
||||
}
|
||||
|
||||
action_text_shadow.setOnClickListener {
|
||||
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.title_text_shadow)).setSelectedValue(Preferences.textShadow)
|
||||
val dialog = BottomSheetMenu<Int>(requireContext(), header = getString(R.string.title_text_shadow)).setSelectedValue(if (activity?.isDarkTheme() == true) Preferences.textShadowDark else Preferences.textShadow)
|
||||
(2 downTo 0).forEach {
|
||||
dialog.addItem(getString(SettingsStringHelper.getTextShadowString(it)), it)
|
||||
}
|
||||
dialog.addOnSelectItemListener { value ->
|
||||
Preferences.textShadow = value
|
||||
if (activity?.isDarkTheme() == true) {
|
||||
Preferences.textShadowDark = value
|
||||
} else {
|
||||
Preferences.textShadow = value
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,10 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -34,6 +36,7 @@ import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.components.CustomNotesDialog
|
||||
import com.tommasoberlose.anotherwidget.components.GlanceProviderSortMenu
|
||||
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentGlanceSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.AlarmHelper
|
||||
@ -188,7 +191,9 @@ class GlanceTabFragment : Fragment() {
|
||||
} catch (e: Exception) {
|
||||
alarm.showIntent?.creatorPackage ?: ""
|
||||
}
|
||||
activity?.toast(getString(R.string.next_alarm_warning).format(appNameOrPackage), long = true)
|
||||
MaterialBottomSheetDialog(requireContext(), message = getString(R.string.next_alarm_warning).format(appNameOrPackage))
|
||||
.setPositiveButton(getString(android.R.string.ok))
|
||||
.show()
|
||||
}
|
||||
}
|
||||
true
|
||||
@ -274,19 +279,23 @@ class GlanceTabFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkNotificationPermission() {
|
||||
if (NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName)) {
|
||||
notification_permission_alert?.isVisible = false
|
||||
MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
|
||||
show_music_label?.text = if (Preferences.showMusic) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
} else if (Preferences.showMusic) {
|
||||
notification_permission_alert?.isVisible = true
|
||||
show_music_label?.text = getString(R.string.settings_request_notification_access)
|
||||
notification_permission_alert?.setOnClickListener {
|
||||
activity?.startActivity(Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"))
|
||||
when {
|
||||
NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName) -> {
|
||||
notification_permission_alert?.isVisible = false
|
||||
MediaPlayerHelper.updatePlayingMediaInfo(requireContext())
|
||||
show_music_label?.text = if (Preferences.showMusic) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
}
|
||||
Preferences.showMusic -> {
|
||||
notification_permission_alert?.isVisible = true
|
||||
show_music_label?.text = getString(R.string.settings_request_notification_access)
|
||||
notification_permission_alert?.setOnClickListener {
|
||||
activity?.startActivity(Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"))
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
show_music_label?.text = getString(R.string.settings_not_visible)
|
||||
notification_permission_alert?.isVisible = false
|
||||
}
|
||||
} else {
|
||||
show_music_label?.text = getString(R.string.settings_not_visible)
|
||||
notification_permission_alert?.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.getCurrentWallpaper
|
||||
import com.tommasoberlose.anotherwidget.utils.isDarkTheme
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
import kotlinx.android.synthetic.main.fragment_app_main.*
|
||||
import kotlinx.android.synthetic.main.the_widget_sans.*
|
||||
@ -62,8 +63,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enterTransition = MaterialSharedAxis.create(MaterialSharedAxis.X, true)
|
||||
reenterTransition = MaterialSharedAxis.create(MaterialSharedAxis.X, false)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
@ -93,9 +94,9 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
}.attach()
|
||||
|
||||
// Init clock
|
||||
time.setTextColor(ColorHelper.getClockFontColor())
|
||||
time.setTextColor(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))
|
||||
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()))
|
||||
time_am_pm.setTextColor(ColorHelper.getClockFontColor())
|
||||
time_am_pm.setTextColor(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))
|
||||
time_am_pm.setTextSize(TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(requireContext()) / 5 * 2)
|
||||
time_container.isVisible = Preferences.showClock
|
||||
|
||||
@ -134,7 +135,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
preview?.setCardBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
if (ColorHelper.getFontColor()
|
||||
if (ColorHelper.getFontColor(activity?.isDarkTheme() == true)
|
||||
.isColorDark()
|
||||
) android.R.color.white else R.color.colorAccent
|
||||
)
|
||||
@ -143,7 +144,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
BitmapHelper.getTintedDrawable(
|
||||
requireContext(),
|
||||
R.drawable.card_background,
|
||||
ColorHelper.getBackgroundColor()
|
||||
ColorHelper.getBackgroundColor(activity?.isDarkTheme() == true)
|
||||
)
|
||||
)
|
||||
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||
@ -165,8 +166,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
// Clock
|
||||
time?.setTextColor(ColorHelper.getClockFontColor())
|
||||
time_am_pm?.setTextColor(ColorHelper.getClockFontColor())
|
||||
time?.setTextColor(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))
|
||||
time_am_pm?.setTextColor(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))
|
||||
time?.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize.toPixel(requireContext())
|
||||
@ -372,7 +373,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
var delayJob: Job? = null
|
||||
private var delayJob: Job? = null
|
||||
|
||||
override fun onSharedPreferenceChanged(preferences: SharedPreferences, p1: String) {
|
||||
delayJob?.cancel()
|
||||
|
@ -50,8 +50,8 @@ class SettingsFragment : Fragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enterTransition = MaterialSharedAxis.create(MaterialSharedAxis.X, true)
|
||||
returnTransition = MaterialSharedAxis.create(MaterialSharedAxis.X, false)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -26,6 +26,7 @@ import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.components.IconPackSelector
|
||||
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentWeatherSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
@ -110,6 +111,7 @@ class WeatherTabFragment : Fragment() {
|
||||
|
||||
viewModel.customLocationAdd.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
background_location_warning.isVisible = it == ""
|
||||
label_custom_location?.text =
|
||||
if (it == "") getString(R.string.custom_location_gps) else it
|
||||
}
|
||||
@ -164,7 +166,11 @@ class WeatherTabFragment : Fragment() {
|
||||
} else if (Preferences.showWeather && Preferences.customLocationAdd == "") {
|
||||
location_permission_alert?.isVisible = true
|
||||
location_permission_alert?.setOnClickListener {
|
||||
requirePermission()
|
||||
MaterialBottomSheetDialog(requireContext(), message = getString(R.string.background_location_warning))
|
||||
.setPositiveButton(getString(android.R.string.ok)) {
|
||||
requirePermission()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
} else {
|
||||
location_permission_alert?.isVisible = false
|
||||
@ -216,6 +222,9 @@ class WeatherTabFragment : Fragment() {
|
||||
.addItem(getString(R.string.fahrenheit), "F")
|
||||
.addItem(getString(R.string.celsius), "C")
|
||||
.addOnSelectItemListener { value ->
|
||||
if (value != Preferences.weatherTempUnit) {
|
||||
WeatherHelper.updateWeather(requireContext())
|
||||
}
|
||||
Preferences.weatherTempUnit = value
|
||||
}.show()
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
|
||||
class CustomDateViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val dateInput: MutableLiveData<String> = MutableLiveData(if (Preferences.dateFormat == "") "EEEE, MMM dd" else Preferences.dateFormat)
|
||||
val isDateCapitalize = Preferences.asLiveData(Preferences::isDateCapitalize)
|
||||
val isDateCapitalize = MutableLiveData<Boolean>(Preferences.isDateCapitalize)
|
||||
val isDateUppercase = MutableLiveData<Boolean>(Preferences.isDateUppercase)
|
||||
}
|
@ -13,12 +13,20 @@ class MainViewModel : ViewModel() {
|
||||
val textSecondaryAlpha = Preferences.asLiveData(Preferences::textSecondaryAlpha)
|
||||
val backgroundCardColor = Preferences.asLiveData(Preferences::backgroundCardColor)
|
||||
val backgroundCardAlpha = Preferences.asLiveData(Preferences::backgroundCardAlpha)
|
||||
val textGlobalColorDark = Preferences.asLiveData(Preferences::textGlobalColorDark)
|
||||
val textGlobalAlphaDark = Preferences.asLiveData(Preferences::textGlobalAlphaDark)
|
||||
val textSecondaryColorDark = Preferences.asLiveData(Preferences::textSecondaryColorDark)
|
||||
val textSecondaryAlphaDark = Preferences.asLiveData(Preferences::textSecondaryAlphaDark)
|
||||
val backgroundCardColorDark = Preferences.asLiveData(Preferences::backgroundCardColorDark)
|
||||
val backgroundCardAlphaDark = Preferences.asLiveData(Preferences::backgroundCardAlphaDark)
|
||||
val textMainSize = Preferences.asLiveData(Preferences::textMainSize)
|
||||
val textSecondSize = Preferences.asLiveData(Preferences::textSecondSize)
|
||||
val textShadow = Preferences.asLiveData(Preferences::textShadow)
|
||||
val textShadowDark = Preferences.asLiveData(Preferences::textShadowDark)
|
||||
val customFont = Preferences.asLiveData(Preferences::customFont)
|
||||
val secondRowInformation = Preferences.asLiveData(Preferences::secondRowInformation)
|
||||
val showDividers = Preferences.asLiveData(Preferences::showDividers)
|
||||
val secondRowTopMargin = Preferences.asLiveData(Preferences::secondRowTopMargin)
|
||||
|
||||
// Calendar Settings
|
||||
val showEvents = Preferences.asLiveData(Preferences::showEvents)
|
||||
@ -30,12 +38,15 @@ class MainViewModel : ViewModel() {
|
||||
val openEventDetails = Preferences.asLiveData(Preferences::openEventDetails)
|
||||
val calendarAppName = Preferences.asLiveData(Preferences::calendarAppName)
|
||||
val widgetUpdateFrequency = Preferences.asLiveData(Preferences::widgetUpdateFrequency)
|
||||
val showOnlyBusyEvents = Preferences.asLiveData(Preferences::showOnlyBusyEvents)
|
||||
|
||||
// Clock Settings
|
||||
val showClock = Preferences.asLiveData(Preferences::showClock)
|
||||
val clockTextSize = Preferences.asLiveData(Preferences::clockTextSize)
|
||||
val clockTextColor = Preferences.asLiveData(Preferences::clockTextColor)
|
||||
val clockTextAlpha = Preferences.asLiveData(Preferences::clockTextAlpha)
|
||||
val clockTextColorDark = Preferences.asLiveData(Preferences::clockTextColorDark)
|
||||
val clockTextAlphaDark = Preferences.asLiveData(Preferences::clockTextAlphaDark)
|
||||
val showAMPMIndicator = Preferences.asLiveData(Preferences::showAMPMIndicator)
|
||||
|
||||
val clockAppName = Preferences.asLiveData(Preferences::clockAppName)
|
||||
|
@ -15,10 +15,7 @@ import android.text.format.DateUtils
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.TextClock
|
||||
import android.widget.TextView
|
||||
import android.widget.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
@ -27,9 +24,11 @@ import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.*
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.toIntValue
|
||||
import com.tommasoberlose.anotherwidget.receivers.*
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.getCapWordString
|
||||
import com.tommasoberlose.anotherwidget.utils.isDarkTheme
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
import kotlinx.android.synthetic.main.the_widget.view.*
|
||||
import java.lang.Exception
|
||||
@ -102,12 +101,12 @@ class MainWidget : AppWidgetProvider() {
|
||||
views.setInt(
|
||||
R.id.widget_shape_background,
|
||||
"setColorFilter",
|
||||
ColorHelper.getBackgroundColorRgb()
|
||||
ColorHelper.getBackgroundColorRgb(context.isDarkTheme())
|
||||
)
|
||||
views.setInt(
|
||||
R.id.widget_shape_background,
|
||||
"setImageAlpha",
|
||||
ColorHelper.getBackgroundAlpha()
|
||||
ColorHelper.getBackgroundAlpha(context.isDarkTheme())
|
||||
)
|
||||
val refreshIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
@ -264,7 +263,21 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_small_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_medium_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_large_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context) && v.calendar_layout.isVisible) {
|
||||
var showSomething = false
|
||||
loop@ for (provider:Constants.GlanceProviderId in GlanceProviderHelper.getGlanceProviders(context)) {
|
||||
when (provider) {
|
||||
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||
@ -276,6 +289,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, musicIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -288,6 +302,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, alarmIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -302,6 +317,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, batteryIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -320,26 +336,44 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, fitIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
views.setImageViewBitmap(
|
||||
R.id.next_event_rect,
|
||||
BitmapHelper.getBitmapFromView(v.next_event, draw = false)
|
||||
)
|
||||
|
||||
views.setImageViewBitmap(
|
||||
R.id.second_row_rect,
|
||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
||||
)
|
||||
if (showSomething) {
|
||||
views.setImageViewBitmap(
|
||||
R.id.next_event_rect,
|
||||
BitmapHelper.getBitmapFromView(v.next_event, draw = false)
|
||||
)
|
||||
|
||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
||||
views.setImageViewBitmap(
|
||||
R.id.second_row_rect,
|
||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
||||
)
|
||||
|
||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
||||
|
||||
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_small_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_medium_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_large_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
@ -408,8 +442,8 @@ class MainWidget : AppWidgetProvider() {
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_medium, View.GONE)
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_large, View.GONE)
|
||||
} else {
|
||||
views.setTextColor(R.id.time, ColorHelper.getClockFontColor())
|
||||
views.setTextColor(R.id.time_am_pm, ColorHelper.getClockFontColor())
|
||||
views.setTextColor(R.id.time, ColorHelper.getClockFontColor(context.isDarkTheme()))
|
||||
views.setTextColor(R.id.time_am_pm, ColorHelper.getClockFontColor(context.isDarkTheme()))
|
||||
views.setTextViewTextSize(
|
||||
R.id.time,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
@ -537,6 +571,10 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
v.empty_layout.visibility = View.GONE
|
||||
v.calendar_layout.visibility = View.VISIBLE
|
||||
|
||||
v.second_row_top_margin_small.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_medium.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_large.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context)) {
|
||||
v.second_row_icon.isVisible = true
|
||||
var showSomething = false
|
||||
@ -615,6 +653,10 @@ class MainWidget : AppWidgetProvider() {
|
||||
v.next_event.text = DateHelper.getDateText(context, now)
|
||||
v.empty_layout.visibility = View.GONE
|
||||
v.calendar_layout.visibility = View.VISIBLE
|
||||
|
||||
v.second_row_top_margin_small.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_medium.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_large.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
} else {
|
||||
v.second_row_icon.isVisible = false
|
||||
}
|
||||
@ -623,7 +665,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
// Color
|
||||
listOf<TextView>(v.empty_date, v.divider1, v.temp, v.next_event, v.next_event_difference_time, v.divider3, v.special_temp).forEach {
|
||||
it.setTextColor(ColorHelper.getFontColor())
|
||||
it.setTextColor(ColorHelper.getFontColor(context.applicationContext.isDarkTheme()))
|
||||
}
|
||||
|
||||
if (Preferences.weatherIconPack != Constants.WeatherIconPack.MINIMAL.value) {
|
||||
@ -631,11 +673,12 @@ class MainWidget : AppWidgetProvider() {
|
||||
} else {
|
||||
listOf<ImageView>(v.action_next, v.action_previous, v.empty_weather_icon, v.special_weather_icon)
|
||||
}.forEach {
|
||||
it.setColorFilter(ColorHelper.getFontColor())
|
||||
it.setColorFilter(ColorHelper.getFontColorRgb(context.applicationContext.isDarkTheme()))
|
||||
it.alpha = (if (context.isDarkTheme()) Preferences.textGlobalAlphaDark.toIntValue().toFloat() else Preferences.textGlobalAlpha.toIntValue().toFloat()) / 100
|
||||
}
|
||||
|
||||
listOf<TextView>(v.next_event_date, v.divider2, v.calendar_temp).forEach {
|
||||
it.setTextColor(ColorHelper.getSecondaryFontColor())
|
||||
it.setTextColor(ColorHelper.getSecondaryFontColor(context.applicationContext.isDarkTheme()))
|
||||
}
|
||||
|
||||
if (Preferences.weatherIconPack != Constants.WeatherIconPack.MINIMAL.value) {
|
||||
@ -643,7 +686,8 @@ class MainWidget : AppWidgetProvider() {
|
||||
} else {
|
||||
listOf<ImageView>(v.second_row_icon, v.weather_icon)
|
||||
}.forEach {
|
||||
it.setColorFilter(ColorHelper.getSecondaryFontColor())
|
||||
it.setColorFilter(ColorHelper.getSecondaryFontColorRgb(context.applicationContext.isDarkTheme()))
|
||||
it.alpha = (if (context.isDarkTheme()) Preferences.textSecondaryAlphaDark.toIntValue().toFloat() else Preferences.textSecondaryAlpha.toIntValue().toFloat()) / 100
|
||||
}
|
||||
|
||||
// Text Size
|
||||
@ -683,19 +727,19 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
|
||||
// Shadows
|
||||
val shadowRadius = when (Preferences.textShadow) {
|
||||
val shadowRadius = when (if (context.isDarkTheme()) Preferences.textShadowDark else Preferences.textShadow) {
|
||||
0 -> 0f
|
||||
1 -> 5f
|
||||
2 -> 5f
|
||||
else -> 5f
|
||||
}
|
||||
val shadowColor = when (Preferences.textShadow) {
|
||||
val shadowColor = when (if (context.isDarkTheme()) Preferences.textShadowDark else Preferences.textShadow) {
|
||||
0 -> Color.TRANSPARENT
|
||||
1 -> R.color.black_50
|
||||
2 -> Color.BLACK
|
||||
else -> R.color.black_50
|
||||
}
|
||||
val shadowDy = when (Preferences.textShadow) {
|
||||
val shadowDy = when (if (context.isDarkTheme()) Preferences.textShadowDark else Preferences.textShadow) {
|
||||
0 -> 0f
|
||||
1 -> 0f
|
||||
2 -> 1f
|
||||
|
@ -143,11 +143,11 @@ fun Context.isTablet(): Boolean {
|
||||
}
|
||||
|
||||
fun String.md5(): String {
|
||||
val MD5 = "MD5"
|
||||
val mD5 = "MD5"
|
||||
try {
|
||||
// Create MD5 Hash
|
||||
val digest = java.security.MessageDigest
|
||||
.getInstance(MD5)
|
||||
.getInstance(mD5)
|
||||
digest.update(toByteArray())
|
||||
val messageDigest = digest.digest()
|
||||
|
||||
@ -172,7 +172,7 @@ fun String.isValidEmail(): Boolean
|
||||
= this.isNotEmpty() &&
|
||||
Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
||||
|
||||
fun Activity.isDarkTheme(): Boolean {
|
||||
fun Context.isDarkTheme(): Boolean {
|
||||
return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
||||
|
BIN
app/src/main/res/drawable-hdpi/ic_capitalize.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
app/src/main/res/drawable-hdpi/outline_info_white.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
app/src/main/res/drawable-hdpi/outline_info_white_18.png
Normal file
After Width: | Height: | Size: 449 B |
BIN
app/src/main/res/drawable-hdpi/outline_info_white_36.png
Normal file
After Width: | Height: | Size: 751 B |
BIN
app/src/main/res/drawable-hdpi/outline_info_white_48.png
Normal file
After Width: | Height: | Size: 953 B |
After Width: | Height: | Size: 241 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 384 B |
BIN
app/src/main/res/drawable-hdpi/round_style_black_18.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
app/src/main/res/drawable-hdpi/round_style_black_24.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-hdpi/round_style_black_36.png
Normal file
After Width: | Height: | Size: 601 B |
BIN
app/src/main/res/drawable-hdpi/round_style_black_48.png
Normal file
After Width: | Height: | Size: 808 B |
BIN
app/src/main/res/drawable-hdpi/round_work_outline.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
app/src/main/res/drawable-hdpi/round_work_outline_white_24.png
Normal file
After Width: | Height: | Size: 236 B |
BIN
app/src/main/res/drawable-hdpi/round_work_outline_white_36.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
app/src/main/res/drawable-hdpi/round_work_outline_white_48.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
app/src/main/res/drawable-mdpi/ic_capitalize.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
app/src/main/res/drawable-mdpi/outline_info_white.png
Normal file
After Width: | Height: | Size: 352 B |
BIN
app/src/main/res/drawable-mdpi/outline_info_white_18.png
Normal file
After Width: | Height: | Size: 306 B |
BIN
app/src/main/res/drawable-mdpi/outline_info_white_36.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
app/src/main/res/drawable-mdpi/outline_info_white_48.png
Normal file
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 270 B |
BIN
app/src/main/res/drawable-mdpi/round_style_black_18.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
app/src/main/res/drawable-mdpi/round_style_black_24.png
Normal file
After Width: | Height: | Size: 320 B |
BIN
app/src/main/res/drawable-mdpi/round_style_black_36.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-mdpi/round_style_black_48.png
Normal file
After Width: | Height: | Size: 567 B |
BIN
app/src/main/res/drawable-mdpi/round_work_outline.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
app/src/main/res/drawable-mdpi/round_work_outline_white_24.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
app/src/main/res/drawable-mdpi/round_work_outline_white_36.png
Normal file
After Width: | Height: | Size: 236 B |
BIN
app/src/main/res/drawable-mdpi/round_work_outline_white_48.png
Normal file
After Width: | Height: | Size: 255 B |
BIN
app/src/main/res/drawable-xhdpi/ic_capitalize.png
Normal file
After Width: | Height: | Size: 592 B |
BIN
app/src/main/res/drawable-xhdpi/outline_info_white.png
Normal file
After Width: | Height: | Size: 672 B |
BIN
app/src/main/res/drawable-xhdpi/outline_info_white_18.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
app/src/main/res/drawable-xhdpi/outline_info_white_36.png
Normal file
After Width: | Height: | Size: 953 B |
BIN
app/src/main/res/drawable-xhdpi/outline_info_white_48.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 270 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 507 B |
BIN
app/src/main/res/drawable-xhdpi/round_style_black_18.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-xhdpi/round_style_black_24.png
Normal file
After Width: | Height: | Size: 567 B |
BIN
app/src/main/res/drawable-xhdpi/round_style_black_36.png
Normal file
After Width: | Height: | Size: 808 B |
BIN
app/src/main/res/drawable-xhdpi/round_style_black_48.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
app/src/main/res/drawable-xhdpi/round_work_outline.png
Normal file
After Width: | Height: | Size: 236 B |
BIN
app/src/main/res/drawable-xhdpi/round_work_outline_white_24.png
Normal file
After Width: | Height: | Size: 255 B |
BIN
app/src/main/res/drawable-xhdpi/round_work_outline_white_36.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
app/src/main/res/drawable-xhdpi/round_work_outline_white_48.png
Normal file
After Width: | Height: | Size: 473 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_capitalize.png
Normal file
After Width: | Height: | Size: 773 B |
BIN
app/src/main/res/drawable-xxhdpi/outline_info_white.png
Normal file
After Width: | Height: | Size: 953 B |
BIN
app/src/main/res/drawable-xxhdpi/outline_info_white_18.png
Normal file
After Width: | Height: | Size: 751 B |
BIN
app/src/main/res/drawable-xxhdpi/outline_info_white_36.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xxhdpi/outline_info_white_48.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 623 B |
After Width: | Height: | Size: 732 B |
BIN
app/src/main/res/drawable-xxhdpi/round_style_black_18.png
Normal file
After Width: | Height: | Size: 601 B |
BIN
app/src/main/res/drawable-xxhdpi/round_style_black_24.png
Normal file
After Width: | Height: | Size: 808 B |
BIN
app/src/main/res/drawable-xxhdpi/round_style_black_36.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_style_black_48.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_work_outline.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
app/src/main/res/drawable-xxhdpi/round_work_outline_white_24.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
app/src/main/res/drawable-xxhdpi/round_work_outline_white_36.png
Normal file
After Width: | Height: | Size: 547 B |
BIN
app/src/main/res/drawable-xxhdpi/round_work_outline_white_48.png
Normal file
After Width: | Height: | Size: 682 B |