Skip to content

Commit

Permalink
Merge pull request #11 from SimpleAppProjects/develop
Browse files Browse the repository at this point in the history
v5.8.3
  • Loading branch information
thewizrd authored Sep 24, 2023
2 parents 94733e5 + 0f7c209 commit aa75264
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 56 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
versionCode 335820400
versionName "5.8.2"
versionCode 335830000
versionName "5.8.3"

vectorDrawables.useSupportLibrary true
}
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,14 @@
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />
android:exported="false"
tools:node="merge">
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,21 @@ import com.thewizrd.shared_resources.weatherdata.model.HourlyForecast
import com.thewizrd.shared_resources.weatherdata.model.Weather
import com.thewizrd.simpleweather.R
import com.thewizrd.simpleweather.main.MainActivity
import com.thewizrd.simpleweather.widgets.preferences.*
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGCOLOR
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGCOLORCODE
import com.thewizrd.simpleweather.widgets.preferences.KEY_BGSTYLE
import com.thewizrd.simpleweather.widgets.preferences.KEY_FORECASTOPTION
import com.thewizrd.simpleweather.widgets.preferences.KEY_ICONSIZE
import com.thewizrd.simpleweather.widgets.preferences.KEY_TEXTSIZE
import com.thewizrd.simpleweather.widgets.preferences.KEY_TXTCOLORCODE
import com.thewizrd.simpleweather.widgets.remoteviews.CustomBackgroundWidgetRemoteViewCreator
import com.thewizrd.simpleweather.widgets.remoteviews.WidgetRemoteViewCreator
import com.thewizrd.weather_api.weatherModule
import kotlinx.coroutines.*
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import java.time.ZonedDateTime
import java.time.temporal.ChronoUnit
import kotlin.math.min
Expand Down Expand Up @@ -312,6 +322,32 @@ object WidgetUpdaterHelper {
WidgetUtils.setMaxForecastLength(appWidgetId, forecasts.size)
WidgetUtils.setMaxHrForecastLength(appWidgetId, hourlyForecasts.size)

if (info.widgetType == WidgetType.Widget4x1) {
updateViews.removeAllViews(R.id.layout_container)
updateViews.addView(
R.id.layout_container, RemoteViews(
context.packageName,
if (forecastPanel != null && hrForecastPanel != null) {
R.layout.app_widget_forecast_layout_anim
} else {
R.layout.app_widget_forecast_layout
}
)
)
} else if (info.widgetType == WidgetType.Widget4x2) {
updateViews.removeAllViews(R.id.forecast_container)
updateViews.addView(
R.id.forecast_container, RemoteViews(
context.packageName,
if (forecastPanel != null && hrForecastPanel != null) {
R.layout.app_widget_forecast_layout_anim
} else {
R.layout.app_widget_forecast_layout
}
)
)
}

if (forecastPanel != null) {
updateViews.addView(R.id.forecast_layout, forecastPanel)
}
Expand Down
14 changes: 1 addition & 13 deletions app/src/main/res/layout/app_widget_4x1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,7 @@
android:layout_weight="1"
android:orientation="horizontal"
android:padding="8dp"
android:baselineAligned="false">

<ViewFlipper
android:id="@+id/forecast_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:autoStart="true"
android:flipInterval="10000"
android:inAnimation="@anim/widget_fade_in"
android:outAnimation="@anim/widget_fade_out" />

</LinearLayout>
android:baselineAligned="false" />

<LinearLayout
android:layout_width="match_parent"
Expand Down
14 changes: 1 addition & 13 deletions app/src/main/res/layout/app_widget_4x1_nolocation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,7 @@
android:layout_weight="1"
android:orientation="horizontal"
android:padding="8dp"
android:baselineAligned="false">

<ViewFlipper
android:id="@+id/forecast_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:autoStart="true"
android:flipInterval="10000"
android:inAnimation="@anim/widget_fade_in"
android:outAnimation="@anim/widget_fade_out" />

</LinearLayout>
android:baselineAligned="false" />

<RelativeLayout
android:layout_width="wrap_content"
Expand Down
16 changes: 6 additions & 10 deletions app/src/main/res/layout/app_widget_4x2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
android:id="@+id/panda_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@id/forecast_layout"
android:layout_alignBottom="@id/forecast_layout"
android:layout_alignTop="@id/forecast_container"
android:layout_alignBottom="@id/forecast_container"
android:adjustViewBounds="true"
android:scaleType="fitXY"
tools:background="@color/colorOnPrimary" />
Expand Down Expand Up @@ -67,7 +67,7 @@
android:id="@+id/layout_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/forecast_layout"
android:layout_above="@id/forecast_container"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:padding="8dp">
Expand Down Expand Up @@ -205,14 +205,10 @@

</LinearLayout>

<ViewFlipper
android:id="@+id/forecast_layout"
<FrameLayout
android:id="@+id/forecast_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:autoStart="true"
android:flipInterval="10000"
android:inAnimation="@anim/widget_fade_in"
android:outAnimation="@anim/widget_fade_out" />
android:layout_alignParentBottom="true" />

</RelativeLayout>
9 changes: 9 additions & 0 deletions app/src/main/res/layout/app_widget_forecast_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/forecast_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:autoStart="true"
android:flipInterval="10000" />
11 changes: 11 additions & 0 deletions app/src/main/res/layout/app_widget_forecast_layout_anim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/forecast_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:autoStart="true"
android:flipInterval="10000"
android:inAnimation="@anim/widget_fade_in"
android:outAnimation="@anim/widget_fade_out" />
4 changes: 2 additions & 2 deletions wearapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
minSdkVersion 26
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)
versionCode 335820401
versionName "5.8.2"
versionCode 335830001
versionName "5.8.3"

