Skip to content

Commit

Permalink
[CHORE] Replaced all hardcode strings with string resources.
Browse files Browse the repository at this point in the history
 - Updated koltin to 2.1.0, media3 to 1.5.1 and coil to 3.0.4
  • Loading branch information
iZakirSheikh committed Nov 28, 2024
1 parent f0d18da commit aed720d
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 32 deletions.
1 change: 1 addition & 0 deletions .idea/CrowdinSettingsPlugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions app/src/main/java/com/zs/gallery/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
// Future versions might include support for alternative authentication on older Android versions
// if a compatibility library or API becomes available.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P)
setNegativeButton("Dismiss", mainExecutor, { _, _ -> })
setNegativeButton(getString(R.string.dismiss), mainExecutor, { _, _ -> })
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
setConfirmationRequired(false)
/*if (Build.VERSION.SDK_INT >= 35) {
Expand All @@ -237,18 +237,17 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
object : BiometricPrompt.AuthenticationCallback() {
// Implement callback methods for authentication events (success, error, etc.)
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) {
showPlatformToast("Authentication Successful!")
onAuthenticated()
}

override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
showPlatformToast("Authentication Failed! Please try again or use an alternative method.")
showPlatformToast(getString(R.string.msg_auth_failed))
}

override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) {
super.onAuthenticationError(errorCode, errString)
showPlatformToast("Authentication Error: $errString")
showPlatformToast(getString(R.string.msg_auth_error_s, errString))
}
}
)
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/zs/gallery/bin/Trash.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.primex.core.findActivity
import com.primex.core.plus
Expand Down Expand Up @@ -113,15 +114,15 @@ private fun TopAppBar(
actions = {
val context = LocalContext.current
Button(
label = "Restore",
label = stringResource(R.string.restore),
onClick = { viewState.restoreAll(context.findActivity()) },
colors = ButtonDefaults.buttonColors(backgroundColor = AppTheme.colors.background(2.dp)),
shape = CircleShape,
elevation = null,
modifier = Modifier.scale(0.9f)
)
Button(
label = "Empty Bin",
label = stringResource(R.string.empty_bin),
onClick = { viewState.empty(context.findActivity()) },
colors = ButtonDefaults.buttonColors(backgroundColor = AppTheme.colors.background(2.dp)),
shape = CircleShape,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/zs/gallery/impl/AlbumViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AlbumViewModel(
title = buildAnnotatedString {
appendLine(getText(R.string.favourites))
withSpanStyle(fontSize = 10.sp) {
append("${favorites.size} Files")
append(getText(R.string.files_d, favorites.size))
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/zs/gallery/impl/FolderViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.lifecycle.SavedStateHandle
import com.primex.core.withSpanStyle
import com.zs.domain.store.MediaProvider
import com.zs.domain.util.PathUtils
import com.zs.gallery.R
import com.zs.gallery.common.get
import com.zs.gallery.files.FolderViewState
import com.zs.gallery.files.RouteFolder
Expand Down Expand Up @@ -70,7 +71,7 @@ class FolderViewModel(
title = buildAnnotatedString {
appendLine(name)
withSpanStyle(fontSize = 10.sp) {
appendLine("$count files, $size")
appendLine(getText(R.string.files_d, size))
}
}

Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/com/zs/gallery/impl/TrashViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.zs.domain.store.MediaProvider
import com.zs.domain.store.Trashed
import com.zs.gallery.R
import com.zs.gallery.bin.TrashViewState
import com.zs.gallery.common.GroupSelectionLevel
import kotlin.time.Duration.Companion.milliseconds
Expand Down Expand Up @@ -80,10 +81,10 @@ class TrashViewModel(
// Transform the keys to user-friendly labels
.mapKeys { (daysLeft, _) ->
when {
daysLeft <= 0 -> "Today" // Handle expired items
daysLeft == 1L -> "1 day left"
else -> "$daysLeft days left" // Format remaining days
}
daysLeft <= 0 -> getText(R.string.today) // Handle expired items
daysLeft == 1L -> getText(R.string.trash_one_day_left)
else -> getText(R.string.trash_days_left_d, daysLeft) // Format remaining days
}.toString()
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/zs/gallery/impl/ViewerViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ private fun Activity.setWallpaper(uri: Uri) {
setDataAndType(uri, "image/*");
putExtra("mimeType", "image/*");
}
startActivity(Intent.createChooser(intent, "Set as:"));
startActivity(Intent.createChooser(intent, getString(R.string.viewer_set_as)));
} catch (e: Exception) {
// If any other exception occurs, show a toast message to the user
android.widget.Toast.makeText(
this,
"No wallpaper app found",
getString(R.string.viewer_msg_no_wallpaper_app_found),
android.widget.Toast.LENGTH_SHORT
).show()
}
Expand Down
24 changes: 13 additions & 11 deletions app/src/main/java/com/zs/gallery/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.zs.gallery.settings

import android.annotation.SuppressLint
import android.app.Activity
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
Expand All @@ -37,12 +38,14 @@ import androidx.compose.material.icons.outlined.TouchApp
import androidx.compose.runtime.Composable
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.primex.core.textArrayResource
import com.primex.core.textResource
import com.primex.material2.DropDownPreference
import com.primex.material2.IconButton
Expand All @@ -55,15 +58,14 @@ import com.primex.material2.appbar.TopAppBarDefaults
import com.primex.material2.appbar.TopAppBarScrollBehavior
import com.zs.foundation.AppTheme
import com.zs.foundation.Colors
import com.zs.foundation.NightMode
import com.zs.foundation.None
import com.zs.foundation.adaptive.contentInsets
import com.zs.gallery.BuildConfig
import com.zs.gallery.R
import com.zs.gallery.common.LocalNavController
import com.zs.gallery.common.LocalSystemFacade
import com.zs.foundation.NightMode
import com.zs.gallery.common.preference
import androidx.compose.runtime.getValue

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Constants
Expand Down Expand Up @@ -126,8 +128,6 @@ context(ColumnScope)
private inline fun General(
viewState: SettingsViewState
) {


val prefLiveGallery = viewState.liveGallery
SwitchPreference(
title = prefLiveGallery.title,
Expand All @@ -145,12 +145,14 @@ private inline fun General(
title = prefAppLock.title,
defaultValue = prefAppLock.value,
icon = prefAppLock.vector,
entries = listOf(
"App Lock Disabled" to -1,
"Lock Immediately" to 0,
"Lock After 1 Minute" to 1,
"Lock After 30 Minutes" to 30
),
entries = textArrayResource(R.array.pref_app_lock_options).let {
listOf(
it[0]. toString() to -1,
it[1]. toString() to 0,
it[2]. toString() to 1,
it[3]. toString() to 30
)
},
modifier = Modifier
.background(AppTheme.colors.tileBackgroundColor, CentreTileShape),
onRequestChange = {value ->
Expand All @@ -160,7 +162,7 @@ private inline fun General(
return@DropDownPreference facade.enroll()
}
// Securely make sure that app_lock is set.
facade.authenticate("Confirm Biometric") {
facade.authenticate((facade as Activity).getString(R.string.auth_confirm_biometric)) {
viewState.set(Settings.KEY_APP_LOCK_TIME_OUT, value)
}
},
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/zs/gallery/viewer/Viewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.draw.scale
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.isUnspecified
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,23 @@
<string name="get">Get</string>
<string name="pref_color_nav_bar">Color NavBar</string>
<string name="pref_color_nav_bar_summery">Use the accent color in the navigation bar.</string>
<string name="dismiss">Dismiss</string>
<string name="msg_auth_failed">Authentication Failed! Please try again or use an alternative method.</string>
<string name="msg_auth_error_s">Authentication Error: %1$s</string>
<string name="restore">Restore</string>
<string name="empty_bin">Empty Bin</string>
<string name="files_d" documentation="returns e.g., 23 Files">%1$s Files</string>
<string name="viewer_msg_no_wallpaper_app_found">Oops! No wallpaper app detected. Install one to proceed.</string>
<string name="viewer_set_as">Set as</string>
<string name="today">Today</string>
<string name="trash_one_day_left">1 day left</string>
<string name="trash_days_left_d">%1$s days left</string>
<string name="auth_confirm_biometric">Confirm Biometric</string>
<string-array documentation= "returns array[4], disabled, immidiately, 1 min, 30 min" name="pref_app_lock_options">
<item>App Lock Disabled</item>
<item>Lock Immediately</item>
<item>Lock After 1 Minute</item>
<item>Lock After 30 Minutes</item>
</string-array>

</resources>
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
agp = "8.7.2"
kotlin = "2.0.21"
kotlin = "2.1.0"
compose = "1.8.0-alpha06"
media3 = "1.4.1"
media3 = "1.5.0"
toolkit = "2.1.0"
material_icons = "1.7.5"
coil = "3.0.2"
coil = "3.0.4"

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down Expand Up @@ -53,7 +53,7 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.0.1" }
androidx-startup-runtime = { module = "androidx.startup:startup-runtime", version = "1.2.0" }
lottie-compose = { module = "com.airbnb.android:lottie-compose", version = "6.6.0" }
saket-zoomable = { module = "me.saket.telephoto:zoomable", version = "0.13.0" }
saket-zoomable = { module = "me.saket.telephoto:zoomable", version = "0.14.0" }
play-app-update-ktx = { module = "com.google.android.play:app-update-ktx", version = "2.1.0" }
play-app-review-ktx = { module = "com.google.android.play:review-ktx", version = "2.0.1" }

Expand Down

0 comments on commit aed720d

Please sign in to comment.