Skip to content

Commit

Permalink
[NoTicket] Bump up the min sdk version from 23 to 24 (#2108)
Browse files Browse the repository at this point in the history
* bump up the min sdk version from 23 to 24

* update default sdk version for robolectric tests

* removed some unneeded android N (sdk 24) checks

* lint

* more lint

* fix a couple tests

* more tests getting fixed
  • Loading branch information
mtgriego authored Aug 26, 2024
1 parent 32bbf87 commit 9b593a1
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 54 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ android {
defaultConfig {
compileSdk 34
applicationId "com.kickstarter"
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
testApplicationId "com.kickstarter.internal.debug.test"
testInstrumentationRunner "com.kickstarter.screenshoot.testing.KSScreenShotTestRunner"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/kickstarter/libs/ApiCapabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ private ApiCapabilities() {}
public static boolean canCreateNotificationChannels() {
return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
}

public static boolean needsLegacyHtml() {
return android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.N;
}
}
7 changes: 1 addition & 6 deletions app/src/main/java/com/kickstarter/libs/utils/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import androidx.annotation.Nullable;

import com.kickstarter.R;
import com.kickstarter.libs.ApiCapabilities;
import com.kickstarter.ui.views.ConfirmDialog;

import rx.functions.Action1;
Expand Down Expand Up @@ -68,11 +67,7 @@ public static int getScreenWidthDp(final @NonNull Context context) {
*
*/
public static Spanned html(final @NonNull String htmlString) {
if (ApiCapabilities.needsLegacyHtml()) {
return Html.fromHtml(htmlString);
} else {
return Html.fromHtml(htmlString, Html.FROM_HTML_MODE_COMPACT);
}
return Html.fromHtml(htmlString, Html.FROM_HTML_MODE_COMPACT);
}

public static boolean isFontScaleLarge(final @NonNull Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package com.kickstarter.libs.utils.extensions

import android.os.Build
import android.text.Html
import android.text.Spanned
import android.text.TextUtils
Expand Down Expand Up @@ -212,11 +211,7 @@ fun String.hrefUrlFromTranslation(): String {
* Takes a String resource with HTMl Returns displayable styled text from the provided HTML string.
*/
fun String.toHtml(): Spanned {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(TextUtils.htmlEncode(this), Html.FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(TextUtils.htmlEncode(this))
}
return Html.fromHtml(TextUtils.htmlEncode(this), Html.FROM_HTML_MODE_LEGACY)
}

fun String.toHashedSHAEmail(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.kickstarter.ui.fragments.projectpage

import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.text.Html
import android.text.Html.FROM_HTML_MODE_LEGACY
Expand Down Expand Up @@ -429,11 +428,8 @@ class ProjectOverviewFragment : Fragment(), Configure {
}

private fun setBlurbTextViews(blurb: String) {
val blurbHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val blurbHtml =
Html.fromHtml(TextUtils.htmlEncode(blurb), FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(TextUtils.htmlEncode(blurb))
}
binding.blurb.text = blurbHtml
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.kickstarter.ui.viewholders
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.text.Html
import android.util.Pair
import com.facebook.share.model.ShareLinkContent
Expand Down Expand Up @@ -90,32 +89,18 @@ class ThanksShareViewHolder(private val binding: ThanksShareViewBinding) : KSVie
}

private fun showPostCampaignPledgeText(pcptext: Pair<Double, Project>) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
binding.backedProject.text = Html.fromHtml(
ksString.format(
context().getString(R.string.You_have_successfully_pledged_to_project_post_campaign_html_short),
"pledge_total",
ksCurrency.format(
initialValue = pcptext.first,
project = pcptext.second,
roundingMode = RoundingMode.HALF_UP
)
),
Html.FROM_HTML_MODE_LEGACY
)
} else {
binding.backedProject.text = Html.fromHtml(
ksString.format(
context().getString(R.string.You_have_successfully_pledged_to_project_post_campaign_html_short),
"pledge_total",
ksCurrency.format(
initialValue = pcptext.first,
project = pcptext.second,
roundingMode = RoundingMode.HALF_UP
)
),
)
}
binding.backedProject.text = Html.fromHtml(
ksString.format(
context().getString(R.string.You_have_successfully_pledged_to_project_post_campaign_html_short),
"pledge_total",
ksCurrency.format(
initialValue = pcptext.first,
project = pcptext.second,
roundingMode = RoundingMode.HALF_UP
)
),
Html.FROM_HTML_MODE_LEGACY
)
}

private fun startShare(projectNameAndShareUrl: Pair<String, String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.robolectric.RobolectricTestRunner;

public class KSRobolectricGradleTestRunner extends RobolectricTestRunner {
static final int DEFAULT_SDK = Build.VERSION_CODES.M;
static final int DEFAULT_SDK = Build.VERSION_CODES.N;

public KSRobolectricGradleTestRunner(final Class<?> testClass) throws InitializationError {
super(testClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class SendThirdPartyEventUseCaseTest : KSRobolectricTestCase() {
assertEquals(false, input.appData.iOSConsent)
assertEquals("a2", input.appData.extInfo.first())
assertEquals(16, input.appData.extInfo.size)
assertEquals("6.0.1", input.appData.extInfo[4])
assertEquals("7.0", input.appData.extInfo[4])
}

@Test
Expand Down Expand Up @@ -404,7 +404,7 @@ class SendThirdPartyEventUseCaseTest : KSRobolectricTestCase() {
assertEquals(false, input.appData.iOSConsent)
assertEquals("a2", input.appData.extInfo.first())
assertEquals(16, input.appData.extInfo.size)
assertEquals("6.0.1", input.appData.extInfo[4])
assertEquals("7.0", input.appData.extInfo[4])
}

private fun subscribeToThirdPartyEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class SendThirdPartyEventUseCaseV2Test : KSRobolectricTestCase() {
assertEquals(false, input.appData.iOSConsent)
assertEquals("a2", input.appData.extInfo.first())
assertEquals(16, input.appData.extInfo.size)
assertEquals("6.0.1", input.appData.extInfo[4])
assertEquals("7.0", input.appData.extInfo[4])
}

@Test
Expand Down Expand Up @@ -416,7 +416,7 @@ class SendThirdPartyEventUseCaseV2Test : KSRobolectricTestCase() {
assertEquals(false, input.appData.iOSConsent)
assertEquals("a2", input.appData.extInfo.first())
assertEquals(16, input.appData.extInfo.size)
assertEquals("6.0.1", input.appData.extInfo[4])
assertEquals("7.0", input.appData.extInfo[4])
}

private fun subscribeToThirdPartyEvent(
Expand Down

0 comments on commit 9b593a1

Please sign in to comment.