Merge "Removing querying whether DWB time limit is for a group" into ub-launcher3-master
This commit is contained in:
commit
f81da5f4ee
|
@ -62,8 +62,4 @@
|
|||
<!-- Annotation shown on an app card in Recents, telling that the app has a usage limit set by
|
||||
the user, and a given time is left for it today [CHAR LIMIT=20] -->
|
||||
<string name="time_left_for_app"><xliff:g id="time" example="7 minutes">%1$s</xliff:g> left today</string>
|
||||
|
||||
<!-- Annotation shown on an app card in Recents, telling that the app is in a group that has a
|
||||
usage limit set by the user, and a given time is left for the group today [CHAR LIMIT=20] -->
|
||||
<string name="time_left_for_group"><xliff:g id="time" example="1 hour">%1$s</xliff:g> left for group</string>
|
||||
</resources>
|
|
@ -77,7 +77,6 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
Utilities.THREAD_POOL_EXECUTOR.execute(() -> {
|
||||
long appUsageLimitTimeMs = -1;
|
||||
long appRemainingTimeMs = -1;
|
||||
boolean isGroupLimit = true;
|
||||
|
||||
try {
|
||||
final Method getAppUsageLimit = LauncherApps.class.getMethod(
|
||||
|
@ -95,8 +94,6 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
invoke(usageLimit);
|
||||
appRemainingTimeMs = (long) appUsageLimitClass.getMethod("getUsageRemaining").
|
||||
invoke(usageLimit);
|
||||
isGroupLimit = (boolean) appUsageLimitClass.getMethod("isGroupLimit").
|
||||
invoke(usageLimit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Do nothing
|
||||
|
@ -104,14 +101,13 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
|
||||
final long appUsageLimitTimeMsFinal = appUsageLimitTimeMs;
|
||||
final long appRemainingTimeMsFinal = appRemainingTimeMs;
|
||||
final boolean isGroupLimitFinal = isGroupLimit;
|
||||
|
||||
post(() -> {
|
||||
if (appUsageLimitTimeMsFinal < 0) {
|
||||
setVisibility(GONE);
|
||||
} else {
|
||||
setVisibility(VISIBLE);
|
||||
mText.setText(getText(appRemainingTimeMsFinal, isGroupLimitFinal));
|
||||
mText.setText(getText(appRemainingTimeMsFinal));
|
||||
mImage.setImageResource(appRemainingTimeMsFinal > 0 ?
|
||||
R.drawable.hourglass_top : R.drawable.hourglass_bottom);
|
||||
}
|
||||
|
@ -119,9 +115,7 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
callback.call(
|
||||
appUsageLimitTimeMsFinal >= 0 && appRemainingTimeMsFinal <= 0 ? 0 : 1,
|
||||
getContentDescriptionForTask(
|
||||
task, appUsageLimitTimeMsFinal,
|
||||
appRemainingTimeMsFinal,
|
||||
isGroupLimitFinal));
|
||||
task, appUsageLimitTimeMsFinal, appRemainingTimeMsFinal));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -185,12 +179,12 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
duration, FormatWidth.NARROW, R.string.shorter_duration_less_than_one_minute);
|
||||
}
|
||||
|
||||
private String getText(long remainingTime, boolean isGroupLimit) {
|
||||
private String getText(long remainingTime) {
|
||||
final Resources resources = getResources();
|
||||
return (remainingTime <= 0) ?
|
||||
resources.getString(R.string.app_in_grayscale) :
|
||||
resources.getString(
|
||||
isGroupLimit ? R.string.time_left_for_group : R.string.time_left_for_app,
|
||||
R.string.time_left_for_app,
|
||||
getShorterReadableDuration(Duration.ofMillis(remainingTime)));
|
||||
}
|
||||
|
||||
|
@ -214,12 +208,12 @@ public final class DigitalWellBeingToast extends LinearLayout {
|
|||
}
|
||||
|
||||
private String getContentDescriptionForTask(
|
||||
Task task, long appUsageLimitTimeMs, long appRemainingTimeMs, boolean isGroupLimit) {
|
||||
Task task, long appUsageLimitTimeMs, long appRemainingTimeMs) {
|
||||
return appUsageLimitTimeMs >= 0 ?
|
||||
getResources().getString(
|
||||
R.string.task_contents_description_with_remaining_time,
|
||||
task.titleDescription,
|
||||
getText(appRemainingTimeMs, isGroupLimit)) :
|
||||
getText(appRemainingTimeMs)) :
|
||||
task.titleDescription;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue