Search in sources :

Example 1 with InitListener

use of com.waz.api.InitListener in project wire-android by wireapp.

the class DevicesPreferences method onCreatePreferences2.

@Override
public void onCreatePreferences2(Bundle savedInstanceState, String rootKey) {
    super.onCreatePreferences2(savedInstanceState, rootKey);
    addPreferencesFromResource(R.xml.preferences_devices);
    getStoreFactory().getZMessagingApiStore().getApi().onInit(new InitListener() {

        @Override
        public void onInitialized(Self user) {
            setupOtrDevices();
        }
    });
    trackViewingOtrClients();
}
Also used : InitListener(com.waz.api.InitListener) Self(com.waz.api.Self)

Example 2 with InitListener

use of com.waz.api.InitListener in project wire-android by wireapp.

the class RootPreferences method onCreatePreferences2.

@Override
public void onCreatePreferences2(Bundle savedInstanceState, String rootKey) {
    super.onCreatePreferences2(savedInstanceState, rootKey);
    if (BuildConfig.SHOW_DEVELOPER_OPTIONS) {
        addPreferencesFromResource(R.xml.preference_root__developer);
        findPreference(getString(R.string.pref_dev_avs_screen_key)).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                getChildFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).add(AvsOptionsDialogFragment.newInstance(), AvsOptionsDialogFragment.TAG).addToBackStack(AvsOptionsDialogFragment.TAG).commit();
                return true;
            }
        });
    } else {
        addPreferencesFromResource(R.xml.preference_root);
    }
    inviteButtonPreference = (ButtonPreference) findPreference(getString(R.string.pref_invite_key));
    inviteButtonPreference.setAccentColor(getControllerFactory().getAccentColorController().getColor());
    inviteButtonPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            sendGenericInvite();
            return true;
        }
    });
    devicesPreferenceScreenLike = (BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_devices_screen_key));
    devicesPreferenceScreenLike.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (otrClients != null) {
                for (OtrClient client : otrClients) {
                    client.setVerified(false);
                }
            }
            return false;
        }
    });
    getStoreFactory().getZMessagingApiStore().getApi().onInit(new InitListener() {

        @Override
        public void onInitialized(Self user) {
            otrClientsObserver.setAndUpdate(getStoreFactory().getZMessagingApiStore().getApi().getSelf().getIncomingOtrClients());
        }
    });
    if (savedInstanceState == null) {
        boolean showSpotifyLogin = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_SPOTIFY_LOGIN, false);
        boolean showOtrDevices = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_OTR_DEVICES, false);
        boolean showAccount = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_ACCOUNT, false);
        boolean showUsernameEdit = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_USERNAME_EDIT);
        final PreferenceManager.OnNavigateToScreenListener navigateToScreenListener = getPreferenceManager().getOnNavigateToScreenListener();
        PreferenceScreen preference = null;
        if (showAccount) {
            preference = (PreferenceScreen) findPreference(getString(R.string.pref_account_screen_key));
        } else if (showSpotifyLogin) {
            preference = (PreferenceScreen) findPreference(getString(R.string.pref_options_screen_key));
            getControllerFactory().getSpotifyController().login(getActivity());
        } else if (showOtrDevices) {
            preference = devicesPreferenceScreenLike.getPreferenceScreen();
        } else if (showUsernameEdit) {
            preference = ((BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_account_screen_key))).getPreferenceScreen();
        }
        if (preference != null) {
            preference.getExtras().putAll(getArguments());
            navigateToScreenListener.onNavigateToScreen(preference);
        }
    }
}
Also used : InitListener(com.waz.api.InitListener) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) Self(com.waz.api.Self) OtrClient(com.waz.api.OtrClient) PreferenceManager(android.support.v7.preference.PreferenceManager)

Aggregations

InitListener (com.waz.api.InitListener)2 Self (com.waz.api.Self)2 Preference (android.support.v7.preference.Preference)1 PreferenceManager (android.support.v7.preference.PreferenceManager)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 OtrClient (com.waz.api.OtrClient)1