Use custom tabs as view whenever possible

This commit is contained in:
M66B 2018-09-19 11:19:16 +00:00
parent 30d69cb880
commit 8b14f68a35
4 changed files with 20 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
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) {
Log.i(Helper.TAG, "Custom tab=" + uri);
// https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(context, R.attr.colorPrimary));