Android Open Source - minimalclockfree Tom Clock V1 Configure






From Project

Back to project page minimalclockfree.

License

The source code is released under:

Copyright 2011 Richard Martin. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project minimalclockfree listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package tom.clock;
//from ww w.ja  v a  2  s.  c om
import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * @author tom
 *
 */
public class TomClockV1Configure extends Activity {
  
  static final String PREFS_KEY = "tom.clock.TomClockV1";
  static final String TWENTY_FOUR_HOUR_MODE = "24 hour mode";
  static final String SHOW_CLOCK = "show clock";
  
  protected int widgetId;
  
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tom_clock_v1_configure);

    ((Button) findViewById(R.id.confirm_button_12)).setOnClickListener(confirm12ClickListener);
    ((Button) findViewById(R.id.confirm_button_24)).setOnClickListener(confirm24ClickListener);

    Bundle extras = getIntent().getExtras();
    widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
  }

  protected void postResult() {
    Intent resultValue = new Intent();
    resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    setResult(RESULT_OK, resultValue);
    finish();
  }

  protected void set24HourMode(final boolean mode24) {
    SharedPreferences.Editor prefs = getSharedPreferences(PREFS_KEY, 0).edit();
    prefs.putBoolean(TWENTY_FOUR_HOUR_MODE, mode24);
    prefs.commit();
  }

  View.OnClickListener confirm12ClickListener = new View.OnClickListener() {
    public void onClick(View v) {
      set24HourMode(false);
      postResult();
    }
  };

  View.OnClickListener confirm24ClickListener = new View.OnClickListener() {
    public void onClick(View v) {
      set24HourMode(true);
      postResult();
    }
  };
}




Java Source Code List

tom.clock.TomClockV1Configure.java
tom.clock.TomClockV1Service.java
tom.clock.TomClockV1.java