Use custom tabs as view whenever possible

pull/145/head
M66B 6 years ago
parent 30d69cb880
commit 8b14f68a35

@ -118,7 +118,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
if (responseCode != BillingClient.BillingResponse.OK) if (responseCode != BillingClient.BillingResponse.OK)
Snackbar.make(getView(), text, Snackbar.LENGTH_LONG).show(); Snackbar.make(getView(), text, Snackbar.LENGTH_LONG).show();
} else } else
startActivity(getIntentPro()); Helper.view(this, getIntentPro());
} }
private void onActivatePro(Intent intent) { private void onActivatePro(Intent intent) {

@ -548,7 +548,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(update); Helper.view(ActivityView.this, update);
} }
}) })
.show(); .show();
@ -624,7 +624,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
private void onMenuFAQ() { private void onMenuFAQ() {
startActivity(getIntentFAQ()); Helper.view(this, getIntentFAQ());
} }
private void onMenuPro() { private void onMenuPro() {
@ -634,7 +634,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
private void onMenuPrivacy() { private void onMenuPrivacy() {
startActivity(getIntentPrivacy()); Helper.view(this, getIntentPrivacy());
} }
private void onMenuAbout() { private void onMenuAbout() {
@ -646,20 +646,20 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onMenuRate() { private void onMenuRate() {
Intent faq = getIntentFAQ(); Intent faq = getIntentFAQ();
if (faq.resolveActivity(getPackageManager()) == null) if (faq.resolveActivity(getPackageManager()) == null)
startActivity(getIntentRate()); Helper.view(this, getIntentRate());
else { else {
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage(R.string.title_issue) .setMessage(R.string.title_issue)
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(getIntentFAQ()); Helper.view(ActivityView.this, getIntentFAQ());
} }
}) })
.setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(getIntentRate()); Helper.view(ActivityView.this, getIntentRate());
} }
}) })
.show(); .show();
@ -667,7 +667,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
private void onMenuOtherApps() { private void onMenuOtherApps() {
startActivity(getIntentOtherApps()); Helper.view(this, getIntentOtherApps());
} }
private class DrawerItem { private class DrawerItem {

@ -180,7 +180,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
return; return;
} }
context.startActivity(intent); Helper.view(context, intent);
} else { } else {
if (attachment.progress == null) { if (attachment.progress == null) {
Bundle args = new Bundle(); Bundle args = new Bundle();

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.net.Uri; import android.net.Uri;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -77,7 +78,17 @@ public class Helper {
} }
}; };
static void view(Context context, Intent intent) {
Uri uri = intent.getData();
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))
view(context, intent.getData());
else
context.startActivity(intent);
}
static void view(Context context, Uri uri) { static void view(Context context, Uri uri) {
Log.i(Helper.TAG, "Custom tab=" + uri);
// https://developer.chrome.com/multidevice/android/customtabs // https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(context, R.attr.colorPrimary)); builder.setToolbarColor(Helper.resolveColor(context, R.attr.colorPrimary));

Loading…
Cancel
Save