Chromium Code Reviews| 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..e63e536096e0ecffce5b6a85a2dc23a88d7bfc1d |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareEntryActivity.java |
| @@ -0,0 +1,65 @@ |
| +// 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; |
| + |
| +/** |
| + * A simple activity that allows Chrome to start the physical web sharing service. |
|
cco3
2017/03/16 22:54:33
Update.
iankc
2017/03/17 00:08:44
Done.
|
| + */ |
| +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) { |
| + ContextUtils.getAppSharedPreferences() |
|
cco3
2017/03/16 22:54:33
I'd move reading and writing to this value to Phys
iankc
2017/03/17 00:08:44
Done.
|
| + .edit() |
| + .putBoolean( |
| + PhysicalWeb.PHYSICAL_WEB_SHARING_PREFERENCE, true) |
| + .apply(); |
| + |
| + 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_alert) |
|
cco3
2017/03/16 22:54:33
It seems a little harsh, is this what we want? Ar
iankc
2017/03/17 00:08:44
Yep. I could use the ic_dialog_info. http://docs.s
|
| + .setCancelable(false) |
|
cco3
2017/03/16 22:54:32
Wouldn't it make more sense to get rid of the nega
iankc
2017/03/17 00:08:44
Acknowledged.
|
| + .show(); |
| + } |
| + |
| + private void startBroadcastService(String url) { |
| + Intent intent = |
| + new Intent(ContextUtils.getApplicationContext(), PhysicalWebBroadcastService.class); |
| + intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); |
| + startService(intent); |
| + } |
| +} |