vectorDrawables.useSupportLibrary true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.SwitchPreference
import androidx.recyclerview.widget.RecyclerView
import androidx.wear.remote.interactions.RemoteActivityHelper
import androidx.wear.widget.ConfirmationOverlay
import androidx.wear.widget.WearableLinearLayoutManager
import com.thewizrd.common.helpers.LocationPermissionLauncher
import com.thewizrd.common.helpers.backgroundLocationPermissionEnabled
import com.thewizrd.common.helpers.getBackgroundLocationRationale
Expand Down Expand Up @@ -117,6 +119,10 @@ class SettingsActivity : WearableListenerActivity() {

supportFragmentManager.addOnBackStackChangedListener {
fragmentOnBackPressedCallback.isEnabled = supportFragmentManager.backStackEntryCount > 0

supportFragmentManager.findFragmentById(android.R.id.content)?.let { f ->
f.view?.requestFocus()
}
}

// Display the fragment as the main content.
Expand Down Expand Up @@ -1004,5 +1010,9 @@ class SettingsActivity : WearableListenerActivity() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.pref_oslibs, rootKey)
}

override fun onCreateLayoutManager(): RecyclerView.LayoutManager {
return WearableLinearLayoutManager(context, null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ abstract class SwipeDismissPreferenceFragment : PreferenceFragmentCompat() {
return binding.swipeLayout
}

override fun onResume() {
super.onResume()
binding.swipeLayout.requestFocus()
}

override fun onDestroyView() {
binding.swipeLayout.removeCallback(swipeCallback)
super.onDestroyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
)
)

binding.content.addView(recyclerView)

if (params.mCheckedItem > 0) {
if (params.mCheckedItem >= 0) {
recyclerView.addOnChildAttachStateChangeListener(object :
RecyclerView.OnChildAttachStateChangeListener {
override fun onChildViewAttachedToWindow(view: View) {
Expand All @@ -296,7 +294,7 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
view.viewTreeObserver.removeOnPreDrawListener(this)

val height = view.measuredHeight
binding.root.scrollBy(0, params.mCheckedItem * height)
binding.root.scrollTo(0, params.mCheckedItem * height)

return true
}
Expand All @@ -306,6 +304,8 @@ abstract class WearPreferenceDialogFragment : DialogFragment(), WearDialogInterf
override fun onChildViewDetachedFromWindow(view: View) {}
})
}

binding.content.addView(recyclerView)
}

private inner class DialogListAdapter(private val params: WearDialogParams) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class SetupActivity : UserLocaleActivity() {
binding = FragmentSetupBinding.inflate(layoutInflater)
setContentView(binding.root)

supportFragmentManager.addOnBackStackChangedListener {
// Bring focus back
supportFragmentManager.findFragmentById(android.R.id.content)?.let { f ->
f.view?.requestFocus()
} ?: binding.root.requestFocus()
}

// Controls
binding.searchButton.setOnClickListener {
supportFragmentManager.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
Expand All @@ -22,13 +23,15 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.Text
import androidx.wear.compose.material.dialog.Dialog
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
import com.google.android.horologist.compose.navscaffold.scrollableColumn
import com.thewizrd.common.controls.WeatherAlertViewModel
import com.thewizrd.shared_resources.utils.getColorFromAlertSeverity
Expand Down Expand Up @@ -62,9 +65,14 @@ private fun WeatherAlertPanel(
val severityColor = remember(alertSeverityColor) { Color(alertSeverityColor) }

Chip(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
label = {
Text(text = title)
Text(
text = title,
overflow = TextOverflow.Ellipsis
)
},
icon = {
Icon(
Expand Down Expand Up @@ -133,6 +141,7 @@ private fun WeatherAlertPanel(
}

@WearPreviewDevices
@WearPreviewFontScales
@Composable
private fun PreviewWeatherAlertPanel() {
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package com.thewizrd.simpleweather.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.Text
Expand All @@ -32,7 +31,7 @@ fun WeatherDetailItem(
Chip(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 60.dp),
.wrapContentHeight(),
label = {
Text(
text = spannableStringToAnnotatedString(model.label)
Expand Down
Loading

0 comments on commit aa75264

Please sign in to comment.