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

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

Issue 2946003005: Change Custom Tab Client test app to be easier for Browser Actions test. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Application/src/main/res/layout/main.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Application/src/main/java/org/chromium/customtabsclient/MainActivity.java
diff --git a/Application/src/main/java/org/chromium/customtabsclient/MainActivity.java b/Application/src/main/java/org/chromium/customtabsclient/MainActivity.java
index 2f6ae41e9148afb30dcb494490d970ef5154935e..1f4b5a18e15cd7ca07e8d4c5c9d1a08e1a642a9a 100644
--- a/Application/src/main/java/org/chromium/customtabsclient/MainActivity.java
+++ b/Application/src/main/java/org/chromium/customtabsclient/MainActivity.java
@@ -61,11 +61,9 @@ import java.util.List;
/**
* Example client activity for using Chrome Custom Tabs.
*/
-public class MainActivity extends Activity
- implements OnClickListener, ServiceConnectionCallback, OnLongClickListener {
+public class MainActivity extends Activity implements OnClickListener, ServiceConnectionCallback {
private static final String TAG = "CustomTabsClientExample";
private static final String TOOLBAR_COLOR = "#ef6c00";
- private static final String URL_STRING = "https://www.google.com";
private EditText mEditText;
private CustomTabsSession mCustomTabsSession;
@@ -77,7 +75,7 @@ public class MainActivity extends Activity
private Button mMayLaunchButton;
private Button mLaunchButton;
private MediaPlayer mMediaPlayer;
- private TextView mUrlLinkText;
+ private Button mLaunchBrowserActionsButton;
/**
* Once per second, asks the framework for the process importance, and logs any change.
@@ -123,15 +121,14 @@ public class MainActivity extends Activity
mMayLaunchButton = (Button) findViewById(R.id.may_launch_button);
mLaunchButton = (Button) findViewById(R.id.launch_button);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
- mUrlLinkText = (TextView) findViewById(R.id.url_link);
+ mLaunchBrowserActionsButton = (Button) findViewById(R.id.launch_browser_actions_button);
mEditText.requestFocus();
mConnectButton.setOnClickListener(this);
mWarmupButton.setOnClickListener(this);
mMayLaunchButton.setOnClickListener(this);
mLaunchButton.setOnClickListener(this);
mMediaPlayer = MediaPlayer.create(this, R.raw.amazing_grace);
- mUrlLinkText.setText(URL_STRING);
- mUrlLinkText.setOnLongClickListener(this);
+ mLaunchBrowserActionsButton.setOnClickListener(this);
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
PackageManager pm = getPackageManager();
@@ -256,6 +253,19 @@ public class MainActivity extends Activity
CustomTabsIntent customTabsIntent = builder.build();
CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
customTabsIntent.launchUrl(this, Uri.parse(url));
+ } else if (viewId == R.id.launch_browser_actions_button) {
+ Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
+ BrowserActionItem item =
+ new BrowserActionItem("Open the link (without icon)", pendingIntent);
+ BrowserActionItem item2 =
+ new BrowserActionItem("Open the link (with icon)", pendingIntent, icon);
+ ArrayList<BrowserActionItem> items = new ArrayList<>();
+ items.add(item);
+ items.add(item2);
+ BrowserActionsIntent.openBrowserAction(this, Uri.parse(url),
+ BrowserActionsIntent.URL_TYPE_IMAGE, items);
}
}
@@ -304,21 +314,4 @@ public class MainActivity extends Activity
mLaunchButton.setEnabled(false);
mClient = null;
}
-
- @Override
- public boolean onLongClick(View v) {
- Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_STRING));
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
- BrowserActionItem item =
- new BrowserActionItem("Open the link (without icon)", pendingIntent);
- BrowserActionItem item2 =
- new BrowserActionItem("Open the link (with icon)", pendingIntent, icon);
- ArrayList<BrowserActionItem> items = new ArrayList<>();
- items.add(item);
- items.add(item2);
- BrowserActionsIntent.openBrowserAction(this, Uri.parse(mUrlLinkText.getText().toString()),
- BrowserActionsIntent.URL_TYPE_IMAGE, items);
- return true;
- }
}
« no previous file with comments | « no previous file | Application/src/main/res/layout/main.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698