Java Code Examples for org.chromium.base.ApplicationStatus#getLastTrackedFocusedActivity()
The following examples show how to use
org.chromium.base.ApplicationStatus#getLastTrackedFocusedActivity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMediaRouteDialogManager.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void openDialog() { if (mAndroidMediaRouter == null) { mDelegate.onDialogCancelled(); return; } FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity == null) { mDelegate.onDialogCancelled(); return; } FragmentManager fm = currentActivity.getSupportFragmentManager(); if (fm == null) { mDelegate.onDialogCancelled(); return; } mDialogFragment = openDialogInternal(fm); if (mDialogFragment == null) { mDelegate.onDialogCancelled(); return; } }
Example 2
Source File: BaseMediaRouteDialogManager.java From delion with Apache License 2.0 | 6 votes |
@Override public void openDialog() { if (mAndroidMediaRouter == null) { mDelegate.onDialogCancelled(); return; } FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity == null) { mDelegate.onDialogCancelled(); return; } FragmentManager fm = currentActivity.getSupportFragmentManager(); if (fm == null) { mDelegate.onDialogCancelled(); return; } mDialogFragment = openDialogInternal(fm); if (mDialogFragment == null) { mDelegate.onDialogCancelled(); return; } }
Example 3
Source File: CastNotificationControl.java From 365browser with Apache License 2.0 | 6 votes |
private String getCurrentTabOrigin() { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (!(activity instanceof ChromeTabbedActivity)) return null; Tab tab = ((ChromeTabbedActivity) activity).getActivityTab(); if (tab == null || !tab.isInitialized()) return null; String url = tab.getUrl(); try { return UrlFormatter.formatUrlForSecurityDisplay(new URI(url), true); } catch (URISyntaxException | UnsatisfiedLinkError e) { // UnstatisfiedLinkError can only happen in tests as the natives are not initialized // yet. Log.e(TAG, "Unable to parse the origin from the URL. Using the full URL instead."); return url; } }
Example 4
Source File: BaseMediaRouteDialogManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void openDialog() { if (mAndroidMediaRouter == null) { mDelegate.onDialogCancelled(); return; } FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity == null) { mDelegate.onDialogCancelled(); return; } FragmentManager fm = currentActivity.getSupportFragmentManager(); if (fm == null) { mDelegate.onDialogCancelled(); return; } mDialogFragment = openDialogInternal(fm); if (mDialogFragment == null) { mDelegate.onDialogCancelled(); return; } }
Example 5
Source File: ChromeApplication.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Shows an error dialog following a startup error, and then exits the application. * @param e The exception reported by Chrome initialization. */ public static void reportStartupErrorAndExit(final ProcessInitException e) { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DESTROYED) { return; } InvalidStartupDialog.show(activity, e.getErrorCode()); }
Example 6
Source File: DownloadController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Returns whether file access is allowed. * * @return true if allowed, or false otherwise. */ @CalledByNative private static boolean hasFileAccess() { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (activity instanceof ChromeActivity) { return ((ChromeActivity) activity) .getWindowAndroid() .hasPermission(permission.WRITE_EXTERNAL_STORAGE); } return false; }
Example 7
Source File: RemoteMediaPlayerController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Links this object to the Activity that owns the video, if it exists. * */ private void linkToBrowserActivity() { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity != null) { mChromeVideoActivity = new WeakReference<Activity>(currentActivity); mCastContextApplicationContext = currentActivity.getApplicationContext(); createMediaRouteControllers(currentActivity); } }
Example 8
Source File: DownloadSnackbarController.java From 365browser with Apache License 2.0 | 5 votes |
private Activity getActivity() { if (ApplicationStatus.hasVisibleActivities()) { return ApplicationStatus.getLastTrackedFocusedActivity(); } else { return null; } }
Example 9
Source File: OfflinePageDownloadBridge.java From 365browser with Apache License 2.0 | 5 votes |
private static ComponentName getComponentName() { if (!ApplicationStatus.hasVisibleActivities()) return null; Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (activity instanceof ChromeTabbedActivity) { return activity.getComponentName(); } return null; }
Example 10
Source File: RemoteMediaPlayerController.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called when a lower layer requests that a video be cast. This will typically be a request * from Blink when the cast button is pressed on the default video controls. * @param player the player for which cast is being requested * @param frameUrl the URL of the frame containing the video, needed for YouTube videos */ public void requestRemotePlayback( MediaRouteController.MediaStateListener player, MediaRouteController controller) { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); mChromeVideoActivity = new WeakReference<Activity>(currentActivity); if (mCurrentRouteController != null && controller != mCurrentRouteController) { mCurrentRouteController.release(); } onStateReset(controller); showMediaRouteDialog(player, controller, currentActivity); }
Example 11
Source File: RemoteMediaPlayerController.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Links this object to the Activity that owns the video, if it exists. * */ private void linkToBrowserActivity() { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity != null) { mChromeVideoActivity = new WeakReference<Activity>(currentActivity); mCastContextApplicationContext = currentActivity.getApplicationContext(); createMediaRouteControllers(currentActivity); } }
Example 12
Source File: ActivityStopMetrics.java From delion with Apache License 2.0 | 5 votes |
/** * Records the reason that the parent Activity was stopped. * @param parent Activity that owns this {@link ActivityStopMetrics} instance. */ public void onStopWithNative(Activity parent) { if (mStopReason == STOP_REASON_COUNT) { if (parent != ApplicationStatus.getLastTrackedFocusedActivity() && ApplicationStatus.hasVisibleActivities()) { mStopReason = STOP_REASON_OTHER_CHROME_ACTIVITY_IN_FOREGROUND; } else { mStopReason = STOP_REASON_UNKNOWN; } } RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_NAME, mStopReason, STOP_REASON_COUNT); mStopReason = STOP_REASON_COUNT; }
Example 13
Source File: OMADownloadHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Shows a dialog to ask whether user wants to open the nextURL. * * @param omaInfo Information about the OMA content. */ private void showNextUrlDialog(OMAInfo omaInfo) { if (omaInfo.isValueEmpty(OMA_NEXT_URL)) { return; } final String nextUrl = omaInfo.getValue(OMA_NEXT_URL); final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(mContext.getPackageName()); activity.startActivity(intent); } } }; new AlertDialog.Builder(activity) .setTitle(R.string.open_url_post_oma_download) .setPositiveButton(R.string.ok, clickListener) .setNegativeButton(R.string.cancel, clickListener) .setMessage(nextUrl) .setCancelable(false) .show(); }
Example 14
Source File: DownloadSnackbarController.java From AndroidChromium with Apache License 2.0 | 5 votes |
public SnackbarManager getSnackbarManager() { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (activity != null && ApplicationStatus.hasVisibleActivities() && activity instanceof SnackbarManager.SnackbarManageable) { return ((SnackbarManager.SnackbarManageable) activity).getSnackbarManager(); } return null; }
Example 15
Source File: ActivityStopMetrics.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Records the reason that the parent Activity was stopped. * @param parent Activity that owns this {@link ActivityStopMetrics} instance. */ public void onStopWithNative(Activity parent) { if (mStopReason == STOP_REASON_COUNT) { if (parent != ApplicationStatus.getLastTrackedFocusedActivity() && ApplicationStatus.hasVisibleActivities()) { mStopReason = STOP_REASON_OTHER_CHROME_ACTIVITY_IN_FOREGROUND; } else { mStopReason = STOP_REASON_UNKNOWN; } } RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_NAME, mStopReason, STOP_REASON_COUNT); mStopReason = STOP_REASON_COUNT; }
Example 16
Source File: RemoteMediaPlayerController.java From delion with Apache License 2.0 | 5 votes |
/** * Called when a lower layer requests that a video be cast. This will typically be a request * from Blink when the cast button is pressed on the default video controls. * @param player the player for which cast is being requested * @param frameUrl the URL of the frame containing the video, needed for YouTube videos */ public void requestRemotePlayback( MediaRouteController.MediaStateListener player, MediaRouteController controller) { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); mChromeVideoActivity = new WeakReference<Activity>(currentActivity); if (mCurrentRouteController != null && controller != mCurrentRouteController) { mCurrentRouteController.release(); } onStateReset(controller); showMediaRouteDialog(player, controller, currentActivity); }
Example 17
Source File: RemoteMediaPlayerController.java From delion with Apache License 2.0 | 5 votes |
/** * Links this object to the Activity that owns the video, if it exists. * */ private void linkToBrowserActivity() { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity != null) { mChromeVideoActivity = new WeakReference<Activity>(currentActivity); mCastContextApplicationContext = currentActivity.getApplicationContext(); createMediaRouteControllers(currentActivity); } }
Example 18
Source File: ChromeApplication.java From delion with Apache License 2.0 | 5 votes |
/** * Shows an error dialog following a startup error, and then exits the application. * @param e The exception reported by Chrome initialization. */ public static void reportStartupErrorAndExit(final ProcessInitException e) { Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DESTROYED) { return; } InvalidStartupDialog.show(activity, e.getErrorCode()); }
Example 19
Source File: OMADownloadHandler.java From delion with Apache License 2.0 | 5 votes |
/** * Shows a dialog to ask whether user wants to open the nextURL. * * @param omaInfo Information about the OMA content. */ private void showNextUrlDialog(OMAInfo omaInfo) { if (omaInfo.isValueEmpty(OMA_NEXT_URL)) { return; } final String nextUrl = omaInfo.getValue(OMA_NEXT_URL); final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(mContext.getPackageName()); activity.startActivity(intent); } } }; new AlertDialog.Builder(activity) .setTitle(R.string.open_url_post_oma_download) .setPositiveButton(R.string.ok, clickListener) .setNegativeButton(R.string.cancel, clickListener) .setMessage(nextUrl) .setCancelable(false) .show(); }
Example 20
Source File: RemoteMediaPlayerController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called when a lower layer requests that a video be cast. This will typically be a request * from Blink when the cast button is pressed on the default video controls. * @param player the player for which cast is being requested * @param frameUrl the URL of the frame containing the video, needed for YouTube videos */ public void requestRemotePlayback( MediaRouteController.MediaStateListener player, MediaRouteController controller) { Activity currentActivity = ApplicationStatus.getLastTrackedFocusedActivity(); mChromeVideoActivity = new WeakReference<Activity>(currentActivity); if (mCurrentRouteController != null && controller != mCurrentRouteController) { mCurrentRouteController.release(); } onStateReset(controller); showMediaRouteDialog(player, controller, currentActivity); }