diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 145d61cedf..fdb7ebdf55 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -40,7 +40,7 @@ + tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs"/> diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 409fe53919..de30ccf70a 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -389,6 +389,7 @@ dependencies { compile 'com.android.support:cardview-v7:26.1.0' compile 'com.android.support:appcompat-v7:26.1.0' compile 'com.android.support:design:26.1.0' + compile 'com.android.support:customtabs:26.1.0' compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs') legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 8cc8337dbb..292082ab93 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -5,9 +5,11 @@ import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.app.DialogFragment; @@ -17,9 +19,7 @@ import android.support.v7.widget.PopupMenu; import android.text.Html; import android.text.Spannable; import android.text.SpannableString; -import android.text.Spanned; import android.text.TextUtils; -import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; import android.view.Gravity; import android.view.LayoutInflater; @@ -32,7 +32,6 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.data.Amenity; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.util.Algorithms; @@ -189,9 +188,7 @@ public class WikipediaDialogFragment extends DialogFragment { @Override public void onClick(View view) { String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_'); - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(article)); - startActivity(i); + showFullArticle(Uri.parse(article)); } }); @@ -214,6 +211,19 @@ public class WikipediaDialogFragment extends DialogFragment { } } + private void showFullArticle(Uri uri) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() + .setToolbarColor(ContextCompat.getColor(getContext(), darkMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color)) + .build(); + customTabsIntent.launchUrl(getContext(), uri); + } else { + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(uri); + startActivity(i); + } + } + private void showPopupLangMenu(View view, final String langSelected) { final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT); Set namesSet = new TreeSet<>();