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

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

Issue 2961203002: Support library changes to allow a callback notifying the selection of default items for Browser Ac… (Closed)
Patch Set: Update based on Yusuf's comments. Created 3 years, 5 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,
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.ActivityManager; 18 import android.app.ActivityManager;
19 import android.app.ActivityOptions; 19 import android.app.ActivityOptions;
20 import android.app.PendingIntent; 20 import android.app.PendingIntent;
21 import android.content.BroadcastReceiver;
22 import android.content.Context;
21 import android.content.Intent; 23 import android.content.Intent;
24 import android.content.IntentFilter;
22 import android.content.pm.PackageManager; 25 import android.content.pm.PackageManager;
23 import android.content.pm.ResolveInfo; 26 import android.content.pm.ResolveInfo;
24 import android.graphics.Bitmap; 27 import android.graphics.Bitmap;
25 import android.graphics.BitmapFactory; 28 import android.graphics.BitmapFactory;
26 import android.graphics.Color; 29 import android.graphics.Color;
27 import android.media.MediaPlayer; 30 import android.media.MediaPlayer;
28 import android.net.Uri; 31 import android.net.Uri;
29 import android.os.Bundle; 32 import android.os.Bundle;
30 import android.os.Handler; 33 import android.os.Handler;
31 import android.os.Looper; 34 import android.os.Looper;
(...skipping 11 matching lines...) Expand all
43 import android.view.View; 46 import android.view.View;
44 import android.view.View.OnClickListener; 47 import android.view.View.OnClickListener;
45 import android.view.View.OnLongClickListener; 48 import android.view.View.OnLongClickListener;
46 import android.view.ViewGroup; 49 import android.view.ViewGroup;
47 import android.widget.AdapterView; 50 import android.widget.AdapterView;
48 import android.widget.ArrayAdapter; 51 import android.widget.ArrayAdapter;
49 import android.widget.Button; 52 import android.widget.Button;
50 import android.widget.EditText; 53 import android.widget.EditText;
51 import android.widget.Spinner; 54 import android.widget.Spinner;
52 import android.widget.TextView; 55 import android.widget.TextView;
56 import android.widget.Toast;
53 57
54 import org.chromium.customtabsclient.shared.CustomTabsHelper; 58 import org.chromium.customtabsclient.shared.CustomTabsHelper;
55 import org.chromium.customtabsclient.shared.ServiceConnection; 59 import org.chromium.customtabsclient.shared.ServiceConnection;
56 import org.chromium.customtabsclient.shared.ServiceConnectionCallback; 60 import org.chromium.customtabsclient.shared.ServiceConnectionCallback;
57 61
58 import java.util.ArrayList; 62 import java.util.ArrayList;
59 import java.util.List; 63 import java.util.List;
60 64
61 /** 65 /**
62 * Example client activity for using Chrome Custom Tabs. 66 * Example client activity for using Chrome Custom Tabs.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawabl e.ic_launcher); 261 Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawabl e.ic_launcher);
258 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 262 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
259 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, int ent, 0); 263 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, int ent, 0);
260 BrowserActionItem item = 264 BrowserActionItem item =
261 new BrowserActionItem("Open the link (without icon)", pendin gIntent); 265 new BrowserActionItem("Open the link (without icon)", pendin gIntent);
262 BrowserActionItem item2 = 266 BrowserActionItem item2 =
263 new BrowserActionItem("Open the link (with icon)", pendingIn tent, icon); 267 new BrowserActionItem("Open the link (with icon)", pendingIn tent, icon);
264 ArrayList<BrowserActionItem> items = new ArrayList<>(); 268 ArrayList<BrowserActionItem> items = new ArrayList<>();
265 items.add(item); 269 items.add(item);
266 items.add(item2); 270 items.add(item2);
267 BrowserActionsIntent.openBrowserAction(this, Uri.parse(url), 271 Intent defaultIntent = new Intent();
268 BrowserActionsIntent.URL_TYPE_IMAGE, items); 272 defaultIntent.setClass(getApplicationContext(), BrowserActionsReceiv er.class);
273 PendingIntent defaultAction = PendingIntent.getBroadcast(this, 0, de faultIntent, 0);
274 BrowserActionsIntent.openBrowserAction(
275 this, Uri.parse(url), BrowserActionsIntent.URL_TYPE_NONE, it ems, defaultAction);
269 } 276 }
270 } 277 }
271 278
272 private void prepareMenuItems(CustomTabsIntent.Builder builder) { 279 private void prepareMenuItems(CustomTabsIntent.Builder builder) {
273 Intent menuIntent = new Intent(); 280 Intent menuIntent = new Intent();
274 menuIntent.setClass(getApplicationContext(), this.getClass()); 281 menuIntent.setClass(getApplicationContext(), this.getClass());
275 // Optional animation configuration when the user clicks menu items. 282 // Optional animation configuration when the user clicks menu items.
276 Bundle menuBundle = ActivityOptions.makeCustomAnimation(this, android.R. anim.slide_in_left, 283 Bundle menuBundle = ActivityOptions.makeCustomAnimation(this, android.R. anim.slide_in_left,
277 android.R.anim.slide_out_right).toBundle(); 284 android.R.anim.slide_out_right).toBundle();
278 PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, menuIntent, 0, 285 PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, menuIntent, 0,
(...skipping 29 matching lines...) Expand all
308 315
309 @Override 316 @Override
310 public void onServiceDisconnected() { 317 public void onServiceDisconnected() {
311 mConnectButton.setEnabled(true); 318 mConnectButton.setEnabled(true);
312 mWarmupButton.setEnabled(false); 319 mWarmupButton.setEnabled(false);
313 mMayLaunchButton.setEnabled(false); 320 mMayLaunchButton.setEnabled(false);
314 mLaunchButton.setEnabled(false); 321 mLaunchButton.setEnabled(false);
315 mClient = null; 322 mClient = null;
316 } 323 }
317 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698