Skip to content

Commit

Permalink
Merge branch 'hotfix/patch' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed May 13, 2019
2 parents 31d9cf8 + 98b8cb7 commit 3b6d810
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 38 deletions.
4 changes: 2 additions & 2 deletions app/.meta/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"code": 104,
"code": 105,
"migration": false,
"releaseNotes": "",
"version": "1.4.1",
"version": "1.4.2",
"appId": "com.mxt.anitrend"
}
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":104,"versionName":"1.4.1","enabled":true,"outputFile":"anitrend_v1.4.1_rc_104.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.4.1_rc_104.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":105,"versionName":"1.4.2","enabled":true,"outputFile":"anitrend_v1.4.2_rc_105.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.4.2_rc_105.apk","properties":{}}]
4 changes: 3 additions & 1 deletion app/src/main/assets/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ which can result in authentication errors [read more](https://github.com/square/

#### Enhancements
- Reintroduced emoji support
- Spoiler tags support (Mittens)
- Spoiler tags in media pages (Mittens)
- New notification type for media the user may be interested in

#### Bug Fixes
- Multiple translations fixed
- Scores not matching sorted order
- Crashes on some device related to crunchyroll feeds

#### Current Issues
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/java/com/mxt/anitrend/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ import org.greenrobot.eventbus.EventBus

class App : MultiDexApplication() {

val applicationPref by lazy {
ApplicationPref(this)
val applicationPref = ApplicationPref(this)

init {
EventBus.builder().logNoSubscriberMessages(BuildConfig.DEBUG)
.sendNoSubscriberEvent(BuildConfig.DEBUG)
.sendSubscriberExceptionEvent(BuildConfig.DEBUG)
.throwSubscriberException(BuildConfig.DEBUG)
.installDefaultEventBus()
}

/**
Expand All @@ -42,6 +48,7 @@ class App : MultiDexApplication() {
*/
lateinit var boxStore: BoxStore
private set

/**
* Get application global registered fabric instance, depending on
* the current application preferences the application may have
Expand All @@ -60,7 +67,7 @@ class App : MultiDexApplication() {

private fun setCrashAnalytics() {
if (!BuildConfig.DEBUG)
if (applicationPref.isCrashReportsEnabled!!) {
if (applicationPref.isCrashReportsEnabled == true) {
val crashlyticsCore = CrashlyticsCore.Builder()
.build()

Expand All @@ -72,17 +79,11 @@ class App : MultiDexApplication() {
}

private fun initApp() {
EventBus.builder().logNoSubscriberMessages(BuildConfig.DEBUG)
.sendNoSubscriberEvent(BuildConfig.DEBUG)
.sendSubscriberExceptionEvent(BuildConfig.DEBUG)
.throwSubscriberException(BuildConfig.DEBUG)
.installDefaultEventBus()
if (applicationPref.isUsageAnalyticsEnabled == true) {
analytics = FirebaseAnalytics.getInstance(this).apply {
setAnalyticsCollectionEnabled(applicationPref.isUsageAnalyticsEnabled!!)
}
}
JobSchedulerUtil.scheduleJob(applicationContext)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
ProviderInstaller.installIfNeededAsync(applicationContext,
object : ProviderInstaller.ProviderInstallListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,41 +147,41 @@ private void setRating(MediaList mediaList) {
}

private void setRating(MediaBase mediaBase) {
float mediaScoreDefault = (float) mediaBase.getMeanScore() * 5 / 100f;
float mediaScoreDefault = (float) mediaBase.getAverageScore() * 5 / 100f;
if(mediaListOptions != null)
switch (mediaListOptions.getScoreFormat()) {
case KeyUtil.POINT_10_DECIMAL:
mediaScoreDefault = (mediaBase.getMeanScore() / 10f);
mediaScoreDefault = (mediaBase.getAverageScore() / 10f);
binding.ratingValue.setText(String.format(Locale.getDefault(),"%.1f", mediaScoreDefault));
break;
case KeyUtil.POINT_100:
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getMeanScore()));
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getAverageScore()));
break;
case KeyUtil.POINT_10:
mediaScoreDefault = (mediaBase.getMeanScore() / 10);
mediaScoreDefault = (mediaBase.getAverageScore() / 10f);
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", (int) mediaScoreDefault));
break;
case KeyUtil.POINT_5:
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", (int) mediaScoreDefault));
break;
case KeyUtil.POINT_3:
binding.ratingValue.setText("");
if(mediaBase.getMeanScore() == 0)
if(mediaBase.getAverageScore() == 0)
binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.INSTANCE.getDrawable(getContext(),
R.drawable.ic_face_white_18dp), null, null, null);
if(mediaBase.getMeanScore() > 0 && mediaBase.getMeanScore() <= 33)
if(mediaBase.getAverageScore() > 0 && mediaBase.getAverageScore() <= 33)
binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.INSTANCE.getDrawable(getContext(),
R.drawable.ic_sentiment_dissatisfied_white_18dp), null, null, null);
else if (mediaBase.getMeanScore() >= 34 && mediaBase.getMeanScore() <= 66)
else if (mediaBase.getAverageScore() >= 34 && mediaBase.getAverageScore() <= 66)
binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.INSTANCE.getDrawable(getContext(),
R.drawable.ic_sentiment_neutral_white_18dp), null, null, null);
else if (mediaBase.getMeanScore() >= 67 && mediaBase.getMeanScore() <= 100)
else if (mediaBase.getAverageScore() >= 67 && mediaBase.getAverageScore() <= 100)
binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.INSTANCE.getDrawable(getContext(),
R.drawable.ic_sentiment_satisfied_white_18dp), null, null, null);
break;
}
else
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getMeanScore()));
binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getAverageScore()));
}

@BindingAdapter("rating")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import com.mxt.anitrend.util.JobSchedulerUtil

class SchedulerDelegate : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {
if (intent.action != null && intent.action == Intent.ACTION_BOOT_COMPLETED)
JobSchedulerUtil.scheduleJob(context)
override fun onReceive(context: Context, intent: Intent?) {
when (intent?.action) {
Intent.ACTION_BOOT_COMPLETED ->
JobSchedulerUtil.scheduleJob(context)
}
}
}
21 changes: 10 additions & 11 deletions app/src/main/java/com/mxt/anitrend/util/CompatUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,16 @@ object CompatUtil {
/**
* Capitalize words for text view consumption
*/
fun capitalizeWords(input: String): String {
if (!TextUtils.isEmpty(input)) {
fun capitalizeWords(input: String?): String {
if (!input.isNullOrBlank()) {
val exceptions = constructListFrom(KeyUtil.TV, KeyUtil.ONA, KeyUtil.OVA)
val result = StringBuilder(input.length)
val words = input.split("_|\\s".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
var index = 0
for (word in words) {
if (!TextUtils.isEmpty(word)) {
val words = input.split("_|\\s".toRegex())
.dropLastWhile {
it.isEmpty()
}.toTypedArray()
for ((index, word) in words.withIndex()) {
if (word.isNotEmpty()) {
if (exceptions.contains(word))
result.append(word)
else {
Expand All @@ -484,7 +486,6 @@ object CompatUtil {
}
if (index != word.length - 1)
result.append(" ")
index++
}
return result.toString()
}
Expand All @@ -495,10 +496,8 @@ object CompatUtil {
* Get a list from a given array of strings
* @return list of capitalized strings
*/
fun capitalizeWords(vararg strings: String): List<String> {
return Stream.of(*strings)
.map<String> { capitalizeWords(it) }
.toList()
fun capitalizeWords(strings: Array<String>): List<String> {
return strings.map { capitalizeWords(it) }
}

fun <T : Collection<*>> isEmpty(collection: T?): Boolean {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
compileSdk = 28
targetSdk = 28
minSdk = 17
versionCode = 104
versionName = '1.4.1'
versionCode = 105
versionName = '1.4.2'
butterKnife = '8.8.1'
glide = '4.9.0'
retrofit = '2.5.0'
Expand Down

0 comments on commit 3b6d810

Please sign in to comment.