use of edu.berkeley.cs.amplab.carat.android.subscreens.KillAppFragment in project carat by amplab.
the class SuggestionsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (CaratApplication.storage.getHogReport().length == 0 && CaratApplication.storage.getBugReport().length == 0) {
root = inflater.inflate(R.layout.emptyactions, container, false);
return root;
}
root = inflater.inflate(R.layout.suggestions, container, false);
final ListView lv = (ListView) root.findViewById(android.R.id.list);
lv.setCacheColorHint(0);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv.getItemAtPosition(position);
SimpleHogBug fullObject = (SimpleHogBug) o;
final String raw = fullObject.getAppName();
// Log.v(TAG, "Showing kill view for " + raw);
if (raw.equals("OsUpgrade"))
mMainActivity.showHTMLFile("upgradeos", getString(R.string.upgradeosinfo), false);
else // GoToSyncScreen();
if (raw.equals(getString(R.string.helpcarat))) {
mMainActivity.showHTMLFile("collectdata", getString(R.string.collectdatainfo), false);
} else if (raw.equals(getString(R.string.questionnaire))) {
openQuestionnaire();
} else {
displayKillAppFragment(fullObject, raw);
}
}
/*
* display a fragment (KillAppFragment) for killing the buggy app
*/
private void displayKillAppFragment(SimpleHogBug fullObject, final String raw) {
// we need to pass the buggy app info (as a bundle named "args")
// to the fragment
Bundle args = new Bundle();
args.putString("raw", raw);
Constants.Type type = fullObject.getType();
if (type == Constants.Type.BUG) {
args.putBoolean("isBug", true);
args.putBoolean("isHog", false);
args.putBoolean("isOther", false);
} else if (type == Constants.Type.HOG) {
args.putBoolean("isHog", true);
args.putBoolean("isBug", false);
args.putBoolean("isOther", false);
}
if (type == Constants.Type.OTHER) {
args.putString("appPriority", fullObject.getAppPriority());
} else {
args.putString("appPriority", CaratApplication.translatedPriority(fullObject.getAppPriority()));
}
args.putString("benefit", fullObject.getBenefitText());
Fragment fragment = new KillAppFragment();
fragment.setArguments(args);
CaratApplication.getMainActivity().replaceFragment(fragment, getString(R.string.kill) + " " + raw, false);
/*
* if (raw.equals("Disable bluetooth")) { double benefitOther =
* PowerProfileHelper. bluetoothBenefit(c); hours = (int)
* (benefitOther); min = (int) (benefitOther * 60); min -= hours
* * 60; } else if (raw.equals("Disable Wifi")) { double
* benefitOther = PowerProfileHelper.wifiBenefit(c); hours =
* (int) (benefitOther); min = (int) (benefitOther * 60); min -=
* hours * 60; } else if (raw.equals("Dim the Screen")) { double
* benefitOther = PowerProfileHelper.
* screenBrightnessBenefit(c); hours = (int) (benefitOther); min
* = (int) (benefitOther * 60); min -= hours * 60; }
*/
}
});
initUpgradeOsView(root);
/*
getActivity().setTitle(getResources().getString(R.string.tab_actions));
*/
return root;
}
Aggregations