<commit_before>package fr.neamar.kiss.loader;

import android.content.Context;
import android.content.pm.PackageManager;

import java.util.ArrayList;

import fr.neamar.kiss.R;
import fr.neamar.kiss.pojo.TogglePojo;

public class LoadTogglePojos extends LoadPojos<TogglePojo> {

    public LoadTogglePojos(Context context) {
        super(context, "toggle://");
    }

    @Override
    protected ArrayList<TogglePojo> doInBackground(Void... params) {
        ArrayList<TogglePojo> toggles = new ArrayList<>();
        PackageManager pm = context.getPackageManager();
        if (pm.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
            toggles.add(createPojo(context.getString(R.string.toggle_wifi), "wifi", R.drawable.toggle_wifi));
        }
        if (pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
            toggles.add(createPojo(context.getString(R.string.toggle_bluetooth), "bluetooth", R.drawable.toggle_bluetooth));
        }
        toggles.add(createPojo(context.getString(R.string.toggle_silent), "silent", R.drawable.toggle_silent));
        if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
            toggles.add(createPojo(context.getString(R.string.toggle_data), "data", R.drawable.toggle_data));
        }

        return toggles;
    }

    private TogglePojo createPojo(String name, String settingName, int resId) {
        TogglePojo pojo = new TogglePojo();
        pojo.id = pojoScheme + name.toLowerCase();
        pojo.name = name;<commit_msg>Disable network toggle on API21+, fix #183<commit_after>package fr.neamar.kiss.loader;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

import java.util.ArrayList;

import fr.neamar.kiss.R;
import fr.neamar.kiss.pojo.TogglePojo;

public class LoadTogglePojos extends LoadPojos<TogglePojo> {

    public LoadTogglePojos(Context context) {
        super(context, "toggle://");
    }

    @Override
    protected ArrayList<TogglePojo> doInBackground(Void... params) {
        ArrayList<TogglePojo> toggles = new ArrayList<>();
        PackageManager pm = context.getPackageManager();
        if (pm.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
            toggles.add(createPojo(context.getString(R.string.toggle_wifi), "wifi", R.drawable.toggle_wifi));
        }
        if (pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
            toggles.add(createPojo(context.getString(R.string.toggle_bluetooth), "bluetooth", R.drawable.toggle_bluetooth));
        }
        toggles.add(createPojo(context.getString(R.string.toggle_silent), "silent", R.drawable.toggle_silent));
        if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) && android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
            // Not working after 4.4
            // See http://stackoverflow.com/questions/26539445/the-setmobiledataenabled-method-is-no-longer-callable-as-of-android-l-and-later
            toggles.add(createPojo(context.getString(R.string.toggle_data), "data", R.drawable.toggle_data));
        }

        return toggles;
    }

    private TogglePojo createPojo(String name, String settingName, int resId) {
        TogglePojo pojo = new TogglePojo();
        pojo.id = pojoScheme + name.toLowerCase();
        pojo.name = name;
{'fraction_non_alphanumeric': 0.11932162325863113, 'fraction_numerical': 0.0045427013930950935, 'mean_word_length': 3.5621546961325965, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7319075', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1037, 'n_words': 157}