Example usage for android.preference CheckBoxPreference CheckBoxPreference

List of usage examples for android.preference CheckBoxPreference CheckBoxPreference

Introduction

In this page you can find the example usage for android.preference CheckBoxPreference CheckBoxPreference.

Prototype

public CheckBoxPreference(Context context) 

Source Link

Usage

From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java

private void populateNewsSources() {
    PreferenceCategory news_sources = (PreferenceCategory) findPreference("card_news_sources");
    NewsManager cm = new NewsManager(mContext);
    Cursor cur = cm.getNewsSources();
    if (cur.moveToFirst()) {
        do {/*from  ww  w  . j  a v  a2s . c  om*/
            final CheckBoxPreference pref = new CheckBoxPreference(mContext);
            pref.setKey("card_news_source_" + cur.getString(0));
            pref.setDefaultValue(true);
            if (Build.VERSION.SDK_INT >= 11) {
                // Load news source icon in background and set it
                final String url = cur.getString(1);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        NetUtils net = new NetUtils(mContext);
                        final Bitmap bmp = net.downloadImageToBitmap(url);
                        mContext.runOnUiThread(new Runnable() {
                            @TargetApi(11)
                            @Override
                            public void run() {
                                pref.setIcon(new BitmapDrawable(getResources(), bmp));
                            }
                        });
                    }
                }).start();
            }
            pref.setTitle(cur.getString(2));
            news_sources.addPreference(pref);
        } while (cur.moveToNext());
    }
    cur.close();
}

From source file:nya.miku.wishmaster.chans.nullchancc.NullchanccModule.java

private void addOnlyNewPostsPreference(PreferenceGroup group) {
    Context context = group.getContext();
    CheckBoxPreference onlyNewPostsPreference = new CheckBoxPreference(context);
    onlyNewPostsPreference.setTitle(R.string.nullchancc_prefs_only_new_posts);
    onlyNewPostsPreference.setSummary(R.string.nullchancc_prefs_only_new_posts_summary);
    onlyNewPostsPreference.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS));
    onlyNewPostsPreference.setDefaultValue(true);
    group.addItemFromInflater(onlyNewPostsPreference);
}

From source file:nya.miku.wishmaster.api.AbstractWakabaModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addPasswordPreference(preferenceGroup);
    if (canHttps()) {
        CheckBoxPreference httpsPref = new CheckBoxPreference(context);
        httpsPref.setTitle(R.string.pref_use_https);
        httpsPref.setSummary(R.string.pref_use_https_summary);
        httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS));
        httpsPref.setDefaultValue(useHttpsDefaultValue());
        preferenceGroup.addPreference(httpsPref);
        addUnsafeSslPreference(preferenceGroup, getSharedKey(PREF_KEY_USE_HTTPS));
    }// w  w  w.  ja va2  s.  c  o  m
    addProxyPreferences(preferenceGroup);
}

From source file:nya.miku.wishmaster.api.AbstractChanModule.java

/**
 *     ( ?/ ) -? "  SSL"/*from w  w w. j  a v  a2  s  . co  m*/
 * @param group ,   ??? 
 * @param dependencyKey -?? ?  ,   null
 */
protected void addUnsafeSslPreference(PreferenceGroup group, String dependencyKey) {
    final Context context = group.getContext();
    CheckBoxPreference unsafeSslPref = new CheckBoxPreference(context); //? "  SSL"
    unsafeSslPref.setTitle(R.string.pref_ignore_ssl_errors);
    unsafeSslPref.setSummary(R.string.pref_ignore_ssl_errors_summary);
    unsafeSslPref.setKey(getSharedKey(PREF_KEY_UNSAFE_SSL));
    unsafeSslPref.setDefaultValue(false);
    unsafeSslPref.setOnPreferenceChangeListener(updateHttpListener);
    group.addPreference(unsafeSslPref);
    if (dependencyKey != null)
        unsafeSslPref.setDependency(dependencyKey);
}