@@ -0,0 +1,3044 @@
+package com.rabidllamastudios.avigate;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A/**%0A * Created by Ryan on 12/22/15.%0A * Manages objects stored via Android's SharedPreferences feature%0A */%0Apublic class SharedPreferencesManager %7B%0A    public static final String KEY_CRAFT_NAME = %22CraftName%22;%0A%0A    private static final String CRAFT_PROFILES =%22CraftProfiles%22;%0A    private static final String PREFS_FILE = %22AvigatePreferences%22;%0A%0A    private SharedPreferences mSharedPreferences;%0A%0A    public SharedPreferencesManager(Context context) %7B%0A        mSharedPreferences = context.getSharedPreferences(PREFS_FILE,%0A                Context.MODE_PRIVATE);%0A    %7D%0A%0A    //Use hasCraft method before calling this one%0A    public void addCraft(String craftName) %7B%0A        Set%3CString%3E craftProfileNames = getCraftList();%0A        craftProfileNames.add(craftName);%0A        SharedPreferences.Editor editor = mSharedPreferences.edit();%0A        editor.putStringSet(CRAFT_PROFILES, craftProfileNames);%0A        editor.apply();%0A    %7D%0A%0A    public String getCraftConfiguration(String craftName) %7B%0A        if (mSharedPreferences.contains(craftName)) %7B%0A            return mSharedPreferences.getString(craftName, null);%0A        %7D%0A        return null;%0A    %7D%0A%0A    public Set%3CString%3E getCraftList() %7B%0A        if (mSharedPreferences.contains(CRAFT_PROFILES)) %7B%0A            return mSharedPreferences.getStringSet(CRAFT_PROFILES, null);%0A        %7D%0A        return new HashSet%3C%3E();%0A    %7D%0A%0A    public boolean hasCraft(String craftName) %7B%0A        Set%3CString%3E craftProfileNames = getCraftList();%0A        return craftProfileNames != null && craftProfileNames.contains(craftName);%0A    %7D%0A%0A    public void removeCraft(String craftName) %7B%0A        Set%3CString%3E craftProfileNames = getCraftList();%0A        SharedPreferences.Editor editor = mSharedPreferences.edit();%0A%0A        if (craftProfileNames.contains(craftName)) craftProfileNames.remove(craftName);%0A        editor.remove(CRAFT_PROFILES);%0A        editor.putStringSet(CRAFT_PROFILES, craftProfileNames);%0A        editor.remove(craftName);%0A        editor.apply();%0A    %7D%0A%0A    public void updateCraftName(String oldCraftName, String newCraftName) %7B%0A        Set%3CString%3E craftProfileNames = getCraftList();%0A        SharedPreferences.Editor editor = mSharedPreferences.edit();%0A%0A        if (craftProfileNames.contains(oldCraftName)) craftProfileNames.remove(oldCraftName);%0A        craftProfileNames.add(newCraftName);%0A        editor.remove(CRAFT_PROFILES);%0A        editor.putStringSet(CRAFT_PROFILES, craftProfileNames);%0A%0A        String configuration = mSharedPreferences.getString(oldCraftName, null);%0A        editor.remove(oldCraftName);%0A        editor.putString(newCraftName, configuration);%0A        editor.apply();%0A    %7D%0A%0A    public void updateCraftConfiguration(String craftName, String craftConfiguration) %7B%0A        SharedPreferences.Editor editor = mSharedPreferences.edit();%0A        editor.putString(craftName, craftConfiguration);%0A        editor.apply();%0A    %7D%0A%0A%7D%0A

Add SharedPreferencesManager to manage future saved craft configurations