Use lib strings

This commit is contained in:
sim 2025-01-15 16:13:25 +01:00
parent 1845b608be
commit ac22124244
6 changed files with 25 additions and 36 deletions

View file

@ -14,6 +14,7 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import org.unifiedpush.distributor.sunup.R
import org.unifiedpush.android.distributor.ui.R as LibR
import org.unifiedpush.distributor.sunup.activities.AppAction
import org.unifiedpush.distributor.sunup.activities.AppBarViewModel
import org.unifiedpush.distributor.sunup.activities.publishAction
@ -42,7 +43,7 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
) {
Icon(
imageVector = Icons.Default.MoreVert,
contentDescription = stringResource(R.string.app_bar_dropdown_description)
contentDescription = stringResource(LibR.string.app_bar_dropdown_description)
)
}
Dropdown(
@ -79,7 +80,7 @@ fun Dropdown(expanded: Boolean, onRestart: () -> Unit, onDismiss: () -> Unit, on
DropdownMenuItem(
onClick = onRestart,
text = {
Text(stringResource(R.string.app_dropdown_restart))
Text(stringResource(LibR.string.app_dropdown_restart))
}
)
DropdownMenuItem(
@ -89,7 +90,7 @@ fun Dropdown(expanded: Boolean, onRestart: () -> Unit, onDismiss: () -> Unit, on
},
text = {
Text(
stringResource(R.string.app_dropdown_change_server)
stringResource(LibR.string.app_dropdown_change_server)
)
}
)

View file

@ -15,7 +15,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.unifiedpush.distributor.sunup.BuildConfig
import org.unifiedpush.distributor.sunup.R
import org.unifiedpush.android.distributor.ui.R
@Preview
@Composable

View file

@ -19,7 +19,7 @@ import org.unifiedpush.distributor.sunup.AppStore
import org.unifiedpush.distributor.sunup.DatabaseFactory
import org.unifiedpush.distributor.sunup.Distributor
import org.unifiedpush.distributor.sunup.Distributor.sendMessage
import org.unifiedpush.distributor.sunup.R
import org.unifiedpush.android.distributor.ui.R as LibR
import org.unifiedpush.distributor.sunup.activities.UiAction
import org.unifiedpush.distributor.sunup.api.data.ClientMessage
import org.unifiedpush.distributor.sunup.api.data.ServerMessage
@ -93,7 +93,7 @@ class ServerConnection(private val context: Context, private val releaseLock: ()
Handler(Looper.getMainLooper()).post {
Toast.makeText(
context,
context.getString(R.string.toast_url_candidate_success, it),
context.getString(LibR.string.toast_url_candidate_success, it),
Toast.LENGTH_SHORT
).show()
}
@ -178,7 +178,7 @@ class ServerConnection(private val context: Context, private val releaseLock: ()
Handler(Looper.getMainLooper()).post {
Toast.makeText(
context,
context.getString(R.string.toast_url_candidate_fail, url),
context.getString(LibR.string.toast_url_candidate_fail, url),
Toast.LENGTH_SHORT
).show()
}

View file

@ -6,6 +6,7 @@ import android.content.Context
import java.util.concurrent.atomic.AtomicBoolean
import org.unifiedpush.distributor.AppNotification
import org.unifiedpush.distributor.sunup.R
import org.unifiedpush.android.distributor.ui.R as LibR
import org.unifiedpush.distributor.sunup.activities.MainActivity
import org.unifiedpush.distributor.sunup.services.MainRegistrationCounter
@ -31,9 +32,9 @@ class MainNotificationData(
private val Context.warningChannelData: AppNotification.ChannelData
get() = AppNotification.ChannelData(
"${this.getString(R.string.app_name)}.Warning",
"Warning",
this.getString(LibR.string.warning),
NotificationManager.IMPORTANCE_HIGH,
this.getString(R.string.warning_notif_description)
this.resources.getString(LibR.string.warning_notif_description).format(this.getString(R.string.app_name))
)
class DisconnectedNotification(context: Context) : AppNotification(
@ -42,8 +43,10 @@ class DisconnectedNotification(context: Context) : AppNotification(
NOTIFICATION_ID_WARNING,
MainNotificationData(
context.getString(R.string.app_name),
context.getString(R.string.warning_notif_content),
context.getString(R.string.warning_notif_ticker),
context.getString(LibR.string.warning_notif_content).format(
context.getString(R.string.app_name)
),
context.getString(LibR.string.warning),
Notification.PRIORITY_HIGH,
true
),
@ -57,20 +60,21 @@ class ForegroundNotification(context: Context) : AppNotification(
MainNotificationData(
context.getString(R.string.app_name),
if (MainRegistrationCounter.oneOrMore(context)) {
context.getString(R.string.foreground_notif_content_with_reg)
.format(MainRegistrationCounter.getCount(context))
MainRegistrationCounter.getCount(context).let {
context.resources.getQuantityString(LibR.plurals.foreground_notif_content_with_reg, it, it)
}
} else {
context.getString(R.string.foreground_notif_content_no_reg)
context.getString(LibR.string.foreground_notif_content_no_reg)
},
context.getString(R.string.foreground_notif_ticker),
context.getString(LibR.string.foreground_service),
Notification.PRIORITY_LOW,
true
),
ChannelData(
"${context.getString(R.string.app_name)}.Listener",
"Foreground Service",
context.getString(LibR.string.foreground_service),
NotificationManager.IMPORTANCE_LOW,
context.getString(R.string.foreground_notif_description)
context.getString(LibR.string.foreground_notif_description)
)
)

View file

@ -1,16 +0,0 @@
<resources>
<string name="foreground_notif_description">Notification to run in the foreground</string>
<string name="foreground_notif_content_no_reg">Waiting for registration to connect</string>
<string name="foreground_notif_content_with_reg">Connected for %s registration(s)</string>
<string name="foreground_notif_ticker">Foreground</string>
<string name="app_dropdown_restart">Restart Service</string>
<string name="app_dropdown_change_server">Change server</string>
<string name="warning_notif_content">Sunup is disconnected</string>
<string name="warning_notif_description">Warn when Sunup is disconnected or an issue occurred.</string>
<string name="warning_notif_ticker">Warning</string>
<string name="toast_url_candidate_fail">Fail to use %1$s</string>
<string name="toast_url_candidate_success">Successfully using %1$s</string>
<string name="app_bar_dropdown_description">Actions</string>
<string name="custom_push_server">Custom Push server</string>
<string name="url">URL</string>
</resources>

View file

@ -9,10 +9,10 @@ androidx-lifecycle = "2.8.7"
androidx-runtimeAndroid = "1.7.6"
androidx-work = "2.10.0"
appcompat = "1.7.0"
unifiedpush_distributor = "0.1.0"
unifiedpush_distributor_ui = "0.1.0"
unifiedpush_distributor = "0.1.1"
unifiedpush_distributor_ui = "0.1.1"
kotlin = "2.1.0"
kotlinx_serializationJson = "1.8.0-RC"
kotlinx_serializationJson = "1.8.0"
ktlint = "12.1.2"
material = "1.12.0"
material3Android = "1.3.1"