Search in sources :

Example 1 with ExternalLinksProvider

use of com.owncloud.android.datamodel.ExternalLinksProvider in project android by nextcloud.

the class DrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
        mCheckedMenuItem = savedInstanceState.getInt(KEY_CHECKED_MENU_ITEM, Menu.NONE);
    }
    mCurrentAccountAvatarRadiusDimension = getResources().getDimension(R.dimen.nav_drawer_header_avatar_radius);
    mOtherAccountAvatarRadiusDimension = getResources().getDimension(R.dimen.nav_drawer_header_avatar_other_accounts_radius);
    mMenuAccountAvatarRadiusDimension = getResources().getDimension(R.dimen.nav_drawer_menu_avatar_radius);
    externalLinksProvider = new ExternalLinksProvider(getContentResolver());
    arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
}
Also used : ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) ExternalLinksProvider(com.owncloud.android.datamodel.ExternalLinksProvider)

Example 2 with ExternalLinksProvider

use of com.owncloud.android.datamodel.ExternalLinksProvider in project android by nextcloud.

the class Preferences method loadExternalSettingLinks.

private void loadExternalSettingLinks(PreferenceCategory preferenceCategory) {
    if (getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
        ExternalLinksProvider externalLinksProvider = new ExternalLinksProvider(getContentResolver());
        for (final ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.SETTINGS)) {
            // only add if it does not exist, in case activity is re-used
            if (findPreference(link.id.toString()) == null) {
                Preference p = new Preference(this);
                p.setTitle(link.name);
                p.setKey(link.id.toString());
                p.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                    @Override
                    public boolean onPreferenceClick(Preference preference) {
                        Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
                        externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.name);
                        externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.url);
                        externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
                        externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, link.id);
                        startActivity(externalWebViewIntent);
                        return true;
                    }
                });
                preferenceCategory.addPreference(p);
            }
        }
    }
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) ExternalLinksProvider(com.owncloud.android.datamodel.ExternalLinksProvider) Intent(android.content.Intent) ExternalLink(com.owncloud.android.lib.common.ExternalLink)

Aggregations

ExternalLinksProvider (com.owncloud.android.datamodel.ExternalLinksProvider)2 Intent (android.content.Intent)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 SwitchPreference (android.preference.SwitchPreference)1 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)1 ExternalLink (com.owncloud.android.lib.common.ExternalLink)1