use of fr.neamar.kiss.pojo.TogglesPojo in project KISS by Neamar.
the class LoadTogglesPojos method createPojo.
private TogglesPojo createPojo(String name, String settingName, int resId) {
TogglesPojo pojo = new TogglesPojo();
pojo.id = pojoScheme + name.toLowerCase();
pojo.name = name;
pojo.nameNormalized = pojo.name.toLowerCase();
pojo.settingName = settingName;
pojo.icon = resId;
return pojo;
}
use of fr.neamar.kiss.pojo.TogglesPojo in project KISS by Neamar.
the class LoadTogglesPojos method doInBackground.
@Override
protected ArrayList<TogglesPojo> doInBackground(Void... params) {
ArrayList<TogglesPojo> 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));
}
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
toggles.add(createPojo(context.getString(R.string.toggle_torch), "torch", R.drawable.toggle_torch));
}
//toggle for synchronization
toggles.add(createPojo(context.getString(R.string.toggle_sync), "sync", R.drawable.toggle_sync));
//toggle for autorotation
toggles.add(createPojo(context.getString(R.string.toggle_autorotate), "autorotate", R.drawable.toggle_rotation));
return toggles;
}
use of fr.neamar.kiss.pojo.TogglesPojo in project KISS by Neamar.
the class TogglesProvider method getResults.
public ArrayList<Pojo> getResults(String query) {
ArrayList<Pojo> results = new ArrayList<>();
int relevance;
String toggleNameLowerCased;
for (TogglesPojo toggle : pojos) {
relevance = 0;
toggleNameLowerCased = toggle.nameNormalized;
if (toggleNameLowerCased.startsWith(query))
relevance = 75;
else if (toggleNameLowerCased.contains(" " + query))
relevance = 30;
else if (toggleNameLowerCased.contains(query))
relevance = 1;
else if (toggleName.startsWith(query)) {
// Also display for a search on "settings" for instance
relevance = 4;
}
if (relevance > 0) {
toggle.displayName = toggle.name.replaceFirst("(?i)(" + Pattern.quote(query) + ")", "{$1}");
toggle.relevance = relevance;
results.add(toggle);
}
}
return results;
}
Aggregations