| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.share; | 5 package org.chromium.chrome.browser.share; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
| 9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
| 10 import android.os.AsyncTask; | 10 import android.os.AsyncTask; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * Enables sharing options. | 39 * Enables sharing options. |
| 40 * @param triggeringActivity The activity that will be triggering the share
action. The | 40 * @param triggeringActivity The activity that will be triggering the share
action. The |
| 41 * activity's state will be tracked to disable the options w
hen | 41 * activity's state will be tracked to disable the options w
hen |
| 42 * the share operation has been completed. | 42 * the share operation has been completed. |
| 43 * @param enabledClasses classes to be enabled. | 43 * @param enabledClasses classes to be enabled. |
| 44 * @param callback The callback to be triggered after the options have been
enabled. This | 44 * @param callback The callback to be triggered after the options have been
enabled. This |
| 45 * may or may not be synchronous depending on whether this w
ill require | 45 * may or may not be synchronous depending on whether this w
ill require |
| 46 * interacting with the Android framework. | 46 * interacting with the Android framework. |
| 47 */ | 47 */ |
| 48 public static void enableOptionalShareActivities(final Activity triggeringAc
tivity, | 48 public static void enableOptionalShareActivities(final Activity triggeringAc
tivity, |
| 49 final List<Class<? extends Activity>> enabledClasses, final Runnable
callback) { | 49 final List<Class<? extends ShareActivity>> enabledClasses, final Run
nable callback) { |
| 50 ThreadUtils.assertOnUiThread(); | 50 ThreadUtils.assertOnUiThread(); |
| 51 | 51 |
| 52 if (sStateListener == null) { | 52 if (sStateListener == null) { |
| 53 sStateListener = new ActivityStateListener() { | 53 sStateListener = new ActivityStateListener() { |
| 54 @Override | 54 @Override |
| 55 public void onActivityStateChange(Activity triggeringActivity, i
nt newState) { | 55 public void onActivityStateChange(Activity triggeringActivity, i
nt newState) { |
| 56 if (newState == ActivityState.PAUSED) return; | 56 if (newState == ActivityState.PAUSED) return; |
| 57 handleShareFinish(triggeringActivity); | 57 handleShareFinish(triggeringActivity); |
| 58 } | 58 } |
| 59 }; | 59 }; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 try { | 142 try { |
| 143 sStateChangeTask.get(); | 143 sStateChangeTask.get(); |
| 144 sStateChangeTask = null; | 144 sStateChangeTask = null; |
| 145 } catch (InterruptedException | ExecutionException e) { | 145 } catch (InterruptedException | ExecutionException e) { |
| 146 Log.e(TAG, "State change task did not complete as expected"); | 146 Log.e(TAG, "State change task did not complete as expected"); |
| 147 } finally { | 147 } finally { |
| 148 StrictMode.setThreadPolicy(oldPolicy); | 148 StrictMode.setThreadPolicy(oldPolicy); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } | 151 } |
| OLD | NEW |