mirror of
https://github.com/breezy-weather/breezy-weather.git
synced 2025-12-07 13:50:05 +00:00
Drop support for Android Lollipop
This commit is contained in:
parent
89dd380c7a
commit
9e4a5fe2e5
22 changed files with 189 additions and 238 deletions
|
|
@ -19,7 +19,6 @@ package org.breezyweather.background.forecast
|
|||
import android.app.Notification
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationCompat
|
||||
import breezyweather.domain.location.model.Location
|
||||
import breezyweather.domain.weather.model.Daily
|
||||
|
|
@ -130,9 +129,7 @@ class ForecastNotificationNotifier(
|
|||
)
|
||||
}.build()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
weather.current?.weatherCode != null
|
||||
) {
|
||||
if (weather.current?.weatherCode != null) {
|
||||
try {
|
||||
notification.javaClass
|
||||
.getMethod("setSmallIcon", Icon::class.java)
|
||||
|
|
@ -144,7 +141,7 @@ class ForecastNotificationNotifier(
|
|||
daytime
|
||||
)
|
||||
)
|
||||
} catch (ignore: Exception) {
|
||||
} catch (_: Exception) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,13 +177,6 @@ class WeatherContentProvider : ContentProvider() {
|
|||
selectionArgs: Array<String>?,
|
||||
sortOrder: String?,
|
||||
): Cursor? {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
// Disable the content provider on SDK < 23 since it grants dangerous
|
||||
// permissions at install-time
|
||||
Log.w(TAG, "Content provider read is only available for SDK >= 23")
|
||||
return null
|
||||
}
|
||||
|
||||
if (!isAllowedPackage()) {
|
||||
Log.w(TAG, "Content provider is disabled for this app")
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ class AppUpdateChecker @Inject constructor(
|
|||
forceCheck: Boolean = false,
|
||||
): GetApplicationRelease.Result {
|
||||
// Disable app update checks for older Android versions that we're going to drop support for
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
/*if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
AppUpdateNotifier(context).promptOldAndroidVersion()
|
||||
return GetApplicationRelease.Result.OsTooOld
|
||||
}
|
||||
}*/
|
||||
|
||||
return withIOContext {
|
||||
val result = getApplicationRelease.await(
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ class WeatherUpdateJob @AssistedInject constructor(
|
|||
}
|
||||
} finally {
|
||||
notifier.cancelProgressNotification()
|
||||
// if (BuildConfig.FLAVOR != "freenet" && SettingsManager.getInstance(context).isAppUpdateCheckEnabled) {
|
||||
if ((BuildConfig.FLAVOR != "freenet" && SettingsManager.getInstance(context).isAppUpdateCheckEnabled) ||
|
||||
/*if ((BuildConfig.FLAVOR != "freenet" && SettingsManager.getInstance(context).isAppUpdateCheckEnabled) ||
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
||||
) {
|
||||
) {*/
|
||||
if (BuildConfig.FLAVOR != "freenet" && SettingsManager.getInstance(context).isAppUpdateCheckEnabled) {
|
||||
try {
|
||||
updateChecker.checkForUpdate(context, forceCheck = false)
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
|
|
@ -17,14 +17,11 @@
|
|||
package org.breezyweather.common.actionmodecallback
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.view.ActionMode
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
internal class BreezyFloatingTextActionModeCallback(
|
||||
private val callback: BreezyTextActionModeCallback,
|
||||
) : ActionMode.Callback2() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.view.ActionMode
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.platform.TextToolbar
|
||||
import androidx.compose.ui.platform.TextToolbarStatus
|
||||
|
|
@ -49,40 +48,36 @@ internal class BreezyTextToolbar(
|
|||
textActionModeCallback.rect = rect
|
||||
textActionModeCallback.onCopyRequested = onCopyRequested
|
||||
textActionModeCallback.onSelectAllRequested = onSelectAllRequested
|
||||
textActionModeCallback.onTranslateRequested = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
{
|
||||
// Get selected text by copying it, then restore the previous clip
|
||||
val clipboardManager = view.context.clipboardManager
|
||||
val previousClipboard = clipboardManager.primaryClip
|
||||
onCopyRequested?.invoke()
|
||||
val text = clipboardManager.text
|
||||
if (previousClipboard != null) {
|
||||
clipboardManager.setPrimaryClip(previousClipboard)
|
||||
} else {
|
||||
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, " "))
|
||||
}
|
||||
|
||||
val intent = Intent().apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
action = Intent.ACTION_TRANSLATE
|
||||
putExtra(Intent.EXTRA_TEXT, text.trim())
|
||||
} else {
|
||||
action = Intent.ACTION_PROCESS_TEXT
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_PROCESS_TEXT, text.trim())
|
||||
putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true)
|
||||
}
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
|
||||
try {
|
||||
view.context.startActivity(Intent.createChooser(intent, ""))
|
||||
} catch (e: Exception) {
|
||||
SnackbarHelper.showSnackbar(view.context.getString(R.string.action_translate_no_app))
|
||||
}
|
||||
textActionModeCallback.onTranslateRequested = {
|
||||
// Get selected text by copying it, then restore the previous clip
|
||||
val clipboardManager = view.context.clipboardManager
|
||||
val previousClipboard = clipboardManager.primaryClip
|
||||
onCopyRequested?.invoke()
|
||||
val text = clipboardManager.text
|
||||
if (previousClipboard != null) {
|
||||
clipboardManager.setPrimaryClip(previousClipboard)
|
||||
} else {
|
||||
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, " "))
|
||||
}
|
||||
|
||||
val intent = Intent().apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
action = Intent.ACTION_TRANSLATE
|
||||
putExtra(Intent.EXTRA_TEXT, text.trim())
|
||||
} else {
|
||||
action = Intent.ACTION_PROCESS_TEXT
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_PROCESS_TEXT, text.trim())
|
||||
putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true)
|
||||
}
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
|
||||
try {
|
||||
view.context.startActivity(Intent.createChooser(intent, ""))
|
||||
} catch (e: Exception) {
|
||||
SnackbarHelper.showSnackbar(view.context.getString(R.string.action_translate_no_app))
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
textActionModeCallback.onShareRequested = {
|
||||
// Get selected text by copying it, then restore the previous clip
|
||||
|
|
@ -112,16 +107,11 @@ internal class BreezyTextToolbar(
|
|||
}
|
||||
if (actionMode == null) {
|
||||
status = TextToolbarStatus.Shown
|
||||
actionMode =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
TextToolbarHelperMethods.startActionMode(
|
||||
view,
|
||||
BreezyFloatingTextActionModeCallback(textActionModeCallback),
|
||||
ActionMode.TYPE_FLOATING
|
||||
)
|
||||
} else {
|
||||
view.startActionMode(BreezyPrimaryTextActionModeCallback(textActionModeCallback))
|
||||
}
|
||||
actionMode = TextToolbarHelperMethods.startActionMode(
|
||||
view,
|
||||
BreezyFloatingTextActionModeCallback(textActionModeCallback),
|
||||
ActionMode.TYPE_FLOATING
|
||||
)
|
||||
} else {
|
||||
actionMode?.invalidate()
|
||||
}
|
||||
|
|
@ -155,9 +145,7 @@ internal class BreezyTextToolbar(
|
|||
* compiled. It is expected that this class will soft-fail verification, but the classes which use
|
||||
* this method will pass.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
internal object TextToolbarHelperMethods {
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun startActionMode(
|
||||
view: View,
|
||||
actionModeCallback: ActionMode.Callback,
|
||||
|
|
@ -166,7 +154,6 @@ internal object TextToolbarHelperMethods {
|
|||
return view.startActionMode(actionModeCallback, type)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun invalidateContentRect(actionMode: ActionMode) {
|
||||
actionMode.invalidateContentRect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,10 +222,6 @@ fun Window.setSystemBarStyle(
|
|||
val colorSystemBarDark = Color.argb(0x80, 0x1b, 0x1b, 0x1b)
|
||||
val colorSystemBarLight = Color.argb(0xe6, 0xFF, 0xFF, 0xFF)
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
// Always apply a dark shader as a light or transparent status bar is not supported
|
||||
newLightStatus = false
|
||||
}
|
||||
statusBarColor = Color.TRANSPARENT
|
||||
|
||||
navigationBarColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && lightStatus) {
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ abstract class AbstractWidgetConfigActivity : BreezyActivity() {
|
|||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun bindWallpaper(checkPermissions: Boolean) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkPermissions) {
|
||||
if (checkPermissions) {
|
||||
val hasPermission = checkPermissions(0)
|
||||
if (!hasPermission) {
|
||||
return
|
||||
|
|
@ -674,7 +674,6 @@ abstract class AbstractWidgetConfigActivity : BreezyActivity() {
|
|||
* @return true : already got permissions.
|
||||
* false: request permissions.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun checkPermissions(requestCode: Int): Boolean {
|
||||
if (!hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), requestCode)
|
||||
|
|
@ -779,10 +778,7 @@ abstract class AbstractWidgetConfigActivity : BreezyActivity() {
|
|||
updateHostView()
|
||||
return
|
||||
}
|
||||
var hasPermission = true
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
hasPermission = checkPermissions(1)
|
||||
}
|
||||
val hasPermission = checkPermissions(1)
|
||||
if (hasPermission) {
|
||||
updateHostView()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ object MultiCityWidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
val notification = context.notificationBuilder(Notifications.CHANNEL_WIDGET).apply {
|
||||
priority = NotificationCompat.PRIORITY_MAX
|
||||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
if (temperature != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (temperature != null) {
|
||||
setSmallIcon(
|
||||
IconCompat.createWithBitmap(
|
||||
ResourceHelper.createTempBitmap(context, temperature, temperatureUnit)
|
||||
|
|
@ -110,7 +110,7 @@ object MultiCityWidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
setOnlyAlertOnce(true)
|
||||
}.build()
|
||||
|
||||
if (!tempIcon && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!tempIcon) {
|
||||
current.weatherCode?.let { weatherCode ->
|
||||
try {
|
||||
notification.javaClass
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ object NativeWidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
val notification = context.notificationBuilder(Notifications.CHANNEL_WIDGET).apply {
|
||||
priority = NotificationCompat.PRIORITY_MAX
|
||||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
if (temperature != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (temperature != null) {
|
||||
setSmallIcon(
|
||||
IconCompat.createWithBitmap(
|
||||
ResourceHelper.createTempBitmap(context, temperature, temperatureUnit)
|
||||
|
|
@ -123,7 +123,7 @@ object NativeWidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
setContentIntent(getWeatherPendingIntent(context, null, Notifications.ID_WIDGET))
|
||||
}.build()
|
||||
|
||||
if (!tempIcon && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!tempIcon) {
|
||||
current.weatherCode?.let { weatherCode ->
|
||||
try {
|
||||
notification.javaClass
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ object WidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
val notification = context.notificationBuilder(Notifications.CHANNEL_WIDGET).apply {
|
||||
priority = NotificationCompat.PRIORITY_MAX
|
||||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
if (temperature != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (temperature != null) {
|
||||
setSmallIcon(
|
||||
IconCompat.createWithBitmap(
|
||||
ResourceHelper.createTempBitmap(context, temperature, temperatureUnit)
|
||||
|
|
@ -139,7 +139,7 @@ object WidgetNotificationIMP : AbstractRemoteViewsPresenter() {
|
|||
setOnlyAlertOnce(true)
|
||||
}.build()
|
||||
|
||||
if (!tempIcon && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!tempIcon) {
|
||||
current.weatherCode?.let { weatherCode ->
|
||||
try {
|
||||
notification.javaClass
|
||||
|
|
|
|||
|
|
@ -362,8 +362,7 @@ class MainActivity : BreezyActivity(), HomeFragment.Callback, ManagementFragment
|
|||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.locationPermissionsRequest.collect {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
it != null &&
|
||||
if (it != null &&
|
||||
it.permissionList.isNotEmpty() &&
|
||||
it.consume()
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ class MainActivityViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || !checkPermissions) {
|
||||
if (!checkPermissions) {
|
||||
updating = true
|
||||
SettingsManager.getInstance(getApplication())
|
||||
.weatherManualUpdateLastTimestamp = Date().time
|
||||
|
|
|
|||
|
|
@ -235,35 +235,33 @@ fun BackgroundSettingsScreen(
|
|||
largeSeparatorItem()
|
||||
|
||||
sectionHeaderItem(R.string.settings_background_updates_section_troubleshoot)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
clickablePreferenceItem(R.string.settings_background_updates_battery_optimization) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = R.string.settings_background_updates_battery_optimization_summary,
|
||||
isFirst = true
|
||||
) {
|
||||
val packageName: String = context.packageName
|
||||
if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) {
|
||||
try {
|
||||
@SuppressLint("BatteryLife")
|
||||
val intent = Intent().apply {
|
||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = "package:$packageName".toUri()
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(
|
||||
R.string.settings_background_updates_battery_optimization_activity_not_found
|
||||
)
|
||||
)
|
||||
clickablePreferenceItem(R.string.settings_background_updates_battery_optimization) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = R.string.settings_background_updates_battery_optimization_summary,
|
||||
isFirst = true
|
||||
) {
|
||||
val packageName: String = context.packageName
|
||||
if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) {
|
||||
try {
|
||||
@SuppressLint("BatteryLife")
|
||||
val intent = Intent().apply {
|
||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = "package:$packageName".toUri()
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
} else {
|
||||
context.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_background_updates_battery_optimization_disabled)
|
||||
context.getString(
|
||||
R.string.settings_background_updates_battery_optimization_activity_not_found
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_background_updates_battery_optimization_disabled)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,28 +171,59 @@ fun LocationSettingsScreen(
|
|||
sectionFooterItem(R.string.settings_location_section_general)
|
||||
largeSeparatorItem()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
sectionHeaderItem(R.string.location_service_native)
|
||||
clickablePreferenceItem(R.string.settings_location_access_switch_title) { id ->
|
||||
sectionHeaderItem(R.string.location_service_native)
|
||||
clickablePreferenceItem(R.string.settings_location_access_switch_title) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = if (accessCoarseLocationPermissionState.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_switch_summaryOn
|
||||
} else {
|
||||
R.string.settings_location_access_switch_summaryOff
|
||||
},
|
||||
isFirst = true,
|
||||
isLast = accessBackgroundLocationPermissionState == null &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.S,
|
||||
onClick = {
|
||||
if (accessCoarseLocationPermissionState.status != PermissionStatus.Granted) {
|
||||
if (
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
context,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
)
|
||||
) {
|
||||
accessCoarseLocationPermissionState.launchPermissionRequest()
|
||||
} else {
|
||||
context.openApplicationDetailsSettings()
|
||||
}
|
||||
} else {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_location_access_permission_already_granted)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
accessBackgroundLocationPermissionState?.let {
|
||||
smallSeparatorItem()
|
||||
clickablePreferenceItem(R.string.settings_location_access_background_title) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = if (accessCoarseLocationPermissionState.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_switch_summaryOn
|
||||
summaryId = if (it.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_background_summaryOn
|
||||
} else {
|
||||
R.string.settings_location_access_switch_summaryOff
|
||||
R.string.settings_location_access_background_summaryOff
|
||||
},
|
||||
isFirst = true,
|
||||
isLast = accessBackgroundLocationPermissionState == null &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.S,
|
||||
enabled = accessCoarseLocationPermissionState.status == PermissionStatus.Granted,
|
||||
isLast = Build.VERSION.SDK_INT < Build.VERSION_CODES.S,
|
||||
onClick = {
|
||||
if (accessCoarseLocationPermissionState.status != PermissionStatus.Granted) {
|
||||
if (it.status != PermissionStatus.Granted) {
|
||||
if (
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
context,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION
|
||||
)
|
||||
) {
|
||||
accessCoarseLocationPermissionState.launchPermissionRequest()
|
||||
it.launchPermissionRequest()
|
||||
} else {
|
||||
context.openApplicationDetailsSettings()
|
||||
}
|
||||
|
|
@ -204,74 +235,41 @@ fun LocationSettingsScreen(
|
|||
}
|
||||
)
|
||||
}
|
||||
accessBackgroundLocationPermissionState?.let {
|
||||
smallSeparatorItem()
|
||||
clickablePreferenceItem(R.string.settings_location_access_background_title) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = if (it.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_background_summaryOn
|
||||
} else {
|
||||
R.string.settings_location_access_background_summaryOff
|
||||
},
|
||||
enabled = accessCoarseLocationPermissionState.status == PermissionStatus.Granted,
|
||||
isLast = Build.VERSION.SDK_INT < Build.VERSION_CODES.S,
|
||||
onClick = {
|
||||
if (it.status != PermissionStatus.Granted) {
|
||||
if (
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
context,
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION
|
||||
)
|
||||
) {
|
||||
it.launchPermissionRequest()
|
||||
} else {
|
||||
context.openApplicationDetailsSettings()
|
||||
}
|
||||
} else {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_location_access_permission_already_granted)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
smallSeparatorItem()
|
||||
clickablePreferenceItem(R.string.settings_location_access_precise_title) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = if (accessFineLocationPermissionState.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_precise_summaryOn
|
||||
} else {
|
||||
R.string.settings_location_access_precise_summaryOff
|
||||
},
|
||||
enabled = accessCoarseLocationPermissionState.status == PermissionStatus.Granted,
|
||||
isLast = true,
|
||||
onClick = {
|
||||
if (accessFineLocationPermissionState.status != PermissionStatus.Granted) {
|
||||
if (
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
context,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
)
|
||||
) {
|
||||
accessFineLocationPermissionState.launchPermissionRequest()
|
||||
} else {
|
||||
context.openApplicationDetailsSettings()
|
||||
}
|
||||
} else {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_location_access_permission_already_granted)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
sectionFooterItem(R.string.location_service_native)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
smallSeparatorItem()
|
||||
clickablePreferenceItem(R.string.settings_location_access_precise_title) { id ->
|
||||
PreferenceViewWithCard(
|
||||
titleId = id,
|
||||
summaryId = if (accessFineLocationPermissionState.status == PermissionStatus.Granted) {
|
||||
R.string.settings_location_access_precise_summaryOn
|
||||
} else {
|
||||
R.string.settings_location_access_precise_summaryOff
|
||||
},
|
||||
enabled = accessCoarseLocationPermissionState.status == PermissionStatus.Granted,
|
||||
isLast = true,
|
||||
onClick = {
|
||||
if (accessFineLocationPermissionState.status != PermissionStatus.Granted) {
|
||||
if (
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
context,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
)
|
||||
) {
|
||||
accessFineLocationPermissionState.launchPermissionRequest()
|
||||
} else {
|
||||
context.openApplicationDetailsSettings()
|
||||
}
|
||||
} else {
|
||||
SnackbarHelper.showSnackbar(
|
||||
context.getString(R.string.settings_location_access_permission_already_granted)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
sectionFooterItem(R.string.location_service_native)
|
||||
|
||||
// TODO: Duplicate code from weather sources
|
||||
locationSources.filterIsInstance<ConfigurableSource>().forEach { preferenceSource ->
|
||||
|
|
|
|||
|
|
@ -324,7 +324,6 @@ fun ModulesSettingsScreen(
|
|||
nameArrayId = R.array.notification_styles,
|
||||
enabled = notificationEnabled && hasNotificationPermission,
|
||||
card = true,
|
||||
isLast = Build.VERSION.SDK_INT < Build.VERSION_CODES.M,
|
||||
onValueChanged = {
|
||||
SettingsManager
|
||||
.getInstance(context)
|
||||
|
|
@ -333,46 +332,44 @@ fun ModulesSettingsScreen(
|
|||
}
|
||||
)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
smallSeparatorItem()
|
||||
switchPreferenceItem(R.string.settings_modules_notification_temp_icon_switch) { id ->
|
||||
SwitchPreferenceView(
|
||||
titleId = id,
|
||||
summaryOnId = R.string.settings_enabled,
|
||||
summaryOffId = R.string.settings_disabled,
|
||||
checked = SettingsManager
|
||||
smallSeparatorItem()
|
||||
switchPreferenceItem(R.string.settings_modules_notification_temp_icon_switch) { id ->
|
||||
SwitchPreferenceView(
|
||||
titleId = id,
|
||||
summaryOnId = R.string.settings_enabled,
|
||||
summaryOffId = R.string.settings_disabled,
|
||||
checked = SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationTemperatureIconEnabled,
|
||||
enabled = notificationEnabled && hasNotificationPermission,
|
||||
onValueChanged = {
|
||||
SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationTemperatureIconEnabled,
|
||||
enabled = notificationEnabled && hasNotificationPermission,
|
||||
onValueChanged = {
|
||||
SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationTemperatureIconEnabled = it
|
||||
updateNotificationIfNecessary(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
smallSeparatorItem()
|
||||
switchPreferenceItem(R.string.settings_modules_notification_feels_like_switch) { id ->
|
||||
SwitchPreferenceView(
|
||||
titleId = id,
|
||||
summaryOnId = R.string.settings_enabled,
|
||||
summaryOffId = R.string.settings_disabled,
|
||||
checked = SettingsManager
|
||||
.isWidgetNotificationTemperatureIconEnabled = it
|
||||
updateNotificationIfNecessary(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
smallSeparatorItem()
|
||||
switchPreferenceItem(R.string.settings_modules_notification_feels_like_switch) { id ->
|
||||
SwitchPreferenceView(
|
||||
titleId = id,
|
||||
summaryOnId = R.string.settings_enabled,
|
||||
summaryOffId = R.string.settings_disabled,
|
||||
checked = SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationUsingFeelsLike,
|
||||
enabled = notificationEnabled &&
|
||||
hasNotificationPermission &&
|
||||
notificationTemperatureIconEnabled,
|
||||
isLast = true,
|
||||
onValueChanged = {
|
||||
SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationUsingFeelsLike,
|
||||
enabled = notificationEnabled &&
|
||||
hasNotificationPermission &&
|
||||
notificationTemperatureIconEnabled,
|
||||
isLast = true,
|
||||
onValueChanged = {
|
||||
SettingsManager
|
||||
.getInstance(context)
|
||||
.isWidgetNotificationUsingFeelsLike = it
|
||||
updateNotificationIfNecessary(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
.isWidgetNotificationUsingFeelsLike = it
|
||||
updateNotificationIfNecessary(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
sectionFooterItem(R.string.settings_modules_section_notification_widget)
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ object ResourceHelper {
|
|||
return provider.getMinimalXmlIcon(code, daytime)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
fun getMinimalIcon(
|
||||
provider: ResourceProvider,
|
||||
code: WeatherCode,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ class ChronusResourceProvider(
|
|||
return mDefaultProvider.getMinimalXmlIcon(code, dayTime)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun getMinimalIcon(code: WeatherCode?, dayTime: Boolean): Icon {
|
||||
return mDefaultProvider.getMinimalIcon(code, dayTime)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ class DefaultResourceProvider : ResourceProvider() {
|
|||
return getDrawable(getMiniXmlIconName(code, dayTime))!!
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun getMinimalIcon(code: WeatherCode?, dayTime: Boolean): Icon {
|
||||
return Objects.requireNonNull(
|
||||
Icon.createWithResource(
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ import android.content.pm.PackageManager
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.annotation.IntRange
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.Size
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import breezyweather.domain.weather.reference.WeatherCode
|
||||
|
|
@ -338,12 +336,11 @@ open class IconPackResourcesProvider(
|
|||
if (mConfig.hasMinimalIcons) {
|
||||
return getDrawable(getMiniXmlIconName(code, dayTime))!!
|
||||
}
|
||||
} catch (ignore: Exception) {
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
return mDefaultProvider.getMinimalXmlIcon(code, dayTime)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun getMinimalIcon(code: WeatherCode?, dayTime: Boolean): Icon {
|
||||
try {
|
||||
if (mConfig.hasMinimalIcons) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ abstract class ResourceProvider {
|
|||
abstract fun getWeatherAnimators(code: WeatherCode?, dayTime: Boolean): Array<Animator?>
|
||||
|
||||
// minimal icon.
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
abstract fun getMinimalIcon(code: WeatherCode?, dayTime: Boolean): Icon
|
||||
abstract fun getMinimalLightIcon(code: WeatherCode?, dayTime: Boolean): Drawable
|
||||
abstract fun getMinimalLightIconUri(code: WeatherCode?, dayTime: Boolean): Uri
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget as KotlinJvmTarget
|
|||
|
||||
object AndroidConfig {
|
||||
const val COMPILE_SDK = 36
|
||||
const val MIN_SDK = 21
|
||||
const val MIN_SDK = 23
|
||||
const val TARGET_SDK = 36
|
||||
const val BUILD_TOOLS = "35.0.1"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue