Drop dependency upon apache's commons-text

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-05-15 14:33:35 +05:30
parent 66d0f54ec9
commit dbaf577f2a
52 changed files with 19 additions and 125 deletions

View File

@@ -6,7 +6,6 @@ import com.aurora.store.util.Preferences
import com.aurora.store.util.Preferences.PREFERENCE_UNIQUE_GROUP_IDS
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.apache.commons.lang3.RandomUtils
class RequestGroupIdBuilder {
@@ -45,9 +44,9 @@ fun App.getGroupId(context: Context): Int {
return item.key
}
}
var randomGroupID = RandomUtils.nextInt(0, Int.MAX_VALUE)
var randomGroupID = (0 until Int.MAX_VALUE).random()
while (groupIDMap.containsKey(randomGroupID)) {
randomGroupID = RandomUtils.nextInt(0, Int.MAX_VALUE)
randomGroupID = (0 until Int.MAX_VALUE).random()
}
groupIDMap[randomGroupID] = RequestGroupIdBuilder.AppIDnVersion(this.id, this.versionCode)
Preferences.getPrefs(context).edit().putString(PREFERENCE_UNIQUE_GROUP_IDS, gson.toJson(groupIDMap)).apply()

View File

@@ -51,7 +51,6 @@ import com.aurora.store.view.ui.downloads.DownloadActivity
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.tonyodev.fetch2.*
import org.apache.commons.lang3.StringUtils
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import java.lang.reflect.Modifier
@@ -212,19 +211,13 @@ class NotificationService : Service() {
}
Status.DOWNLOADING -> {
val contentString = getString(R.string.download_progress)
val partString = StringUtils.joinWith(
"/",
fetchGroup.completedDownloads.size + 1,
fetchGroup.downloads.size
)
val speedString: String =
CommonUtil.humanReadableByteSpeed(download.downloadedBytesPerSecond, true)
progressBigText.bigText(
StringUtils.joinWith(
" \u2022 ",
contentString,
partString,
getString(
R.string.download_progress,
fetchGroup.completedDownloads.size + 1,
fetchGroup.downloads.size,
speedString
)
)
@@ -252,16 +245,11 @@ class NotificationService : Service() {
Status.PAUSED -> {
val pauseString = getString(R.string.download_paused)
val filesString = StringUtils.joinWith(
"/",
fetchGroup.completedDownloads.size,
fetchGroup.downloads.size
)
progressBigText.bigText(
StringUtils.joinWith(
" \u2022 ",
pauseString,
filesString
getString(
R.string.download_paused,
fetchGroup.completedDownloads.size,
fetchGroup.downloads.size
)
)
builder.setStyle(progressBigText)

View File

@@ -24,7 +24,6 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.tonyodev.fetch2.*
import nl.komponents.kovenant.task
import org.apache.commons.lang3.StringUtils
import java.lang.reflect.Modifier
import java.util.*
import java.util.concurrent.TimeUnit
@@ -46,7 +45,7 @@ class SelfUpdateService : Service() {
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
val rawSelfUpdate = intent.getStringExtra(Constants.STRING_EXTRA)
if (StringUtils.isNotEmpty(rawSelfUpdate)) {
if (rawSelfUpdate?.isNotBlank() == true) {
val selfUpdate = gson.fromJson(rawSelfUpdate, SelfUpdate::class.java)
selfUpdate?.let {
downloadAndUpdate(it)

View File

@@ -29,7 +29,6 @@ import com.airbnb.epoxy.ModelView
import com.aurora.store.R
import com.aurora.store.databinding.ViewDeviceBinding
import com.aurora.store.view.epoxy.views.BaseView
import org.apache.commons.lang3.StringUtils
import java.util.*
@ModelView(
@@ -64,10 +63,10 @@ class DeviceView : RelativeLayout {
@ModelProp
fun properties(properties: Properties) {
B.line1.text = properties.getProperty("UserReadableName")
B.line2.text = StringUtils.joinWith(
" \u2022 ",
B.line2.text = resources.getString(
R.string.spoof_property,
properties.getProperty("Build.MANUFACTURER"),
"API " + properties.getProperty("Build.VERSION.SDK_INT")
properties.getProperty("Build.VERSION.SDK_INT")
)
B.line3.text = properties.getProperty("Platforms")
}