@@ -0,0 +1,2129 @@
+package ch.ebu.cpa.utils;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0A%0Aimport com.google.gson.Gson;%0A%0Aimport ch.ebu.cpa.model.CpaClientToken;%0Aimport ch.ebu.cpa.model.CpaUserToken;%0A%0A/**%0A *  Copyright (c) European Broadcasting Union. All rights reserved.%0A *%0A *  Licence information is available from the LICENCE file.%0A */%0Apublic class PrefsUtils %7B%0A%0A    private static final String CPA_SHARED_PREF = %22cpa_shared_preference%22;%0A%0A    private static SharedPreferences prefs;%0A%0A    public static void persistClientToken(Context context, CpaClientToken token, String domain) %7B%0A        SharedPreferences prefs = context.getSharedPreferences(CPA_SHARED_PREF, Context.MODE_PRIVATE);%0A        SharedPreferences.Editor editor = prefs.edit();%0A        Gson gson = new Gson();%0A        String tokenString = gson.toJson(token);%0A        editor.putString(domain, tokenString);%0A        editor.apply();%0A    %7D%0A%0A    public static CpaClientToken retreiveClientToken(Context context, String domain) %7B%0A        SharedPreferences prefs = context.getSharedPreferences(CPA_SHARED_PREF, Context.MODE_PRIVATE);%0A        if (!prefs.contains(domain)) %7B%0A            return null;%0A        %7D else %7B%0A            Gson gson = new Gson();%0A            return gson.fromJson(prefs.getString(domain, %22%22), CpaClientToken.class);%0A        %7D%0A    %7D%0A%0A    private void persistUserToken(Context context, CpaUserToken token, String domain) %7B%0A        SharedPreferences prefs = context.getSharedPreferences(CPA_SHARED_PREF, Context.MODE_PRIVATE);%0A        SharedPreferences.Editor editor = prefs.edit();%0A        Gson gson = new Gson();%0A        String tokenString = gson.toJson(token);%0A        editor.putString(domain, tokenString);%0A        editor.apply();%0A    %7D%0A%0A    private CpaUserToken retreiveUserToken(Context context, String domain) %7B%0A        SharedPreferences prefs = context.getSharedPreferences(CPA_SHARED_PREF, Context.MODE_PRIVATE);%0A        if (!prefs.contains(domain)) %7B%0A            return null;%0A        %7D else %7B%0A            Gson gson = new Gson();%0A            return gson.fromJson(prefs.getString(domain, %22%22), CpaUserToken.class);%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

add cap prefs helpers