use of com.android.contacts.common.testing.NeededForTesting in project android_packages_apps_Dialer by MoKee.
the class CallLogListItemViewHolder method createForTest.
@NeededForTesting
public static CallLogListItemViewHolder createForTest(Context context) {
Resources resources = context.getResources();
CallLogCache callLogCache = CallLogCache.getCallLogCache(context);
PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(context, resources, callLogCache);
CallLogListItemViewHolder viewHolder = new CallLogListItemViewHolder(context, null, null, /* expandCollapseListener */
callLogCache, new CallLogListItemHelper(phoneCallDetailsHelper, resources, callLogCache), null, /* voicemailPlaybackPresenter */
null, /* filteredNumberAsyncQueryHandler */
null, /* filteredNumberDialogCallback */
new View(context), new QuickContactBadge(context), new View(context), PhoneCallDetailsViews.createForTest(context), new CardView(context), new TextView(context), new ImageView(context), false);
viewHolder.detailsButtonView = new TextView(context);
viewHolder.actionsView = new View(context);
viewHolder.voicemailPlaybackView = new VoicemailPlaybackLayout(context);
viewHolder.workIconView = new ImageButton(context);
viewHolder.userMarkButtonView = new TextView(context);
return viewHolder;
}
use of com.android.contacts.common.testing.NeededForTesting in project packages_apps_Contacts by AOKP.
the class ContactEditorUtils method shouldShowAccountChangedNotification.
/**
* @return true if the contact editor should show the "accounts changed" notification, that is:
* - If it's the first launch.
* - Or, if the default account has been removed.
* (And some extra sanity check)
*
* Note if this method returns {@code false}, the caller can safely assume that
* {@link #getDefaultAccount} will return a valid account. (Either an account which still
* exists, or {@code null} which should be interpreted as "local only".)
*/
@NeededForTesting
public boolean shouldShowAccountChangedNotification() {
// If default account is defined, accounts change should not show.
final AccountWithDataSet overlayDefaultAccount = getOverlayDefualtAccount();
if (overlayDefaultAccount != null) {
return false;
}
if (isFirstLaunch()) {
return true;
}
final List<AccountWithDataSet> currentWritableAccounts = getWritableAccounts();
final AccountWithDataSet defaultAccount = getDefaultAccount();
// Does default account still exist?
if (!isValidAccount(defaultAccount)) {
return true;
}
// state after they respond to the notification.
if ((defaultAccount == null || defaultAccount.isLocalAccount()) && currentWritableAccounts.size() > 0) {
Log.e(TAG, "Preferences file in an inconsistent state, request that the default account" + " and current writable accounts be saved again");
return true;
}
// All good.
return false;
}
use of com.android.contacts.common.testing.NeededForTesting in project android_packages_apps_Dialer by MoKee.
the class PromoCardViewHolder method createForTest.
@NeededForTesting
public static PromoCardViewHolder createForTest(Context context) {
PromoCardViewHolder viewHolder = new PromoCardViewHolder(new View(context));
viewHolder.mPrimaryActionView = new View(context);
viewHolder.mSecondaryActionView = new View(context);
return viewHolder;
}
use of com.android.contacts.common.testing.NeededForTesting in project android_packages_apps_Dialer by MoKee.
the class VoicemailAsyncTaskUtil method setVoicemailArchiveStatus.
/**
* Updates the archived_by_user flag of the archived voicemail.
*/
@NeededForTesting
public void setVoicemailArchiveStatus(final OnSetVoicemailArchiveStatusListener listener, final Uri voicemailUri, final boolean archivedByUser) {
Preconditions.checkNotNull(listener);
Preconditions.checkNotNull(voicemailUri);
mAsyncTaskExecutor.submit(Tasks.SET_VOICEMAIL_ARCHIVE_STATUS, new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
ContentValues values = new ContentValues(1);
values.put(VoicemailArchiveContract.VoicemailArchive.ARCHIVED, archivedByUser);
return mResolver.update(voicemailUri, values, null, null) > 0;
}
@Override
protected void onPostExecute(Boolean success) {
listener.onSetVoicemailArchiveStatus(success);
}
});
}
use of com.android.contacts.common.testing.NeededForTesting in project packages_apps_Contacts by AOKP.
the class ContactInteractionUtil method formatDateStringFromTimestamp.
/**
* Takes in a timestamp and outputs a human legible date. This checks the timestamp against
* compareCalendar.
* This formats the date based on a few conditions:
* 1. If the timestamp is today, the time is shown
* 2. If the timestamp occurs tomorrow or yesterday, that is displayed
* 3. Otherwise {Month Date} format is used
*/
@NeededForTesting
public static String formatDateStringFromTimestamp(long timestamp, Context context, Calendar compareCalendar) {
Calendar interactionCalendar = Calendar.getInstance();
interactionCalendar.setTimeInMillis(timestamp);
// compareCalendar is initialized to today
if (compareCalendarDayYear(interactionCalendar, compareCalendar)) {
return DateFormat.getTimeInstance(DateFormat.SHORT).format(interactionCalendar.getTime());
}
// Turn compareCalendar to yesterday
compareCalendar.add(Calendar.DAY_OF_YEAR, -1);
if (compareCalendarDayYear(interactionCalendar, compareCalendar)) {
return context.getString(R.string.yesterday);
}
// Turn compareCalendar to tomorrow
compareCalendar.add(Calendar.DAY_OF_YEAR, 2);
if (compareCalendarDayYear(interactionCalendar, compareCalendar)) {
return context.getString(R.string.tomorrow);
}
return DateUtils.formatDateTime(context, interactionCalendar.getTimeInMillis(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR);
}
Aggregations