blob: 6247e22edb44d94127d471b03e47eaac076baa21 [file] [log] [blame]
Filipe Gonçalves837e1572015-01-23 17:52:35 +00001
2package com.fairphone.updater;
3
4import android.app.Activity;
Filipe Gonçalves837e1572015-01-23 17:52:35 +00005import android.view.View;
6import android.view.View.OnClickListener;
7import android.widget.Button;
8import android.widget.Toast;
9
10import com.fairphone.updater.tools.Utils;
11
12public class BetaEnabler extends Activity {
13
14 private static final String FAIRPHONE_BETA_PROPERTY = "fairphone.ota.beta";
15 private static final String BETA_DISABLED = "0";
16 private static final String BETA_ENABLED = "1";
17
18 @Override
Filipe Gonçalves837e1572015-01-23 17:52:35 +000019 protected void onResume() {
20 super.onResume();
21 setContentView(R.layout.activity_beta_enabler);
22
23 Button b = (Button) findViewById(R.id.beta_activator);
24
25 if(!isBetaEnabled()){
26 b.setEnabled(true);
27 b.setText(R.string.enable_beta);
28 b.setOnClickListener(new OnClickListener() {
29 @Override
30 public void onClick(View v) {
Filipe Gonçalvesb31d5862015-02-04 17:28:58 +000031 Utils.setprop(FAIRPHONE_BETA_PROPERTY, BETA_ENABLED);
Filipe Gonçalves837e1572015-01-23 17:52:35 +000032 if (isBetaEnabled()) {
33 Button b = (Button) findViewById(R.id.beta_activator);
34 b.setEnabled(false);
35 b.setText(R.string.beta_is_enabled);
36 b.setOnClickListener(null);
37 } else {
38 Toast.makeText(getApplicationContext(), R.string.beta_activation_failed, Toast.LENGTH_LONG).show();
39 }
40 }
41 });
42 }
43 }
44
45 private boolean isBetaEnabled(){
46 return Utils.getprop(FAIRPHONE_BETA_PROPERTY, BETA_DISABLED).equals(BETA_ENABLED);
47 }
48
49}