Skip to content

Commit aa75264

Browse files
authored
Merge pull request #11 from SimpleAppProjects/develop
v5.8.3
2 parents 94733e5 + 0f7c209 commit aa75264

21 files changed

+153
-56
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
minSdkVersion rootProject.minSdkVersion
1515
targetSdkVersion rootProject.targetSdkVersion
1616
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
17-
versionCode 335820400
18-
versionName "5.8.2"
17+
versionCode 335830000
18+
versionName "5.8.3"
1919

2020
vectorDrawables.useSupportLibrary true
2121
}

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@
358358
<provider
359359
android:name="androidx.startup.InitializationProvider"
360360
android:authorities="${applicationId}.androidx-startup"
361-
tools:node="remove" />
361+
android:exported="false"
362+
tools:node="merge">
363+
<!-- If you are using androidx.startup to initialize other components -->
364+
<meta-data
365+
android:name="androidx.work.WorkManagerInitializer"
366+
android:value="androidx.startup"
367+
tools:node="remove" />
368+
</provider>
362369

363370
<service
364371
android:name="androidx.work.impl.foreground.SystemForegroundService"

app/src/main/java/com/thewizrd/simpleweather/widgets/WidgetUpdaterHelper.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,21 @@ import com.thewizrd.shared_resources.weatherdata.model.HourlyForecast
3232
import com.thewizrd.shared_resources.weatherdata.model.Weather
3333
import com.thewizrd.simpleweather.R
3434
import com.thewizrd.simpleweather.main.MainActivity
35-
import com.thewizrd.simpleweather.widgets.preferences.*
35+
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGCOLOR
36+
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGCOLORCODE
37+
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGSTYLE
38+
import com.thewizrd.simpleweather.widgets.preferences.KEY_FORECASTOPTION
39+
import com.thewizrd.simpleweather.widgets.preferences.KEY_ICONSIZE
40+
import com.thewizrd.simpleweather.widgets.preferences.KEY_TEXTSIZE
41+
import com.thewizrd.simpleweather.widgets.preferences.KEY_TXTCOLORCODE
3642
import com.thewizrd.simpleweather.widgets.remoteviews.CustomBackgroundWidgetRemoteViewCreator
3743
import com.thewizrd.simpleweather.widgets.remoteviews.WidgetRemoteViewCreator
3844
import com.thewizrd.weather_api.weatherModule
39-
import kotlinx.coroutines.*
45+
import kotlinx.coroutines.Deferred
46+
import kotlinx.coroutines.Dispatchers
47+
import kotlinx.coroutines.async
48+
import kotlinx.coroutines.awaitAll
49+
import kotlinx.coroutines.coroutineScope
4050
import java.time.ZonedDateTime
4151
import java.time.temporal.ChronoUnit
4252
import kotlin.math.min
@@ -312,6 +322,32 @@ object WidgetUpdaterHelper {
312322
WidgetUtils.setMaxForecastLength(appWidgetId, forecasts.size)
313323
WidgetUtils.setMaxHrForecastLength(appWidgetId, hourlyForecasts.size)
314324

325+
if (info.widgetType == WidgetType.Widget4x1) {
326+
updateViews.removeAllViews(R.id.layout_container)
327+
updateViews.addView(
328+
R.id.layout_container, RemoteViews(
329+
context.packageName,
330+
if (forecastPanel != null && hrForecastPanel != null) {
331+
R.layout.app_widget_forecast_layout_anim
332+
} else {
333+
R.layout.app_widget_forecast_layout
334+
}
335+
)
336+
)
337+
} else if (info.widgetType == WidgetType.Widget4x2) {
338+
updateViews.removeAllViews(R.id.forecast_container)
339+
updateViews.addView(
340+
R.id.forecast_container, RemoteViews(
341+
context.packageName,
342+
if (forecastPanel != null && hrForecastPanel != null) {
343+
R.layout.app_widget_forecast_layout_anim
344+
} else {
345+
R.layout.app_widget_forecast_layout
346+
}
347+
)
348+
)
349+
}
350+
315351
if (forecastPanel != null) {
316352
updateViews.addView(R.id.forecast_layout, forecastPanel)
317353
}

app/src/main/res/layout/app_widget_4x1.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,7 @@
2222
android:layout_weight="1"
2323
android:orientation="horizontal"
2424
android:padding="8dp"
25-
android:baselineAligned="false">
26-
27-
<ViewFlipper
28-
android:id="@+id/forecast_layout"
29-
android:layout_width="match_parent"
30-
android:layout_height="wrap_content"
31-
android:layout_gravity="center_vertical"
32-
android:autoStart="true"
33-
android:flipInterval="10000"
34-
android:inAnimation="@anim/widget_fade_in"
35-
android:outAnimation="@anim/widget_fade_out" />
36-
37-
</LinearLayout>
25+
android:baselineAligned="false" />
3826

3927
<LinearLayout
4028
android:layout_width="match_parent"

app/src/main/res/layout/app_widget_4x1_nolocation.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,7 @@
2424
android:layout_weight="1"
2525
android:orientation="horizontal"
2626
android:padding="8dp"
27-
android:baselineAligned="false">
28-
29-
<ViewFlipper
30-
android:id="@+id/forecast_layout"
31-
android:layout_width="match_parent"
32-
android:layout_height="wrap_content"
33-
android:layout_gravity="center_vertical"
34-
android:autoStart="true"
35-
android:flipInterval="10000"
36-
android:inAnimation="@anim/widget_fade_in"
37-
android:outAnimation="@anim/widget_fade_out" />
38-
39-
</LinearLayout>
27+
android:baselineAligned="false" />
4028

4129
<RelativeLayout
4230
android:layout_width="wrap_content"

app/src/main/res/layout/app_widget_4x2.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
android:id="@+id/panda_container"
1818
android:layout_width="match_parent"
1919
android:layout_height="wrap_content"
20-
android:layout_alignTop="@id/forecast_layout"
21-
android:layout_alignBottom="@id/forecast_layout"
20+
android:layout_alignTop="@id/forecast_container"
21+
android:layout_alignBottom="@id/forecast_container"
2222
android:adjustViewBounds="true"
2323
android:scaleType="fitXY"
2424
tools:background="@color/colorOnPrimary" />
@@ -67,7 +67,7 @@
6767
android:id="@+id/layout_container"
6868
android:layout_width="match_parent"
6969
android:layout_height="wrap_content"
70-
android:layout_above="@id/forecast_layout"
70+
android:layout_above="@id/forecast_container"
7171
android:layout_alignParentTop="true"
7272
android:orientation="vertical"
7373
android:padding="8dp">
@@ -205,14 +205,10 @@
205205

206206
</LinearLayout>
207207

208-
<ViewFlipper
209-
android:id="@+id/forecast_layout"
208+
<FrameLayout
209+
android:id="@+id/forecast_container"
210210
android:layout_width="match_parent"
211211
android:layout_height="wrap_content"
212-
android:layout_alignParentBottom="true"
213-
android:autoStart="true"
214-
android:flipInterval="10000"
215-
android:inAnimation="@anim/widget_fade_in"
216-
android:outAnimation="@anim/widget_fade_out" />
212+
android:layout_alignParentBottom="true" />
217213

218214
</RelativeLayout>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/forecast_layout"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:layout_alignParentBottom="true"
7+
android:layout_gravity="center_vertical"
8+
android:autoStart="true"
9+
android:flipInterval="10000" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/forecast_layout"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:layout_alignParentBottom="true"
7+
android:layout_gravity="center_vertical"
8+
android:autoStart="true"
9+
android:flipInterval="10000"
10+
android:inAnimation="@anim/widget_fade_in"
11+
android:outAnimation="@anim/widget_fade_out" />

wearapp/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
minSdkVersion 26
1515
targetSdkVersion rootProject.targetSdkVersion
1616
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
17-
versionCode 335820401
18-
versionName "5.8.2"
17+
versionCode 335830001
18+
versionName "5.8.3"
1919

2020
vectorDrawables.useSupportLibrary true
2121
}

wearapp/src/main/java/com/thewizrd/simpleweather/preferences/SettingsActivity.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import androidx.preference.ListPreference
2828
import androidx.preference.Preference
2929
import androidx.preference.PreferenceCategory
3030
import androidx.preference.SwitchPreference
31+
import androidx.recyclerview.widget.RecyclerView
3132
import androidx.wear.remote.interactions.RemoteActivityHelper
3233
import androidx.wear.widget.ConfirmationOverlay
34+
import androidx.wear.widget.WearableLinearLayoutManager
3335
import com.thewizrd.common.helpers.LocationPermissionLauncher
3436
import com.thewizrd.common.helpers.backgroundLocationPermissionEnabled
3537
import com.thewizrd.common.helpers.getBackgroundLocationRationale
@@ -117,6 +119,10 @@ class SettingsActivity : WearableListenerActivity() {
117119

118120
supportFragmentManager.addOnBackStackChangedListener {
119121
fragmentOnBackPressedCallback.isEnabled = supportFragmentManager.backStackEntryCount > 0
122+
123+
supportFragmentManager.findFragmentById(android.R.id.content)?.let { f ->
124+
f.view?.requestFocus()
125+
}
120126
}
121127

122128
// Display the fragment as the main content.
@@ -1004,5 +1010,9 @@ class SettingsActivity : WearableListenerActivity() {
10041010
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
10051011
setPreferencesFromResource(R.xml.pref_oslibs, rootKey)
10061012
}
1013+
1014+
override fun onCreateLayoutManager(): RecyclerView.LayoutManager {
1015+
return WearableLinearLayoutManager(context, null)
1016+
}
10071017
}
10081018
}

