use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class ChromeTabbedActivity method maybeMergeTabs.
/**
* Merges tabs from a second ChromeTabbedActivity instance if necesssary and calls
* finishAndRemoveTask() on the other activity.
*/
@TargetApi(Build.VERSION_CODES.M)
@VisibleForTesting
public void maybeMergeTabs() {
if (!FeatureUtilities.isTabModelMergingEnabled())
return;
Class<?> otherWindowActivityClass = MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(this);
// 1. Find the other activity's task if it's still running so that it can be removed from
// Android recents.
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.AppTask> appTasks = activityManager.getAppTasks();
ActivityManager.AppTask otherActivityTask = null;
for (ActivityManager.AppTask task : appTasks) {
if (task.getTaskInfo() == null || task.getTaskInfo().baseActivity == null)
continue;
String baseActivity = task.getTaskInfo().baseActivity.getClassName();
if (baseActivity.equals(otherWindowActivityClass.getName())) {
otherActivityTask = task;
}
}
if (otherActivityTask != null) {
for (WeakReference<Activity> activityRef : ApplicationStatus.getRunningActivities()) {
Activity activity = activityRef.get();
if (activity == null)
continue;
// starts, causing some duplicate work to be done. Avoid the redundancy.
if (activity.getClass().equals(otherWindowActivityClass)) {
((ChromeTabbedActivity) activity).saveState();
break;
}
}
// 3. Kill the other activity's task to remove it from Android recents.
otherActivityTask.finishAndRemoveTask();
}
// 4. Ask TabPersistentStore to merge state.
RecordUserAction.record("Android.MergeState.Live");
mTabModelSelectorImpl.mergeState();
setMergedInstanceTaskId(getTaskId());
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class BluetoothChooserDialog method show.
/**
* Show the BluetoothChooserDialog.
*/
@VisibleForTesting
void show() {
// Emphasize the origin.
Profile profile = Profile.getLastUsedProfile();
SpannableString origin = new SpannableString(mOrigin);
OmniboxUrlEmphasizer.emphasizeUrl(origin, mActivity.getResources(), profile, mSecurityLevel, false, true, true);
// Construct a full string and replace the origin text with emphasized version.
SpannableString title = new SpannableString(mActivity.getString(R.string.bluetooth_dialog_title, mOrigin));
int start = title.toString().indexOf(mOrigin);
TextUtils.copySpansFrom(origin, 0, origin.length(), Object.class, title, start);
String message = mActivity.getString(R.string.bluetooth_not_found);
SpannableString noneFound = SpanApplier.applySpans(message, new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));
SpannableString searching = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_searching), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
String positiveButton = mActivity.getString(R.string.bluetooth_confirm_button);
SpannableString statusIdleNoneFound = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it_idle_none_found), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
SpannableString statusActive = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));
SpannableString statusIdleSomeFound = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_not_seeing_it_idle_some_found), new SpanInfo("<link1>", "</link1>", new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)), new SpanInfo("<link2>", "</link2>", new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));
ItemChooserDialog.ItemChooserLabels labels = new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive, statusIdleNoneFound, statusIdleSomeFound, positiveButton);
mItemChooserDialog = new ItemChooserDialog(mActivity, this, labels);
mActivity.registerReceiver(mLocationModeBroadcastReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
mIsLocationModeChangedReceiverRegistered = true;
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class BluetoothChooserDialog method notifyAdapterTurnedOff.
@VisibleForTesting
@CalledByNative
void notifyAdapterTurnedOff() {
SpannableString adapterOffMessage = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_adapter_off), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.ADAPTER_OFF, mActivity)));
SpannableString adapterOffStatus = SpanApplier.applySpans(mActivity.getString(R.string.bluetooth_adapter_off_help), new SpanInfo("<link>", "</link>", new BluetoothClickableSpan(LinkType.ADAPTER_OFF_HELP, mActivity)));
mItemChooserDialog.setErrorState(adapterOffMessage, adapterOffStatus);
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class UsbChooserDialog method show.
/**
* Shows the UsbChooserDialog.
*
* @param activity Activity which is used for launching a dialog.
* @param origin The origin for the site wanting to connect to the USB device.
* @param securityLevel The security level of the connection to the site wanting to connect to
* the USB device. For valid values see SecurityStateModel::SecurityLevel.
*/
@VisibleForTesting
void show(Activity activity, String origin, int securityLevel) {
// Emphasize the origin.
Profile profile = Profile.getLastUsedProfile();
SpannableString originSpannableString = new SpannableString(origin);
OmniboxUrlEmphasizer.emphasizeUrl(originSpannableString, activity.getResources(), profile, securityLevel, false, /* isInternalPage */
true, /* useDarkColors */
true);
// Construct a full string and replace the origin text with emphasized version.
SpannableString title = new SpannableString(activity.getString(R.string.usb_chooser_dialog_prompt, origin));
int start = title.toString().indexOf(origin);
TextUtils.copySpansFrom(originSpannableString, 0, originSpannableString.length(), Object.class, title, start);
String searching = "";
String noneFound = activity.getString(R.string.usb_chooser_dialog_no_devices_found_prompt);
SpannableString statusActive = SpanApplier.applySpans(activity.getString(R.string.usb_chooser_dialog_footnote_text), new SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
@Override
public void onClick(View view) {
if (mNativeUsbChooserDialogPtr == 0) {
return;
}
nativeLoadUsbHelpPage(mNativeUsbChooserDialogPtr);
// Get rid of the highlight background on selection.
view.invalidate();
}
}));
SpannableString statusIdleNoneFound = statusActive;
SpannableString statusIdleSomeFound = statusActive;
String positiveButton = activity.getString(R.string.usb_chooser_dialog_connect_button_text);
ItemChooserDialog.ItemChooserLabels labels = new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive, statusIdleNoneFound, statusIdleSomeFound, positiveButton);
mItemChooserDialog = new ItemChooserDialog(activity, this, labels);
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class MinidumpUploadService method createUploadIntent.
/**
* Creates an intent that when started will find all minidumps, and try to upload them.
*
* @param minidumpFile the minidump file to upload.
* @return an Intent to use to start the service.
*/
@VisibleForTesting
public static Intent createUploadIntent(Context context, File minidumpFile, File logfile) {
Intent intent = new Intent(context, MinidumpUploadService.class);
intent.setAction(ACTION_UPLOAD);
intent.putExtra(FILE_TO_UPLOAD_KEY, minidumpFile.getAbsolutePath());
intent.putExtra(UPLOAD_LOG_KEY, logfile.getAbsolutePath());
return intent;
}
Aggregations