public class Conditions extends Activity{
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// Close the menu
if (Intent.ACTION_MAIN.equals(intent.getAction())) {
getWindow().closeAllPanels();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
stopService(new Intent(this, SleepListenService.class));
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
boolean terms = settings.getBoolean("terms", true);
if(!terms){
startActivity(new Intent(this, SlideUnlocker.class));
finish();
}else{
setContentView(R.layout.terms);
Button yes = (Button) findViewById(R.id.yes);
Button no = (Button) findViewById(R.id.no);
WebView wv = (WebView) findViewById(R.id.gpl3);
try {
wv.loadData(IOUtils.toString(getResources().openRawResource(R.raw.gpl)).toString(), "text/html", "utf-8");
} catch (Exception e) {
throw new RuntimeException("Blowup");
}
showMessage("This project is under GPL3, you must agree to the terms and conditions before proceeding");
yes.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivity(new Intent(TermsConditions.this, SlideUnlocker.class));
Editor editor = settings.edit();
editor.putBoolean("terms", false);
editor.commit();
finish();
}
});
no.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
yes.setVisibility(View.VISIBLE);
no.setVisibility(View.VISIBLE);
}
}
private void showMessage(String errorString) {
Toast text = Toast.makeText(this,
errorString, Toast.LENGTH_LONG);
text.show();
}
}
http://download.csdn.net/detail/sun6223508/5780687