Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ae2abef authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove Time use." am: 34db0a31 am: 40451798

parents 02bdbdef 40451798
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -16,7 +16,11 @@


package com.android.contacts.common.util;
package com.android.contacts.common.util;


import android.text.format.Time;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;



/** Utility methods for processing dates. */
/** Utility methods for processing dates. */
public class DateUtils {
public class DateUtils {
@@ -30,13 +34,9 @@ public class DateUtils {
   * @param date2 Second date to check.
   * @param date2 Second date to check.
   * @return The absolute difference in days between the two dates.
   * @return The absolute difference in days between the two dates.
   */
   */
  public static int getDayDifference(Time time, long date1, long date2) {
  public static int getDayDifference(ZoneId timeZone, long date1, long date2) {
    time.set(date1);
    LocalDate localDate1 = Instant.ofEpochMilli(date1).atZone(timeZone).toLocalDate();
    int startDay = Time.getJulianDay(date1, time.gmtoff);
    LocalDate localDate2 = Instant.ofEpochMilli(date2).atZone(timeZone).toLocalDate();

    return Math.abs((int) ChronoUnit.DAYS.between(localDate2, localDate1));
    time.set(date2);
    int currentDay = Time.getJulianDay(date2, time.gmtoff);

    return Math.abs(currentDay - startDay);
  }
  }
}
}
+4 −3
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.VisibleForTesting;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.text.TextUtils;
import android.text.format.Time;
import com.android.contacts.common.util.DateUtils;
import com.android.contacts.common.util.DateUtils;
import com.android.dialer.calllogutils.CallbackActionHelper;
import com.android.dialer.calllogutils.CallbackActionHelper;
import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
@@ -31,6 +30,8 @@ import com.android.dialer.compat.telephony.TelephonyManagerCompat;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.phonenumbercache.CallLogQuery;
import com.android.dialer.phonenumbercache.CallLogQuery;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;

import java.time.ZoneId;
import java.util.Objects;
import java.util.Objects;


/**
/**
@@ -56,7 +57,7 @@ public class CallLogGroupBuilder {
  /** Day grouping for calls which occurred before last week. */
  /** Day grouping for calls which occurred before last week. */
  public static final int DAY_GROUP_OTHER = 2;
  public static final int DAY_GROUP_OTHER = 2;
  /** Instance of the time object used for time calculations. */
  /** Instance of the time object used for time calculations. */
  private static final Time TIME = new Time();
  private static final ZoneId TIME_ZONE = ZoneId.systemDefault();


  private final Context appContext;
  private final Context appContext;
  /** The object on which the groups are created. */
  /** The object on which the groups are created. */
@@ -255,7 +256,7 @@ public class CallLogGroupBuilder {
   * @return The date group the call belongs in.
   * @return The date group the call belongs in.
   */
   */
  private int getDayGroup(long date, long now) {
  private int getDayGroup(long date, long now) {
    int days = DateUtils.getDayDifference(TIME, date, now);
    int days = DateUtils.getDayDifference(TIME_ZONE, date, now);


    if (days == 0) {
    if (days == 0) {
      return DAY_GROUP_TODAY;
      return DAY_GROUP_TODAY;