package com.android.launcher3.settings;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;

import com.secspace.lib.common.utils.UtilsKt;


public class AppModel {

    private final Context mContext;
    private final ApplicationInfo mInfo;

    private String mAppLabel;
    private Drawable mIcon;
    private int mAppType = APP_TYPE_USER;

    public static final int APP_TYPE_SYSTEM = 0;
    public static final int APP_TYPE_USER = 1;

    public AppModel(Context context, String label, Drawable icon, int appType) {
        this.mAppLabel = label;
        this.mIcon = icon;
        this.mAppType = appType;
        this.mContext = context;
        mInfo = null;
    }

    public AppModel(Context context, ApplicationInfo info) {
        mContext = context;
        mInfo = info;
        loadLabel();
        loadIcon();
    }

    public ApplicationInfo getAppInfo() {
        return mInfo;
    }

    public int getAppType() {
        return mAppType;
    }

    public String getApplicationPackageName() {
        return getAppInfo().packageName;
    }

    public String getLabel() {
        return mAppLabel;
    }

    public Drawable getIcon() {
        return mIcon;
    }

    private void loadIcon() {
        mIcon = UtilsKt.getApplicationIcon(mContext, mInfo.packageName);
    }

    private void loadLabel() {
        mAppLabel = UtilsKt.getApplicationName(mContext, mInfo.packageName);
    }
}
