package com.fastaccess.permission.base.model;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;

import com.fastaccess.permission.R;


public class PermissionModelBuilder {
    private final Context context;
    private final PermissionModel permissionModel;

    private PermissionModelBuilder(@NonNull Context context) {
        this.context = context;
        this.permissionModel = new PermissionModel(); // Generate sane default values
        withTextColor(Color.WHITE);
        withTextSize(context.getResources().getDimensionPixelSize(R.dimen.text_size));
        withRequestIcon(R.drawable.ic_arrow_done);
        withPreviousIcon(R.drawable.ic_arrow_left);
        withNextIcon(R.drawable.ic_arrow_right);
    }

    public static PermissionModelBuilder withContext(@NonNull Context context) {
        return new PermissionModelBuilder(context);
    }

    public PermissionModel build() {
        return permissionModel;
    }

    public PermissionModelBuilder withPermissionName(@NonNull String permissionName) {
        this.permissionModel.setPermissionName(permissionName);
        return this;
    }

    public PermissionModelBuilder withImageResourceId(@DrawableRes int imageResourceId) {
        this.permissionModel.setImageResourceId(imageResourceId);
        return this;
    }


    public PermissionModelBuilder withLayoutColor(@ColorInt int layoutColor) {
        this.permissionModel.setLayoutColor(layoutColor);
        return this;
    }

    public PermissionModelBuilder withLayoutColorRes(@ColorRes int layoutColor) {
        this.permissionModel.setLayoutColor(context.getResources().getColor(layoutColor));
        return this;
    }


    public PermissionModelBuilder withTextColor(@ColorInt int textColor) {
        this.permissionModel.setTextColor(textColor);
        return this;
    }

    public PermissionModelBuilder withTextColorRes(@ColorRes int textColor) {
        this.permissionModel.setTextColor(context.getResources().getColor(textColor));
        return this;
    }


    public PermissionModelBuilder withTextSize(@DimenRes int textSize) {
        this.permissionModel.setTextSize(textSize);
        return this;
    }

    public PermissionModelBuilder withExplanationMessage(@NonNull String explanationMessage) {
        this.permissionModel.setExplanationMessage(explanationMessage);
        return this;
    }

    public PermissionModelBuilder withExplanationMessage(@StringRes int explanationMessage) {
        this.permissionModel.setExplanationMessage(context.getResources().getString(explanationMessage));
        return this;
    }

    public PermissionModelBuilder withCanSkip(boolean canSkip) {
        this.permissionModel.setCanSkip(canSkip);
        return this;
    }


    public PermissionModelBuilder withRequestIcon(@DrawableRes int requestIcon) {
        this.permissionModel.setRequestIcon(requestIcon);
        return this;
    }


    public PermissionModelBuilder withPreviousIcon(@DrawableRes int previousIcon) {
        this.permissionModel.setPreviousIcon(previousIcon);
        return this;
    }


    public PermissionModelBuilder withNextIcon(@DrawableRes int nextIcon) {
        this.permissionModel.setNextIcon(nextIcon);
        return this;
    }


    public PermissionModelBuilder withMessage(@NonNull String message) {
        this.permissionModel.setMessage(message);
        return this;
    }

    public PermissionModelBuilder withMessage(@StringRes int message) {
        this.permissionModel.setMessage(context.getResources().getString(message));
        return this;
    }

    public PermissionModelBuilder withTitle(@NonNull String title) {
        this.permissionModel.setTitle(title);
        return this;
    }

    public PermissionModelBuilder withTitle(@StringRes int title) {
        this.permissionModel.setTitle(context.getResources().getString(title));
        return this;
    }

    /**
     * @param fontType ex: (fonts/my_custom_text.ttf);
     */
    public PermissionModelBuilder withFontType(@NonNull String fontType) {
        this.permissionModel.setFontType(fontType);
        return this;
    }
}

@@ -72,16 +72,54 @@
 ontext;%0A
+import android.content.res.Resources;%0A
 import a
@@ -141,16 +141,16 @@
 .Color;%0A
-
 import a
@@ -503,31 +503,29 @@
 e final 
-Context context
+Resources res
 ;%0A    pr
@@ -646,23 +646,19 @@
    this.
-context
+res
  = conte
@@ -659,16 +659,31 @@
  context
+.getResources()
 ;%0A      
@@ -819,38 +819,19 @@
 extSize(
-context.getResources()
+res
 .getDime
@@ -1896,38 +1896,19 @@
 utColor(
-context.getResources()
+res
 .getColo
@@ -2230,38 +2230,19 @@
 xtColor(
-context.getResources()
+res
 .getColo
@@ -2778,38 +2778,19 @@
 Message(
-context.getResources()
+res
 .getStri
@@ -3748,38 +3748,19 @@
 Message(
-context.getResources()
+res
 .getStri
@@ -4050,38 +4050,19 @@
 etTitle(
-context.getResources()
+res
 .getStri

Replace global context with Resources