Merge "Fix notification preferences" into qt-dev

This commit is contained in:
Julia Reynolds
2019-04-24 17:46:28 +00:00
committed by Android (Google) Code Review
6 changed files with 46 additions and 23 deletions

View File

@@ -108,10 +108,12 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true);
} else if (sortOrder == R.id.sort_order_frequent_notification) {
if (state.avgSentWeekly > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly);
if (state.avgSentDaily > 0) {
return context.getResources().getQuantityString(
R.plurals.notifications_sent_daily, state.avgSentDaily, state.avgSentDaily);
}
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily);
return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
} else {
return "";
}

View File

@@ -91,6 +91,7 @@ public class ImportancePreference extends Preference {
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
TextView textView = (TextView) holder.findViewById(R.id.description);
mSilenceButton = (Button) holder.findViewById(R.id.silence);

View File

@@ -425,10 +425,12 @@ public class NotificationBackend {
return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true);
} else {
if (state.avgSentWeekly > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly);
if (state.avgSentDaily > 0) {
return context.getResources().getQuantityString(R.plurals.notifications_sent_daily,
state.avgSentDaily, state.avgSentDaily);
}
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily);
return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
}
}