Fix #120
This commit is contained in:
parent
b04b103634
commit
b81461f725
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -22,7 +22,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 90
|
versionCode 91
|
||||||
versionName "2.0.9"
|
versionName "2.0.9"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
Binary file not shown.
@ -17,15 +17,15 @@
|
|||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:fullBackupContent="@xml/my_backup_rules"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:name=".AWApplication"
|
android:name=".AWApplication"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
tools:ignore="LockedOrientationActivity">
|
tools:ignore="LockedOrientationActivity"
|
||||||
<activity android:name=".ui.activities.MainActivity" android:launchMode="singleInstance" android:theme="@style/AppTheme.Main">
|
android:fullBackupContent="@xml/backup_descriptor">
|
||||||
|
<activity android:name=".ui.activities.MainActivity" android:launchMode="singleInstance" android:theme="@style/AppTheme.Main" android:screenOrientation="portrait">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ class EventRepository(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearEvents() {
|
||||||
|
realm.executeTransaction { realm ->
|
||||||
|
realm.where(Event::class.java).findAll().deleteAllFromRealm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun resetNextEventData() {
|
fun resetNextEventData() {
|
||||||
Preferences.bulk {
|
Preferences.bulk {
|
||||||
remove(Preferences::nextEventId)
|
remove(Preferences::nextEventId)
|
||||||
|
@ -102,6 +102,7 @@ object CalendarHelper {
|
|||||||
|
|
||||||
if (eventList.isEmpty()) {
|
if (eventList.isEmpty()) {
|
||||||
eventRepository.resetNextEventData()
|
eventRepository.resetNextEventData()
|
||||||
|
eventRepository.clearEvents()
|
||||||
} else {
|
} else {
|
||||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
||||||
if (event.allDay && event1.allDay) {
|
if (event.allDay && event1.allDay) {
|
||||||
@ -134,6 +135,7 @@ object CalendarHelper {
|
|||||||
MainWidget.updateWidget(context)
|
MainWidget.updateWidget(context)
|
||||||
|
|
||||||
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||||
|
eventRepository.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
||||||
|
@ -79,12 +79,15 @@ object GlanceProviderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun showGlanceProviders(context: Context): Boolean {
|
fun showGlanceProviders(context: Context): Boolean {
|
||||||
return Preferences.showGlance && EventRepository(context).getEventsCount() == 0 && (
|
val eventRepository = EventRepository(context)
|
||||||
|
val showGlance = Preferences.showGlance && eventRepository.getEventsCount() == 0 && (
|
||||||
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
|
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
|
||||||
(MediaPlayerHelper.isSomeonePlaying(context)) ||
|
(MediaPlayerHelper.isSomeonePlaying(context)) ||
|
||||||
(Preferences.isBatteryLevelLow) ||
|
(Preferences.isBatteryLevelLow) ||
|
||||||
(Preferences.customNotes.isNotEmpty()) ||
|
(Preferences.customNotes.isNotEmpty()) ||
|
||||||
(Preferences.showDailySteps && Preferences.googleFitSteps > 0)
|
(Preferences.showDailySteps && Preferences.googleFitSteps > 0)
|
||||||
)
|
)
|
||||||
|
eventRepository.close()
|
||||||
|
return showGlance
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ import android.content.Context
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import com.google.android.gms.location.LocationServices
|
import com.google.android.gms.location.LocationServices
|
||||||
import com.tommasoberlose.anotherwidget.R
|
import com.tommasoberlose.anotherwidget.R
|
||||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
|
||||||
import com.tommasoberlose.anotherwidget.global.Constants
|
import com.tommasoberlose.anotherwidget.global.Constants
|
||||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||||
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
||||||
|
@ -24,5 +24,6 @@ class NewCalendarEventReceiver : BroadcastReceiver() {
|
|||||||
eventRepository.goToPreviousEvent()
|
eventRepository.goToPreviousEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
eventRepository.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
setEventUpdate(context, event)
|
setEventUpdate(context, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
eventRepository.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setEventUpdate(context: Context, event: Event) {
|
private fun setEventUpdate(context: Context, event: Event) {
|
||||||
@ -135,9 +136,11 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
fun removeUpdates(context: Context) {
|
fun removeUpdates(context: Context) {
|
||||||
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||||
EventRepository(context).getEvents().forEach {
|
val eventRepository = EventRepository(context)
|
||||||
|
eventRepository.getEvents().forEach {
|
||||||
cancel(PendingIntent.getBroadcast(context, it.eventID.toInt(), Intent(context, UpdatesReceiver::class.java), 0))
|
cancel(PendingIntent.getBroadcast(context, it.eventID.toInt(), Intent(context, UpdatesReceiver::class.java), 0))
|
||||||
}
|
}
|
||||||
|
eventRepository.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
||||||
|
|
||||||
controlExtras(intent)
|
controlExtras(intent)
|
||||||
requirePermission()
|
if (Preferences.showWallpaper) {
|
||||||
|
requirePermission()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
@ -321,7 +321,7 @@ class GeneralTabFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action_show_dividers.setOnClickListener {
|
action_show_dividers.setOnClickListener {
|
||||||
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_multiple_events_title)).setSelectedValue(Preferences.showDividers)
|
BottomSheetMenu<Boolean>(requireContext(), header = getString(R.string.settings_show_dividers_title)).setSelectedValue(Preferences.showDividers)
|
||||||
.addItem(getString(R.string.settings_visible), true)
|
.addItem(getString(R.string.settings_visible), true)
|
||||||
.addItem(getString(R.string.settings_not_visible), false)
|
.addItem(getString(R.string.settings_not_visible), false)
|
||||||
.addOnSelectItemListener { value ->
|
.addOnSelectItemListener { value ->
|
||||||
|
@ -145,7 +145,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
ColorHelper.getBackgroundColor()
|
ColorHelper.getBackgroundColor()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
uiJob = viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val generatedView = MainWidget.generateWidgetView(requireContext())
|
val generatedView = MainWidget.generateWidgetView(requireContext())
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
@ -230,10 +230,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
).apply {
|
).apply {
|
||||||
duration = 500L
|
duration = 500L
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
val animatedValue = animatedValue as Int
|
if (preview != null) {
|
||||||
val layoutParams = preview.layoutParams
|
val animatedValue = animatedValue as Int
|
||||||
layoutParams.height = animatedValue
|
val layoutParams = preview.layoutParams
|
||||||
preview.layoutParams = layoutParams
|
layoutParams.height = animatedValue
|
||||||
|
preview.layoutParams = layoutParams
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
@ -253,10 +255,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
).apply {
|
).apply {
|
||||||
duration = 300L
|
duration = 300L
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
val animatedValue = animatedValue as Int
|
if (preview != null) {
|
||||||
val layoutParams = preview.layoutParams
|
val animatedValue = animatedValue as Int
|
||||||
layoutParams.height = animatedValue
|
val layoutParams = preview.layoutParams
|
||||||
preview?.layoutParams = layoutParams
|
layoutParams.height = animatedValue
|
||||||
|
preview?.layoutParams = layoutParams
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
@ -264,8 +268,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
widget_loader?.animate()?.scaleX(0f)?.scaleY(0f)?.alpha(0f)?.setDuration(200L)?.start()
|
widget_loader?.animate()?.scaleX(0f)?.scaleY(0f)?.alpha(0f)?.setDuration(200L)?.start()
|
||||||
bitmap_container?.apply {
|
bitmap_container?.apply {
|
||||||
setImageBitmap(bitmap)
|
setImageBitmap(bitmap)
|
||||||
scaleX = 0.9f
|
// scaleX = 0.9f
|
||||||
scaleY = 0.9f
|
// scaleY = 0.9f
|
||||||
}
|
}
|
||||||
widget?.animate()?.alpha(1f)?.start()
|
widget?.animate()?.alpha(1f)?.start()
|
||||||
}
|
}
|
||||||
@ -278,10 +282,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
).apply {
|
).apply {
|
||||||
duration = 300L
|
duration = 300L
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
val animatedValue = animatedValue as Int
|
if (preview != null) {
|
||||||
val layoutParams = preview.layoutParams
|
val animatedValue = animatedValue as Int
|
||||||
layoutParams.height = animatedValue
|
val layoutParams = preview.layoutParams
|
||||||
preview.layoutParams = layoutParams
|
layoutParams.height = animatedValue
|
||||||
|
preview.layoutParams = layoutParams
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import java.text.DateFormat
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
|
||||||
class MainWidget : AppWidgetProvider() {
|
class MainWidget : AppWidgetProvider() {
|
||||||
@ -140,9 +141,8 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCalendarView(context: Context, v: View, views: RemoteViews, widgetID: Int): RemoteViews {
|
private fun updateCalendarView(context: Context, v: View, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||||
|
val eventRepository = EventRepository(context)
|
||||||
try {
|
try {
|
||||||
val eventRepository = EventRepository(context)
|
|
||||||
|
|
||||||
views.setImageViewBitmap(
|
views.setImageViewBitmap(
|
||||||
R.id.empty_date_rect,
|
R.id.empty_date_rect,
|
||||||
BitmapHelper.getBitmapFromView(v.empty_date, draw = false)
|
BitmapHelper.getBitmapFromView(v.empty_date, draw = false)
|
||||||
@ -340,6 +340,8 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
ex.printStackTrace()
|
ex.printStackTrace()
|
||||||
CrashlyticsReceiver.sendCrash(context, ex)
|
CrashlyticsReceiver.sendCrash(context, ex)
|
||||||
|
} finally {
|
||||||
|
eventRepository.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return views
|
return views
|
||||||
@ -698,7 +700,7 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
v.weather.visibility = View.VISIBLE
|
v.weather.visibility = View.VISIBLE
|
||||||
v.calendar_weather.visibility = View.VISIBLE
|
v.calendar_weather.visibility = View.VISIBLE
|
||||||
v.special_weather.visibility = View.VISIBLE
|
v.special_weather.visibility = View.VISIBLE
|
||||||
val currentTemp = String.format(Locale.getDefault(), "%.0f °%s", Preferences.weatherTemp, Preferences.weatherRealTempUnit)
|
val currentTemp = String.format(Locale.getDefault(), "%d °%s", Preferences.weatherTemp.roundToInt(), Preferences.weatherRealTempUnit)
|
||||||
|
|
||||||
val icon: String = Preferences.weatherIcon
|
val icon: String = Preferences.weatherIcon
|
||||||
if (icon == "") {
|
if (icon == "") {
|
||||||
@ -734,6 +736,8 @@ class MainWidget : AppWidgetProvider() {
|
|||||||
it.isVisible = Preferences.showDividers
|
it.isVisible = Preferences.showDividers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventRepository.close()
|
||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:paddingLeft="32dp"
|
android:paddingLeft="32dp"
|
||||||
android:paddingRight="32dp"
|
android:paddingRight="32dp"
|
||||||
android:textSize="16sp"
|
android:textSize="18sp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:id="@+id/header_text"
|
android:id="@+id/header_text"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:paddingLeft="32dp"
|
android:paddingLeft="32dp"
|
||||||
android:paddingRight="32dp"
|
android:paddingRight="32dp"
|
||||||
android:textSize="16sp"
|
android:textSize="18sp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:id="@+id/header_text"
|
android:id="@+id/header_text"
|
||||||
|
4
app/src/main/res/xml/backup_descriptor.xml
Normal file
4
app/src/main/res/xml/backup_descriptor.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<full-backup-content>
|
||||||
|
<include domain="sharedpref" path="." />
|
||||||
|
</full-backup-content>
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<full-backup-content>
|
|
||||||
<include domain="sharedpref" path="."/>
|
|
||||||
</full-backup-content>
|
|
Loading…
x
Reference in New Issue
Block a user