Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
| index 09891aa8bbbe61dbc91eb2978a1d954d048f65cc..cc7e3fc8774d954bcbcc96d3db81c8ef28654f33 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
| @@ -5,8 +5,11 @@ |
| package org.chromium.chrome.browser.physicalweb; |
| import android.content.Intent; |
| +import android.content.SharedPreferences; |
| import android.os.Build; |
| +import org.chromium.base.ContextUtils; |
| +import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.ChromeActivity; |
| import org.chromium.chrome.browser.share.ShareActivity; |
| @@ -16,9 +19,22 @@ import org.chromium.chrome.browser.share.ShareActivity; |
| public class PhysicalWebShareActivity extends ShareActivity { |
| @Override |
| protected void handleShareAction(ChromeActivity triggeringActivity) { |
| - String url = triggeringActivity.getActivityTab().getUrl(); |
| + final String url = triggeringActivity.getActivityTab().getUrl(); |
|
cco3
2017/03/16 22:54:32
Why is this final?
iankc
2017/03/17 00:08:44
At one point I was using it in an attempt to open
|
| - Intent intent = new Intent(this, PhysicalWebBroadcastService.class); |
| + SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); |
| + boolean optedIn = |
|
cco3
2017/03/16 22:54:32
I'd move reading and writing to this value to Phys
iankc
2017/03/17 00:08:44
Done.
|
| + sharedPrefs.getBoolean(PhysicalWeb.PHYSICAL_WEB_SHARING_PREFERENCE, false); |
| + if (!optedIn) { |
| + triggeringActivity.onMenuOrKeyboardAction(R.id.physical_web_sharing_id, true); |
| + return; |
| + } |
| + |
| + startBroadcastService(url); |
| + } |
| + |
| + private void startBroadcastService(String url) { |
| + Intent intent = |
| + new Intent(ContextUtils.getApplicationContext(), PhysicalWebBroadcastService.class); |
| intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); |
| startService(intent); |
| } |
| @@ -35,6 +51,6 @@ public class PhysicalWebShareActivity extends ShareActivity { |
| public static boolean featureIsAvailable() { |
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false; |
| return PhysicalWeb.hasBleAdvertiseCapability() && PhysicalWeb.bluetoothIsEnabled() |
| - && PhysicalWeb.sharingIsEnabled(); |
| + && !PhysicalWeb.sharingIsEnabled(); |
|
cco3
2017/03/16 22:54:32
?
iankc
2017/03/17 00:08:44
That was for testing...
|
| } |
| } |