Search in sources :

Example 1 with NeededForTesting

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;
}
Also used : CallLogCache(com.android.dialer.calllog.calllogcache.CallLogCache) ImageButton(android.widget.ImageButton) QuickContactBadge(android.widget.QuickContactBadge) VoicemailPlaybackLayout(com.android.dialer.voicemail.VoicemailPlaybackLayout) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) NeededForTesting(com.android.contacts.common.testing.NeededForTesting)

Example 2 with NeededForTesting

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;
}
Also used : AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) NeededForTesting(com.android.contacts.common.testing.NeededForTesting)

Example 3 with NeededForTesting

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;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) CardView(android.support.v7.widget.CardView) View(android.view.View) NeededForTesting(com.android.contacts.common.testing.NeededForTesting)

Example 4 with NeededForTesting

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);
        }
    });
}
Also used : ContentValues(android.content.ContentValues) NeededForTesting(com.android.contacts.common.testing.NeededForTesting)

Example 5 with NeededForTesting

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);
}
Also used : Calendar(java.util.Calendar) NeededForTesting(com.android.contacts.common.testing.NeededForTesting)

Aggregations

NeededForTesting (com.android.contacts.common.testing.NeededForTesting)5 CardView (android.support.v7.widget.CardView)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ContentValues (android.content.ContentValues)1 Resources (android.content.res.Resources)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 QuickContactBadge (android.widget.QuickContactBadge)1 TextView (android.widget.TextView)1 AccountWithDataSet (com.android.contacts.common.model.account.AccountWithDataSet)1 CallLogCache (com.android.dialer.calllog.calllogcache.CallLogCache)1 VoicemailPlaybackLayout (com.android.dialer.voicemail.VoicemailPlaybackLayout)1 Calendar (java.util.Calendar)1