refactored some code
This commit is contained in:
parent
a145ead97a
commit
8cd25174b6
2 changed files with 8 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.mapcontextmenu;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -181,7 +182,7 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
||||||
showFullArticle(Uri.parse(article));
|
showFullArticle(view.getContext(), darkMode, Uri.parse(article));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -207,16 +208,16 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFullArticle(Uri uri) {
|
public static void showFullArticle(Context context, boolean nightMode, Uri uri) {
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
||||||
.setToolbarColor(ContextCompat.getColor(getContext(), darkMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
.setToolbarColor(ContextCompat.getColor(context, nightMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
||||||
.build();
|
.build();
|
||||||
customTabsIntent.launchUrl(getContext(), uri);
|
customTabsIntent.launchUrl(context, uri);
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
i.setData(uri);
|
i.setData(uri);
|
||||||
startActivity(i);
|
context.startActivity(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,11 +291,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
ll.setOnClickListener(new View.OnClickListener() {
|
ll.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (textPrefix.equals("Wikipedia") && (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH)) {
|
if (textPrefix.equals("Wikipedia")) {
|
||||||
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
|
WikipediaDialogFragment.showFullArticle(v.getContext(), !light, Uri.parse(text));
|
||||||
.setToolbarColor(ContextCompat.getColor(v.getContext(), !light ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
|
|
||||||
.build();
|
|
||||||
customTabsIntent.launchUrl(v.getContext(), Uri.parse(text));
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(text));
|
intent.setData(Uri.parse(text));
|
||||||
|
|
Loading…
Reference in a new issue