Compare commits
5 Commits
v2.0.5-bet
...
v2.0.5-bet
Author | SHA1 | Date | |
---|---|---|---|
f5c4ee7eb0 | |||
4feb72381d | |||
bea0803c3a | |||
dd450443c8 | |||
6279846cea |
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/tasksintegration/build
|
BIN
.idea/caches/build_file_checksums.ser
generated
@ -18,7 +18,7 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 59
|
||||
versionCode 65
|
||||
versionName "2.0.5"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@ -59,15 +59,14 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
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'
|
||||
|
||||
// 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.browser:browser:1.2.0'
|
||||
implementation 'net.idik:slimadapter:2.1.2'
|
||||
@ -78,6 +77,8 @@ 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"
|
||||
|
||||
// EventBus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
||||
@ -89,6 +90,8 @@ dependencies {
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
implementation 'me.everything:providers-android:1.0.1'
|
||||
|
||||
//Glide
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
@ -104,6 +107,7 @@ dependencies {
|
||||
implementation "androidx.core:core-ktx:1.2.0"
|
||||
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'
|
||||
|
||||
// Recommended: Add the Firebase SDK for Google Analytics.
|
||||
implementation 'com.google.firebase:firebase-analytics:17.4.0'
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.tommasoberlose.anotherwidget">
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
@ -16,19 +18,20 @@
|
||||
android:name=".AWApplication"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".ui.activities.MainActivity" android:launchMode="singleInstance" android:theme="@style/AppTheme.Main">
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="LockedOrientationActivity">
|
||||
<activity android:name=".ui.activities.MainActivity" android:launchMode="singleInstance" android:theme="@style/AppTheme.Main" android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".ui.activities.ChooseApplicationActivity" android:launchMode="singleInstance" />
|
||||
<activity android:name=".ui.activities.CustomLocationActivity" android:launchMode="singleInstance" />
|
||||
<activity android:name=".ui.activities.WeatherProviderActivity" android:launchMode="singleInstance" />
|
||||
<activity android:name=".ui.activities.SupportDevActivity" android:launchMode="singleInstance" />
|
||||
<activity android:name=".ui.activities.CustomDateActivity" android:launchMode="singleInstance" />
|
||||
<activity android:name=".ui.activities.ChooseApplicationActivity" android:launchMode="singleInstance" android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.activities.CustomLocationActivity" android:launchMode="singleInstance" android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.activities.WeatherProviderActivity" android:launchMode="singleInstance" android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.activities.SupportDevActivity" android:launchMode="singleInstance" android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.activities.CustomDateActivity" android:launchMode="singleInstance" android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<receiver android:name=".ui.widgets.MainWidget">
|
||||
@ -67,6 +70,8 @@
|
||||
<action android:name="android.app.action.NEXT_ALARM_CLOCK_CHANGED" />
|
||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
@ -79,6 +84,8 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.tommasoberlose.anotherwidget.db
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.chibatching.kotpref.bulk
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.UpdatesWorker
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmResults
|
||||
@ -33,13 +35,10 @@ class EventRepository(val context: Context) {
|
||||
remove(Preferences::nextEventEndDate)
|
||||
remove(Preferences::nextEventCalendarId)
|
||||
}
|
||||
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
|
||||
fun saveNextEventData(event: Event) {
|
||||
Preferences.nextEventId = event.id
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
|
||||
fun getNextEvent(): Event? = realm.where(Event::class.java).equalTo("id", Preferences.nextEventId).findFirst() ?: realm.where(Event::class.java).findFirst()
|
||||
@ -57,7 +56,7 @@ class EventRepository(val context: Context) {
|
||||
} else {
|
||||
resetNextEventData()
|
||||
}
|
||||
UpdatesReceiver.setUpdates(context)
|
||||
UpdatesWorker.setUpdates(context)
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ class EventRepository(val context: Context) {
|
||||
} else {
|
||||
resetNextEventData()
|
||||
}
|
||||
UpdatesReceiver.setUpdates(context)
|
||||
UpdatesWorker.setUpdates(context)
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,14 @@ object Preferences : KotprefModel() {
|
||||
var darkThemePreference by intPref(default = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) MODE_NIGHT_FOLLOW_SYSTEM else MODE_NIGHT_AUTO_BATTERY)
|
||||
|
||||
var showEvents by booleanPref(key = "PREF_SHOW_EVENTS", default = false)
|
||||
var showWeather by booleanPref(key = "PREF_SHOW_WEATHER")
|
||||
var weatherIcon by stringPref(key = "PREF_WEATHER_ICON")
|
||||
var weatherTemp by floatPref(key = "PREF_WEATHER_TEMP")
|
||||
var showWeather by booleanPref(key = "PREF_SHOW_WEATHER", default = false)
|
||||
var weatherIcon by stringPref(key = "PREF_WEATHER_ICON", default = "")
|
||||
var weatherTemp by floatPref(key = "PREF_WEATHER_TEMP", default = 0f)
|
||||
var weatherTempUnit by stringPref(key = "PREF_WEATHER_TEMP_UNIT", default = "F")
|
||||
var weatherRealTempUnit by stringPref(key = "PREF_WEATHER_REAL_TEMP_UNIT", default = "F")
|
||||
var calendarAllDay by booleanPref(key = "PREF_CALENDAR_ALL_DAY", default = false)
|
||||
var calendarAllDay by booleanPref(key = "PREF_CALENDAR_ALL_DAY", default = true)
|
||||
var calendarFilter by stringPref(key = "PREF_CALENDAR_FILTER", default = "")
|
||||
|
||||
var eventId by intPref(key = "PREF_EVENT_ID", default = -1)
|
||||
var nextEventId by longPref(key = "PREF_NEXT_EVENT_ID", default = -1)
|
||||
var nextEventName by stringPref(key = "PREF_NEXT_EVENT_NAME")
|
||||
var nextEventStartDate by longPref(key = "PREF_NEXT_EVENT_START_DATE")
|
||||
@ -29,7 +28,6 @@ object Preferences : KotprefModel() {
|
||||
var customLocationLat by stringPref(key = "PREF_CUSTOM_LOCATION_LAT", default = "")
|
||||
var customLocationLon by stringPref(key = "PREF_CUSTOM_LOCATION_LON", default = "")
|
||||
var customLocationAdd by stringPref(key = "PREF_CUSTOM_LOCATION_ADD", default = "")
|
||||
var hourFormat by stringPref(key = "PREF_HOUR_FORMAT", default = "12")
|
||||
var dateFormat by stringPref(default = "")
|
||||
var weatherRefreshPeriod by intPref(key = "PREF_WEATHER_REFRESH_PERIOD", default = 1)
|
||||
var showUntil by intPref(key = "PREF_SHOW_UNTIL", default = 1)
|
||||
@ -40,7 +38,7 @@ object Preferences : KotprefModel() {
|
||||
var weatherProviderApi by stringPref(key = "PREF_WEATHER_PROVIDER_API_KEY", default = "")
|
||||
var eventAppName by stringPref(key = "PREF_EVENT_APP_NAME", default = "")
|
||||
var eventAppPackage by stringPref(key = "PREF_EVENT_APP_PACKAGE", default = "")
|
||||
var showEventLocation by stringPref(key = "PREF_SHOW_EVENT_LOCATION", default = "")
|
||||
var openEventDetails by booleanPref(default = true)
|
||||
var textGlobalColor by stringPref(key = "PREF_TEXT_COLOR", default = "#FFFFFF")
|
||||
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
||||
@ -49,20 +47,16 @@ object Preferences : KotprefModel() {
|
||||
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 showNextAlarm by booleanPref(default = true)
|
||||
var showNextAlarm by booleanPref(default = false)
|
||||
var textShadow by intPref(key = "PREF_TEXT_SHADOW", default = 1)
|
||||
var showDiffTime by booleanPref(key = "PREF_SHOW_DIFF_TIME")
|
||||
var showDeclinedEvents by booleanPref(key = "PREF_SHOW_DECLINED_EVENTS", default = true)
|
||||
var openWeatherApiKey by stringPref(key = "PREF_OPEN_WEATHER_API_KEY", default = "")
|
||||
var darkSkyApiKey by stringPref(key = "PREF_DARK_SKY_API_KEY", default = "")
|
||||
var wuApiKey by stringPref(key = "PREF_WU_API_KEY", default = "")
|
||||
var secondRowInformation by intPref(key = "PREF_SECOND_ROW_INFORMATION", 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 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")
|
||||
var showNextEvent by booleanPref(key = "PREF_SHOW_NEXT_EVENT", default = true)
|
||||
var showGpsInformation by booleanPref(key = "PREF_SHOW_GPS_NOTIFICATION", default = true)
|
||||
|
||||
var showWallpaper by booleanPref(default = false)
|
||||
var showWallpaper by booleanPref(default = true)
|
||||
var showBigClockWarning by booleanPref(default = true)
|
||||
var showWeatherWarning by booleanPref(default = true)
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ object AlarmHelper {
|
||||
val alarm = nextAlarmClock
|
||||
return if (
|
||||
alarm != null
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis > 2 * 60 * 1000
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis > 10 * 60 * 1000
|
||||
&& alarm.triggerTime - Calendar.getInstance().timeInMillis < 12 * 60 * 60 * 1000
|
||||
) {
|
||||
"%s %s".format(
|
||||
|
@ -7,6 +7,7 @@ import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.drawToBitmap
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import java.lang.Exception
|
||||
|
||||
@ -19,10 +20,11 @@ object BitmapHelper {
|
||||
view.measure(measuredWidth, measuredHeight)
|
||||
|
||||
return try {
|
||||
Log.d("ciao", "bitmap ${view.measuredWidth}, ${view.measuredHeight} - draw = ${draw}")
|
||||
val btm = Bitmap.createBitmap(
|
||||
view.measuredWidth,
|
||||
view.measuredHeight,
|
||||
Bitmap.Config.ARGB_8888
|
||||
if (draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
|
||||
)
|
||||
if (draw) {
|
||||
//Bind a canvas to it
|
||||
@ -35,7 +37,7 @@ object BitmapHelper {
|
||||
btm
|
||||
} catch (ex: Exception) {
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
Bitmap.createBitmap(5, 5, Bitmap.Config.ARGB_8888)
|
||||
Bitmap.createBitmap(5, 5, Bitmap.Config.ALPHA_8)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.UpdatesWorker
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
@ -124,7 +125,8 @@ object CalendarHelper {
|
||||
eventRepository.resetNextEventData()
|
||||
}
|
||||
|
||||
UpdatesReceiver.setUpdates(context)
|
||||
UpdatesWorker.setUpdates(context)
|
||||
Log.d("ciao", "force update? 7")
|
||||
MainWidget.updateWidget(context)
|
||||
|
||||
EventBus.getDefault().post(MainActivity.UpdateUiMessageEvent())
|
||||
|
@ -30,35 +30,6 @@ object IntentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun getCalendarIntent(context: Context): Intent {
|
||||
return when (Preferences.calendarAppPackage) {
|
||||
"" -> {
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
}
|
||||
}
|
||||
"_" -> {
|
||||
Intent()
|
||||
}
|
||||
else -> {
|
||||
val pm: PackageManager = context.packageManager
|
||||
try {
|
||||
pm.getLaunchIntentForPackage(Preferences.calendarAppPackage)!!.apply {
|
||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getWeatherIntent(context: Context): Intent {
|
||||
return when (Preferences.weatherAppPackage) {
|
||||
"" -> {
|
||||
@ -91,15 +62,12 @@ object IntentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun getEventIntent(context: Context, e: Event): Intent {
|
||||
return when (Preferences.eventAppPackage) {
|
||||
fun getCalendarIntent(context: Context): Intent {
|
||||
return when (Preferences.calendarAppPackage) {
|
||||
"" -> {
|
||||
val uri = ContentUris.withAppendedId(Events.CONTENT_URI, e.eventID)
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
data = uri
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
}
|
||||
}
|
||||
"_" -> {
|
||||
@ -107,26 +75,47 @@ object IntentHelper {
|
||||
}
|
||||
else -> {
|
||||
val pm: PackageManager = context.packageManager
|
||||
val uri = ContentUris.withAppendedId(Events.CONTENT_URI, e.eventID)
|
||||
try {
|
||||
pm.getLaunchIntentForPackage(Preferences.eventAppPackage)!!.apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
data = uri
|
||||
pm.getLaunchIntentForPackage(Preferences.calendarAppPackage)!!.apply {
|
||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
// addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
// putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate)
|
||||
// putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getEventIntent(context: Context, e: Event, forceEventDetails: Boolean = false): Intent {
|
||||
return when (Preferences.openEventDetails || forceEventDetails) {
|
||||
true -> {
|
||||
val uri = ContentUris.withAppendedId(Events.CONTENT_URI, e.eventID)
|
||||
|
||||
if (Preferences.calendarAppPackage == "") {
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
data = uri
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate)
|
||||
}
|
||||
} else {
|
||||
getCalendarIntent(context).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
data = uri
|
||||
putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
false -> {
|
||||
getCalendarIntent(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getClockIntent(context: Context): Intent {
|
||||
|
@ -2,6 +2,8 @@ package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
||||
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
||||
@ -24,7 +26,7 @@ object WeatherHelper {
|
||||
val networkApi = WeatherNetworkApi(context)
|
||||
if (Preferences.customLocationAdd != "") {
|
||||
networkApi.updateWeather()
|
||||
} else if (context.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
} else if (context.checkGrantedPermission(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
LocationServices.getFusedLocationProviderClient(context).lastLocation.addOnCompleteListener { task ->
|
||||
if (task.isSuccessful) {
|
||||
val location = task.result
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
|
||||
object WidgetHelper {
|
||||
class WidgetSizeProvider(
|
||||
private val context: Context,
|
||||
private val appWidgetManager: AppWidgetManager
|
||||
) {
|
||||
|
||||
fun getWidgetsSize(widgetId: Int): Pair<Int, Int> {
|
||||
val isPortrait = context.resources.configuration.orientation == ORIENTATION_PORTRAIT
|
||||
val width = getWidgetWidth(isPortrait, widgetId)
|
||||
val height = getWidgetHeight(isPortrait, widgetId)
|
||||
val widthInPx = context.dip(width)
|
||||
val heightInPx = context.dip(height)
|
||||
return widthInPx to heightInPx
|
||||
}
|
||||
|
||||
private fun getWidgetWidth(isPortrait: Boolean, widgetId: Int): Int =
|
||||
if (isPortrait) {
|
||||
getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
|
||||
} else {
|
||||
getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
|
||||
}
|
||||
|
||||
private fun getWidgetHeight(isPortrait: Boolean, widgetId: Int): Int =
|
||||
if (isPortrait) {
|
||||
getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
|
||||
} else {
|
||||
getWidgetSizeInDp(widgetId, AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
|
||||
}
|
||||
|
||||
private fun getWidgetSizeInDp(widgetId: Int, key: String): Int =
|
||||
appWidgetManager.getAppWidgetOptions(widgetId).getInt(key, 0)
|
||||
|
||||
private fun Context.dip(value: Int): Int = (value * resources.displayMetrics.density).toInt()
|
||||
|
||||
}
|
||||
|
||||
fun Pair<Int, Int>.reduceDimensionWithMaxWidth(width: Int): Pair<Int, Int> {
|
||||
return if (first < width) {
|
||||
this
|
||||
} else {
|
||||
val factor = width / first
|
||||
width to second * factor
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.tommasoberlose.anotherwidget.network
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
||||
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
||||
import com.kwabenaberko.openweathermaplib.implementation.callbacks.CurrentWeatherCallback
|
||||
@ -23,9 +24,7 @@ class WeatherNetworkApi(val context: Context) {
|
||||
Preferences.weatherTemp = currentWeather.main.temp.toFloat()
|
||||
Preferences.weatherIcon = currentWeather.weather[0].icon
|
||||
Preferences.weatherRealTempUnit = Preferences.weatherTempUnit
|
||||
MainWidget.updateWidget(
|
||||
context
|
||||
)
|
||||
MainWidget.updateWidget(context)
|
||||
|
||||
EventBus.getDefault().post(MainActivity.UpdateUiMessageEvent())
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ class NewCalendarEventReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val eventRepository = EventRepository(context)
|
||||
Log.d("ciao", "nuovo evento")
|
||||
when (intent.action) {
|
||||
Intent.ACTION_PROVIDER_CHANGED,
|
||||
Intent.ACTION_TIME_CHANGED -> {
|
||||
|
@ -21,45 +21,17 @@ class UpdatesReceiver : BroadcastReceiver() {
|
||||
when (intent.action) {
|
||||
Intent.ACTION_BOOT_COMPLETED,
|
||||
Intent.ACTION_MY_PACKAGE_REPLACED,
|
||||
Intent.ACTION_TIME_CHANGED,
|
||||
Intent.ACTION_TIMEZONE_CHANGED,
|
||||
Intent.ACTION_LOCALE_CHANGED,
|
||||
Actions.ACTION_CALENDAR_UPDATE -> CalendarHelper.updateEventList(context)
|
||||
|
||||
"com.sec.android.widgetapp.APPWIDGET_RESIZE",
|
||||
Intent.ACTION_DATE_CHANGED,
|
||||
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED -> MainWidget.updateWidget(context)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun setUpdates(context: Context) {
|
||||
removeUpdates(context)
|
||||
|
||||
val eventRepository = EventRepository(context)
|
||||
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||
eventRepository.getEvents().forEach { event ->
|
||||
val hoursDiff = Period(Calendar.getInstance().timeInMillis, event.startDate).hours
|
||||
|
||||
// Update the widget every hour till the event
|
||||
(0 .. hoursDiff).forEach {
|
||||
setExact(
|
||||
AlarmManager.RTC_WAKEUP,
|
||||
(event.startDate + 1000) - it * 1000 * 60* 60,
|
||||
PendingIntent.getBroadcast(context, 0, Intent(context, UpdatesReceiver::class.java).apply { action = Actions.ACTION_TIME_UPDATE }, 0)
|
||||
)
|
||||
}
|
||||
|
||||
// Update the widget one second after the event is finished
|
||||
setExact(
|
||||
AlarmManager.RTC_WAKEUP,
|
||||
event.endDate + 1000,
|
||||
PendingIntent.getBroadcast(context, 0, Intent(context, UpdatesReceiver::class.java).apply { action = Actions.ACTION_TIME_UPDATE }, 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun removeUpdates(context: Context) {
|
||||
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||
cancel(PendingIntent.getBroadcast(context, 0, Intent(context, UpdatesReceiver::class.java), 0))
|
||||
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED,
|
||||
Actions.ACTION_TIME_UPDATE -> {
|
||||
Log.d("ciao", "force update? 4 - ${intent.action}")
|
||||
MainWidget.updateWidget(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import android.content.Intent
|
||||
import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
||||
import com.tommasoberlose.anotherwidget.services.WeatherWorker
|
||||
import java.util.*
|
||||
|
||||
|
||||
@ -17,68 +18,9 @@ class WeatherReceiver : BroadcastReceiver() {
|
||||
when (intent.action) {
|
||||
Intent.ACTION_BOOT_COMPLETED,
|
||||
Intent.ACTION_MY_PACKAGE_REPLACED,
|
||||
Intent.ACTION_TIME_CHANGED -> setUpdates(context)
|
||||
|
||||
Actions.ACTION_WEATHER_UPDATE -> WeatherHelper.updateWeather(context)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun setUpdates(context: Context) {
|
||||
removeUpdates(context)
|
||||
|
||||
if (Preferences.showWeather && Preferences.weatherProviderApi != "") {
|
||||
WeatherHelper.updateWeather(context)
|
||||
|
||||
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||
val pi = PendingIntent.getBroadcast(
|
||||
context,
|
||||
1,
|
||||
Intent(context, WeatherReceiver::class.java).apply {
|
||||
action = Actions.ACTION_WEATHER_UPDATE
|
||||
},
|
||||
0
|
||||
)
|
||||
|
||||
val refresh: Long = when (Preferences.weatherRefreshPeriod) {
|
||||
0 -> 30
|
||||
1 -> 60
|
||||
2 -> 60 * 3
|
||||
3 -> 60 * 6
|
||||
4 -> 60 * 12
|
||||
5 -> 60 * 24
|
||||
else -> 60
|
||||
}
|
||||
val now = Calendar.getInstance().apply {
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
set(Calendar.SECOND, 0)
|
||||
}
|
||||
|
||||
setRepeating(AlarmManager.RTC_WAKEUP, now.timeInMillis, 1000 * 60 * refresh, pi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setOneTimeUpdate(context: Context) {
|
||||
// Update the weather in a few minuter when the api key has been changed
|
||||
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||
val pi = PendingIntent.getBroadcast(context, 1, Intent(context, WeatherReceiver::class.java).apply { action = Actions.ACTION_WEATHER_UPDATE }, 0)
|
||||
val now = Calendar.getInstance().apply {
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
set(Calendar.SECOND, 0)
|
||||
}
|
||||
|
||||
listOf(10, 15, 20).forEach {
|
||||
setExact(AlarmManager.RTC_WAKEUP, now.timeInMillis + 1000 * 60 * it, pi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun removeUpdates(context: Context) {
|
||||
val intent = Intent(context, WeatherReceiver::class.java)
|
||||
val sender = PendingIntent.getBroadcast(context, 1, intent, 0)
|
||||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
alarmManager.cancel(sender)
|
||||
Intent.ACTION_TIMEZONE_CHANGED,
|
||||
Intent.ACTION_LOCALE_CHANGED,
|
||||
Intent.ACTION_TIME_CHANGED -> WeatherWorker.setUpdates(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.tommasoberlose.anotherwidget.services
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import org.joda.time.Period
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
class UpdatesWorker(appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
|
||||
override fun doWork(): Result {
|
||||
CalendarHelper.updateEventList(applicationContext)
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val JOB_TAG = "UPDATES_WORKER"
|
||||
|
||||
fun setUpdates(context: Context) {
|
||||
removeUpdates(context)
|
||||
val now = Calendar.getInstance().timeInMillis
|
||||
val workManager = WorkManager.getInstance(context)
|
||||
val eventRepository = EventRepository(context)
|
||||
eventRepository.getEvents().forEach { event ->
|
||||
val hoursDiff = Period(Calendar.getInstance().timeInMillis, event.startDate).hours
|
||||
|
||||
// Update the widget every hour till the event
|
||||
(0 .. hoursDiff).forEach {
|
||||
workManager.enqueue(OneTimeWorkRequestBuilder<UpdatesWorker>().setInitialDelay((event.startDate + 1000) - now - it * 1000 * 60* 60, TimeUnit.MILLISECONDS).build())
|
||||
}
|
||||
|
||||
// Update the widget one second after the event is finished
|
||||
workManager.enqueue(OneTimeWorkRequestBuilder<UpdatesWorker>().setInitialDelay(event.endDate + 1000 - now, TimeUnit.MILLISECONDS).build())
|
||||
}
|
||||
}
|
||||
|
||||
fun removeUpdates(context: Context) {
|
||||
WorkManager.getInstance(context).cancelAllWorkByTag(JOB_TAG)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.tommasoberlose.anotherwidget.services
|
||||
|
||||
import android.app.AlarmManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.work.*
|
||||
import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
|
||||
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
class WeatherWorker(appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
|
||||
override fun doWork(): Result {
|
||||
WeatherHelper.updateWeather(applicationContext)
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val JOB_TAG = "WEATHER_WORKER"
|
||||
|
||||
fun setUpdates(context: Context) {
|
||||
removeUpdates(context)
|
||||
|
||||
if (Preferences.showWeather && Preferences.weatherProviderApi != "") {
|
||||
WeatherHelper.updateWeather(context)
|
||||
|
||||
WorkManager.getInstance(context).enqueue(PeriodicWorkRequestBuilder<WeatherWorker>(
|
||||
when (Preferences.weatherRefreshPeriod) {
|
||||
0 -> 30
|
||||
1 -> 60
|
||||
2 -> 60L * 3
|
||||
3 -> 60L * 6
|
||||
4 -> 60L * 12
|
||||
5 -> 60L * 24
|
||||
else -> 60
|
||||
}
|
||||
, TimeUnit.MINUTES)
|
||||
.addTag(JOB_TAG)
|
||||
.build())
|
||||
}
|
||||
}
|
||||
|
||||
fun setOneTimeUpdate(context: Context) {
|
||||
val workManager = WorkManager.getInstance(context)
|
||||
listOf(10L, 15L, 20L).forEach {
|
||||
workManager.enqueue(OneTimeWorkRequestBuilder<WeatherWorker>().setInitialDelay(it, TimeUnit.MINUTES).addTag(JOB_TAG).build())
|
||||
}
|
||||
}
|
||||
|
||||
fun removeUpdates(context: Context) {
|
||||
WorkManager.getInstance(context).cancelAllWorkByTag(JOB_TAG)
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.location.Address
|
||||
import android.location.Geocoder
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import android.text.Editable
|
||||
@ -125,7 +126,7 @@ class CustomLocationActivity : AppCompatActivity() {
|
||||
private fun requirePermission() {
|
||||
Dexter.withContext(this)
|
||||
.withPermissions(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION
|
||||
).withListener(object: MultiplePermissionsListener {
|
||||
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
|
||||
report?.let {
|
||||
|
@ -5,6 +5,7 @@ import android.app.Activity
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
@ -34,13 +35,11 @@ import com.tommasoberlose.anotherwidget.utils.getCurrentWallpaper
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.the_widget_sans.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.lang.Exception
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
@ -83,7 +82,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||
subscribeUi(viewModel)
|
||||
updateUI()
|
||||
|
||||
CalendarHelper.updateEventList(this)
|
||||
WeatherHelper.updateWeather(this)
|
||||
}
|
||||
|
||||
@ -91,12 +89,21 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||
|
||||
private fun updateUI() {
|
||||
preview.setCardBackgroundColor(getColor(if (ColorHelper.getFontColor().isColorDark()) android.R.color.white else R.color.colorAccent))
|
||||
val generatedView = MainWidget.generateWidgetView(this@MainActivity)
|
||||
generatedView.measure(0, 0)
|
||||
preview.measure(0, 0)
|
||||
|
||||
uiJob?.cancel()
|
||||
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||
delay(200)
|
||||
val generatedView = MainWidget.generateWidgetView(this@MainActivity)
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
generatedView.measure(0, 0)
|
||||
preview.measure(0, 0)
|
||||
try {
|
||||
// Try to recycle old bitmaps
|
||||
(bitmap_container.drawable as BitmapDrawable).bitmap.recycle()
|
||||
} catch (ignore: Exception) {}
|
||||
}
|
||||
|
||||
val bitmap = BitmapHelper.getBitmapFromView(generatedView, if (preview.width > 0) preview.width else generatedView.measuredWidth, generatedView.measuredHeight)
|
||||
withContext(Dispatchers.Main) {
|
||||
// Clock
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -69,7 +70,8 @@ class AdvancedSettingsFragment : Fragment() {
|
||||
|
||||
setupListener()
|
||||
|
||||
app_version.text = "v%s".format(BuildConfig.VERSION_NAME)
|
||||
app_version.text = "v%s (%s)".format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
|
||||
requirePermission()
|
||||
}
|
||||
|
||||
private fun subscribeUi(
|
||||
@ -117,7 +119,7 @@ class AdvancedSettingsFragment : Fragment() {
|
||||
action_show_wallpaper.setOnClickListener {
|
||||
maintainScrollPosition {
|
||||
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_title_show_wallpaper))
|
||||
.setSelectedValue(Preferences.showWallpaper)
|
||||
.setSelectedValue(Preferences.showWallpaper && activity?.checkGrantedPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == true)
|
||||
.addItem(
|
||||
getString(R.string.settings_visible),
|
||||
true
|
||||
@ -174,6 +176,7 @@ class AdvancedSettingsFragment : Fragment() {
|
||||
).withListener(object: MultiplePermissionsListener {
|
||||
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
|
||||
report?.let {
|
||||
Preferences.showWallpaper = false
|
||||
Preferences.showWallpaper = report.areAllPermissionsGranted()
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ class CalendarSettingsFragment : Fragment() {
|
||||
binding.isCalendarEnabled = it
|
||||
|
||||
if (it) {
|
||||
requirePermission()
|
||||
CalendarHelper.setEventUpdatesAndroidN(requireContext())
|
||||
} else {
|
||||
CalendarHelper.removeEventUpdatesAndroidN(requireContext())
|
||||
@ -147,9 +148,9 @@ class CalendarSettingsFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.eventAppName.observe(viewLifecycleOwner, Observer {
|
||||
viewModel.openEventDetails.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
event_app_label.text = if (it != "") it else getString(R.string.default_calendar_app)
|
||||
open_event_details_label.text = if (it) getString(R.string.default_event_app) else getString(R.string.default_calendar_app)
|
||||
}
|
||||
})
|
||||
|
||||
@ -301,8 +302,15 @@ class CalendarSettingsFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
action_event_app.setOnClickListener {
|
||||
startActivityForResult(Intent(requireContext(), ChooseApplicationActivity::class.java), RequestCode.EVENT_APP_REQUEST_CODE.code)
|
||||
action_open_event_details.setOnClickListener {
|
||||
if (Preferences.showEvents) {
|
||||
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_event_app_title)).setSelectedValue(Preferences.openEventDetails)
|
||||
.addItem(getString(R.string.default_event_app), true)
|
||||
.addItem(getString(R.string.default_calendar_app), false)
|
||||
.addOnSelectItemListener { value ->
|
||||
Preferences.openEventDetails = value
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
action_calendar_app.setOnClickListener {
|
||||
|
@ -3,8 +3,8 @@ package com.tommasoberlose.anotherwidget.ui.fragments
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -28,6 +28,7 @@ import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.global.RequestCode
|
||||
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.WeatherWorker
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.CustomLocationActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
@ -115,6 +116,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
temp_unit.text =
|
||||
if (it == "F") getString(R.string.fahrenheit) else getString(R.string.celsius)
|
||||
}
|
||||
checkLocationPermission()
|
||||
})
|
||||
|
||||
viewModel.weatherRefreshPeriod.observe(viewLifecycleOwner, Observer {
|
||||
@ -133,9 +135,9 @@ class WeatherSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkLocationPermission() {
|
||||
if (activity?.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION) == true) {
|
||||
if (activity?.checkGrantedPermission(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION) == true) {
|
||||
location_permission_alert_icon.isVisible = false
|
||||
WeatherReceiver.setUpdates(requireContext())
|
||||
WeatherWorker.setUpdates(requireContext())
|
||||
} else if (Preferences.showWeather && Preferences.customLocationAdd == "") {
|
||||
location_permission_alert_icon.isVisible = true
|
||||
location_permission_alert_icon.setOnClickListener {
|
||||
@ -210,7 +212,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
when (requestCode) {
|
||||
Constants.RESULT_CODE_CUSTOM_LOCATION -> {
|
||||
WeatherReceiver.setUpdates(requireContext())
|
||||
WeatherWorker.setUpdates(requireContext())
|
||||
checkLocationPermission()
|
||||
}
|
||||
RequestCode.WEATHER_APP_REQUEST_CODE.code -> {
|
||||
@ -221,7 +223,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
MainWidget.updateWidget(requireContext())
|
||||
}
|
||||
RequestCode.WEATHER_PROVIDER_REQUEST_CODE.code -> {
|
||||
WeatherReceiver.setOneTimeUpdate(requireContext())
|
||||
WeatherWorker.setOneTimeUpdate(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,7 +233,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
private fun requirePermission() {
|
||||
Dexter.withContext(requireContext())
|
||||
.withPermissions(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION
|
||||
).withListener(object: MultiplePermissionsListener {
|
||||
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
|
||||
report?.let {
|
||||
|
@ -21,10 +21,9 @@ class MainViewModel : ViewModel() {
|
||||
val showDiffTime = Preferences.asLiveData(Preferences::showDiffTime)
|
||||
val showDeclinedEvents = Preferences.asLiveData(Preferences::showDeclinedEvents)
|
||||
val showNextEvent = Preferences.asLiveData(Preferences::showNextEvent)
|
||||
|
||||
val openEventDetails = Preferences.asLiveData(Preferences::openEventDetails)
|
||||
val calendarAppName = Preferences.asLiveData(Preferences::calendarAppName)
|
||||
|
||||
val eventAppName = Preferences.asLiveData(Preferences::eventAppName)
|
||||
|
||||
// Clock Settings
|
||||
val showClock = Preferences.asLiveData(Preferences::showClock)
|
||||
|
@ -20,21 +20,25 @@ import android.widget.RemoteViews
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
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.WidgetHelper.reduceDimensionWithMaxWidth
|
||||
import com.tommasoberlose.anotherwidget.receivers.NewCalendarEventReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.WidgetClickListenerReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.UpdatesWorker
|
||||
import com.tommasoberlose.anotherwidget.services.WeatherWorker
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.convertSpToPixels
|
||||
import com.tommasoberlose.anotherwidget.utils.getCapWordString
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
import kotlinx.android.synthetic.main.the_widget.view.*
|
||||
import java.lang.Exception
|
||||
import java.text.DateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
@ -55,7 +59,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
CalendarHelper.updateEventList(context)
|
||||
WeatherReceiver.setUpdates(context)
|
||||
WeatherWorker.setUpdates(context)
|
||||
|
||||
if (Preferences.showEvents) {
|
||||
CalendarHelper.setEventUpdatesAndroidN(context)
|
||||
@ -65,8 +69,10 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context) {
|
||||
UpdatesReceiver.removeUpdates(context)
|
||||
WeatherReceiver.removeUpdates(context)
|
||||
if (getWidgetCount(context) == 0) {
|
||||
UpdatesWorker.removeUpdates(context)
|
||||
WeatherWorker.removeUpdates(context)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -81,26 +87,26 @@ class MainWidget : AppWidgetProvider() {
|
||||
context.sendBroadcast(update)
|
||||
}
|
||||
|
||||
fun getWidgetCount(context: Context): Int {
|
||||
val widgetManager = AppWidgetManager.getInstance(context)
|
||||
val widgetComponent = ComponentName(context, MainWidget::class.java)
|
||||
return widgetManager.getAppWidgetIds(widgetComponent).size
|
||||
}
|
||||
|
||||
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager,
|
||||
appWidgetId: Int) {
|
||||
val displayMetrics = Resources.getSystem().displayMetrics
|
||||
var height = 110.toPixel(context)
|
||||
val width = displayMetrics.widthPixels
|
||||
if (Preferences.showClock) {
|
||||
height += Preferences.clockTextSize.convertSpToPixels(context).toInt() + 16.toPixel(context)
|
||||
}
|
||||
if (Preferences.textMainSize > 30 && Preferences.textSecondSize > 22) {
|
||||
height += 24.toPixel(context)
|
||||
}
|
||||
|
||||
generateWidgetView(context, appWidgetId, appWidgetManager, width - 16.toPixel(context))
|
||||
val dimensions = WidgetHelper.WidgetSizeProvider(context, appWidgetManager).getWidgetsSize(appWidgetId).reduceDimensionWithMaxWidth(1200)
|
||||
generateWidgetView(context, appWidgetId, appWidgetManager, dimensions.first - 8.toPixel(context) /*width - 16.toPixel(context)*/)
|
||||
}
|
||||
|
||||
private fun generateWidgetView(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager, w: Int) {
|
||||
var views = RemoteViews(context.packageName, R.layout.the_widget_sans)
|
||||
|
||||
val generatedView = generateWidgetView(context)
|
||||
views.setImageViewBitmap(R.id.bitmap_container, BitmapHelper.getBitmapFromView(generatedView, width = w - 32.toPixel(context)))
|
||||
views.setImageViewBitmap(R.id.bitmap_container, BitmapHelper.getBitmapFromView(generatedView, width = w))
|
||||
|
||||
// Clock
|
||||
views = updateClockView(context, views, appWidgetId)
|
||||
@ -113,15 +119,24 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
private fun updateCalendarView(context: Context, v: View, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
try {
|
||||
val eventRepository = EventRepository(context)
|
||||
|
||||
views.setImageViewBitmap(R.id.empty_date_rect, BitmapHelper.getBitmapFromView(v.empty_date, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.empty_date_rect,
|
||||
BitmapHelper.getBitmapFromView(v.empty_date, draw = false)
|
||||
)
|
||||
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.second_row_rect, View.GONE)
|
||||
|
||||
val calPIntent = PendingIntent.getActivity(context, widgetID, IntentHelper.getCalendarIntent(context), 0)
|
||||
val calPIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getCalendarIntent(context),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.empty_date_rect, calPIntent)
|
||||
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
@ -129,61 +144,135 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
if (Preferences.showEvents && context.checkGrantedPermission(Manifest.permission.READ_CALENDAR) && nextEvent != null) {
|
||||
if (Preferences.showNextEvent && eventRepository.getEventsCount() > 1) {
|
||||
views.setImageViewBitmap(R.id.action_next_rect, BitmapHelper.getBitmapFromView(v.action_next, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.action_next_rect,
|
||||
BitmapHelper.getBitmapFromView(v.action_next, draw = false)
|
||||
)
|
||||
views.setViewVisibility(R.id.action_next_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.action_next_rect, PendingIntent.getBroadcast(context, widgetID, Intent(context, NewCalendarEventReceiver::class.java).apply { action = Actions.ACTION_GO_TO_NEXT_EVENT }, 0))
|
||||
views.setOnClickPendingIntent(
|
||||
R.id.action_next_rect,
|
||||
PendingIntent.getBroadcast(
|
||||
context,
|
||||
widgetID,
|
||||
Intent(
|
||||
context,
|
||||
NewCalendarEventReceiver::class.java
|
||||
).apply { action = Actions.ACTION_GO_TO_NEXT_EVENT },
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
views.setImageViewBitmap(R.id.action_previous_rect, BitmapHelper.getBitmapFromView(v.action_previous, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.action_previous_rect,
|
||||
BitmapHelper.getBitmapFromView(v.action_previous, draw = false)
|
||||
)
|
||||
views.setViewVisibility(R.id.action_previous_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.action_previous_rect, PendingIntent.getBroadcast(context, widgetID, Intent(context, NewCalendarEventReceiver::class.java).apply { action = Actions.ACTION_GO_TO_PREVIOUS_EVENT }, 0))
|
||||
views.setOnClickPendingIntent(
|
||||
R.id.action_previous_rect,
|
||||
PendingIntent.getBroadcast(
|
||||
context,
|
||||
widgetID,
|
||||
Intent(
|
||||
context,
|
||||
NewCalendarEventReceiver::class.java
|
||||
).apply { action = Actions.ACTION_GO_TO_PREVIOUS_EVENT },
|
||||
0
|
||||
)
|
||||
)
|
||||
} else {
|
||||
views.setViewVisibility(R.id.action_next_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.action_previous_rect, View.GONE)
|
||||
}
|
||||
|
||||
val pIntent = PendingIntent.getActivity(context, widgetID, IntentHelper.getEventIntent(context, nextEvent), 0)
|
||||
val pIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getEventIntent(context, nextEvent),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.next_event_rect, pIntent)
|
||||
views.setOnClickPendingIntent(R.id.next_event_difference_time_rect, pIntent)
|
||||
|
||||
if (Preferences.showDiffTime && Calendar.getInstance().timeInMillis < (nextEvent.startDate - 1000 * 60 * 60)) {
|
||||
views.setImageViewBitmap(R.id.next_event_difference_time_rect, BitmapHelper.getBitmapFromView(v.next_event_difference_time, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.next_event_difference_time_rect,
|
||||
BitmapHelper.getBitmapFromView(
|
||||
v.next_event_difference_time,
|
||||
draw = false
|
||||
)
|
||||
)
|
||||
views.setViewVisibility(R.id.next_event_difference_time_rect, View.VISIBLE)
|
||||
} else {
|
||||
views.setViewVisibility(R.id.next_event_difference_time_rect, View.GONE)
|
||||
}
|
||||
|
||||
if (nextEvent.address != "" && Preferences.secondRowInformation == 1) {
|
||||
val mapIntent = PendingIntent.getActivity(context, widgetID, IntentHelper.getGoogleMapsIntentFromAddress(context, nextEvent.address), 0)
|
||||
val mapIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getGoogleMapsIntentFromAddress(context, nextEvent.address),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, mapIntent)
|
||||
} else {
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, pIntent)
|
||||
val pIntentDetail = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getEventIntent(
|
||||
context,
|
||||
nextEvent,
|
||||
forceEventDetails = true
|
||||
),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, pIntentDetail)
|
||||
}
|
||||
|
||||
views.setImageViewBitmap(R.id.next_event_rect, BitmapHelper.getBitmapFromView(v.next_event, draw = false))
|
||||
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))
|
||||
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)
|
||||
} else if (Preferences.showNextAlarm && nextAlarm != "") {
|
||||
val clockIntent = PendingIntent.getActivity(context, widgetID, IntentHelper.getClockIntent(context), 0)
|
||||
val clockIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getClockIntent(context),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, clockIntent)
|
||||
|
||||
views.setImageViewBitmap(R.id.next_event_rect, BitmapHelper.getBitmapFromView(v.next_event, draw = false))
|
||||
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))
|
||||
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)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
}
|
||||
|
||||
return views
|
||||
}
|
||||
|
||||
private fun updateWeatherView(context: Context, v: View, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
|
||||
try {
|
||||
if (Preferences.showWeather && Preferences.weatherIcon != "") {
|
||||
views.setViewVisibility(R.id.weather_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.calendar_weather_rect, View.VISIBLE)
|
||||
@ -195,17 +284,27 @@ class MainWidget : AppWidgetProvider() {
|
||||
views.setOnClickPendingIntent(R.id.weather_rect, weatherPIntent)
|
||||
views.setOnClickPendingIntent(R.id.calendar_weather_rect, weatherPIntent)
|
||||
|
||||
views.setImageViewBitmap(R.id.weather_rect, BitmapHelper.getBitmapFromView(v.weather, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.weather_rect,
|
||||
BitmapHelper.getBitmapFromView(v.weather, draw = false)
|
||||
)
|
||||
|
||||
views.setImageViewBitmap(R.id.calendar_weather_rect, BitmapHelper.getBitmapFromView(v.calendar_weather, draw = false))
|
||||
views.setImageViewBitmap(
|
||||
R.id.calendar_weather_rect,
|
||||
BitmapHelper.getBitmapFromView(v.calendar_weather, draw = false)
|
||||
)
|
||||
} else {
|
||||
views.setViewVisibility(R.id.weather_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_weather_rect, View.GONE)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
}
|
||||
return views
|
||||
}
|
||||
|
||||
private fun updateClockView(context: Context, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
try {
|
||||
if (!Preferences.showClock) {
|
||||
views.setViewVisibility(R.id.time, View.GONE)
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_none, View.GONE)
|
||||
@ -214,15 +313,39 @@ class MainWidget : AppWidgetProvider() {
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_large, View.GONE)
|
||||
} else {
|
||||
views.setTextColor(R.id.time, ColorHelper.getFontColor())
|
||||
views.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_SP, Preferences.clockTextSize.toPixel(context))
|
||||
val clockPIntent = PendingIntent.getActivity(context, widgetID, IntentHelper.getClockIntent(context), 0)
|
||||
views.setTextViewTextSize(
|
||||
R.id.time,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize.toPixel(context)
|
||||
)
|
||||
val clockPIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
widgetID,
|
||||
IntentHelper.getClockIntent(context),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.time, clockPIntent)
|
||||
views.setViewVisibility(R.id.time, View.VISIBLE)
|
||||
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_none, if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.NONE.value) View.VISIBLE else View.GONE)
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_small, if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.SMALL.value) View.VISIBLE else View.GONE)
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_medium, if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.MEDIUM.value) View.VISIBLE else View.GONE)
|
||||
views.setViewVisibility(R.id.clock_bottom_margin_large, if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.LARGE.value) View.VISIBLE else View.GONE)
|
||||
views.setViewVisibility(
|
||||
R.id.clock_bottom_margin_none,
|
||||
if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.NONE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.clock_bottom_margin_small,
|
||||
if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.clock_bottom_margin_medium,
|
||||
if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.clock_bottom_margin_large,
|
||||
if (Preferences.clockBottomMargin == Constants.ClockBottomMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
}
|
||||
|
||||
return views
|
||||
|
BIN
app/src/main/res/drawable-hdpi/round_update_black_18.png
Normal file
After Width: | Height: | Size: 389 B |
BIN
app/src/main/res/drawable-hdpi/round_update_black_24.png
Normal file
After Width: | Height: | Size: 492 B |
BIN
app/src/main/res/drawable-hdpi/round_update_black_36.png
Normal file
After Width: | Height: | Size: 699 B |
BIN
app/src/main/res/drawable-hdpi/round_update_black_48.png
Normal file
After Width: | Height: | Size: 876 B |
BIN
app/src/main/res/drawable-mdpi/round_update_black_18.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
app/src/main/res/drawable-mdpi/round_update_black_24.png
Normal file
After Width: | Height: | Size: 342 B |
BIN
app/src/main/res/drawable-mdpi/round_update_black_36.png
Normal file
After Width: | Height: | Size: 492 B |
BIN
app/src/main/res/drawable-mdpi/round_update_black_48.png
Normal file
After Width: | Height: | Size: 607 B |
BIN
app/src/main/res/drawable-xhdpi/round_update_black_18.png
Normal file
After Width: | Height: | Size: 492 B |
BIN
app/src/main/res/drawable-xhdpi/round_update_black_24.png
Normal file
After Width: | Height: | Size: 607 B |
BIN
app/src/main/res/drawable-xhdpi/round_update_black_36.png
Normal file
After Width: | Height: | Size: 876 B |
BIN
app/src/main/res/drawable-xhdpi/round_update_black_48.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_update_black_18.png
Normal file
After Width: | Height: | Size: 699 B |
BIN
app/src/main/res/drawable-xxhdpi/round_update_black_24.png
Normal file
After Width: | Height: | Size: 876 B |
BIN
app/src/main/res/drawable-xxhdpi/round_update_black_36.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_update_black_48.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_update_black_18.png
Normal file
After Width: | Height: | Size: 876 B |
BIN
app/src/main/res/drawable-xxxhdpi/round_update_black_24.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_update_black_36.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_update_black_48.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
10
app/src/main/res/drawable/round_update.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,8.75v3.68c0,0.35 0.19,0.68 0.49,0.86l3.12,1.85c0.36,0.21 0.82,0.09 1.03,-0.26c0.21,-0.36 0.1,-0.82 -0.26,-1.03l-2.87,-1.71v-3.4C12.5,8.34 12.16,8 11.75,8S11,8.34 11,8.75zM21,9.5V4.21c0,-0.45 -0.54,-0.67 -0.85,-0.35l-1.78,1.78c-1.81,-1.81 -4.39,-2.85 -7.21,-2.6c-4.19,0.38 -7.64,3.75 -8.1,7.94C2.46,16.4 6.69,21 12,21c4.59,0 8.38,-3.44 8.93,-7.88c0.07,-0.6 -0.4,-1.12 -1,-1.12c-0.5,0 -0.92,0.37 -0.98,0.86c-0.43,3.49 -3.44,6.19 -7.05,6.14c-3.71,-0.05 -6.84,-3.18 -6.9,-6.9C4.94,8.2 8.11,5 12,5c1.93,0 3.68,0.79 4.95,2.05l-2.09,2.09C14.54,9.46 14.76,10 15.21,10h5.29C20.78,10 21,9.78 21,9.5z"/>
|
||||
</vector>
|
@ -203,7 +203,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_event_note"
|
||||
android:src="@drawable/round_code"
|
||||
android:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -371,6 +371,43 @@
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/action_open_event_details"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_event_note"
|
||||
android:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Settings.Title"
|
||||
android:text="@string/settings_event_app_title"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/open_event_details_label"
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -408,43 +445,6 @@
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/action_event_app"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_add_to_home_screen"
|
||||
android:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Settings.Title"
|
||||
android:text="@string/settings_event_app_title"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/event_app_label"
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@ -250,7 +250,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_schedule"
|
||||
android:src="@drawable/round_update"
|
||||
android:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -132,7 +132,7 @@
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:scaleType="fitCenter"
|
||||
android:id="@+id/bitmap_container"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -66,7 +66,7 @@
|
||||
<string name="error_opening_uri">Fehler beim Öffnen der URL: Link in die Zwischenablage kopiert.</string>
|
||||
<string name="loading_text">Daten werden geladen...</string>
|
||||
<string name="error_opening_app">Fehler beim Öffnen der App.</string>
|
||||
<string name="settings_calendar_app_title">Beim Klick auf\'s Datum öffnet sich</string>
|
||||
<string name="settings_calendar_app_title">Standard Kalender-App</string>
|
||||
<string name="settings_weather_app_title">Beim Klick auf\'s Wetter öffnet sich</string>
|
||||
<string name="default_name">Standardapp</string>
|
||||
<string name="action_choose_application">App wählen</string>
|
||||
@ -100,7 +100,7 @@
|
||||
Schlüssel aktiviert ist, ist das Wetter sichtbar.
|
||||
</string>
|
||||
<string name="api_key_info_start">Hi zusammen!</string>
|
||||
<string name="action_open_provider">Öffnen von OpenWeather.com</string>
|
||||
<string name="action_open_provider">Öffnen von OpenWeatherMap.com</string>
|
||||
<string name="api_key_info_all_set">
|
||||
<![CDATA[Es kann bis zu <b> zehn Minuten </b> dauern, bis der API-Schlüssel aktiviert wird.<BR /><i> Entspannen </ i> Sie! Das Wetter wird aktualisiert, sobald es verfügbar ist !!]]></string>
|
||||
<string name="well_done">Gut gemacht!</string>
|
||||
@ -136,7 +136,7 @@
|
||||
<string name="settings_not_visible">Nicht sichtbar</string>
|
||||
<string name="settings_show_declined_events_title">Abgelehnte Ereignisse</string>
|
||||
<string name="default_weather_app">Google Wetter</string>
|
||||
<string name="default_event_app">Google Kalender Veranstalungsdetails</string>
|
||||
<string name="default_event_app">Veranstalungsdetails</string>
|
||||
<string name="default_calendar_app">Standard Kalender-App</string>
|
||||
<string name="default_clock_app">Standard Uhr-App</string>
|
||||
<string name="settings_show_until_subtitle_7">1 Stunde später</string>
|
||||
|
@ -60,7 +60,7 @@
|
||||
<string name="error_opening_uri">Erreur lors de l\'ouverture de l\'URL : Lien copié dans le presse-papiers.</string>
|
||||
<string name="loading_text">Chargement des données…</string>
|
||||
<string name="error_opening_app">Erreur lors de l\'ouverture de l\'app.</string>
|
||||
<string name="settings_calendar_app_title">Taper sur la date ouvre</string>
|
||||
<string name="settings_calendar_app_title">App calendrier par défaut</string>
|
||||
<string name="settings_weather_app_title">Taper sur la météo ouvre</string>
|
||||
<string name="default_name">App par défaut</string>
|
||||
<string name="action_choose_application">Choisir une application</string>
|
||||
@ -86,7 +86,7 @@
|
||||
<string name="api_key_title_3">Saisissez la clé dans l\'app</string>
|
||||
<string name="api_key_subtitle_3">Collez la clé dans le champ ci-dessus et enregistrez-la. Une fois la clé activée, la météo deviendra visible.</string>
|
||||
<string name="api_key_info_start">Bonjour tout le monde !</string>
|
||||
<string name="action_open_provider">Aller sur le site d\'OpenWeather</string>
|
||||
<string name="action_open_provider">Aller sur le site d\'OpenWeatherMap</string>
|
||||
<string name="api_key_info_all_set"><![CDATA[Cela peut prendre jusqu\'à <b> 10 minutes </b> avant que votre clé API soit activée. La météo sera mise à jour dès qu\'elle sera disponible !]]></string>
|
||||
<string name="well_done">Bien joué !</string>
|
||||
<string name="hs_code">h</string>
|
||||
@ -120,7 +120,7 @@
|
||||
<string name="settings_not_visible">Non visible</string>
|
||||
<string name="settings_show_declined_events_title">Événements refusés</string>
|
||||
<string name="default_weather_app">Google Weather</string>
|
||||
<string name="default_event_app">Détails de l\'événement dans Google Agenda</string>
|
||||
<string name="default_event_app">Détails de l\'événement</string>
|
||||
<string name="default_calendar_app">App calendrier par défaut</string>
|
||||
<string name="default_clock_app">App horloge par défaut</string>
|
||||
<string name="settings_show_until_subtitle_7">1 heure après</string>
|
||||
|
@ -61,7 +61,7 @@
|
||||
<string name="error_opening_uri">Errore apertura URL: Link copiato negli appunti.</string>
|
||||
<string name="loading_text">Caricamento…</string>
|
||||
<string name="error_opening_app">Errore apertura App.</string>
|
||||
<string name="settings_calendar_app_title">La data apre</string>
|
||||
<string name="settings_calendar_app_title">Applicazione predefinita calendario</string>
|
||||
<string name="settings_weather_app_title">Il meteo apre</string>
|
||||
<string name="default_name">App Predefinita</string>
|
||||
<string name="action_choose_application">Scegli Applicazione</string>
|
||||
@ -80,8 +80,8 @@
|
||||
<string name="error_no_calendar">Nessun calendario trovato.</string>
|
||||
<string name="api_key_info_title">Cosa fare</string>
|
||||
<string name="api_key_title_1">Registrati su OpenWeather</string>
|
||||
<string name="action_open_provider">Apri OpenWeather.com</string>
|
||||
<string name="api_key_subtitle_1">Registra un account gratuito su OpenWeather.com in pochi minuti.</string>
|
||||
<string name="action_open_provider">Apri OpenWeatherMap.com</string>
|
||||
<string name="api_key_subtitle_1">Registra un account gratuito su OpenWeatherMap.com in pochi minuti.</string>
|
||||
<string name="api_key_subtitle_2">Accedi alle chiavi API nelle impostazioni e copia la chiave di default.</string>
|
||||
<string name="api_key_subtitle_3">Aggiungi la chiave all\'applicazione in questa sezione e, una volta che la chiave sarà attivata, apparirà il meteo.</string>
|
||||
<string name="api_key_title_2">Copia la chiave API</string>
|
||||
@ -120,7 +120,7 @@
|
||||
<string name="settings_show_declined_events_title">Event Rifiutati</string>
|
||||
<string name="settings_visible">Visibile</string>
|
||||
<string name="settings_not_visible">Non Visibile</string>
|
||||
<string name="default_event_app">Dettagli Evento Google Calendar</string>
|
||||
<string name="default_event_app">Dettagli evento</string>
|
||||
<string name="default_calendar_app">App Calendario di Default</string>
|
||||
<string name="default_weather_app">Meteo Google</string>
|
||||
<string name="default_clock_app">App Orologio di Default</string>
|
||||
|
@ -66,7 +66,7 @@
|
||||
<string name="error_opening_uri">Error opening URL: Link copied to clipboard.</string>
|
||||
<string name="loading_text">Loading Data…</string>
|
||||
<string name="error_opening_app">Error opening app.</string>
|
||||
<string name="settings_calendar_app_title">Tap on date opens</string>
|
||||
<string name="settings_calendar_app_title">Calendar default application</string>
|
||||
<string name="settings_weather_app_title">Tap on weather opens</string>
|
||||
<string name="default_name">Default app</string>
|
||||
<string name="action_choose_application">Choose application</string>
|
||||
@ -93,7 +93,7 @@
|
||||
<string name="api_key_title_3">Enter the key to the app</string>
|
||||
<string name="api_key_subtitle_3">Paste the key into the field above and save it. Once the key is activated the weather will become visible.</string>
|
||||
<string name="api_key_info_start">Hi Everyone!</string>
|
||||
<string name="action_open_provider">Go to OpenWeather.com</string>
|
||||
<string name="action_open_provider">Go to OpenWeatherMap.com</string>
|
||||
<string name="api_key_info_all_set"><![CDATA[It may take up to <b>ten minutes</b> before your API key is activated. The weather will be updated as soon as it is available!]]></string>
|
||||
<string name="well_done">Well Done!</string>
|
||||
<string name="hs_code">h</string>
|
||||
@ -125,12 +125,12 @@
|
||||
<string name="beta" translatable="false">Beta</string>
|
||||
<string name="settings_product_sans_font_title">Product Sans Font</string>
|
||||
<string name="settings_product_sans_font_subtitle">Using Product Sans disabled the possibility to tap widget elements. I\'m working on it.</string>
|
||||
<string name="settings_show_diff_time_title">Time left in the event</string>
|
||||
<string name="settings_show_diff_time_title">Time left to the event</string>
|
||||
<string name="settings_visible">Visible</string>
|
||||
<string name="settings_not_visible">Hidden</string>
|
||||
<string name="settings_show_declined_events_title">Declined events</string>
|
||||
<string name="default_weather_app">Google Weather</string>
|
||||
<string name="default_event_app">Google Calendar event details</string>
|
||||
<string name="default_event_app">Event details</string>
|
||||
<string name="default_calendar_app">Default calendar app</string>
|
||||
<string name="default_clock_app">Default clock app</string>
|
||||
<string name="settings_show_until_subtitle_7">1 hour later</string>
|
||||
|
@ -10,5 +10,5 @@
|
||||
android:minResizeWidth="300dp"
|
||||
android:previewImage="@drawable/widget_preview"
|
||||
android:resizeMode="vertical|horizontal"
|
||||
android:updatePeriodMillis="60000"
|
||||
android:updatePeriodMillis="86400000"
|
||||
android:widgetCategory="home_screen" />
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="59"
|
||||
android:versionCode="64"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -1 +1 @@
|
||||
#Mon May 04 17:41:28 CEST 2020
|
||||
#Mon May 04 20:02:45 CEST 2020
|
||||
|
@ -1,4 +1,4 @@
|
||||
#Mon May 04 18:04:57 CEST 2020
|
||||
#Tue May 05 14:08:04 CEST 2020
|
||||
base.0=/Users/tommaso/Documents/MyCode/another-widget/tasksintegration/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex
|
||||
path.0=classes.dex
|
||||
renamed.0=classes.dex
|
||||
|
@ -4,7 +4,7 @@
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:targetSandboxVersion="2"
|
||||
android:versionCode="59"
|
||||
android:versionCode="64"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
3 xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
4 featureSplit="tasksintegration"
|
||||
5 package="com.tommasoberlose.anotherwidget"
|
||||
6 android:versionCode="59"
|
||||
6 android:versionCode="64"
|
||||
7 android:versionName="2.0.5" >
|
||||
8
|
||||
9 <uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="59"
|
||||
android:versionCode="64"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="59"
|
||||
android:versionCode="64"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk android:targetSdkVersion="29" />
|
||||
|