use of it.angelic.mpw.model.enums.PoolEnum in project MPW by shineangelic.
the class Utils method getHomeStatsURL.
public static String getHomeStatsURL(SharedPreferences prefs) {
String mPool = prefs.getString("poolEnum", "");
String mCur = prefs.getString("curEnum", "");
// prefs.getString("wallet_addr" + PoolEnum.valueOf(mPool).name() + "_" + CurrencyEnum.valueOf(mCur).name(), "");
PoolEnum puil = PoolEnum.valueOf(mPool);
String compose = (puil.getOmitCurrency() ? "" : mCur.toLowerCase()) + puil.getRadixSuffix();
return puil.getTransportProtocolBase() + compose + (compose.length() == 0 ? "" : ".") + puil.getWebRoot() + Constants.HOME_STATS_URL;
}
use of it.angelic.mpw.model.enums.PoolEnum in project MPW by shineangelic.
the class Utils method getWalletStatsUrl.
public static String getWalletStatsUrl(SharedPreferences prefs) {
String mPool = prefs.getString("poolEnum", "");
String mCur = prefs.getString("curEnum", "");
PoolEnum tgtpool = PoolEnum.valueOf(mPool);
String compose = (tgtpool.getOmitCurrency() ? "" : mCur.toLowerCase()) + tgtpool.getRadixSuffix();
return tgtpool.getTransportProtocolBase() + compose + (compose.length() == 0 ? "" : ".") + tgtpool.getWebRoot() + Constants.ACCOUNTS_STATS_URL;
}
use of it.angelic.mpw.model.enums.PoolEnum in project MPW by shineangelic.
the class Utils method getBlocksURL.
public static String getBlocksURL(SharedPreferences prefs) {
String mPool = prefs.getString("poolEnum", "");
String mCur = prefs.getString("curEnum", "");
PoolEnum tgtpool = PoolEnum.valueOf(mPool);
String compose = (tgtpool.getOmitCurrency() ? "" : mCur.toLowerCase()) + tgtpool.getRadixSuffix();
return tgtpool.getTransportProtocolBase() + compose + (compose.length() == 0 ? "" : ".") + tgtpool.getWebRoot() + Constants.BLOCKS_URL;
}
use of it.angelic.mpw.model.enums.PoolEnum in project MPW by shineangelic.
the class SettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.preferences);
// Crashlytics.getInstance().crash();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity());
PoolEnum mPool = PoolEnum.valueOf(prefs.getString("poolEnum", ""));
CurrencyEnum mCur = CurrencyEnum.valueOf(prefs.getString("curEnum", ""));
final android.support.v7.preference.SwitchPreferenceCompat globalNotifications = (SwitchPreferenceCompat) findPreference("pref_notify");
final android.support.v7.preference.EditTextPreference walletAddr = (EditTextPreference) findPreference("wallet_addr");
final android.support.v7.preference.SwitchPreferenceCompat service = (SwitchPreferenceCompat) findPreference("pref_sync");
final android.support.v7.preference.ListPreference listFreqPreference = (ListPreference) findPreference("pref_sync_freq");
final android.support.v7.preference.SwitchPreferenceCompat offlineNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_offline");
final android.support.v7.preference.SwitchPreferenceCompat blockNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_block");
final android.support.v7.preference.SwitchPreferenceCompat paymentNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_payment");
// Service Enabled listener
Preference.OnPreferenceChangeListener listenerServ = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// newValue is the value you choose
listFreqPreference.setEnabled((Boolean) newValue);
Boolean nv = (Boolean) newValue;
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(getActivity()));
dispatcher.cancelAll();
if (nv) {
Job myJob = MPWService.getJobUpdate(prefs, dispatcher, true);
int res = dispatcher.schedule(myJob);
if (res != dispatcher.SCHEDULE_RESULT_SUCCESS) {
Toast.makeText(getActivity(), "Cannot enable service. Is Play Services up to date? Notifications won't work", Toast.LENGTH_SHORT).show();
return false;
}
Log.w(Constants.TAG, "SERVICE ACTIVE, schedule res: " + res);
}
// firebase log event
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, nv.toString());
mFirebaseAnalytics.logEvent("service_active", bundle);
return true;
}
};
service.setOnPreferenceChangeListener(listenerServ);
// Service FREQ listener
Preference.OnPreferenceChangeListener listenerServF = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Integer nv = Integer.valueOf((String) newValue);
// newValue is the value you choose
Log.w(Constants.TAG, "Changed FREQ setting to: " + nv);
// pezza perche il val ancora non c'e
prefs.edit().putString("pref_sync_freq", "" + nv).apply();
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(getActivity()));
Job myJob = MPWService.getJobUpdate(prefs, dispatcher, true);
dispatcher.schedule(myJob);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "" + nv);
mFirebaseAnalytics.logEvent("service_freq", bundle);
return true;
}
};
listFreqPreference.setOnPreferenceChangeListener(listenerServF);
// Notification global
Preference.OnPreferenceChangeListener listener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Log.w(Constants.TAG, "Changed NOTIF setting to: " + newValue);
Boolean nv = (Boolean) newValue;
// newValue is the value you choose
blockNotifications.setEnabled(nv);
offlineNotifications.setEnabled(nv);
paymentNotifications.setEnabled(nv);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "" + nv);
mFirebaseAnalytics.logEvent("service_notifications", bundle);
return true;
}
};
globalNotifications.setOnPreferenceChangeListener(listener);
// Listener x controllo correttezza
walletAddr.setOnPreferenceChangeListener(new WalletPrefChangeListener(getActivity(), mPool, mCur));
walletAddr.setSummary(getString(R.string.wallet_info, mPool.toString(), mCur.toString()));
walletAddr.setDialogTitle(mPool.toString() + " Network Login");
}
use of it.angelic.mpw.model.enums.PoolEnum in project MPW by shineangelic.
the class ChoosePoolActivity method attemptLogin.
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void attemptLogin() {
if (mAuthTask != null) {
return;
}
// Reset errors.
mWalletView.setError(null);
// Store values at the time of the login attempt.
String email = mWalletView.getText().toString();
boolean cancel = false;
View focusView = null;
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
// focusView.requestFocus();
} else {
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true);
mAuthTask = new UserLoginTask(email, (PoolEnum) poolSpinner.getItemAtPosition(poolSpinner.getSelectedItemPosition()), (CurrencyEnum) currencySpinner.getItemAtPosition(currencySpinner.getSelectedItemPosition()));
mAuthTask.execute((Void) null);
}
}
Aggregations