Search in sources :

Example 1 with PoolEnum

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;
}
Also used : PoolEnum(it.angelic.mpw.model.enums.PoolEnum)

Example 2 with PoolEnum

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;
}
Also used : PoolEnum(it.angelic.mpw.model.enums.PoolEnum)

Example 3 with PoolEnum

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;
}
Also used : PoolEnum(it.angelic.mpw.model.enums.PoolEnum)

Example 4 with PoolEnum

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");
}
Also used : FirebaseJobDispatcher(com.firebase.jobdispatcher.FirebaseJobDispatcher) SharedPreferences(android.content.SharedPreferences) SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) Bundle(android.os.Bundle) GooglePlayDriver(com.firebase.jobdispatcher.GooglePlayDriver) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference) PoolEnum(it.angelic.mpw.model.enums.PoolEnum) EditTextPreference(android.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) Job(com.firebase.jobdispatcher.Job) CurrencyEnum(it.angelic.mpw.model.enums.CurrencyEnum)

Example 5 with PoolEnum

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);
    }
}
Also used : PoolEnum(it.angelic.mpw.model.enums.PoolEnum) View(android.view.View) AdapterView(android.widget.AdapterView) AdView(com.google.android.gms.ads.AdView) TextView(android.widget.TextView) CurrencyEnum(it.angelic.mpw.model.enums.CurrencyEnum)

Aggregations

PoolEnum (it.angelic.mpw.model.enums.PoolEnum)9 CurrencyEnum (it.angelic.mpw.model.enums.CurrencyEnum)5 SharedPreferences (android.content.SharedPreferences)4 Context (android.content.Context)2 Bundle (android.os.Bundle)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 FirebaseJobDispatcher (com.firebase.jobdispatcher.FirebaseJobDispatcher)2 GooglePlayDriver (com.firebase.jobdispatcher.GooglePlayDriver)2 Job (com.firebase.jobdispatcher.Job)2 JobParameters (com.firebase.jobdispatcher.JobParameters)2 AdView (com.google.android.gms.ads.AdView)2 NotificationManager (android.app.NotificationManager)1 Intent (android.content.Intent)1 EditTextPreference (android.support.v7.preference.EditTextPreference)1 ListPreference (android.support.v7.preference.ListPreference)1 Preference (android.support.v7.preference.Preference)1 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)1 OnClickListener (android.view.View.OnClickListener)1