package com.sjriley.zappit;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.util.Linkify;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class TermsActivity extends Activity
{
private Button acceptButton;
private Button rejectButton;
private TextView termsTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.terms);
termsTextView = (TextView)findViewById(R.id.termsTextView);
acceptButton = (Button)findViewById(R.id.acceptButton);
rejectButton = (Button)findViewById(R.id.rejectButton);
String terms = "By clicking accept, I agree to zappit\'s terms and conditions at " +
"www.zappit.co/terms and " +
"the privacy statement www.zappit.co/privacy" +
"<br/>For further details please visit www.zappit.co";
termsTextView.setText(Html.fromHtml(terms));
//jmt: pattern we want to match and turn into a clickable link
Pattern pattern = Pattern.compile("www.zappit.co/terms|www.zappit.co/privacy|www.zappit.co");
//jmt: prefix our pattern with http://
Linkify.addLinks(termsTextView, pattern, "http://");
acceptButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
acceptClick();
}
});
rejectButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
rejectClick();
}
});
}
private void acceptClick() {
Intent intent = new Intent(this, CaptureActivity.class);
startActivity(intent);
}
private void rejectClick() {
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
}
}