wearapp/src/main/java/com/thewizrd/simpleweather/preferences/SwipeDismissPreferenceFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ abstract class SwipeDismissPreferenceFragment : PreferenceFragmentCompat() {
8181
return binding.swipeLayout
8282
}
8383

84+
override fun onResume() {
85+
super.onResume()
86+
binding.swipeLayout.requestFocus()
87+
}
88+
8489
override fun onDestroyView() {
8590
binding.swipeLayout.removeCallback(swipeCallback)
8691
super.onDestroyView()

wearapp/src/main/java/com/thewizrd/simpleweather/preferences/WearPreferenceDialogFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
282282
)
283283
)
284284

285-
binding.content.addView(recyclerView)
286-
287-
if (params.mCheckedItem > 0) {
285+
if (params.mCheckedItem >= 0) {
288286
recyclerView.addOnChildAttachStateChangeListener(object :
289287
RecyclerView.OnChildAttachStateChangeListener {
290288
override fun onChildViewAttachedToWindow(view: View) {
@@ -296,7 +294,7 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
296294
view.viewTreeObserver.removeOnPreDrawListener(this)
297295

298296
val height = view.measuredHeight
299-
binding.root.scrollBy(0, params.mCheckedItem * height)
297+
binding.root.scrollTo(0, params.mCheckedItem * height)
300298

301299
return true
302300
}
@@ -306,6 +304,8 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
306304
override fun onChildViewDetachedFromWindow(view: View) {}
307305
})
308306
}
307+
308+
binding.content.addView(recyclerView)
309309
}
310310

311311
private inner class DialogListAdapter(private val params: WearDialogParams) :

