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

Commit 1fcacf77 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Ignore toast request of pinning if request interval is too short"

parents 55efea25 d8c16035
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.app.ActivityManager;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.Slog;
import android.view.WindowManager;
import android.widget.Toast;

@@ -31,10 +33,12 @@ import com.android.internal.R;
 */
public class LockTaskNotify {
    private static final String TAG = "LockTaskNotify";
    private static final long SHOW_TOAST_MINIMUM_INTERVAL = 1000;

    private final Context mContext;
    private final H mHandler;
    private Toast mLastToast;
    private long mLastShowToastTime;

    public LockTaskNotify(Context context) {
        mContext = context;
@@ -55,10 +59,16 @@ public class LockTaskNotify {
        if (text == null) {
            return;
        }
        long showToastTime = SystemClock.elapsedRealtime();
        if ((showToastTime - mLastShowToastTime) < SHOW_TOAST_MINIMUM_INTERVAL) {
            Slog.i(TAG, "Ignore toast since it is requested in very short interval.");
            return;
        }
        if (mLastToast != null) {
            mLastToast.cancel();
        }
        mLastToast = makeAllUserToastAndShow(text);
        mLastShowToastTime = showToastTime;
    }

    public void show(boolean starting) {