Merge develop
This commit is contained in:
commit
c595168320
5
.gitignore
vendored
5
.gitignore
vendored
@ -8,4 +8,7 @@
|
||||
.externalNativeBuild
|
||||
/tasksintegration/build
|
||||
/app/google-services.json
|
||||
apikey.properties
|
||||
apikey.properties
|
||||
./.idea/*
|
||||
app/release/*
|
||||
/app/release/*
|
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -23,8 +23,8 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 114
|
||||
versionName "2.1.0"
|
||||
versionCode 115
|
||||
versionName "2.1.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField("String", "GOOGLE_API_KEY", apikeyProperties['GOOGLE_API_KEY'])
|
||||
|
Binary file not shown.
@ -14,7 +14,6 @@
|
||||
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@ -163,5 +162,8 @@
|
||||
|
||||
<queries>
|
||||
<package android:name="com.google.android.apps.fitness"/>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
@ -2,7 +2,10 @@ package com.tommasoberlose.anotherwidget.global
|
||||
|
||||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatDelegate.*
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import com.chibatching.kotpref.KotprefModel
|
||||
import com.tommasoberlose.anotherwidget.utils.isMetric
|
||||
import java.util.*
|
||||
|
||||
object Preferences : KotprefModel() {
|
||||
override val commitAllPropertiesByDefault: Boolean = true
|
||||
@ -14,8 +17,8 @@ object Preferences : KotprefModel() {
|
||||
var showWeather by booleanPref(key = "PREF_SHOW_WEATHER", default = false)
|
||||
var weatherIcon by stringPref(key = "PREF_WEATHER_ICON", default = "")
|
||||
var weatherTemp by floatPref(key = "PREF_WEATHER_TEMP", default = 0f)
|
||||
var weatherTempUnit by stringPref(key = "PREF_WEATHER_TEMP_UNIT", default = "F")
|
||||
var weatherRealTempUnit by stringPref(key = "PREF_WEATHER_REAL_TEMP_UNIT", default = "F")
|
||||
var weatherTempUnit by stringPref(key = "PREF_WEATHER_TEMP_UNIT", default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) "C" else "F")
|
||||
var weatherRealTempUnit by stringPref(key = "PREF_WEATHER_REAL_TEMP_UNIT", default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) "C" else "F")
|
||||
var calendarAllDay by booleanPref(key = "PREF_CALENDAR_ALL_DAY", default = true)
|
||||
var calendarFilter by stringPref(key = "PREF_CALENDAR_FILTER", default = "")
|
||||
|
||||
@ -43,7 +46,7 @@ object Preferences : KotprefModel() {
|
||||
var weatherProviderApiWeatherApi by stringPref(default = "")
|
||||
var weatherProviderApiWeatherBit by stringPref(default = "")
|
||||
var weatherProviderApiAccuweather by stringPref(default = "")
|
||||
var weatherProvider by intPref(default = Constants.WeatherProvider.OPEN_WEATHER.value)
|
||||
var weatherProvider by intPref(default = if (ConfigurationCompat.getLocales(context.resources.configuration)[0].isMetric()) Constants.WeatherProvider.YR.value else Constants.WeatherProvider.WEATHER_GOV.value)
|
||||
var weatherProviderError by stringPref(default = "")
|
||||
var weatherProviderLocationError by stringPref(default = "")
|
||||
var eventAppName by stringPref(key = "PREF_EVENT_APP_NAME", default = "")
|
||||
|
@ -69,11 +69,7 @@ class CustomLocationActivity : AppCompatActivity() {
|
||||
injector
|
||||
.text(R.id.text, getString(R.string.custom_location_gps))
|
||||
.clicked(R.id.text) {
|
||||
MaterialBottomSheetDialog(this, message = getString(R.string.background_location_warning))
|
||||
.setPositiveButton(getString(android.R.string.ok)) {
|
||||
requirePermission()
|
||||
}
|
||||
.show()
|
||||
requirePermission()
|
||||
}
|
||||
}
|
||||
.register<Address>(R.layout.custom_location_item) { item, injector ->
|
||||
|
@ -117,7 +117,6 @@ class WeatherTabFragment : Fragment() {
|
||||
|
||||
viewModel.customLocationAdd.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
background_location_warning.isVisible = it == ""
|
||||
label_custom_location?.text =
|
||||
if (it == "") getString(R.string.custom_location_gps) else it
|
||||
}
|
||||
@ -163,11 +162,9 @@ class WeatherTabFragment : Fragment() {
|
||||
private fun checkLocationPermission() {
|
||||
if (requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
location_permission_alert?.isVisible = false
|
||||
background_location_warning.isVisible = Preferences.customLocationAdd == ""
|
||||
WeatherReceiver.setUpdates(requireContext())
|
||||
} else if (Preferences.showWeather && Preferences.customLocationAdd == "") {
|
||||
location_permission_alert?.isVisible = true
|
||||
background_location_warning.isVisible = true
|
||||
location_permission_alert?.setOnClickListener {
|
||||
MaterialBottomSheetDialog(requireContext(), message = getString(R.string.background_location_warning))
|
||||
.setPositiveButton(getString(android.R.string.ok)) {
|
||||
|
@ -257,4 +257,11 @@ fun Intent.isDefaultSet(context: Context): Boolean {
|
||||
} catch (ex: java.lang.Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fun Locale.isMetric(): Boolean {
|
||||
return when (country.toUpperCase(this)) {
|
||||
"US", "LR", "MM", "GB" -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
@ -190,20 +190,6 @@
|
||||
android:layout_marginStart="64dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
|
||||
app:textAllCaps="false" />
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:duplicateParentState="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:paddingStart="64dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:id="@+id/background_location_warning"
|
||||
android:text="@string/background_location_warning"
|
||||
android:textColor="@color/colorSecondaryText"
|
||||
android:letterSpacing="0"
|
||||
android:fontFamily="@font/google_sans"
|
||||
android:textAppearance="@style/AnotherWidget.Settings.Subtitle"
|
||||
app:textAllCaps="false" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -164,7 +164,7 @@
|
||||
<string name="location_access_notification_channel_id" translatable="false">location-access</string>
|
||||
<string name="location_access_notification_channel_name">Background service</string>
|
||||
<string name="location_access_notification_channel_description">Service used to update the weather based on the current location of the user.</string>
|
||||
<string name="location_access_notification_title">Weather update</string>
|
||||
<string name="location_access_notification_title">Updating the weather…</string>
|
||||
<string name="location_access_notification_subtitle">We\'re updating the weather based on your current location.</string>
|
||||
|
||||
<!-- Clock -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user