Java Code Examples for org.chromium.base.ApplicationStatus#registerStateListenerForActivity()

The following examples show how to use org.chromium.base.ApplicationStatus#registerStateListenerForActivity() . 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: RecentTabsPage.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 2
Source File: ChromeLifetimeController.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onTerminate(boolean restart) {
    mRestartChromeOnDestroy = restart;

    for (WeakReference<Activity> weakActivity : ApplicationStatus.getRunningActivities()) {
        Activity activity = weakActivity.get();
        if (activity != null) {
            ApplicationStatus.registerStateListenerForActivity(this, activity);
            mRemainingActivitiesCount++;
            activity.finish();
        }
    }

    // Start the Activity that will ultimately kill this process.
    fireBrowserRestartActivityIntent(BrowserRestartActivity.ACTION_START_WATCHDOG);
}
 
Example 3
Source File: ChromeLifetimeController.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onTerminate(boolean restart) {
    mRestartChromeOnDestroy = restart;

    for (WeakReference<Activity> weakActivity : ApplicationStatus.getRunningActivities()) {
        Activity activity = weakActivity.get();
        if (activity != null) {
            ApplicationStatus.registerStateListenerForActivity(this, activity);
            mRemainingActivitiesCount++;
            activity.finish();
        }
    }

    // Start the Activity that will ultimately kill this process.
    fireBrowserRestartActivityIntent(BrowserRestartActivity.ACTION_START_WATCHDOG);
}
 
Example 4
Source File: ChromeLifetimeController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onTerminate(boolean restart) {
    mRestartChromeOnDestroy = restart;

    // Tell all Chrome Activities to finish themselves.
    for (WeakReference<Activity> weakActivity : ApplicationStatus.getRunningActivities()) {
        Activity activity = weakActivity.get();
        if (activity != null) {
            ApplicationStatus.registerStateListenerForActivity(this, activity);
            mRemainingActivitiesCount++;
            activity.finish();
        }
    }

    // Kick off a timer to kill the process after a delay, which fires only if the Activities
    // take too long to be finished.
    mHandler.postDelayed(mRestartRunnable, WATCHDOG_DELAY_MS);
}
 
Example 5
Source File: RecentTabsPage.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 6
Source File: ActivityWindowAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an Activity-specific WindowAndroid with associated intent functionality.
 * @param context Context wrapping an activity associated with the WindowAndroid.
 * @param listenToActivityState Whether to listen to activity state changes.
 */
public ActivityWindowAndroid(Context context, boolean listenToActivityState) {
    super(context);
    Activity activity = activityFromContext(context);
    if (activity == null) {
        throw new IllegalArgumentException("Context is not and does not wrap an Activity");
    }
    mHandler = new Handler();
    mOutstandingPermissionRequests = new SparseArray<PermissionCallback>();
    if (listenToActivityState) {
        ApplicationStatus.registerStateListenerForActivity(this, activity);
    }

    setAndroidPermissionDelegate(new ActivityAndroidPermissionDelegate());
}
 
Example 7
Source File: OverlayPanel.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param activity The ChromeActivity associated with the panel.
 */
public void setChromeActivity(ChromeActivity activity) {
    mActivity = activity;
    if (mActivity != null) {
        ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    }

    // TODO(pedrosimonetti): Coordinate with mdjones@ to move this to the OverlayPanelBase
    // constructor, once we are able to get the Activity during instantiation. The Activity
    // is needed in order to get the correct height of the Toolbar, which varies depending
    // on the Activity (WebApps have a smaller toolbar for example).
    initializeUiState();
}
 
Example 8
Source File: RecentTabsPage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(ChromeActivity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = new RecentTabsRowAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    if (activity.getBottomSheet() != null) {
        View recentTabsRoot = mView.findViewById(R.id.recent_tabs_root);
        ApiCompatibilityUtils.setPaddingRelative(recentTabsRoot,
                ApiCompatibilityUtils.getPaddingStart(recentTabsRoot), 0,
                ApiCompatibilityUtils.getPaddingEnd(recentTabsRoot),
                activity.getResources().getDimensionPixelSize(
                        R.dimen.bottom_control_container_height));
    }

    onUpdated();
}
 
Example 9
Source File: VrWindowAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public VrWindowAndroid(Context context, DisplayAndroid display) {
    super(context, display);
    Activity activity = activityFromContext(context);
    if (activity == null) {
        throw new IllegalArgumentException("Context is not and does not wrap an Activity");
    }
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    setAndroidPermissionDelegate(new ActivityAndroidPermissionDelegate());
}
 
