package com.rdiot.yx485.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

import com.rdiot.yx485.device.view.DeviceListActivity;
import com.rdiot.yx485.login.LoginWithPwdActivity;
import com.rdiot.yx485.login.SetPwdActivity;
import com.rdiot.yx485.room.RoomManageActivity;

public class IntentUtils {

    public static Intent goToAppSetting(Activity activity, boolean justGo) {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
        intent.setData(uri);
        if (justGo) {
            activity.startActivity(intent);
        }
        return intent;
    }

    public static void gotoRoomManage(Context context, String homeId) {
        RoomManageActivity.newInstance(context, homeId);
    }

    public static void intentToAddDevice(Context context) {
        Intent intent = new Intent(context, DeviceListActivity.class);
        context.startActivity(intent);
    }

    public static void intentToSetPwd(Context context, boolean isFirst) {
        Intent intent = new Intent(context, SetPwdActivity.class);
        intent.putExtra("isFirst", isFirst);
        context.startActivity(intent);
    }

    public static void intentToLogin(Activity context) {
        Intent intent = new Intent(context, LoginWithPwdActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        context.finish();
    }
}
