mirror of
https://github.com/Michatec/michas-droid.git
synced 2026-05-31 02:12:42 +02:00
Further rework strings
This commit is contained in:
@@ -315,11 +315,11 @@ class EditRepositoryFragment(): ScreenFragment() {
|
||||
if (usernameInvalid) {
|
||||
layout.usernameError.setText(R.string.invalid_username_format)
|
||||
} else if (usernameEmpty) {
|
||||
layout.usernameError.setText(R.string.username_is_not_specified)
|
||||
layout.usernameError.setText(R.string.username_missing)
|
||||
}
|
||||
layout.username.setError(usernameEmpty)
|
||||
if (passwordEmpty) {
|
||||
layout.passwordError.setText(R.string.password_is_not_specified)
|
||||
layout.passwordError.setText(R.string.password_missing)
|
||||
}
|
||||
layout.password.setError(passwordEmpty)
|
||||
usernamePasswordError = usernameInvalid || usernameEmpty || passwordEmpty
|
||||
@@ -474,7 +474,7 @@ class EditRepositoryFragment(): ScreenFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): AlertDialog {
|
||||
val mirrors = requireArguments().getStringArrayList(EXTRA_MIRRORS)!!
|
||||
return AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.select_the_mirror)
|
||||
.setTitle(R.string.select_mirror)
|
||||
.setItems(mirrors.toTypedArray()) { _, position -> (parentFragment as EditRepositoryFragment)
|
||||
.setMirror(mirrors[position]) }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
|
||||
@@ -126,19 +126,19 @@ class MessageDialog(): DialogFragment() {
|
||||
val dialog = AlertDialog.Builder(requireContext())
|
||||
when (val message = requireArguments().getParcelable<Message>(EXTRA_MESSAGE)!!) {
|
||||
is Message.DeleteRepositoryConfirm -> {
|
||||
dialog.setTitle(R.string.confirm_action)
|
||||
dialog.setMessage(R.string.delete_repository_confirm)
|
||||
dialog.setTitle(R.string.confirmation)
|
||||
dialog.setMessage(R.string.delete_repository_DESC)
|
||||
dialog.setPositiveButton(R.string.delete) { _, _ -> (parentFragment as RepositoryFragment).onDeleteConfirm() }
|
||||
dialog.setNegativeButton(R.string.cancel, null)
|
||||
}
|
||||
is Message.CantEditSyncing -> {
|
||||
dialog.setTitle(R.string.action_failed)
|
||||
dialog.setMessage(R.string.cant_edit_sync_description)
|
||||
dialog.setMessage(R.string.cant_edit_sync_DESC)
|
||||
dialog.setPositiveButton(R.string.ok, null)
|
||||
}
|
||||
is Message.Link -> {
|
||||
dialog.setTitle(R.string.confirm_action)
|
||||
dialog.setMessage(getString(R.string.open_link_confirm_format, message.uri.toString()))
|
||||
dialog.setTitle(R.string.confirmation)
|
||||
dialog.setMessage(getString(R.string.open_DESC_FORMAT, message.uri.toString()))
|
||||
dialog.setPositiveButton(R.string.ok) { _, _ ->
|
||||
try {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, message.uri))
|
||||
@@ -177,7 +177,7 @@ class MessageDialog(): DialogFragment() {
|
||||
if (builder.isNotEmpty()) {
|
||||
builder.delete(builder.length - 2, builder.length)
|
||||
} else {
|
||||
builder.append(getString(R.string.no_description_available_description))
|
||||
builder.append(getString(R.string.no_description_available_DESC))
|
||||
}
|
||||
dialog.setTitle(title)
|
||||
dialog.setMessage(builder)
|
||||
@@ -190,19 +190,19 @@ class MessageDialog(): DialogFragment() {
|
||||
val maxSdkVersion = if (Release.Incompatibility.MaxSdk in message.incompatibilities)
|
||||
message.maxSdkVersion else null
|
||||
if (minSdkVersion != null || maxSdkVersion != null) {
|
||||
val versionMessage = minSdkVersion?.let { getString(R.string.incompatible_sdk_min_description_format, it) }
|
||||
?: maxSdkVersion?.let { getString(R.string.incompatible_sdk_max_description_format, it) }
|
||||
builder.append(getString(R.string.incompatible_sdk_description_format,
|
||||
val versionMessage = minSdkVersion?.let { getString(R.string.incompatible_api_min_DESC_FORMAT, it) }
|
||||
?: maxSdkVersion?.let { getString(R.string.incompatible_api_max_DESC_FORMAT, it) }
|
||||
builder.append(getString(R.string.incompatible_api_DESC_FORMAT,
|
||||
Android.name, Android.sdk, versionMessage.orEmpty())).append("\n\n")
|
||||
}
|
||||
if (Release.Incompatibility.Platform in message.incompatibilities) {
|
||||
builder.append(getString(R.string.incompatible_platforms_description_format,
|
||||
builder.append(getString(R.string.incompatible_platforms_DESC_FORMAT,
|
||||
Android.primaryPlatform ?: getString(R.string.unknown),
|
||||
message.platforms.joinToString(separator = ", "))).append("\n\n")
|
||||
}
|
||||
val features = message.incompatibilities.mapNotNull { it as? Release.Incompatibility.Feature }
|
||||
if (features.isNotEmpty()) {
|
||||
builder.append(getString(R.string.incompatible_features_description))
|
||||
builder.append(getString(R.string.incompatible_features_DESC))
|
||||
for (feature in features) {
|
||||
builder.append("\n\u2022 ").append(feature.feature)
|
||||
}
|
||||
@@ -217,12 +217,12 @@ class MessageDialog(): DialogFragment() {
|
||||
}
|
||||
is Message.ReleaseOlder -> {
|
||||
dialog.setTitle(R.string.incompatible_version)
|
||||
dialog.setMessage(R.string.incompatible_older_description)
|
||||
dialog.setMessage(R.string.incompatible_older_DESC)
|
||||
dialog.setPositiveButton(R.string.ok, null)
|
||||
}
|
||||
is Message.ReleaseSignatureMismatch -> {
|
||||
dialog.setTitle(R.string.incompatible_version)
|
||||
dialog.setMessage(R.string.incompatible_signature_description)
|
||||
dialog.setMessage(R.string.incompatible_signature_DESC)
|
||||
dialog.setPositiveButton(R.string.ok, null)
|
||||
}
|
||||
}::class
|
||||
|
||||
@@ -54,12 +54,12 @@ class PreferencesFragment: ScreenFragment() {
|
||||
addEnumeration(Preferences.Key.AutoSync, getString(R.string.sync_repositories_automatically)) {
|
||||
when (it) {
|
||||
Preferences.AutoSync.Never -> getString(R.string.never)
|
||||
Preferences.AutoSync.Wifi -> getString(R.string.over_wifi)
|
||||
Preferences.AutoSync.Wifi -> getString(R.string.only_on_wifi)
|
||||
Preferences.AutoSync.Always -> getString(R.string.always)
|
||||
}
|
||||
}
|
||||
addSwitch(Preferences.Key.UpdateNotify, getString(R.string.update_notifications),
|
||||
getString(R.string.update_notifications_summary))
|
||||
addSwitch(Preferences.Key.UpdateNotify, getString(R.string.notify_about_updates),
|
||||
getString(R.string.notify_about_updates_summary))
|
||||
addSwitch(Preferences.Key.UpdateUnstable, getString(R.string.unstable_updates),
|
||||
getString(R.string.unstable_updates_summary))
|
||||
}
|
||||
|
||||
@@ -102,24 +102,24 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
|
||||
private enum class SectionType(val titleResId: Int, val colorAttrResId: Int) {
|
||||
ANTI_FEATURES(R.string.anti_features, R.attr.colorError),
|
||||
WHATS_NEW(R.string.whats_new, android.R.attr.colorAccent),
|
||||
CHANGES(R.string.changes, android.R.attr.colorAccent),
|
||||
LINKS(R.string.links, android.R.attr.colorAccent),
|
||||
DONATE(R.string.donate, android.R.attr.colorAccent),
|
||||
PERMISSIONS(R.string.permissions, android.R.attr.colorAccent),
|
||||
SCREENSHOTS(R.string.screenshots, android.R.attr.colorAccent),
|
||||
RELEASES(R.string.releases, android.R.attr.colorAccent)
|
||||
VERSIONS(R.string.versions, android.R.attr.colorAccent)
|
||||
}
|
||||
|
||||
internal enum class ExpandType { NOTHING, DESCRIPTION, WHATS_NEW,
|
||||
LINKS, DONATES, PERMISSIONS, SCREENSHOTS, RELEASES }
|
||||
private enum class TextType { DESCRIPTION, ANTI_FEATURES, WHATS_NEW }
|
||||
internal enum class ExpandType { NOTHING, DESCRIPTION, CHANGES,
|
||||
LINKS, DONATES, PERMISSIONS, SCREENSHOTS, VERSIONS }
|
||||
private enum class TextType { DESCRIPTION, ANTI_FEATURES, CHANGES }
|
||||
|
||||
private enum class LinkType(val iconResId: Int, val titleResId: Int,
|
||||
val format: ((Context, String) -> String)? = null) {
|
||||
AUTHOR(R.drawable.ic_person, R.string.authors_website),
|
||||
EMAIL(R.drawable.ic_email, R.string.authors_email),
|
||||
AUTHOR(R.drawable.ic_person, R.string.author_website),
|
||||
EMAIL(R.drawable.ic_email, R.string.author_email),
|
||||
LICENSE(R.drawable.ic_copyright, R.string.license,
|
||||
format = { context, text -> context.getString(R.string.license_format, text) }),
|
||||
format = { context, text -> context.getString(R.string.license_FORMAT, text) }),
|
||||
SOURCE(R.drawable.ic_code, R.string.source_code),
|
||||
TRACKER(R.drawable.ic_bug_report, R.string.bug_tracker),
|
||||
CHANGELOG(R.drawable.ic_history, R.string.changelog),
|
||||
@@ -636,18 +636,18 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
|
||||
val antiFeatures = productRepository.first.antiFeatures.map {
|
||||
when (it) {
|
||||
"Ads" -> context.getString(R.string.anti_feature_advertising)
|
||||
"ApplicationDebuggable" -> context.getString(R.string.anti_feature_application_debuggable)
|
||||
"DisabledAlgorithm" -> context.getString(R.string.anti_feature_disabled_algorithm)
|
||||
"KnownVuln" -> context.getString(R.string.anti_feature_known_vulnerabilities)
|
||||
"NoSourceSince" -> context.getString(R.string.anti_feature_no_source_since)
|
||||
"NonFreeAdd" -> context.getString(R.string.anti_feature_non_free_addons)
|
||||
"NonFreeAssets" -> context.getString(R.string.anti_feature_non_free_assets)
|
||||
"NonFreeDep" -> context.getString(R.string.anti_feature_non_free_dependencies)
|
||||
"NonFreeNet" -> context.getString(R.string.anti_feature_non_free_network)
|
||||
"Tracking" -> context.getString(R.string.anti_feature_tracking)
|
||||
"UpstreamNonFree" -> context.getString(R.string.anti_feature_upstream_non_free)
|
||||
else -> context.getString(R.string.unknown_format, it)
|
||||
"Ads" -> context.getString(R.string.has_advertising)
|
||||
"ApplicationDebuggable" -> context.getString(R.string.compiled_for_debugging)
|
||||
"DisabledAlgorithm" -> context.getString(R.string.signed_using_unsafe_algorithm)
|
||||
"KnownVuln" -> context.getString(R.string.has_security_vulnerabilities)
|
||||
"NoSourceSince" -> context.getString(R.string.source_code_no_longer_available)
|
||||
"NonFreeAdd" -> context.getString(R.string.promotes_non_free_software)
|
||||
"NonFreeAssets" -> context.getString(R.string.contains_non_free_media)
|
||||
"NonFreeDep" -> context.getString(R.string.has_non_free_dependencies)
|
||||
"NonFreeNet" -> context.getString(R.string.promotes_non_free_network_services)
|
||||
"Tracking" -> context.getString(R.string.tracks_or_reports_your_activity)
|
||||
"UpstreamNonFree" -> context.getString(R.string.upstream_source_code_is_not_free)
|
||||
else -> context.getString(R.string.unknown_FORMAT, it)
|
||||
}
|
||||
}.joinToString(separator = "\n") { "\u2022 $it" }
|
||||
if (antiFeatures.isNotEmpty()) {
|
||||
@@ -655,14 +655,14 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
items += Item.TextItem(TextType.ANTI_FEATURES, antiFeatures)
|
||||
}
|
||||
|
||||
val whatsNew = formatHtml(productRepository.first.whatsNew)
|
||||
if (whatsNew.isNotEmpty()) {
|
||||
items += Item.SectionItem(SectionType.WHATS_NEW)
|
||||
val cropped = if (ExpandType.WHATS_NEW !in expanded) whatsNew.lineCropped(12, 10) else null
|
||||
val item = Item.TextItem(TextType.WHATS_NEW, whatsNew)
|
||||
val changes = formatHtml(productRepository.first.whatsNew)
|
||||
if (changes.isNotEmpty()) {
|
||||
items += Item.SectionItem(SectionType.CHANGES)
|
||||
val cropped = if (ExpandType.CHANGES !in expanded) changes.lineCropped(12, 10) else null
|
||||
val item = Item.TextItem(TextType.CHANGES, changes)
|
||||
if (cropped != null) {
|
||||
items += listOf(Item.TextItem(TextType.WHATS_NEW, cropped),
|
||||
Item.ExpandItem(ExpandType.WHATS_NEW, true, listOf(item)))
|
||||
items += listOf(Item.TextItem(TextType.CHANGES, cropped),
|
||||
Item.ExpandItem(ExpandType.CHANGES, true, listOf(item)))
|
||||
} else {
|
||||
items += item
|
||||
}
|
||||
@@ -758,11 +758,11 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
.sortedByDescending { it.release.versionCode }
|
||||
.toList()
|
||||
if (releaseItems.isNotEmpty()) {
|
||||
items += Item.SectionItem(SectionType.RELEASES)
|
||||
items += Item.SectionItem(SectionType.VERSIONS)
|
||||
val maxReleases = 5
|
||||
if (releaseItems.size > maxReleases && ExpandType.RELEASES !in expanded) {
|
||||
if (releaseItems.size > maxReleases && ExpandType.VERSIONS !in expanded) {
|
||||
items += releaseItems.take(maxReleases)
|
||||
items += Item.ExpandItem(ExpandType.RELEASES, false, releaseItems.takeLast(releaseItems.size - maxReleases))
|
||||
items += Item.ExpandItem(ExpandType.VERSIONS, false, releaseItems.takeLast(releaseItems.size - maxReleases))
|
||||
} else {
|
||||
items += releaseItems
|
||||
}
|
||||
@@ -975,7 +975,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
!ProductPreferences[item.product.packageName].shouldIgnoreUpdate(item.product.versionCode)
|
||||
val version = (if (canUpdate) item.product.version else installedItem?.version)?.nullIfEmpty()
|
||||
?: item.product.version.nullIfEmpty()
|
||||
holder.version.text = version?.let { context.getString(R.string.version_format, it) }
|
||||
holder.version.text = version?.let { context.getString(R.string.version_FORMAT, it) }
|
||||
?: context.getString(R.string.unknown)
|
||||
holder.packageName.text = item.product.packageName
|
||||
val action = action
|
||||
@@ -1002,7 +1002,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
holder.progress.isIndeterminate = true
|
||||
}
|
||||
is Status.Downloading -> {
|
||||
holder.status.text = context.getString(R.string.downloading_format, if (status.total == null)
|
||||
holder.status.text = context.getString(R.string.downloading_FORMAT, if (status.total == null)
|
||||
status.read.formatSize() else "${status.read.formatSize()} / ${status.total.formatSize()}")
|
||||
holder.progress.isIndeterminate = status.total == null
|
||||
if (status.total != null) {
|
||||
@@ -1051,7 +1051,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
holder as ExpandViewHolder
|
||||
item as Item.ExpandItem
|
||||
holder.text.setText(when (item.expandType) {
|
||||
ExpandType.RELEASES -> R.string.show_older_releases
|
||||
ExpandType.VERSIONS -> R.string.show_older_versions
|
||||
else -> R.string.show_more
|
||||
})
|
||||
}
|
||||
@@ -1154,7 +1154,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
val grayOut = incompatibility != null || olderOrSignature
|
||||
val primarySecondaryColor = context.getColorFromAttr(if (grayOut)
|
||||
android.R.attr.textColorSecondary else android.R.attr.textColorPrimary)
|
||||
holder.version.text = context.getString(R.string.version_format, item.release.version)
|
||||
holder.version.text = context.getString(R.string.version_FORMAT, item.release.version)
|
||||
holder.version.setTextColor(primarySecondaryColor)
|
||||
holder.setStatusActive(!grayOut)
|
||||
holder.status.visibility = if (installed || suggested) View.VISIBLE else View.GONE
|
||||
@@ -1163,7 +1163,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
suggested -> R.string.suggested
|
||||
else -> R.string.unknown
|
||||
})
|
||||
holder.source.text = context.getString(R.string.provided_by_format, item.repository.name)
|
||||
holder.source.text = context.getString(R.string.provided_by_FORMAT, item.repository.name)
|
||||
holder.added.text = holder.dateFormat.format(item.release.added)
|
||||
holder.added.setTextColor(primarySecondaryColor)
|
||||
holder.size.text = item.release.size.formatSize()
|
||||
@@ -1173,14 +1173,14 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
holder.compatibility.setTextColor(context.getColorFromAttr(R.attr.colorError))
|
||||
holder.compatibility.text = when (incompatibility) {
|
||||
is Release.Incompatibility.MinSdk,
|
||||
is Release.Incompatibility.MaxSdk -> context.getString(R.string.incompatible_with_format, Android.name)
|
||||
is Release.Incompatibility.Platform -> context.getString(R.string.incompatible_with_format,
|
||||
is Release.Incompatibility.MaxSdk -> context.getString(R.string.incompatible_with_FORMAT, Android.name)
|
||||
is Release.Incompatibility.Platform -> context.getString(R.string.incompatible_with_FORMAT,
|
||||
Android.primaryPlatform ?: context.getString(R.string.unknown))
|
||||
is Release.Incompatibility.Feature -> context.getString(R.string.requires_format, incompatibility.feature)
|
||||
is Release.Incompatibility.Feature -> context.getString(R.string.requires_FORMAT, incompatibility.feature)
|
||||
}
|
||||
} else if (singlePlatform != null) {
|
||||
holder.compatibility.setTextColor(context.getColorFromAttr(android.R.attr.textColorSecondary))
|
||||
holder.compatibility.text = context.getString(R.string.compatible_with_only_format, singlePlatform)
|
||||
holder.compatibility.text = context.getString(R.string.only_compatible_with_FORMAT, singlePlatform)
|
||||
}
|
||||
val enabled = status == null
|
||||
holder.statefulViews.forEach { it.isEnabled = enabled }
|
||||
|
||||
@@ -131,11 +131,11 @@ class ProductsFragment(): ScreenFragment(), CursorOwner.Callback {
|
||||
this.cursor = cursor
|
||||
emptyText = when {
|
||||
cursor == null -> ""
|
||||
searchQuery.isNotEmpty() -> getString(R.string.empty_search_summary)
|
||||
searchQuery.isNotEmpty() -> getString(R.string.no_matching_applications_found)
|
||||
else -> when (source) {
|
||||
Source.AVAILABLE -> getString(R.string.available_empty_summary)
|
||||
Source.INSTALLED -> getString(R.string.installed_empty_summary)
|
||||
Source.UPDATES -> getString(R.string.updates_empty_summary)
|
||||
Source.AVAILABLE -> getString(R.string.no_applications_available)
|
||||
Source.INSTALLED -> getString(R.string.no_applications_installed)
|
||||
Source.UPDATES -> getString(R.string.all_applications_up_to_date)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,11 +128,11 @@ class RepositoryFragment(): ScreenFragment() {
|
||||
Database.ProductAdapter.getCount(repository.id).toString())
|
||||
}
|
||||
} else {
|
||||
layout.addTitleText(R.string.description, getString(R.string.not_updated_description))
|
||||
layout.addTitleText(R.string.description, getString(R.string.repository_not_used_DESC))
|
||||
}
|
||||
if (repository.fingerprint.isEmpty()) {
|
||||
if (repository.updated > 0L) {
|
||||
val builder = SpannableStringBuilder(getString(R.string.unsigned_description))
|
||||
val builder = SpannableStringBuilder(getString(R.string.repository_unsigned_DESC))
|
||||
builder.setSpan(ForegroundColorSpan(layout.context.getColorFromAttr(R.attr.colorError).defaultColor),
|
||||
0, builder.length, SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
layout.addTitleText(R.string.fingerprint, builder)
|
||||
|
||||
@@ -115,7 +115,7 @@ class TabsFragment: ScreenFragment() {
|
||||
|
||||
val toolbar = view.findViewById<Toolbar>(R.id.toolbar)!!
|
||||
screenActivity.onToolbarCreated(toolbar)
|
||||
toolbar.setTitle(R.string.app_name)
|
||||
toolbar.setTitle(R.string.application_name)
|
||||
// Move focus from SearchView to Toolbar
|
||||
toolbar.isFocusableInTouchMode = true
|
||||
|
||||
@@ -147,7 +147,7 @@ class TabsFragment: ScreenFragment() {
|
||||
.setActionView(searchView)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS or MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW)
|
||||
|
||||
sortOrderMenu = addSubMenu(0, 0, 0, R.string.sort_order)
|
||||
sortOrderMenu = addSubMenu(0, 0, 0, R.string.sorting_order)
|
||||
.setIcon(Utils.getToolbarIcon(toolbar.context, R.drawable.ic_sort))
|
||||
.let { menu ->
|
||||
menu.item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||
|
||||
@@ -174,7 +174,7 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
}
|
||||
}
|
||||
|
||||
private enum class ValidationError { HASH, STRUCTURE, INTEGRITY, SIGNATURE, PERMISSIONS }
|
||||
private enum class ValidationError { INTEGRITY, FORMAT, METADATA, SIGNATURE, PERMISSIONS }
|
||||
|
||||
private sealed class ErrorType {
|
||||
object Network: ErrorType()
|
||||
@@ -194,23 +194,22 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
.apply {
|
||||
when (errorType) {
|
||||
is ErrorType.Network -> {
|
||||
setContentTitle(getString(R.string.error_downloading_format, task.name))
|
||||
setContentText(getString(R.string.network_error_description))
|
||||
setContentTitle(getString(R.string.could_not_download_FORMAT, task.name))
|
||||
setContentText(getString(R.string.network_error_DESC))
|
||||
}
|
||||
is ErrorType.Http -> {
|
||||
setContentTitle(getString(R.string.error_downloading_format, task.name))
|
||||
setContentText(getString(R.string.http_error_description))
|
||||
setContentTitle(getString(R.string.could_not_download_FORMAT, task.name))
|
||||
setContentText(getString(R.string.http_error_DESC))
|
||||
}
|
||||
is ErrorType.Validation -> {
|
||||
setContentTitle(getString(R.string.error_validating_format, task.name))
|
||||
val resId = R.string.validation_package_error_description_format
|
||||
setContentText(getString(resId, getString(when (errorType.validateError) {
|
||||
ValidationError.HASH -> R.string.validation_error_hash_lower
|
||||
ValidationError.STRUCTURE -> R.string.validation_error_structure_lower
|
||||
ValidationError.INTEGRITY -> R.string.validation_error_integrity_lower
|
||||
ValidationError.SIGNATURE -> R.string.validation_error_signature_lower
|
||||
ValidationError.PERMISSIONS -> R.string.validation_error_permissions_lower
|
||||
})))
|
||||
setContentTitle(getString(R.string.could_not_validate_FORMAT, task.name))
|
||||
setContentText(getString(when (errorType.validateError) {
|
||||
ValidationError.INTEGRITY -> R.string.integrity_check_error_DESC
|
||||
ValidationError.FORMAT -> R.string.file_format_error_DESC
|
||||
ValidationError.METADATA -> R.string.invalid_metadata_error_DESC
|
||||
ValidationError.SIGNATURE -> R.string.invalid_signature_error_DESC
|
||||
ValidationError.PERMISSIONS -> R.string.invalid_permissions_error_DESC
|
||||
}))
|
||||
}
|
||||
}::class
|
||||
}
|
||||
@@ -227,8 +226,8 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
.setContentIntent(PendingIntent.getBroadcast(this, 0, Intent(this, Receiver::class.java)
|
||||
.setAction("$ACTION_INSTALL.${task.packageName}")
|
||||
.putExtra(EXTRA_CACHE_FILE_NAME, task.release.cacheFileName), PendingIntent.FLAG_UPDATE_CURRENT))
|
||||
.setContentTitle(getString(R.string.finished_downloading_format, task.name))
|
||||
.setContentText(getString(R.string.tap_to_install_description))
|
||||
.setContentTitle(getString(R.string.downloaded_FORMAT, task.name))
|
||||
.setContentText(getString(R.string.tap_to_install_DESC))
|
||||
.build())
|
||||
}
|
||||
|
||||
@@ -253,7 +252,7 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
""
|
||||
}
|
||||
return if (hash.isEmpty() || hash != task.release.hash) {
|
||||
ValidationError.HASH
|
||||
ValidationError.INTEGRITY
|
||||
} else {
|
||||
val packageInfo = try {
|
||||
packageManager.getPackageArchiveInfo(file.path, Android.PackageManager.signaturesFlag)
|
||||
@@ -262,10 +261,10 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
null
|
||||
}
|
||||
if (packageInfo == null) {
|
||||
ValidationError.STRUCTURE
|
||||
ValidationError.FORMAT
|
||||
} else if (packageInfo.packageName != task.packageName ||
|
||||
packageInfo.versionCodeCompat != task.release.versionCode) {
|
||||
ValidationError.INTEGRITY
|
||||
ValidationError.METADATA
|
||||
} else {
|
||||
val signature = packageInfo.singleSignature?.let(Utils::calculateHash).orEmpty()
|
||||
if (signature.isEmpty() || signature != task.release.signature) {
|
||||
@@ -296,12 +295,12 @@ class DownloadService: ConnectionService<DownloadService.Binder>() {
|
||||
startForeground(Common.NOTIFICATION_ID_SYNCING, stateNotificationBuilder.apply {
|
||||
when (state) {
|
||||
is State.Connecting -> {
|
||||
setContentTitle(getString(R.string.downloading_format, state.name))
|
||||
setContentTitle(getString(R.string.downloading_FORMAT, state.name))
|
||||
setContentText(getString(R.string.connecting))
|
||||
setProgress(1, 0, true)
|
||||
}
|
||||
is State.Downloading -> {
|
||||
setContentTitle(getString(R.string.downloading_format, state.name))
|
||||
setContentTitle(getString(R.string.downloading_FORMAT, state.name))
|
||||
if (state.total != null) {
|
||||
setContentText("${state.read.formatSize()} / ${state.total.formatSize()}")
|
||||
setProgress(100, (100f * state.read / state.total).roundToInt(), false)
|
||||
|
||||
@@ -201,15 +201,15 @@ class SyncService: ConnectionService<SyncService.Binder>() {
|
||||
.setSmallIcon(android.R.drawable.stat_sys_warning)
|
||||
.setColor(ContextThemeWrapper(this, R.style.Theme_Main_Light)
|
||||
.getColorFromAttr(android.R.attr.colorAccent).defaultColor)
|
||||
.setContentTitle(getString(R.string.error_syncing_format, repository.name))
|
||||
.setContentTitle(getString(R.string.could_not_sync_FORMAT, repository.name))
|
||||
.setContentText(getString(when (exception) {
|
||||
is RepositoryUpdater.UpdateException -> when (exception.errorType) {
|
||||
RepositoryUpdater.ErrorType.NETWORK -> R.string.network_error_description
|
||||
RepositoryUpdater.ErrorType.HTTP -> R.string.http_error_description
|
||||
RepositoryUpdater.ErrorType.VALIDATION -> R.string.validation_index_error_description
|
||||
RepositoryUpdater.ErrorType.PARSING -> R.string.parsing_index_error_description
|
||||
RepositoryUpdater.ErrorType.NETWORK -> R.string.network_error_DESC
|
||||
RepositoryUpdater.ErrorType.HTTP -> R.string.http_error_DESC
|
||||
RepositoryUpdater.ErrorType.VALIDATION -> R.string.validation_index_error_DESC
|
||||
RepositoryUpdater.ErrorType.PARSING -> R.string.parsing_index_error_DESC
|
||||
}
|
||||
else -> R.string.unknown_error_description
|
||||
else -> R.string.unknown_error_DESC
|
||||
}))
|
||||
.build())
|
||||
}
|
||||
@@ -229,12 +229,12 @@ class SyncService: ConnectionService<SyncService.Binder>() {
|
||||
startForeground(Common.NOTIFICATION_ID_SYNCING, stateNotificationBuilder.apply {
|
||||
when (state) {
|
||||
is State.Connecting -> {
|
||||
setContentTitle(getString(R.string.syncing_format, state.name))
|
||||
setContentTitle(getString(R.string.syncing_FORMAT, state.name))
|
||||
setContentText(getString(R.string.connecting))
|
||||
setProgress(0, 0, true)
|
||||
}
|
||||
is State.Syncing -> {
|
||||
setContentTitle(getString(R.string.syncing_format, state.name))
|
||||
setContentTitle(getString(R.string.syncing_FORMAT, state.name))
|
||||
when (state.stage) {
|
||||
RepositoryUpdater.Stage.DOWNLOAD -> {
|
||||
if (state.total != null) {
|
||||
@@ -247,12 +247,12 @@ class SyncService: ConnectionService<SyncService.Binder>() {
|
||||
}
|
||||
RepositoryUpdater.Stage.PROCESS -> {
|
||||
val progress = state.total?.let { 100f * state.read / it }?.roundToInt()
|
||||
setContentText(getString(R.string.processing_format, "${progress ?: 0}%"))
|
||||
setContentText(getString(R.string.processing_FORMAT, "${progress ?: 0}%"))
|
||||
setProgress(100, progress ?: 0, progress == null)
|
||||
}
|
||||
RepositoryUpdater.Stage.MERGE -> {
|
||||
val progress = (100f * state.read / (state.total ?: state.read)).roundToInt()
|
||||
setContentText(getString(R.string.merging_format, "${state.read} / ${state.total ?: state.read}"))
|
||||
setContentText(getString(R.string.merging_FORMAT, "${state.read} / ${state.total ?: state.read}"))
|
||||
setProgress(100, progress, false)
|
||||
}
|
||||
RepositoryUpdater.Stage.COMMIT -> {
|
||||
@@ -350,7 +350,7 @@ class SyncService: ConnectionService<SyncService.Binder>() {
|
||||
.Builder(this, Common.NOTIFICATION_CHANNEL_UPDATES)
|
||||
.setSmallIcon(R.drawable.ic_new_releases)
|
||||
.setContentTitle(getString(R.string.new_updates_available))
|
||||
.setContentText(resources.getQuantityString(R.plurals.new_updates_description_format,
|
||||
.setContentText(resources.getQuantityString(R.plurals.new_updates_DESC_FORMAT,
|
||||
productItems.size, productItems.size))
|
||||
.setColor(ContextThemeWrapper(this, R.style.Theme_Main_Light)
|
||||
.getColorFromAttr(android.R.attr.colorAccent).defaultColor)
|
||||
@@ -365,7 +365,7 @@ class SyncService: ConnectionService<SyncService.Binder>() {
|
||||
addLine(builder)
|
||||
}
|
||||
if (productItems.size > maxUpdates) {
|
||||
val summary = getString(R.string.plus_more_format, productItems.size - maxUpdates)
|
||||
val summary = getString(R.string.plus_more_FORMAT, productItems.size - maxUpdates)
|
||||
if (Android.sdk(24)) {
|
||||
addLine(summary)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user