Skip to content

Commit

Permalink
HeadsUp: add timeout option (1/2)
Browse files Browse the repository at this point in the history
Forward ported to marshmallow/nougat By: @BeansTown106
this was basically a rewrite as everything about it changed

Change-Id: If542480dc1efd4d92ba1d536fa23d0342569b8e1
  • Loading branch information
kufikugel authored and xlxfoxxlx committed Jun 14, 2017
1 parent c71d02b commit 9ada62d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4396,6 +4396,12 @@ public boolean validate(String value) {
*/
public static final String QS_FOOTER_WARNINGS = "qs_footer_warnings";

/**
* Heads up timeout configuration
* @hide
*/
public static final String HEADS_UP_TIMEOUT = "heads_up_timeout";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.res.Resources;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.UserHandle;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.ArrayMap;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
private static final String SETTING_HEADS_UP_SNOOZE_LENGTH_MS = "heads_up_snooze_length_ms";
private static final int TAG_CLICKED_NOTIFICATION = R.id.is_clicked_heads_up_tag;

private final int mHeadsUpNotificationDecay;
private int mHeadsUpNotificationDecay;
private final int mMinimumDisplayTime;

private final int mTouchAcceptanceDelay;
Expand Down Expand Up @@ -121,7 +122,10 @@ public HeadsUpManager(final Context context, View statusBarWindowView,
mDefaultSnoozeLengthMs = resources.getInteger(R.integer.heads_up_default_snooze_length_ms);
mSnoozeLengthMs = mDefaultSnoozeLengthMs;
mMinimumDisplayTime = resources.getInteger(R.integer.heads_up_notification_minimum_time);
mHeadsUpNotificationDecay = resources.getInteger(R.integer.heads_up_notification_decay);
mHeadsUpNotificationDecay = Settings.System.getIntForUser(context.getContentResolver(),
Settings.System.HEADS_UP_TIMEOUT,
context.getResources().getInteger(R.integer.heads_up_notification_decay),
UserHandle.USER_CURRENT);
mClock = new Clock();

mSnoozeLengthMs = Settings.Global.getInt(context.getContentResolver(),
Expand Down Expand Up @@ -668,6 +672,10 @@ public void updateEntry() {
}

public void updateEntry(boolean updatePostTime) {
mHeadsUpNotificationDecay = Settings.System.getIntForUser(mContext.getContentResolver(),
Settings.System.HEADS_UP_TIMEOUT,
mContext.getResources().getInteger(R.integer.heads_up_notification_decay),
UserHandle.USER_CURRENT);
long currentTime = mClock.currentTimeMillis();
earliestRemovaltime = currentTime + mMinimumDisplayTime;
if (updatePostTime) {
Expand Down

0 comments on commit 9ada62d

Please sign in to comment.