wearapp/src/main/java/com/thewizrd/simpleweather/setup/SetupActivity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class SetupActivity : UserLocaleActivity() {
4949
binding = FragmentSetupBinding.inflate(layoutInflater)
5050
setContentView(binding.root)
5151

52+
supportFragmentManager.addOnBackStackChangedListener {
53+
// Bring focus back
54+
supportFragmentManager.findFragmentById(android.R.id.content)?.let { f ->
55+
f.view?.requestFocus()
56+
} ?: binding.root.requestFocus()
57+
}
58+
5259
// Controls
5360
binding.searchButton.setOnClickListener {
5461
supportFragmentManager.beginTransaction()

wearapp/src/main/java/com/thewizrd/simpleweather/ui/components/WeatherAlertPanel.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
88
import androidx.compose.foundation.layout.fillMaxWidth
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.foundation.layout.size
11+
import androidx.compose.foundation.layout.wrapContentHeight
1112
import androidx.compose.foundation.layout.wrapContentSize
1213
import androidx.compose.foundation.shape.CircleShape
1314
import androidx.compose.runtime.Composable
@@ -22,13 +23,15 @@ import androidx.compose.ui.focus.FocusRequester
2223
import androidx.compose.ui.graphics.Color
2324
import androidx.compose.ui.res.painterResource
2425
import androidx.compose.ui.text.style.TextAlign
26+
import androidx.compose.ui.text.style.TextOverflow
2527
import androidx.compose.ui.unit.dp
2628
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
2729
import androidx.wear.compose.material.Chip
2830
import androidx.wear.compose.material.ChipDefaults
2931
import androidx.wear.compose.material.Icon
3032
import androidx.wear.compose.material.Text
3133
import androidx.wear.compose.material.dialog.Dialog
34+
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
3235
import com.google.android.horologist.compose.navscaffold.scrollableColumn
3336
import com.thewizrd.common.controls.WeatherAlertViewModel
3437
import com.thewizrd.shared_resources.utils.getColorFromAlertSeverity
@@ -62,9 +65,14 @@ private fun WeatherAlertPanel(
6265
val severityColor = remember(alertSeverityColor) { Color(alertSeverityColor) }
6366

6467
Chip(
65-
modifier = Modifier.fillMaxWidth(),
68+
modifier = Modifier
69+
.fillMaxWidth()
70+
.wrapContentHeight(),
6671
label = {
67-
Text(text = title)
72+
Text(
73+
text = title,
74+
overflow = TextOverflow.Ellipsis
75+
)
6876
},
6977
icon = {
7078
Icon(
@@ -133,6 +141,7 @@ private fun WeatherAlertPanel(
133141
}
134142

135143
@WearPreviewDevices
144+
@WearPreviewFontScales
136145
@Composable
137146
private fun PreviewWeatherAlertPanel() {
138147
Box(

wearapp/src/main/java/com/thewizrd/simpleweather/ui/components/WeatherDetailItem.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ package com.thewizrd.simpleweather.ui.components
22

33
import androidx.compose.foundation.Image
44
import androidx.compose.foundation.layout.fillMaxWidth
5-
import androidx.compose.foundation.layout.heightIn
65
import androidx.compose.foundation.layout.size
6+
import androidx.compose.foundation.layout.wrapContentHeight
77
import androidx.compose.foundation.layout.wrapContentSize
88
import androidx.compose.runtime.Composable
99
import androidx.compose.ui.Alignment
1010
import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.draw.rotate
1212
import androidx.compose.ui.platform.LocalInspectionMode
1313
import androidx.compose.ui.res.painterResource
14-
import androidx.compose.ui.unit.dp
1514
import androidx.wear.compose.material.Chip
1615
import androidx.wear.compose.material.ChipDefaults
1716
import androidx.wear.compose.material.Text
@@ -32,7 +31,7 @@ fun WeatherDetailItem(
3231
Chip(
3332
modifier = Modifier
3433
.fillMaxWidth()
35-
.heightIn(min = 60.dp),
34+
.wrapContentHeight(),
3635
label = {
3736
Text(
3837
text = spannableStringToAnnotatedString(model.label)

0 commit comments

Comments
 (0)