use of edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug in project carat by amplab.
the class SettingsSuggestionAdapter method acceptDisableWifi.
private void acceptDisableWifi(ArrayList<SimpleHogBug> result) {
if (SamplingLibrary.getWifiEnabled(a.getApplicationContext())) {
SimpleHogBug item = new SimpleHogBug(a.getString(R.string.disablewifi), Constants.Type.OS);
result.add(item);
}
}
use of edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug in project carat by amplab.
the class SettingsSuggestionAdapter method acceptDisableAutoSync.
private void acceptDisableAutoSync(ArrayList<SimpleHogBug> result) {
if (ContentResolver.getMasterSyncAutomatically() == true) {
SimpleHogBug item = new SimpleHogBug(a.getString(R.string.disableautomaticsync), Constants.Type.OS);
// TODO Get expected benefit
result.add(item);
}
}
use of edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug in project carat by amplab.
the class SettingsSuggestionAdapter method getView.
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.suggestion, null);
holder = new ViewHolder();
holder.icon = (ImageView) convertView.findViewById(R.id.suggestion_app_icon);
holder.txtName = (TextView) convertView.findViewById(R.id.actionName);
holder.txtType = (TextView) convertView.findViewById(R.id.suggestion_type);
holder.txtBenefit = (TextView) convertView.findViewById(R.id.expectedBenefit);
holder.moreInfo = (ImageView) convertView.findViewById(R.id.jscore_info);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (indexes == null || position < 0 || position >= indexes.length)
return convertView;
SimpleHogBug item = indexes[position];
if (item == null)
return convertView;
final String appName = item.getAppName();
Drawable icon = CaratApplication.iconForApp(a.getApplicationContext(), appName);
if (appName.equals(FAKE_ITEM)) {
holder.txtName.setText(a.getString(R.string.osupgrade));
holder.txtType.setText(a.getString(R.string.information));
holder.txtBenefit.setText(a.getString(R.string.unknown));
} else {
String label = CaratApplication.labelForApp(a.getApplicationContext(), appName);
// TODO: modify the labelForApp() method to accommodate returning correct label based on appNames for system settings
if (label == null)
label = a.getString(R.string.unknown);
holder.icon.setImageDrawable(icon);
Constants.Type type = item.getType();
if (type == Constants.Type.BRIGHTNESS)
action = "dim screen brightness";
else if (type == Constants.Type.WIFI)
action = "turn off wifi";
else if (type == Constants.Type.MOBILEDATA)
action = "turn off mobile data";
holder.txtName.setText(action + " " + label);
if (type == Constants.Type.OTHER)
holder.txtType.setText(item.getAppPriority());
else
holder.txtType.setText(CaratApplication.translatedPriority(item.getAppPriority()));
// Do not show a benefit for things that have none.
if (item.getExpectedValue() == 0 && item.getExpectedValueWithout() == 0) {
holder.txtBenefit.setText("");
TextView bl = (TextView) convertView.findViewById(R.id.benefitLegend);
bl.setText("");
} else
holder.txtBenefit.setText(item.getBenefitText());
// TODO: set holder.moreInfos and their click listener ...
}
// }
return convertView;
}
use of edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug in project carat by amplab.
the class HogsBugsComparator method acceptHogsOrBugs.
private void acceptHogsOrBugs(SimpleHogBug[] input, ArrayList<SimpleHogBug> result) {
if (input == null)
return;
for (SimpleHogBug item : input) {
if (item == null)
continue;
double benefit = 100.0 / item.getExpectedValueWithout() - 100.0 / item.getExpectedValue();
// TODO other filter conditions?
// Limit max number of items?
String appName = item.getAppName();
if (appName == null)
appName = a.getString(R.string.unknown);
// if (SpecialAppCases.isSpecialApp(appName))
if (appName.equals(Constants.CARAT_PACKAGE_NAME) || appName.equals(Constants.CARAT_OLD))
continue;
if (SamplingLibrary.isHidden(a.getApplicationContext(), appName))
continue;
if (addFakeItem && appName.equals(FAKE_ITEM))
result.add(item);
// Filter out if benefit is too small
if (SamplingLibrary.isRunning(a.getApplicationContext(), appName) && benefit > 60) {
result.add(item);
}
}
}
use of edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug in project carat by amplab.
the class HogsBugsAdapter method getView.
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.hog, null);
holder = new ViewHolder();
holder.appIcon = (ImageView) convertView.findViewById(R.id.appIcon);
holder.txtName = (TextView) convertView.findViewById(R.id.appName);
holder.textBenefit = (TextView) convertView.findViewById(R.id.benefit);
holder.moreInfo = (ImageView) convertView.findViewById(R.id.jscore_info);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (allBugsOrHogs == null || position < 0 || position >= allBugsOrHogs.length)
return convertView;
SimpleHogBug item = allBugsOrHogs[position];
if (item == null)
return convertView;
Drawable icon = CaratApplication.iconForApp(a.getApplicationContext(), item.getAppName());
String label = CaratApplication.labelForApp(a.getApplicationContext(), item.getAppName());
if (label == null)
label = a.getString(R.string.unknown);
PackageInfo pak = SamplingLibrary.getPackageInfo(a.getApplicationContext(), item.getAppName());
String ver = "";
if (pak != null) {
ver = pak.versionName;
if (ver == null)
ver = pak.versionCode + "";
}
holder.txtName.setText(label + " " + ver);
holder.appIcon.setImageDrawable(icon);
holder.textBenefit.setText(item.getBenefitText());
return convertView;
}
Aggregations