// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app.api; import android.content.SharedPreferences; import com.olio.communication.messages.unit.PairedDeviceProfile; import com.olio.util.ALog; import com.oliodevices.assist.app.core.OlioApplication; // Referenced classes of package com.oliodevices.assist.app.api: // OlioApi public class UserManager { private static final String PREF_ACCESS_TOKEN = "access_token"; private static final String PREF_EMAIL_ADDRESS = "email_address"; private static final String PREF_PAIRED_DEVICE_PROFILE_SENT = "paired_device_profile_sent"; private static final String PREF_UNIT_ID = "unit_id"; private static final String PREF_USER_AGREEMENT_ACCEPTED = "user_agreement"; private static final String PREF_USER_ID = "user_id"; private static UserManager sInstance; private String mAccessToken; private boolean mDeviceProfileSent; private String mEmailAddress; private String mUnitId; private boolean mUserAgreementAccepted; private long mUserId; private UserManager() { load(); } private void clear() { OlioApplication.getApplication().getDefaultSharedPreferences().edit().remove("user_id").remove("email_address").remove("access_token").remove("unit_id").remove("user_agreement").remove("paired_device_profile_sent").apply(); } public static UserManager getInstance() { if (sInstance == null) { sInstance = new UserManager(); } return sInstance; } private void persist() { OlioApplication.getApplication().getDefaultSharedPreferences().edit().putLong("user_id", mUserId).putString("email_address", mEmailAddress).putString("access_token", mAccessToken).putString("unit_id", mUnitId).putBoolean("user_agreement", mUserAgreementAccepted).putBoolean("paired_device_profile_sent", mDeviceProfileSent).apply(); } public void clearDetails() { clear(); load(); } public String getAccessToken() { if (mAccessToken != null) { return mAccessToken; } else { return ""; } } public String getEmailAddress() { if (mEmailAddress != null) { return mEmailAddress; } else { return ""; } } public String getEmailForAnalytics() { if (mEmailAddress != null) { return mEmailAddress; } else { return "Unknown Email"; } } public String getUnitId() { if (mUnitId != null) { return mUnitId; } else { return ""; } } public long getUserId() { return mUserId; } public boolean isUserAgreementAccepted() { return mUserAgreementAccepted; } public boolean isUserAuthenticated() { return !mAccessToken.isEmpty(); } public void load() { SharedPreferences sharedpreferences = OlioApplication.getApplication().getDefaultSharedPreferences(); mUserId = sharedpreferences.getLong("user_id", 0L); mEmailAddress = sharedpreferences.getString("email_address", ""); mAccessToken = sharedpreferences.getString("access_token", ""); mUnitId = sharedpreferences.getString("unit_id", ""); mUserAgreementAccepted = sharedpreferences.getBoolean("user_agreement", false); mDeviceProfileSent = sharedpreferences.getBoolean("paired_device_profile_sent", false); } public void storeAccessToken(String s) { mAccessToken = s; persist(); } public void storeUserDetails(long l, String s) { mUserId = l; mEmailAddress = s; persist(); } public void updateEmailAddress(String s) { mEmailAddress = s; persist(); } public void updateUnitId(String s) { boolean flag; boolean flag1 = false; flag = flag1; if (mUnitId != null) { flag = flag1; if (!mUnitId.equals(s)) { flag = true; } } mUnitId = s; if (s != null) goto _L2; else goto _L1 _L1: ALog.d("reset unitId and device profile", new Object[0]); mDeviceProfileSent = false; _L4: persist(); return; _L2: if (!mDeviceProfileSent || flag) { s = new PairedDeviceProfile(s); ALog.d(s.toString(), new Object[0]); OlioApi.getInstance().updatePairedDeviceProfileSetting(s); mDeviceProfileSent = true; } if (true) goto _L4; else goto _L3 _L3: } public void updateUserAgreementAccepted(boolean flag) { mUserAgreementAccepted = flag; persist(); } }