Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.annotation.StringRes
import androidx.biometric.BiometricManager
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import androidx.core.content.res.ResourcesCompat
import androidx.core.os.bundleOf
import androidx.core.text.BidiFormatter
import androidx.exifinterface.media.ExifInterface
import androidx.loader.content.CursorLoader
import com.github.ajalt.reprint.core.Reprint
Expand Down Expand Up @@ -114,7 +116,6 @@ import org.fossify.commons.helpers.YOUR_ALARM_SOUNDS_MIN_ID
import org.fossify.commons.helpers.ensureBackgroundThread
import org.fossify.commons.helpers.isNougatPlus
import org.fossify.commons.helpers.isOnMainThread
import org.fossify.commons.helpers.isOreoPlus
import org.fossify.commons.helpers.isQPlus
import org.fossify.commons.helpers.isRPlus
import org.fossify.commons.helpers.isSPlus
Expand Down Expand Up @@ -1375,3 +1376,20 @@ fun Context.findActivity(): Activity? = when (this) {
is ContextWrapper -> baseContext.findActivity()
else -> null
}

fun Context.formatWithBadge(
@StringRes labelRes: Int,
@StringRes badgeRes: Int,
vararg labelArgs: Any
): CharSequence {
val label = if (labelArgs.isEmpty()) getString(labelRes)
else getString(labelRes, *labelArgs)

val badge = BidiFormatter.getInstance().unicodeWrap(getString(badgeRes))
return getString(R.string.label_with_badge, label, badge)
}

fun Context.formatWithDeprecatedBadge(
@StringRes labelRes: Int,
vararg labelArgs: Any
): CharSequence = formatWithBadge(labelRes, R.string.badge_deprecated, *labelArgs)
4 changes: 4 additions & 0 deletions commons/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,10 @@
<string name="fee_up_to_pct">Up to %1$d%% fee</string>
<string name="cryptocurrency">Cryptocurrency</string>

<!-- Feature removal -->
<string name="badge_deprecated">(deprecated)</string>
<string name="label_with_badge">%1$s %2$s</string>

<!-- FAQ -->
<string name="frequently_asked_questions">Frequently asked questions</string>
<string name="before_asking_question">Before you ask a question, please first read the</string>
Expand Down
Loading