Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareEntryActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareEntryActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareEntryActivity.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..284a8bd80def15b568a18ef5faf776249849d687 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareEntryActivity.java |
@@ -0,0 +1,61 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.physicalweb; |
+ |
+import android.app.Activity; |
+import android.content.DialogInterface; |
+import android.content.Intent; |
+import android.os.Bundle; |
+import android.support.v7.app.AlertDialog; |
+ |
+import org.chromium.base.ContextUtils; |
+import org.chromium.chrome.R; |
+ |
+/** |
+ * Activity used to interact with user before starting Physical Web Sharing. |
+ * TODO(iankc): add Bluetooth checks handling. |
+ */ |
+public class PhysicalWebShareEntryActivity extends Activity { |
+ public static final String SHARING_ENTRY_URL = "physical_web.entry.url"; |
+ |
+ @Override |
+ protected void onCreate(Bundle savedInstanceState) { |
+ super.onCreate(savedInstanceState); |
+ Bundle extras = getIntent().getExtras(); |
+ if (extras == null) { |
+ finish(); |
+ return; |
+ } |
+ final String url = extras.getString(SHARING_ENTRY_URL); |
+ |
+ new AlertDialog.Builder(this) |
+ .setTitle(R.string.physical_web_share_entry_title) |
+ .setMessage(R.string.physical_web_share_entry_message) |
+ .setPositiveButton(R.string.physical_web_share_entry_continue, |
+ new DialogInterface.OnClickListener() { |
+ public void onClick(DialogInterface dialog, int which) { |
+ PhysicalWeb.setSharingOptedIn(); |
+ startBroadcastService(url); |
+ finish(); |
+ } |
+ }) |
+ .setNegativeButton(R.string.physical_web_share_entry_cancel, |
+ new DialogInterface.OnClickListener() { |
+ public void onClick(DialogInterface dialog, int which) { |
+ finish(); |
+ } |
+ }) |
+ .setIcon(android.R.drawable.ic_dialog_info) |
+ .setCancelable(false) |
+ .show(); |
+ } |
+ |
+ private void startBroadcastService(String url) { |
mattreynolds
2017/03/17 00:52:39
This is duplicated in PhysicalWebShareActivity. It
iankc
2017/03/17 01:46:11
Done.
|
+ Intent intent = |
+ new Intent(ContextUtils.getApplicationContext(), PhysicalWebBroadcastService.class); |
+ intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); |
+ startService(intent); |
+ } |
+} |