Bugfixes
@ -22,7 +22,7 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 132
|
||||
versionCode 134
|
||||
versionName "2.3.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
@ -16,6 +16,7 @@ import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
@ -183,8 +184,6 @@ class MainFragment : Fragment() {
|
||||
private var uiJob: Job? = null
|
||||
|
||||
private fun updateUI() {
|
||||
uiJob?.cancel()
|
||||
|
||||
if (Preferences.showPreview) {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val bgColor: Int = ContextCompat.getColor(
|
||||
@ -207,24 +206,19 @@ class MainFragment : Fragment() {
|
||||
}
|
||||
|
||||
WidgetHelper.runWithCustomTypeface(requireContext()) { typeface ->
|
||||
uiJob?.cancel()
|
||||
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||
val generatedView = MainWidget.getWidgetView(requireContext(), typeface).root
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
generatedView.measure(0, 0)
|
||||
binding.preview.measure(0, 0)
|
||||
}
|
||||
|
||||
val bitmap = BitmapHelper.getBitmapFromView(
|
||||
generatedView,
|
||||
if (binding.preview.width > 0) binding.preview.width else generatedView.measuredWidth,
|
||||
generatedView.measuredHeight
|
||||
)
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.widgetDetail.bitmapContainer.apply {
|
||||
setImageBitmap(bitmap)
|
||||
binding.widgetDetail.content.removeAllViews()
|
||||
val container = LinearLayout(requireContext()).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
container.gravity = if (Preferences.widgetAlign == Constants.WidgetAlign.CENTER.rawValue) Gravity.CENTER else Gravity.NO_GRAVITY
|
||||
container.addView(generatedView)
|
||||
binding.widgetDetail.content.addView(container)
|
||||
|
||||
binding.widgetLoader.animate().scaleX(0f).scaleY(0f).alpha(0f)
|
||||
.setDuration(200L).start()
|
||||
@ -310,7 +304,7 @@ class MainFragment : Fragment() {
|
||||
if (showClock) 0f else 1f,
|
||||
if (showClock) 1f else 0f
|
||||
).apply {
|
||||
duration = 300L
|
||||
duration = 500L
|
||||
addUpdateListener {
|
||||
val animatedValue = animatedValue as Float
|
||||
binding.widgetDetail.timeContainer.layoutParams =
|
||||
@ -318,6 +312,10 @@ class MainFragment : Fragment() {
|
||||
height = (initialHeight * animatedValue).toInt()
|
||||
}
|
||||
binding.widgetDetail.time.alpha = animatedValue
|
||||
binding.widgetDetail.timeAmPm.alpha = animatedValue
|
||||
binding.widgetDetail.altTimezoneTime.alpha = animatedValue
|
||||
binding.widgetDetail.altTimezoneTimeAmPm.alpha = animatedValue
|
||||
binding.widgetDetail.altTimezoneLabel.alpha = animatedValue
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
@ -334,7 +332,7 @@ class MainFragment : Fragment() {
|
||||
requireContext()
|
||||
) else 0)
|
||||
).apply {
|
||||
duration = 300L
|
||||
duration = 500L
|
||||
addUpdateListener {
|
||||
val animatedValue = animatedValue as Int
|
||||
val layoutParams = binding.preview.layoutParams
|
||||
|
@ -88,6 +88,10 @@ class LeftAlignedWidget(val context: Context) {
|
||||
|
||||
private fun updateGridView(bindingView: LeftAlignedWidgetBinding, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
val eventRepository = EventRepository(context)
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val eventsCount = eventRepository.getEventsCount()
|
||||
eventRepository.close()
|
||||
|
||||
try {
|
||||
// Weather
|
||||
if (Preferences.showWeather && Preferences.weatherIcon != "") {
|
||||
@ -131,7 +135,6 @@ class LeftAlignedWidget(val context: Context) {
|
||||
views.setOnClickPendingIntent(R.id.date_rect, calPIntent)
|
||||
views.setViewVisibility(R.id.first_line_rect, View.VISIBLE)
|
||||
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val nextAlarm = AlarmHelper.getNextAlarm(context)
|
||||
|
||||
// Spacing
|
||||
@ -149,7 +152,7 @@ class LeftAlignedWidget(val context: Context) {
|
||||
)
|
||||
|
||||
if (Preferences.showEvents && context.checkGrantedPermission(Manifest.permission.READ_CALENDAR) && nextEvent != null && !Preferences.showEventsAsGlanceProvider) {
|
||||
if (Preferences.showNextEvent && eventRepository.getEventsCount() > 1) {
|
||||
if (Preferences.showNextEvent && eventsCount > 1) {
|
||||
|
||||
// Action next event
|
||||
views.setImageViewBitmap(
|
||||
@ -381,8 +384,6 @@ class LeftAlignedWidget(val context: Context) {
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
} finally {
|
||||
eventRepository.close()
|
||||
}
|
||||
|
||||
return views
|
||||
@ -392,6 +393,10 @@ class LeftAlignedWidget(val context: Context) {
|
||||
// Generates the widget bitmap from the view
|
||||
fun generateWidgetView(typeface: Typeface? = null): LeftAlignedWidgetBinding {
|
||||
val eventRepository = EventRepository(context)
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val eventsCount = eventRepository.getEventsCount()
|
||||
eventRepository.close()
|
||||
|
||||
val bindingView = LeftAlignedWidgetBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
bindingView.loader.isVisible = false
|
||||
@ -440,13 +445,12 @@ class LeftAlignedWidget(val context: Context) {
|
||||
|
||||
bindingView.date.text = DateHelper.getDateText(context, now)
|
||||
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val nextAlarm = AlarmHelper.getNextAlarm(context)
|
||||
|
||||
if (Preferences.showEvents && context.checkGrantedPermission(Manifest.permission.READ_CALENDAR) && nextEvent != null && !Preferences.showEventsAsGlanceProvider) {
|
||||
// Multiple counter
|
||||
bindingView.actionNext.isVisible =
|
||||
Preferences.showNextEvent && eventRepository.getEventsCount() > 1
|
||||
Preferences.showNextEvent && eventsCount > 1
|
||||
|
||||
bindingView.nextEvent.text = nextEvent.title
|
||||
|
||||
@ -883,8 +887,6 @@ class LeftAlignedWidget(val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
eventRepository.close()
|
||||
|
||||
return bindingView
|
||||
}
|
||||
}
|
@ -89,6 +89,10 @@ class StandardWidget(val context: Context) {
|
||||
|
||||
private fun updateGridView(bindingView: TheWidgetBinding, views: RemoteViews, widgetID: Int): RemoteViews {
|
||||
val eventRepository = EventRepository(context)
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val eventsCount = eventRepository.getEventsCount()
|
||||
eventRepository.close()
|
||||
|
||||
try {
|
||||
// Weather
|
||||
if (Preferences.showWeather && Preferences.weatherIcon != "") {
|
||||
@ -138,7 +142,6 @@ class StandardWidget(val context: Context) {
|
||||
BitmapHelper.getBitmapFromView(bindingView.subLine, draw = false)
|
||||
)
|
||||
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val nextAlarm = AlarmHelper.getNextAlarm(context)
|
||||
|
||||
// Spacing
|
||||
@ -156,7 +159,7 @@ class StandardWidget(val context: Context) {
|
||||
)
|
||||
|
||||
if (Preferences.showEvents && context.checkGrantedPermission(Manifest.permission.READ_CALENDAR) && nextEvent != null && !Preferences.showEventsAsGlanceProvider) {
|
||||
if (Preferences.showNextEvent && eventRepository.getEventsCount() > 1) {
|
||||
if (Preferences.showNextEvent && eventsCount > 1) {
|
||||
|
||||
// Action next event
|
||||
views.setImageViewBitmap(
|
||||
@ -402,8 +405,6 @@ class StandardWidget(val context: Context) {
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
} finally {
|
||||
eventRepository.close()
|
||||
}
|
||||
|
||||
return views
|
||||
@ -413,6 +414,10 @@ class StandardWidget(val context: Context) {
|
||||
// Generates the widget bitmap from the view
|
||||
fun generateWidgetView(typeface: Typeface? = null): TheWidgetBinding {
|
||||
val eventRepository = EventRepository(context)
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val eventsCount = eventRepository.getEventsCount()
|
||||
eventRepository.close()
|
||||
|
||||
val bindingView = TheWidgetBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
bindingView.loader.isVisible = false
|
||||
@ -462,15 +467,14 @@ class StandardWidget(val context: Context) {
|
||||
|
||||
bindingView.date.text = DateHelper.getDateText(context, now)
|
||||
|
||||
val nextEvent = eventRepository.getNextEvent()
|
||||
val nextAlarm = AlarmHelper.getNextAlarm(context)
|
||||
|
||||
if (Preferences.showEvents && context.checkGrantedPermission(Manifest.permission.READ_CALENDAR) && nextEvent != null && !Preferences.showEventsAsGlanceProvider) {
|
||||
// Multiple counter
|
||||
bindingView.actionNext.isVisible =
|
||||
Preferences.showNextEvent && eventRepository.getEventsCount() > 1
|
||||
Preferences.showNextEvent && eventsCount > 1
|
||||
bindingView.actionPrevious.isVisible =
|
||||
Preferences.showNextEvent && eventRepository.getEventsCount() > 1
|
||||
Preferences.showNextEvent && eventsCount > 1
|
||||
|
||||
bindingView.nextEvent.text = nextEvent.title
|
||||
|
||||
@ -923,7 +927,6 @@ class StandardWidget(val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
eventRepository.close()
|
||||
|
||||
return bindingView
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable-hdpi/round_more_time_white_18.png
Normal file
After Width: | Height: | Size: 428 B |
BIN
app/src/main/res/drawable-hdpi/round_more_time_white_20.png
Normal file
After Width: | Height: | Size: 448 B |
BIN
app/src/main/res/drawable-hdpi/round_more_time_white_24.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
app/src/main/res/drawable-hdpi/round_more_time_white_36.png
Normal file
After Width: | Height: | Size: 779 B |
BIN
app/src/main/res/drawable-hdpi/round_more_time_white_48.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
app/src/main/res/drawable-mdpi/round_more_time_white_18.png
Normal file
After Width: | Height: | Size: 261 B |
BIN
app/src/main/res/drawable-mdpi/round_more_time_white_20.png
Normal file
After Width: | Height: | Size: 213 B |
BIN
app/src/main/res/drawable-mdpi/round_more_time_white_24.png
Normal file
After Width: | Height: | Size: 288 B |
BIN
app/src/main/res/drawable-mdpi/round_more_time_white_36.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
app/src/main/res/drawable-mdpi/round_more_time_white_48.png
Normal file
After Width: | Height: | Size: 564 B |
BIN
app/src/main/res/drawable-night-hdpi/round_more_time_24.png
Normal file
After Width: | Height: | Size: 445 B |
BIN
app/src/main/res/drawable-night-mdpi/round_more_time_24.png
Normal file
After Width: | Height: | Size: 295 B |
BIN
app/src/main/res/drawable-night-xhdpi/round_more_time_24.png
Normal file
After Width: | Height: | Size: 566 B |
BIN
app/src/main/res/drawable-night-xxhdpi/round_more_time_24.png
Normal file
After Width: | Height: | Size: 871 B |
BIN
app/src/main/res/drawable-night-xxxhdpi/round_more_time_24.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xhdpi/round_more_time_white_18.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
app/src/main/res/drawable-xhdpi/round_more_time_white_20.png
Normal file
After Width: | Height: | Size: 371 B |
BIN
app/src/main/res/drawable-xhdpi/round_more_time_white_24.png
Normal file
After Width: | Height: | Size: 564 B |
BIN
app/src/main/res/drawable-xhdpi/round_more_time_white_36.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
app/src/main/res/drawable-xhdpi/round_more_time_white_48.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_more_time_white_18.png
Normal file
After Width: | Height: | Size: 779 B |
BIN
app/src/main/res/drawable-xxhdpi/round_more_time_white_20.png
Normal file
After Width: | Height: | Size: 590 B |
BIN
app/src/main/res/drawable-xxhdpi/round_more_time_white_24.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
app/src/main/res/drawable-xxhdpi/round_more_time_white_36.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-xxhdpi/round_more_time_white_48.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_more_time_white_18.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
app/src/main/res/drawable-xxxhdpi/round_more_time_white_20.png
Normal file
After Width: | Height: | Size: 791 B |
BIN
app/src/main/res/drawable-xxxhdpi/round_more_time_white_24.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_more_time_white_36.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/round_more_time_white_48.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
16
app/src/main/res/drawable/round_more_time_20.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M8.5,8.53v3.24c0,0.18 0.09,0.34 0.24,0.43l2.52,1.51c0.23,0.14 0.52,0.06 0.66,-0.16l0,0c0.14,-0.23 0.06,-0.53 -0.16,-0.66L9.5,11.55V8.53c0,-0.26 -0.21,-0.48 -0.48,-0.48H8.98C8.71,8.05 8.5,8.26 8.5,8.53z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M13.9,10c0.07,0.32 0.1,0.66 0.1,1c0,2.76 -2.24,5 -5,5s-5,-2.24 -5,-5s2.24,-5 5,-5c0.71,0 1.39,0.15 2,0.42V5.35C10.37,5.13 9.7,5 9,5c-3.31,0 -6,2.69 -6,6s2.69,6 6,6s6,-2.69 6,-6c0,-0.34 -0.04,-0.67 -0.09,-1H13.9z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15,6V4.5C15,4.22 14.78,4 14.5,4h0C14.22,4 14,4.22 14,4.5V6h0h-1.5C12.22,6 12,6.22 12,6.5v0C12,6.78 12.22,7 12.5,7H14v1.5C14,8.78 14.22,9 14.5,9h0C14.78,9 15,8.78 15,8.5V7v0h1.5C16.78,7 17,6.78 17,6.5v0C17,6.22 16.78,6 16.5,6H15z"/>
|
||||
</vector>
|
16
app/src/main/res/drawable/round_more_time_24.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<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="M10.75,8C10.34,8 10,8.34 10,8.75v4.69c0,0.35 0.18,0.67 0.47,0.85l3.64,2.24c0.33,0.2 0.76,0.11 0.97,-0.21c0.23,-0.34 0.12,-0.8 -0.23,-1.01L11.5,13.3V8.75C11.5,8.34 11.16,8 10.75,8z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M17.92,12c0.05,0.33 0.08,0.66 0.08,1c0,3.9 -3.1,7 -7,7s-7,-3.1 -7,-7c0,-3.9 3.1,-7 7,-7c0.7,0 1.37,0.1 2,0.29V4.23C12.36,4.08 11.69,4 11,4c-5,0 -9,4 -9,9s4,9 9,9s9,-4 9,-9c0,-0.34 -0.02,-0.67 -0.06,-1H17.92z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M22,5h-2V3c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1v2h-2c-0.55,0 -1,0.45 -1,1c0,0.55 0.45,1 1,1h2v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1V7h2c0.55,0 1,-0.45 1,-1C23,5.45 22.55,5 22,5z"/>
|
||||
</vector>
|
@ -163,7 +163,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_text_fields_24"
|
||||
android:src="@drawable/round_more_time_24"
|
||||
app:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -28,6 +28,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:format12Hour="h:mm"
|
||||
android:padding="0dp"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
@ -39,6 +40,7 @@
|
||||
android:format12Hour="a"
|
||||
android:format24Hour=""
|
||||
android:padding="0dp"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
@ -62,6 +64,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:format12Hour="h:mm"
|
||||
android:padding="0dp"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
@ -72,6 +75,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:format12Hour="a"
|
||||
android:format24Hour=""
|
||||
android:includeFontPadding="false"
|
||||
android:padding="0dp"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
@ -116,7 +120,8 @@
|
||||
android:id="@+id/clock_bottom_margin_large" />
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/content">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -30,6 +30,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:format12Hour="h:mm"
|
||||
android:includeFontPadding="false"
|
||||
android:padding="0dp"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
@ -41,6 +42,7 @@
|
||||
android:gravity="center"
|
||||
android:format12Hour="a"
|
||||
android:format24Hour=""
|
||||
android:includeFontPadding="false"
|
||||
android:padding="0dp"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
@ -66,6 +68,7 @@
|
||||
android:padding="0dp"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
android:gravity="center_vertical"/>
|
||||
<TextClock
|
||||
@ -75,6 +78,7 @@
|
||||
android:format12Hour="a"
|
||||
android:format24Hour=""
|
||||
android:padding="0dp"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
@ -118,7 +122,8 @@
|
||||
android:id="@+id/clock_bottom_margin_large" />
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/content">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|