Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliseomartelli/simplecustomtabs
Android Library made to use custom tabs without going crazy!
https://github.com/eliseomartelli/simplecustomtabs
Last synced: 6 days ago
JSON representation
Android Library made to use custom tabs without going crazy!
- Host: GitHub
- URL: https://github.com/eliseomartelli/simplecustomtabs
- Owner: eliseomartelli
- License: mit
- Created: 2015-12-19T14:52:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-12T07:53:44.000Z (over 8 years ago)
- Last Synced: 2024-10-30T04:07:16.680Z (9 days ago)
- Language: Java
- Size: 172 KB
- Stars: 82
- Watchers: 9
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SimpleCustomTabs
A library made to use custom tabs without going crazy!
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SimpleCustomTabs-orange.svg?style=flat)](http://android-arsenal.com/details/1/2950)
To use this library in your project add the dependency to your build.gradle file.
```gradle
dependencies {
compile 'io.github.eliseomartelli:simple-custom-tabs:1.4.3'
}
```You can see an **example** use of this library opening [*"example"*](https://github.com/eliseomartelli/SimpleCustomTabs/tree/master/example) module.
## Bare Minimum
```java
private CustomTabs.Warmer warmer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);//Warm up section
warmer = CustomTabs.with(getApplicationContext()).warm();//Load section
CustomTabs.with(getApplicationContext()).openUrl("http://google.com", this);
}@Override
protected void onDestroy() {
super.onDestroy();
warmer.unwarm();
}```
## Styling
Choose what to style!
```java
CustomTabs.Style style = new CustomTabs.Style(getApplicationContext());
style.setActionButton(icon, description, pendingIntent, tint);
style.setCloseButton(closeIcon);
style.setShowTitle(showTitle);
style.setStartAnimation(android.R.anim.fade_in, android.R.anim.fade_out);
style.setExitAnimation(android.R.anim.fade_in, android.R.anim.fade_out);
style.setToolbarColor(R.color.colorPrimary);
style.setToolbarColorInt(color);
style.addMenuItem(itemDescription, itemPendingIntent);CustomTabs
.with(getApplicationContext())
.setStyle(style)
.openUrl("http://google.com", this);
```
Do you want to **write less**? No Problem!```java
CustomTabs.with(getApplicationContext())
.setStyle(new CustomTabs.Style(getApplicationContext())
.setShowTitle(true)
.setStartAnimation(R.anim.animation, R.anim.animation)
.setExitAnimation(R.anim.animation, R.anim.animation)
.setToolbarColor(R.color.toolbarColor))
.openUrl("http://google.com", this);
```## Fallback
Your user doesn't have Chrome Installed? No Problem!
The url will be opened in an installed browser without any edit to the code.If you want a customized experience you can set a fallback activity by using:
```java
CustomTabs.with(getApplicationContext())
.setFallBackActivity(ActivityToOpen.class)
.openUrl("http://google.com", this);
```The URI of the site will be placed in Intent's data.
To get the URI from the newly fired you have to get the data from Activity's intent.
To get the data from the Activity intent you can do like this:```java
Uri uri = getIntent().getData();
```You can see an example [here](https://github.com/eliseomartelli/SimpleCustomTabs/blob/master/example/src/main/java/io/github/eliseomartelli/myapplication/FallbackActivity.java).
## Screenshots
***
Hope you enjoy!