Skip to content

Commit

Permalink
Refactor String.format, update versionCode
Browse files Browse the repository at this point in the history
  • Loading branch information
AIDEA775 committed Nov 8, 2018
1 parent 01b1e53 commit b15b896
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
applicationId "com.uncmorfi"
minSdkVersion 16
targetSdkVersion 28
versionCode 8
versionCode 9
versionName "v5.0 Espagueti"
resValue "string", "app_name", "UNCmorfi"
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class BalanceFragment : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
}

private fun getNewUserMsg(card: String): String {
return String.format(Locale.US, getString(R.string.balance_new_user_adding), card)
return getString(R.string.balance_new_user_adding).format(card)
}

private fun updateBalance(vararg users: User) {
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/uncmorfi/balance/UserCursorAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ internal class UserCursorAdapter(private val mContext: Context,
itemView.userBalance.setTextColor(mContext.colorOf(
if (user.balance < WARNING_USER_BALANCE) R.color.accent else R.color.primary_dark))

itemView.userExpiration.text = String.format(
mContext.getString(R.string.balance_expiration),
textExpiration(user.expiration))
itemView.userExpiration.text = mContext.getString(R.string.balance_expiration)
.format(textExpiration(user.expiration))

itemView.userExpiration.setTextColor(mContext.colorOf(
if (warningExpiration(user.expiration)) R.color.accent else R.color.secondary_text))

itemView.userLastUpdate.text = String.format(
mContext.getString(R.string.balance_last_update),
DateUtils.getRelativeTimeSpanString(user.lastUpdate).toString().toLowerCase())
itemView.userLastUpdate.text = mContext.getString(R.string.balance_last_update)
.format(DateUtils.getRelativeTimeSpanString(user.lastUpdate).toString().toLowerCase())
}

private fun textExpiration(expiration: Long): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DeleteUserDialog : BaseDialogHelper() {
}
val negativeListener = DialogInterface.OnClickListener { _, _ -> dismiss() }

builder.setMessage(String.format(getString(R.string.balance_delete_user_title), user.name))
builder.setMessage(getString(R.string.balance_delete_user_title).format(user.name))
.setPositiveButton(getString(R.string.balance_delete_user_positive), positiveListener)
.setNegativeButton(getString(android.R.string.cancel), negativeListener)

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/uncmorfi/counter/CounterFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CounterFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) {
val windows = progress + 3 // Mínimo 3 ventanas
counterDistance.text = String.format(getString(R.string.counter_distance), windows)
counterDistance.text = getString(R.string.counter_distance).format(windows)
}
}

Expand Down Expand Up @@ -162,7 +162,7 @@ class CounterFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
*/
private fun generatePieChartText(total: Int, percent: Float) : SpannableString {
val pText = "%.2f%%".format(percent)
val tText = String.format(getString(R.string.counter_rations_title), total, FOOD_RATIONS)
val tText = getString(R.string.counter_rations_title).format(total, FOOD_RATIONS)
val s = SpannableString("$pText\n$tText")

s.setSpan(RelativeSizeSpan(3f), 0, pText.length, 0)
Expand Down

0 comments on commit b15b896

Please sign in to comment.