Skip to content

yucombinator/MicrowaveTimePicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicrowaveTimePicker

Backport of the new "Microwave-style" TimePicker found in the AlarmClock app in Android 4.2+. It's easier to use than the old TimePicker, and looks awesome, too.

TimePickerDialogFragmentTimePicker

Use

Import the library project to your app, then

Insert in the layout file:

    <com.icechen1.microwavetimepicker.TimePicker 
        xmlns:timepicker="http://schemas.android.com/apk/res-auto"
        android:id="@+id/time_picker"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        timepicker:format_24="true" />

where timepicker:format_24="true|false"

true: 24H format

false: 12H format(AM/PM)

To use the view as a dialog, do the following:

public class MainActivity extends FragmentActivity implements TimePickerDialogFragment.TimePickerDialogHandler {
//...
    public void opendialog_am(View v){
		FragmentManager manager = getSupportFragmentManager();
        final FragmentTransaction ft = manager.beginTransaction();
        //Close pre-existing dialogs if any
        final Fragment prev = manager.findFragmentByTag("time_dialog");
        if (prev != null) {
            ft.remove(prev);
        }
        final TimePickerDialogFragment fragment = TimePickerDialogFragment.newInstance();
        fragment.show(ft, "time_dialog");
	}

//...
    @Override
	public void onDialogTimeSet(int hourOfDay, int minute) {
    	//code goes here
    }
//...
		
	}

}

If you are experiencing crashes, you may have to copy the /assets/fonts folder from the library to the root of your project. (your_root/assets/fonts/).

See the sample project for more information

To Do

  • Make it work on Android 2.1+
  • Light theme support
  • Support for different locales
  • There is a weird issue with the padding on the bold font in Android 2.1 - 2.3, I haven't been able to fix it, but if anyone wants to take a look...

Released under the Apache License

About

Backport of the new TimePicker found in the AlarmClock app in Android 4.2+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published