This repository has been archived by the owner on May 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lizhaotailang
committed
Mar 27, 2017
1 parent
7815734
commit 7b029e0
Showing
34 changed files
with
397 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
mobile/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.github.marktony.espresso.customtabs; | ||
|
||
import android.content.ActivityNotFoundException; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.net.Uri; | ||
import android.preference.PreferenceManager; | ||
import android.support.customtabs.CustomTabsIntent; | ||
import android.support.v4.content.ContextCompat; | ||
import android.widget.Toast; | ||
|
||
import io.github.marktony.espresso.R; | ||
import io.github.marktony.espresso.util.SettingsUtil; | ||
|
||
/** | ||
* Created by lizhaotailang on 2017/3/27. | ||
*/ | ||
|
||
public class CustomTabsHelper { | ||
|
||
public static void openUrl(Context context, String url) { | ||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | ||
|
||
if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) { | ||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); | ||
builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark)); | ||
builder.build().launchUrl(context, Uri.parse(url)); | ||
} else { | ||
try { | ||
context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url))); | ||
} catch (ActivityNotFoundException e) { | ||
Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.