Browse Source

Refactoring

main
M66B 6 years ago
parent
commit
30d69cb880
3 changed files with 13 additions and 13 deletions
  1. +1
    -7
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  2. +1
    -6
      app/src/main/java/eu/faircode/email/FragmentWebView.java
  3. +11
    -0
      app/src/main/java/eu/faircode/email/Helper.java

+ 1
- 7
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -89,7 +89,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -336,12 +335,7 @@ public class FragmentMessage extends FragmentEx {
return; return;
} }
// https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(getContext(), R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), uri);
Helper.view(getContext(), uri);
} }
}) })
.setNegativeButton(R.string.title_no, null) .setNegativeButton(R.string.title_no, null)


+ 1
- 6
app/src/main/java/eu/faircode/email/FragmentWebView.java View File

@ -34,7 +34,6 @@ import android.widget.ProgressBar;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
// https://developer.android.com/reference/android/webkit/WebView // https://developer.android.com/reference/android/webkit/WebView
@ -64,11 +63,7 @@ public class FragmentWebView extends FragmentEx {
setSubtitle(url); setSubtitle(url);
return false; return false;
} else { } else {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(getContext(), R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), Uri.parse(url));
Helper.view(getContext(), Uri.parse(url));
return true; return true;
} }
} }


+ 11
- 0
app/src/main/java/eu/faircode/email/Helper.java View File

@ -23,6 +23,7 @@ import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.net.Uri;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
@ -55,6 +56,7 @@ import javax.mail.FolderClosedException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.browser.customtabs.CustomTabsIntent;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND; import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
@ -75,6 +77,15 @@ public class Helper {
} }
}; };
static void view(Context context, Uri uri) {
// https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(context, R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, uri);
}
static int resolveColor(Context context, int attr) { static int resolveColor(Context context, int attr) {
int[] attrs = new int[]{attr}; int[] attrs = new int[]{attr};
TypedArray a = context.getTheme().obtainStyledAttributes(attrs); TypedArray a = context.getTheme().obtainStyledAttributes(attrs);


Loading…
Cancel
Save