From 8aa217c028069e061a9de7aaaf78f9ee1e3f0cbb Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Fri, 20 Dec 2019 20:08:02 +0100 Subject: [PATCH] upgrade androidx.browser to 1.2.0 (#1595) --- app/build.gradle | 3 ++- .../com/keylesspalace/tusky/LoginActivity.kt | 14 +++++++++++--- .../com/keylesspalace/tusky/util/LinkHelper.java | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 65a384a1..0c4ab184 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -107,7 +107,8 @@ dependencies { implementation "androidx.core:core-ktx:1.2.0-beta01" implementation "androidx.appcompat:appcompat:1.1.0" implementation "androidx.fragment:fragment-ktx:1.1.0" - implementation "androidx.browser:browser:1.0.0" + implementation "androidx.browser:browser:1.2.0" + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation "androidx.recyclerview:recyclerview:1.0.0" implementation "androidx.exifinterface:exifinterface:1.0.0" implementation "androidx.cardview:cardview:1.0.0" diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt index b7f47273..f659ab86 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt @@ -20,14 +20,15 @@ import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.net.Uri +import android.os.Build import android.os.Bundle -import androidx.browser.customtabs.CustomTabsIntent import android.text.method.LinkMovementMethod import android.util.Log import android.view.MenuItem import android.view.View import android.widget.TextView import androidx.appcompat.app.AlertDialog +import androidx.browser.customtabs.CustomTabsIntent import com.bumptech.glide.Glide import com.keylesspalace.tusky.di.Injectable import com.keylesspalace.tusky.entity.AccessToken @@ -345,9 +346,16 @@ class LoginActivity : BaseActivity(), Injectable { private fun openInCustomTab(uri: Uri, context: Context): Boolean { val toolbarColor = ThemeUtils.getColor(context, R.attr.custom_tab_toolbar) - val customTabsIntent = CustomTabsIntent.Builder() + val customTabsIntentBuilder = CustomTabsIntent.Builder() .setToolbarColor(toolbarColor) - .build() + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + customTabsIntentBuilder.setNavigationBarColor( + ThemeUtils.getColor(context, android.R.attr.navigationBarColor) + ) + } + + val customTabsIntent = customTabsIntentBuilder.build() try { customTabsIntent.launchUrl(context, uri) } catch (e: ActivityNotFoundException) { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java index 606a36a9..bcc2ce5c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java @@ -19,6 +19,7 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.method.LinkMovementMethod; @@ -68,7 +69,7 @@ public class LinkHelper { * @param listener to notify about particular spans that are clicked */ public static void setClickableText(TextView view, Spanned content, - @Nullable Status.Mention[] mentions, final LinkListener listener) { + @Nullable Status.Mention[] mentions, final LinkListener listener) { SpannableStringBuilder builder = new SpannableStringBuilder(content); URLSpan[] urlSpans = content.getSpans(0, content.length(), URLSpan.class); for (URLSpan span : urlSpans) { @@ -221,10 +222,17 @@ public class LinkHelper { public static void openLinkInCustomTab(Uri uri, Context context) { int toolbarColor = ThemeUtils.getColor(context, R.attr.custom_tab_toolbar); - CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() + CustomTabsIntent.Builder customTabsIntentBuilder = new CustomTabsIntent.Builder() .setToolbarColor(toolbarColor) - .setShowTitle(true) - .build(); + .setShowTitle(true); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + customTabsIntentBuilder.setNavigationBarColor( + ThemeUtils.getColor(context, android.R.attr.navigationBarColor) + ); + } + + CustomTabsIntent customTabsIntent = customTabsIntentBuilder.build(); try { customTabsIntent.launchUrl(context, uri); } catch (ActivityNotFoundException e) {