Exemplo n.º 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.splash);

    context = getApplicationContext();
    PropertyHolder.init(context);

    if (context.getPackageName().toLowerCase().contains("asmpro")) {
      PropertyHolder.setProVersion(true);
    }

    // 18 December 2013: end of data collection:
    if (PropertyHolder.getShareData()) {
      PropertyHolder.setShareData(false);
      buildEndResearchAnnouncement();
    } else {

      if (Util.trafficCop(this)) finish();
      // check if there was a database update that tried to
      // trigger a values update before any crash
      Util.needDatabaseUpdate = PropertyHolder.needDatabaseValueUpdate();

      // open and close database in order to trigger any updates
      ContentResolver cr = getContentResolver();
      Cursor c =
          cr.query(Util.getFixesUri(context), new String[] {Fixes.KEY_ROWID}, null, null, null);
      c.close();

      if (PropertyHolder.isServiceOn()) {
        Intent scheduler =
            new Intent(
                getResources().getString(R.string.internal_message_id) + Util.MESSAGE_SCHEDULE);
        context.sendBroadcast(scheduler);
      }

      if (PropertyHolder.getUploadOldFiles()) {
        Intent oldFileUploaderIntent = new Intent(SplashScreen.this, OldFileUploader.class);
        startService(oldFileUploaderIntent);
      }

      Intent intent = new Intent(SplashScreen.this, MapMyData.class);
      startActivity(intent);
      finish();
    }
  }
Exemplo n.º 2
0
  public JSONObject exportJSON(Context context) {

    PropertyHolder.init(context);

    JSONObject object = new JSONObject();
    try {
      object.put("userid", PropertyHolder.getUserId());
      object.put("tripid", this.tripid);
      object.put("lat", String.valueOf(this.lat));
      object.put("lon", String.valueOf(this.lng));
      object.put("alt", String.valueOf(this.alt));
      object.put("acc", String.valueOf(this.acc));
      object.put("provider", String.valueOf(this.prov));
      object.put("timestamp", String.valueOf(this.time));
      object.put("pow_bat", String.valueOf(this.pow));

    } catch (JSONException e) {
    }
    return object;
  }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.consent);
    context = getApplicationContext();
    PropertyHolder.init(context);

    TextView consent = (TextView) findViewById(R.id.consenttext);
    consent.setText(Html.fromHtml(getString(R.string.consent_text)));
    consent.setTextColor(Color.WHITE);
    consent.setTextSize(getResources().getDimension(R.dimen.textsize_normal));

    final Button consentButton = (Button) findViewById(R.id.consent_button);
    consentButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            Date now = new Date(System.currentTimeMillis());
            String consentTime = Util.userDate(now);
            PropertyHolder.setConsentTime(consentTime);
            PropertyHolder.setConsent(true);

            if (PropertyHolder.isRegistered()) {
              if (PropertyHolder.getUserId() != null) {
                ContentResolver ucr = getContentResolver();
                ucr.insert(
                    Util.getUploadQueueUri(context),
                    UploadContentValues.createUpload("CON", consentTime));
              }
              Intent i = new Intent(Consent.this, MapMyData.class);
              startActivity(i);
              finish();
              return;
            } else {

              Intent i = new Intent(Consent.this, Registration.class);
              // start the intent
              startActivity(i);
              finish();
              return;
            }
          }
        });

    final Button consentDeclineButton = (Button) findViewById(R.id.consent_decline_button);
    consentDeclineButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            if (PropertyHolder.getProVersion()) {

              PropertyHolder.setShareData(false);

              Intent i = new Intent(Consent.this, MapMyData.class);
              startActivity(i);
            }
            finish();
            return;
          }
        });
  }
Exemplo n.º 4
0
  public String makeFileName(Context context) {

    PropertyHolder.init(context);
    return PropertyHolder.getUserId() + "_" + this.tripid + "_" + Util.fileNameDate(this.time);
  }