Skip to content

Commit 24aca4e

Browse files
committed
usage: remove "Yesterday" option from the interval selector
Also, replaced "Today" with "Daily". Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
1 parent c8e7919 commit 24aca4e

6 files changed

Lines changed: 27 additions & 47 deletions

File tree

app/src/main/java/io/github/muntashirakon/AppManager/usage/AppUsageAdapter.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
package io.github.muntashirakon.AppManager.usage;
44

5-
import static io.github.muntashirakon.AppManager.usage.UsageUtils.USAGE_LAST_BOOT;
6-
import static io.github.muntashirakon.AppManager.usage.UsageUtils.USAGE_TODAY;
7-
import static io.github.muntashirakon.AppManager.usage.UsageUtils.USAGE_WEEKLY;
8-
import static io.github.muntashirakon.AppManager.usage.UsageUtils.USAGE_YESTERDAY;
9-
105
import android.graphics.drawable.Drawable;
116
import android.text.format.Formatter;
127
import android.view.LayoutInflater;
@@ -145,17 +140,12 @@ public void onBindViewHolder(@NonNull ListHeaderViewHolder holder) {
145140

146141
holder.screenTimeView.setText(DateUtils.getFormattedDuration(mActivity, mActivity.viewModel.getTotalScreenTime()));
147142
switch (currentInterval) {
148-
case USAGE_TODAY:
143+
case IntervalType.INTERVAL_DAILY:
149144
holder.usageIntervalView.setText(R.string.usage_today);
150145
break;
151-
case USAGE_YESTERDAY:
152-
holder.usageIntervalView.setText(R.string.usage_yesterday);
153-
break;
154-
case USAGE_WEEKLY:
146+
case IntervalType.INTERVAL_WEEKLY:
155147
holder.usageIntervalView.setText(R.string.usage_7_days);
156148
break;
157-
case USAGE_LAST_BOOT:
158-
break;
159149
}
160150

161151
}
@@ -182,8 +172,8 @@ public void onBindViewHolder(@NonNull ListItemViewHolder holder, int position) {
182172
holder.packageName.setText(usageInfo.packageName);
183173
// Set usage
184174
long lastTimeUsed = usageInfo.lastUsageTime > 1 ? (System.currentTimeMillis() - usageInfo.lastUsageTime) : 0;
185-
if (mActivity.viewModel.getCurrentInterval() != USAGE_YESTERDAY
186-
&& usageInfo.packageName.equals(BuildConfig.APPLICATION_ID)) {
175+
if (usageInfo.packageName.equals(BuildConfig.APPLICATION_ID)) {
176+
// TODO: 9/20/25 Display this only for the present day/week
187177
// Special case for App Manager since the user is using the app right now
188178
holder.lastUsageDate.setText(R.string.running);
189179
} else if (lastTimeUsed > 1) {

app/src/main/java/io/github/muntashirakon/AppManager/usage/AppUsageViewModel.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
package io.github.muntashirakon.AppManager.usage;
44

5-
import static io.github.muntashirakon.AppManager.usage.UsageUtils.USAGE_TODAY;
6-
75
import android.app.Application;
86

97
import androidx.annotation.AnyThread;
@@ -30,8 +28,8 @@ public class AppUsageViewModel extends AndroidViewModel {
3028

3129
private long mTotalScreenTime;
3230
private boolean mHasMultipleUsers;
33-
@UsageUtils.IntervalType
34-
private int mCurrentInterval = USAGE_TODAY;
31+
@IntervalType
32+
private int mCurrentInterval = IntervalType.INTERVAL_DAILY;
3533
private int mSortOrder = SortOrder.SORT_BY_SCREEN_TIME;
3634

3735
public AppUsageViewModel(@NonNull Application application) {
@@ -46,12 +44,12 @@ public LiveData<PackageUsageInfo> getPackageUsageInfo() {
4644
return mPackageUsageInfoLiveData;
4745
}
4846

49-
public void setCurrentInterval(@UsageUtils.IntervalType int currentInterval) {
47+
public void setCurrentInterval(@IntervalType int currentInterval) {
5048
mCurrentInterval = currentInterval;
5149
loadPackageUsageInfoList();
5250
}
5351

54-
@UsageUtils.IntervalType
52+
@IntervalType
5553
public int getCurrentInterval() {
5654
return mCurrentInterval;
5755
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
package io.github.muntashirakon.AppManager.usage;
4+
5+
import androidx.annotation.IntDef;
6+
7+
@IntDef({IntervalType.INTERVAL_DAILY, IntervalType.INTERVAL_WEEKLY})
8+
public @interface IntervalType {
9+
int INTERVAL_DAILY = 0;
10+
int INTERVAL_WEEKLY = 1;
11+
}

app/src/main/java/io/github/muntashirakon/AppManager/usage/TimeInterval.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public TimeInterval(int intervalType, long begin, long end) {
1515

1616
public TimeInterval(long begin, long end) {
1717
super(begin, end);
18-
mIntervalType = UsageUtils.USAGE_TODAY;
18+
mIntervalType = IntervalType.INTERVAL_DAILY;
1919
}
2020

2121
public int getIntervalType() {

app/src/main/java/io/github/muntashirakon/AppManager/usage/UsageUtils.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,19 @@
44

55
import android.os.SystemClock;
66

7-
import androidx.annotation.IntDef;
87
import androidx.annotation.NonNull;
98

109
import java.util.Calendar;
1110
import java.util.TimeZone;
1211
import java.util.concurrent.TimeUnit;
1312

1413
public final class UsageUtils {
15-
@IntDef(value = {
16-
USAGE_TODAY,
17-
USAGE_YESTERDAY,
18-
USAGE_WEEKLY,
19-
USAGE_LAST_BOOT
20-
})
21-
public @interface IntervalType {
22-
}
23-
24-
public static final int USAGE_TODAY = 0;
25-
public static final int USAGE_YESTERDAY = 1;
26-
public static final int USAGE_WEEKLY = 2;
27-
public static final int USAGE_LAST_BOOT = 5;
28-
2914
@NonNull
3015
public static TimeInterval getTimeInterval(@IntervalType int sort) {
3116
switch (sort) {
32-
case USAGE_YESTERDAY:
33-
return getYesterday();
34-
case USAGE_WEEKLY:
17+
case IntervalType.INTERVAL_WEEKLY:
3518
return getLastWeek();
36-
case USAGE_LAST_BOOT:
37-
return getSinceLastBoot();
38-
case USAGE_TODAY:
19+
case IntervalType.INTERVAL_DAILY:
3920
default:
4021
return getToday();
4122
}
@@ -88,7 +69,7 @@ public static TimeInterval getDayBounds(long date) {
8869
calendar.set(Calendar.SECOND, 59);
8970
calendar.set(Calendar.MILLISECOND, 999);
9071
long endOfDay = calendar.getTimeInMillis();
91-
return new TimeInterval(USAGE_TODAY, beginningOfDay, endOfDay);
72+
return new TimeInterval(IntervalType.INTERVAL_DAILY, beginningOfDay, endOfDay);
9273
}
9374

9475
/**
@@ -210,7 +191,7 @@ public static TimeInterval getWeekBounds(int weekNumber, int year) {
210191

211192
// Set weekStart to beginning of Monday (00:00:00.000)
212193
Calendar startCal = Calendar.getInstance(TimeZone.getDefault());
213-
startCal.setTimeInMillis(weekStart);
194+
startCal.setTimeInMillis(weekStart);
214195
startCal.set(Calendar.HOUR_OF_DAY, 0);
215196
startCal.set(Calendar.MINUTE, 0);
216197
startCal.set(Calendar.SECOND, 0);
@@ -224,7 +205,7 @@ public static TimeInterval getWeekBounds(int weekNumber, int year) {
224205
endCal.set(Calendar.SECOND, 59);
225206
endCal.set(Calendar.MILLISECOND, 999);
226207

227-
return new TimeInterval(USAGE_WEEKLY, startCal.getTimeInMillis(), endCal.getTimeInMillis());
208+
return new TimeInterval(IntervalType.INTERVAL_WEEKLY, startCal.getTimeInMillis(), endCal.getTimeInMillis());
228209
}
229210

230211
/**

app/src/main/res/values/arrays.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
<item>@string/type_uri_array_list</item>
6767
</string-array>
6868
<string-array name="usage_interval_dropdown_list">
69-
<item>@string/usage_today</item>
70-
<item>@string/usage_yesterday</item>
69+
<item>@string/usage_daily</item>
7170
<item>@string/usage_weekly</item>
7271
</string-array>
7372
<string-array name="whats_new_titles">
@@ -273,4 +272,5 @@
273272
<item>trackers</item>
274273
<item>version_name</item>
275274
</string-array>
275+
<string name="usage_daily">Daily</string>
276276
</resources>

0 commit comments

Comments
 (0)