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

Side by Side Diff: Application/src/main/java/org/chromium/customtabsclient/MainActivity.java

Issue 2438103002: Add postMessage APIs to the support lib (Closed)
Patch Set: lizeb@ comments Created 4 years, 1 month 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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 package org.chromium.customtabsclient; 15 package org.chromium.customtabsclient;
16 16
17 import android.app.Activity; 17 import android.app.Activity;
18 import android.app.ActivityOptions; 18 import android.app.ActivityOptions;
19 import android.app.PendingIntent; 19 import android.app.PendingIntent;
20 import android.content.Intent; 20 import android.content.Intent;
21 import android.content.pm.PackageInfo;
21 import android.content.pm.PackageManager; 22 import android.content.pm.PackageManager;
22 import android.content.pm.ResolveInfo; 23 import android.content.pm.ResolveInfo;
23 import android.graphics.Bitmap; 24 import android.graphics.Bitmap;
24 import android.graphics.BitmapFactory; 25 import android.graphics.BitmapFactory;
25 import android.graphics.Color; 26 import android.graphics.Color;
26 import android.media.MediaPlayer; 27 import android.media.MediaPlayer;
27 import android.net.Uri; 28 import android.net.Uri;
28 import android.os.Bundle; 29 import android.os.Bundle;
29 import android.support.customtabs.CustomTabsCallback; 30 import android.support.customtabs.CustomTabsCallback;
30 import android.support.customtabs.CustomTabsClient; 31 import android.support.customtabs.CustomTabsClient;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 163
163 @Override 164 @Override
164 public void onClick(View v) { 165 public void onClick(View v) {
165 String url = mEditText.getText().toString(); 166 String url = mEditText.getText().toString();
166 int viewId = v.getId(); 167 int viewId = v.getId();
167 168
168 if (viewId == R.id.connect_button) { 169 if (viewId == R.id.connect_button) {
169 bindCustomTabsService(); 170 bindCustomTabsService();
170 } else if (viewId == R.id.warmup_button) { 171 } else if (viewId == R.id.warmup_button) {
172 try {
173 PackageInfo info = getPackageManager().getPackageInfo("com.twitt er.android", 0);
Benoit L 2016/11/09 10:11:00 You probably want to remove these lines. :-)
Yusuf 2016/11/09 18:29:21 ha!
174 android.util.Log.e("Yusuf",info.signatures[0].toString());
175 } catch (PackageManager.NameNotFoundException e) {
176 //do nothing;
177 }
171 boolean success = false; 178 boolean success = false;
172 if (mClient != null) success = mClient.warmup(0); 179 if (mClient != null) success = mClient.warmup(0);
173 if (!success) mWarmupButton.setEnabled(false); 180 if (!success) mWarmupButton.setEnabled(false);
174 } else if (viewId == R.id.may_launch_button) { 181 } else if (viewId == R.id.may_launch_button) {
175 CustomTabsSession session = getSession(); 182 CustomTabsSession session = getSession();
176 boolean success = false; 183 boolean success = false;
177 if (mClient != null) success = session.mayLaunchUrl(Uri.parse(url), null, null); 184 if (mClient != null) success = session.mayLaunchUrl(Uri.parse(url), null, null);
178 if (!success) mMayLaunchButton.setEnabled(false); 185 if (!success) mMayLaunchButton.setEnabled(false);
179 } else if (viewId == R.id.launch_button) { 186 } else if (viewId == R.id.launch_button) {
180 CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getS ession()); 187 CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getS ession());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 238
232 @Override 239 @Override
233 public void onServiceDisconnected() { 240 public void onServiceDisconnected() {
234 mConnectButton.setEnabled(true); 241 mConnectButton.setEnabled(true);
235 mWarmupButton.setEnabled(false); 242 mWarmupButton.setEnabled(false);
236 mMayLaunchButton.setEnabled(false); 243 mMayLaunchButton.setEnabled(false);
237 mLaunchButton.setEnabled(false); 244 mLaunchButton.setEnabled(false);
238 mClient = null; 245 mClient = null;
239 } 246 }
240 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698