Add custom tabs for displaying wikipedia article
This commit is contained in:
parent
305d877af0
commit
4a126badb5
3 changed files with 18 additions and 7 deletions
|
@ -40,7 +40,7 @@
|
|||
<uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/>
|
||||
|
||||
<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="9"
|
||||
tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes"/>
|
||||
tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs"/>
|
||||
|
||||
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
|
||||
android:xlargeScreens="true" android:anyDensity="true" />
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<String> namesSet = new TreeSet<>();
|
||||
|
|
Loading…
Reference in a new issue