Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use CustomTabsIntent to open links #1576

Merged
merged 3 commits into from
Mar 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Use CustomTabsIntent to open links
ShridharGoel committed Mar 22, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c3f9a2c9a293bac7b751e93750582888a016edbf
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -122,6 +122,7 @@ dependencies {
implementation "com.android.support:cardview-v7:${versions.support_lib}"
implementation "com.android.support:recyclerview-v7:${versions.support_lib}"
implementation "com.android.support:design:${versions.support_lib}"
implementation "com.android.support:customtabs:${versions.support_lib}"
implementation "com.android.support:palette-v7:${versions.support_lib}"
implementation "com.takisoft.fix:preference-v7:${versions.support_lib}.0"
playStoreImplementation "com.google.android.gms:play-services-vision:${versions.play_services}"
19 changes: 15 additions & 4 deletions app/src/fdroid/java/com/eventyay/organizer/utils/BrowserUtils.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package com.eventyay.organizer.utils;

import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat;

import com.eventyay.organizer.R;

public final class BrowserUtils {

private BrowserUtils() {
}

public static void launchUrl(Context context, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
context.startActivity(intent);
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://" + url;
}

new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(context, R.color.color_primary_dark))
.setCloseButtonIcon(BitmapFactory.decodeResource(context.getResources(),
R.drawable.ic_arrow_back_black))
.build()
.launchUrl(context, Uri.parse(url));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.