package com.secspace.lib.common.tips;

import android.content.Context;
import android.content.Intent;
import android.view.WindowManager;

import com.secspace.lib.common.R;

import static com.secspace.lib.common.env.Intents.Launcher.ACTION_PERMISSION_TIP;

/**
 * Created by bxy on 2018/7/9.
 */

public class PermissionTipHelper {
    private static PermissionTipHelper instance;
    protected static final String RES_KEY = "BG_RES";
    protected static final int CAN_DRAW_OVERLAYS_TIP = R.mipmap.common_can_draw_overlays_tip;
    protected static final int NOTIFICATION_TIP = R.mipmap.common_notification_tip;

    public static PermissionTipHelper getInstance() {
        if (instance == null) {
            synchronized (WindowManager.class) {
                if (instance == null) {
                    instance = new PermissionTipHelper();
                }
            }
        }
        return instance;
    }

    private PermissionTipHelper() {

    }

    public void permissionCanDrawOverlaysTip(Context context) {
        Intent intent = new Intent(ACTION_PERMISSION_TIP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setPackage(context.getPackageName());
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.putExtra(RES_KEY, CAN_DRAW_OVERLAYS_TIP);
        context.startActivity(intent);
    }

    public void permissionNotificationTip(Context context) {
        Intent intent = new Intent(ACTION_PERMISSION_TIP);
        intent.setPackage(context.getPackageName());
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.putExtra(RES_KEY, NOTIFICATION_TIP);
        context.startActivity(intent);
    }
}
