Search in sources :

Example 1 with SettingsPojo

use of fr.neamar.kiss.pojo.SettingsPojo in project KISS by Neamar.

the class SettingsProvider method getResults.

public ArrayList<Pojo> getResults(String query) {
    ArrayList<Pojo> results = new ArrayList<>();
    int relevance;
    String settingNameLowerCased;
    for (SettingsPojo setting : pojos) {
        relevance = 0;
        settingNameLowerCased = setting.nameNormalized;
        if (settingNameLowerCased.startsWith(query))
            relevance = 10;
        else if (settingNameLowerCased.contains(" " + query))
            relevance = 5;
        else if (settingName.startsWith(query)) {
            // Also display for a search on "settings" for instance
            relevance = 4;
        }
        if (relevance > 0) {
            setting.displayName = setting.name.replaceFirst("(?i)(" + Pattern.quote(query) + ")", "{$1}");
            setting.relevance = relevance;
            results.add(setting);
        }
    }
    return results;
}
Also used : Pojo(fr.neamar.kiss.pojo.Pojo) SettingsPojo(fr.neamar.kiss.pojo.SettingsPojo) SettingsPojo(fr.neamar.kiss.pojo.SettingsPojo) ArrayList(java.util.ArrayList)

Example 2 with SettingsPojo

use of fr.neamar.kiss.pojo.SettingsPojo in project KISS by Neamar.

the class LoadSettingsPojos method createPojo.

private SettingsPojo createPojo(String name, String packageName, String settingName, int resId) {
    SettingsPojo pojo = this.createPojo(name, settingName, resId);
    pojo.packageName = packageName;
    return pojo;
}
Also used : SettingsPojo(fr.neamar.kiss.pojo.SettingsPojo)

Example 3 with SettingsPojo

use of fr.neamar.kiss.pojo.SettingsPojo in project KISS by Neamar.

the class LoadSettingsPojos method doInBackground.

@Override
protected ArrayList<SettingsPojo> doInBackground(Void... params) {
    PackageManager pm = context.getPackageManager();
    ArrayList<SettingsPojo> settings = new ArrayList<>();
    settings.add(createPojo(context.getString(R.string.settings_airplane), Settings.ACTION_AIRPLANE_MODE_SETTINGS, R.drawable.setting_airplane));
    settings.add(createPojo(context.getString(R.string.settings_device_info), Settings.ACTION_DEVICE_INFO_SETTINGS, R.drawable.setting_info));
    settings.add(createPojo(context.getString(R.string.settings_applications), Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS, R.drawable.setting_apps));
    settings.add(createPojo(context.getString(R.string.settings_connectivity), Settings.ACTION_WIRELESS_SETTINGS, R.drawable.toggle_wifi));
    settings.add(createPojo(context.getString(R.string.settings_storage), Settings.ACTION_INTERNAL_STORAGE_SETTINGS, R.drawable.setting_storage));
    settings.add(createPojo(context.getString(R.string.settings_accessibility), Settings.ACTION_ACCESSIBILITY_SETTINGS, R.drawable.setting_accessibility));
    settings.add(createPojo(context.getString(R.string.settings_battery), Intent.ACTION_POWER_USAGE_SUMMARY, R.drawable.setting_battery));
    settings.add(createPojo(context.getString(R.string.settings_tethering), "com.android.settings", "com.android.settings.TetherSettings", R.drawable.setting_tethering));
    settings.add(createPojo(context.getString(R.string.settings_sound), Settings.ACTION_SOUND_SETTINGS, R.drawable.setting_dev));
    settings.add(createPojo(context.getString(R.string.settings_display), Settings.ACTION_DISPLAY_SETTINGS, R.drawable.setting_dev));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
            settings.add(createPojo(context.getString(R.string.settings_nfc), Settings.ACTION_NFC_SETTINGS, R.drawable.setting_nfc));
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        settings.add(createPojo(context.getString(R.string.settings_dev), Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS, R.drawable.setting_dev));
    }
    return settings;
}
Also used : PackageManager(android.content.pm.PackageManager) SettingsPojo(fr.neamar.kiss.pojo.SettingsPojo) ArrayList(java.util.ArrayList)

Aggregations

SettingsPojo (fr.neamar.kiss.pojo.SettingsPojo)3 ArrayList (java.util.ArrayList)2 PackageManager (android.content.pm.PackageManager)1 Pojo (fr.neamar.kiss.pojo.Pojo)1