Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Side by Side Diff: demos/src/main/java/org/chromium/customtabsdemos/CustomTabActivityHelper.java

Issue 1603383003: color, package and action bar configuration. (Closed) Base URL: https://github.com/GoogleChrome/custom-tabs-client.git@master
Patch Set: fixes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 Google Inc. All Rights Reserved. 1 // Copyright 2015 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * 45 *
46 * @param activity The host activity. 46 * @param activity The host activity.
47 * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is a vailable. 47 * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is a vailable.
48 * @param uri the Uri to be opened. 48 * @param uri the Uri to be opened.
49 * @param fallback a CustomTabFallback to be used if Custom Tabs is not avai lable. 49 * @param fallback a CustomTabFallback to be used if Custom Tabs is not avai lable.
50 */ 50 */
51 public static void openCustomTab(Activity activity, 51 public static void openCustomTab(Activity activity,
52 CustomTabsIntent customTabsIntent, 52 CustomTabsIntent customTabsIntent,
53 Uri uri, 53 Uri uri,
54 CustomTabFallback fallback) { 54 CustomTabFallback fallback) {
55 String packageName = CustomTabsHelper.getPackageNameToUse(activity); 55 openCustomTab(activity, customTabsIntent, uri, fallback, null);
56 }
56 57
57 //If we cant find a package name, it means theres no browser that suppor ts 58 /**
58 //Chrome Custom Tabs installed. So, we fallback to the webview 59 * @see #openCustomTab(Activity, CustomTabsIntent, Uri, CustomTabFallback)
60 * Same as the previous method, but is able to specify which package the use r wants to use.
61 */
62 public static void openCustomTab(Activity activity,
63 CustomTabsIntent customTabsIntent,
64 Uri uri,
65 CustomTabFallback fallback,
66 String packageName) {
59 if (packageName == null) { 67 if (packageName == null) {
60 if (fallback != null) { 68 packageName = CustomTabsHelper.getPackageNameToUse(activity);
61 fallback.openUri(activity, uri); 69 //If we cant find a package name, it means theres no browser that su pports
70 //Chrome Custom Tabs installed. So, we fallback to the webview
71 if (packageName == null) {
72 if (fallback != null) {
73 fallback.openUri(activity, uri);
74 }
62 } 75 }
63 } else { 76 } else {
64 customTabsIntent.intent.setPackage(packageName); 77 customTabsIntent.intent.setPackage(packageName);
65 customTabsIntent.launchUrl(activity, uri); 78 customTabsIntent.launchUrl(activity, uri);
66 } 79 }
67 } 80 }
68 81
69 /** 82 /**
70 * Unbinds the Activity from the Custom Tabs Service. 83 * Unbinds the Activity from the Custom Tabs Service.
71 * @param activity the activity that is connected to the service. 84 * @param activity the activity that is connected to the service.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 public interface CustomTabFallback { 176 public interface CustomTabFallback {
164 /** 177 /**
165 * 178 *
166 * @param activity The Activity that wants to open the Uri. 179 * @param activity The Activity that wants to open the Uri.
167 * @param uri The uri to be opened by the fallback. 180 * @param uri The uri to be opened by the fallback.
168 */ 181 */
169 void openUri(Activity activity, Uri uri); 182 void openUri(Activity activity, Uri uri);
170 } 183 }
171 184
172 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698