Example 10
Source File: MainIntentBehaviorMetrics.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Signal that an intent with ACTION_MAIN was received.
 *
 * This must only be called after the native libraries have been initialized.
 */
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void onMainIntentWithNative(long backgroundDurationMs) {
    sLastMainIntentBehavior = null;

    RecordUserAction.record("MobileStartup.MainIntentReceived");

    if (backgroundDurationMs >= BACKGROUND_TIME_24_HOUR_MS) {
        RecordUserAction.record("MobileStartup.MainIntentReceived.After24Hours");
    } else if (backgroundDurationMs >= BACKGROUND_TIME_12_HOUR_MS) {
        RecordUserAction.record("MobileStartup.MainIntentReceived.After12Hours");
    } else if (backgroundDurationMs >= BACKGROUND_TIME_6_HOUR_MS) {
        RecordUserAction.record("MobileStartup.MainIntentReceived.After6Hours");
    } else if (backgroundDurationMs >= BACKGROUND_TIME_1_HOUR_MS) {
        RecordUserAction.record("MobileStartup.MainIntentReceived.After1Hour");
    }

    if (mPendingActionRecordForMainIntent) return;
    mBackgroundDurationMs = backgroundDurationMs;

    ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    mPendingActionRecordForMainIntent = true;

    mHandler.postDelayed(mTimeoutRunnable, sTimeoutDurationMs);

    mTabModelObserver = new TabModelSelectorTabModelObserver(
            mActivity.getTabModelSelector()) {
        @Override
        public void didAddTab(Tab tab, TabLaunchType type) {
            if (TabLaunchType.FROM_RESTORE.equals(type)) return;
            if (NewTabPage.isNTPUrl(tab.getUrl())) recordUserBehavior(NTP_CREATED);
        }

        @Override
        public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
            recordUserBehavior(SWITCH_TABS);
        }
    };
}
 
Example 11
Source File: OverlayPanel.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param activity The ChromeActivity associated with the panel.
 */
public void setChromeActivity(ChromeActivity activity) {
    mActivity = activity;
    if (mActivity != null) {
        ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    }

    initializeUiState();
}
 
Example 12
Source File: VrWindowAndroid.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
public VrWindowAndroid(Context context) {
    super(context);
    Activity activity = activityFromContext(context);
    if (activity == null) {
        throw new IllegalArgumentException("Context is not and does not wrap an Activity");
    }
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    setAndroidPermissionDelegate(new ActivityAndroidPermissionDelegate());
}
 
Example 13
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param activity The ChromeActivity associated with the panel.
 */
public void setChromeActivity(ChromeActivity activity) {
    mActivity = activity;
    if (mActivity != null) {
        ApplicationStatus.registerStateListenerForActivity(this, mActivity);
    }

    initializeUiState();
}
 
Example 14
Source File: AlwaysDismissedDialog.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public AlwaysDismissedDialog(Activity ownerActivity, int theme) {
    super(ownerActivity, theme);
    ApplicationStatus.registerStateListenerForActivity(this, ownerActivity);
}
 
Example 15
Source File: TabModelSelectorUma.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
TabModelSelectorUma(Activity activity) {
    ApplicationStatus.registerStateListenerForActivity(this, activity);
}
 
Example 16
Source File: TabModelSelectorUma.java    From 365browser with Apache License 2.0 4 votes vote down vote up
TabModelSelectorUma(Activity activity) {
    ApplicationStatus.registerStateListenerForActivity(this, activity);
}
 
Example 17
Source File: AlwaysDismissedDialog.java    From delion with Apache License 2.0 4 votes vote down vote up
public AlwaysDismissedDialog(Activity ownerActivity, int theme) {
    super(ownerActivity, theme);
    ApplicationStatus.registerStateListenerForActivity(this, ownerActivity);
}
 
Example 18
Source File: AlwaysDismissedDialog.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public AlwaysDismissedDialog(Activity ownerActivity, int theme) {
    super(ownerActivity, theme);
    ApplicationStatus.registerStateListenerForActivity(this, ownerActivity);
}
 
Example 19
Source File: TabModelSelectorUma.java    From delion with Apache License 2.0 4 votes vote down vote up
TabModelSelectorUma(Activity activity) {
    ApplicationStatus.registerStateListenerForActivity(this, activity);
}