package com.orhanobut.hawk;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;

public class HawkBuilder {

  /**
   * NEVER ever change TAG and TAG_INFO.
   * It will break backward compatibility in terms of keeping previous data
   */
  private static final String TAG = "HAWK";

  private Context context;
  private String password;
  private Storage cryptoStorage;
  private Converter converter;
  private Parser parser;
  private Encryption encryption;
  private Serializer serializer;

  public HawkBuilder(Context context) {
    HawkUtils.checkNull("Context", context);

    this.context = context.getApplicationContext();
  }

  public HawkBuilder setPassword(String password) {
    if (TextUtils.isEmpty(password)) {
      throw new NullPointerException("Password should not be null or empty");
    }
    this.password = password;
    return this;
  }

  public HawkBuilder setStorage(Storage storage) {
    this.cryptoStorage = storage;
    return this;
  }

  public HawkBuilder setParser(Parser parser) {
    this.parser = parser;
    return this;
  }

  public HawkBuilder setSerializer(Serializer serializer) {
    this.serializer = serializer;
    return this;
  }

  HawkBuilder setConverter(Converter converter) {
    this.converter = converter;
    return this;
  }

  HawkBuilder setEncryption(Encryption encryption) {
    this.encryption = encryption;
    return this;
  }

  String getPassword() {
    return password;
  }

  Storage getStorage() {
    if (cryptoStorage == null) {
      cryptoStorage = new SharedPreferencesStorage(context, TAG);
    }
    return cryptoStorage;
  }

  Converter getConverter() {
    if (converter == null) {
      converter = new HawkConverter(getParser());
    }
    return converter;
  }

  Parser getParser() {
    if (parser == null) {
      parser = new GsonParser(new Gson());
    }
    return parser;
  }

  Encryption getEncryption() {
    if (encryption == null) {
      encryption = new ConcealEncryption(context);
      if (!encryption.init()) {
        encryption = new Base64Encryption();
      }
    }
    return encryption;
  }

  Serializer getSerializer() {
    if (serializer == null) {
      serializer = new HawkSerializer();
    }
    return serializer;
  }

  public void build() {
    Hawk.build(this);
  }
}

@@ -173,19 +173,41 @@
  change 
-TAG
+STORAGE_TAG_DO_NOT_CHANGE
  and TAG
@@ -329,19 +329,42 @@
 ing 
-TAG
+STORAGE_TAG_DO_NOT_CHANGE
  = %22H
-AWK
+awk2
 %22;%0A%0A
@@ -1644,19 +1644,41 @@
 ontext, 
-TAG
+STORAGE_TAG_DO_NOT_CHANGE
 );%0A    %7D

Change the storage tag in order to reset everything for the new version