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"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 90
|
||||
versionCode 91
|
||||
versionName "2.0.9"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
Binary file not shown.
@ -17,15 +17,15 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/my_backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:name=".AWApplication"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="LockedOrientationActivity">
|
||||
<activity android:name=".ui.activities.MainActivity" android:launchMode="singleInstance" android:theme="@style/AppTheme.Main">
|
||||
tools:ignore="LockedOrientationActivity"
|
||||
android:fullBackupContent="@xml/backup_descriptor">
|
||||
<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" />
|
||||
|
||||
|
@ -22,6 +22,12 @@ class EventRepository(val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fun clearEvents() {
|
||||
realm.executeTransaction { realm ->
|
||||
realm.where(Event::class.java).findAll().deleteAllFromRealm()
|
||||
}
|
||||
}
|
||||
|
||||
fun resetNextEventData() {
|
||||
Preferences.bulk {
|
||||
remove(Preferences::nextEventId)
|
||||
|
@ -102,6 +102,7 @@ object CalendarHelper {
|
||||
|
||||
if (eventList.isEmpty()) {
|
||||
eventRepository.resetNextEventData()
|
||||
eventRepository.clearEvents()
|
||||
} else {
|
||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
||||
if (event.allDay && event1.allDay) {
|
||||
@ -134,6 +135,7 @@ object CalendarHelper {
|
||||
MainWidget.updateWidget(context)
|
||||
|
||||
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||
eventRepository.close()
|
||||
}
|
||||
|
||||
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
||||
|
@ -79,12 +79,15 @@ object GlanceProviderHelper {
|
||||
}
|
||||
|
||||
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) != "") ||
|
||||
(MediaPlayerHelper.isSomeonePlaying(context)) ||
|
||||
(Preferences.isBatteryLevelLow) ||
|
||||
(Preferences.customNotes.isNotEmpty()) ||
|
||||
(Preferences.showDailySteps && Preferences.googleFitSteps > 0)
|
||||
)
|
||||
eventRepository.close()
|
||||
return showGlance
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
||||
|
@ -24,5 +24,6 @@ class NewCalendarEventReceiver : BroadcastReceiver() {
|
||||
eventRepository.goToPreviousEvent()
|
||||
}
|
||||
}
|
||||
eventRepository.close()
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ class UpdatesReceiver : BroadcastReceiver() {
|
||||
setEventUpdate(context, event)
|
||||
}
|
||||
}
|
||||
eventRepository.close()
|
||||
}
|
||||
|
||||
private fun setEventUpdate(context: Context, event: Event) {
|
||||
@ -135,9 +136,11 @@ class UpdatesReceiver : BroadcastReceiver() {
|
||||
|
||||
fun removeUpdates(context: Context) {
|
||||
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))
|
||||
}
|
||||
eventRepository.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,9 @@ class MainActivity : AppCompatActivity() {
|
||||
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
||||
|
||||
controlExtras(intent)
|
||||
requirePermission()
|
||||
if (Preferences.showWallpaper) {
|
||||
requirePermission()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -321,7 +321,7 @@ class GeneralTabFragment : Fragment() {
|
||||
}
|
||||
|
||||
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_not_visible), false)
|
||||
.addOnSelectItemListener { value ->
|
||||
|
@ -145,7 +145,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
ColorHelper.getBackgroundColor()
|
||||
)
|
||||
)
|
||||
uiJob = viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||
val generatedView = MainWidget.generateWidgetView(requireContext())
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
@ -230,10 +230,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
).apply {
|
||||
duration = 500L
|
||||
addUpdateListener {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview.layoutParams = layoutParams
|
||||
if (preview != null) {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
@ -253,10 +255,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
).apply {
|
||||
duration = 300L
|
||||
addUpdateListener {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview?.layoutParams = layoutParams
|
||||
if (preview != null) {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview?.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
@ -264,8 +268,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
widget_loader?.animate()?.scaleX(0f)?.scaleY(0f)?.alpha(0f)?.setDuration(200L)?.start()
|
||||
bitmap_container?.apply {
|
||||
setImageBitmap(bitmap)
|
||||
scaleX = 0.9f
|
||||
scaleY = 0.9f
|
||||
// scaleX = 0.9f
|
||||
// scaleY = 0.9f
|
||||
}
|
||||
widget?.animate()?.alpha(1f)?.start()
|
||||
}
|
||||
@ -278,10 +282,12 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
|
||||
).apply {
|
||||
duration = 300L
|
||||
addUpdateListener {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview.layoutParams = layoutParams
|
||||
if (preview != null) {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = preview.layoutParams
|
||||
layoutParams.height = animatedValue
|
||||
preview.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import java.text.DateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
class MainWidget : AppWidgetProvider() {
|
||||
@ -140,9 +141,8 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
private fun updateCalendarView(context: Context, v: View, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
val eventRepository = EventRepository(context)
|
||||
try {
|
||||
val eventRepository = EventRepository(context)
|
||||
|
||||
views.setImageViewBitmap(
|
||||
R.id.empty_date_rect,
|
||||
BitmapHelper.getBitmapFromView(v.empty_date, draw = false)
|
||||
@ -340,6 +340,8 @@ class MainWidget : AppWidgetProvider() {
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
} finally {
|
||||
eventRepository.close()
|
||||
}
|
||||
|
||||
return views
|
||||
@ -698,7 +700,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
v.weather.visibility = View.VISIBLE
|
||||
v.calendar_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
|
||||
if (icon == "") {
|
||||
@ -734,6 +736,8 @@ class MainWidget : AppWidgetProvider() {
|
||||
it.isVisible = Preferences.showDividers
|
||||
}
|
||||
|
||||
eventRepository.close()
|
||||
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
android:textSize="16sp"
|
||||
android:textSize="18sp"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:id="@+id/header_text"
|
||||
|
@ -19,7 +19,7 @@
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
android:textSize="16sp"
|
||||
android:textSize="18sp"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
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