Skip to content

Commit d27d7be

Browse files
committed
添加 Chrome Cuatom Tabs
1 parent ed2c5a3 commit d27d7be

4 files changed

Lines changed: 49 additions & 4 deletions

File tree

diycode-app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ android {
2828

2929
defaultConfig {
3030
applicationId "com.gcssloop.diycode"
31-
minSdkVersion 14
31+
minSdkVersion 15
3232
targetSdkVersion 25
3333
versionCode 4
3434
versionName "v0.0.6"
@@ -59,6 +59,7 @@ dependencies {
5959
compile 'com.github.gcssloop:ViewSupport:v1.3.0'
6060
compile 'com.bm.photoview:library:1.4.1'
6161
compile 'com.romandanylyk:pageindicatorview:0.1.2@aar'
62+
compile 'com.android.support:customtabs:25.3.0'
6263
compile project(':diycode-sdk')
6364
compile project(':expectanim')
6465
compile project(':recyclerview')

diycode-app/src/main/java/com/gcssloop/diycode/utils/IntentUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import android.util.Log;
2929
import android.widget.Toast;
3030

31-
import com.gcssloop.diycode.activity.WebActivity;
32-
import com.gcssloop.diycode_sdk.log.Logger;
31+
import com.gcssloop.diycode.utils.customtabs.CustomTabsHelper;
3332

3433
public class IntentUtil {
3534

@@ -47,6 +46,8 @@ public static void openUrl(Context context, String url) {
4746
Log.i("Diyocde", "Url地址错误");
4847
return;
4948
}
49+
CustomTabsHelper.openUrl(context, url);
50+
/*
5051
Boolean useInside = true;
5152
try {
5253
useInside = Config.getSingleInstance().isUseInsideBrowser();
@@ -58,7 +59,7 @@ public static void openUrl(Context context, String url) {
5859
} else {
5960
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
6061
context.startActivity(intent);
61-
}
62+
}*/
6263
}
6364

6465
/**
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2017 GcsSloop
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* Last modified 2017-04-09 23:33:07
17+
*
18+
* GitHub: https://github.com/GcsSloop
19+
* Website: http://www.gcssloop.com
20+
* Weibo: http://weibo.com/GcsSloop
21+
*/
22+
23+
package com.gcssloop.diycode.utils.customtabs;
24+
25+
import android.content.Context;
26+
import android.graphics.BitmapFactory;
27+
import android.graphics.Color;
28+
import android.net.Uri;
29+
import android.support.customtabs.CustomTabsIntent;
30+
31+
import com.gcssloop.diycode.R;
32+
33+
public class CustomTabsHelper {
34+
35+
public static void openUrl(Context context, String url) {
36+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
37+
builder.setToolbarColor(Color.WHITE);
38+
builder.setShowTitle(true);
39+
builder.setCloseButtonIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_arrow_back));
40+
CustomTabsIntent customTabsIntent = builder.build();
41+
customTabsIntent.launchUrl(context, Uri.parse(url));
42+
}
43+
}
113 Bytes
Loading

0 commit comments

Comments
 (0)