android-betterpickers


Source link: https://github.com/derekbrameyer/android-betterpickers

DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numbers, and other things.

Try out the sample application on Google Play.

Including in Your Project

Gradle

compile 'com.code-troopers.betterpickers:library:3.1.0'

Maven

<dependency>
<groupId>com.code-troopers.betterpickers</groupId>
<artifactId>library</artifactId>
<version>3.1.0</version>
<type>aar</type> </dependency>

Usage

For a working implementation of this project see the sample/ folder.

Calendar Date Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment()

  .setOnDateSetListener(SampleCalendarDateBasicUsage.this)

  .setFirstDayOfWeek(Calendar.SUNDAY)

  .setPreselectedDate(towDaysAgo.getYear(), towDaysAgo.getMonthOfYear() - 1, towDaysAgo.getDayOfMonth())

  .setDateRange(minDate, null)

  .setDoneText("Yay")

  .setCancelText("Nop")

  .setThemeDark(true);

cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);

  
}
 
}
);

Radial Time Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment()

  .setOnTimeSetListener(SampleRadialTimeBasicUsage.this)

  .setStartTime(10, 10)

  .setDoneText("Yay")

  .setCancelText("Nop")

  .setThemeDark(true);

rtpd.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);

  
}
 
}
);

Recurrence Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

FragmentManager fm = getSupportFragmentManager();

Bundle bundle = new Bundle();

Time time = new Time();

time.setToNow();

bundle.putLong(RecurrencePickerDialogFragment.BUNDLE_START_TIME_MILLIS, time.toMillis(false));

bundle.putString(RecurrencePickerDialogFragment.BUNDLE_TIME_ZONE, time.timezone);

bundle.putString(RecurrencePickerDialogFragment.BUNDLE_RRULE, mRrule);

bundle.putBoolean(RecurrencePickerDialogFragment.BUNDLE_HIDE_SWITCH_BUTTON, true);

 RecurrencePickerDialogFragment rpd = new RecurrencePickerDialogFragment();

rpd.setArguments(bundle);

rpd.setOnRecurrenceSetListener(SampleRecurrenceBasicUsage.this);

rpd.show(fm, FRAG_TAG_RECUR_PICKER);

  
}
 
}
);

Timezone Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

FragmentManager fm = getSupportFragmentManager();

Bundle bundle = new Bundle();

Time time = new Time();

time.setToNow();

bundle.putLong(TimeZonePickerDialogFragment.BUNDLE_START_TIME_MILLIS, time.toMillis(false));

bundle.putString(TimeZonePickerDialogFragment.BUNDLE_TIME_ZONE, time.timezone);

bundle.putString(RecurrencePickerDialogFragment.BUNDLE_RRULE, mRrule);

 TimeZonePickerDialogFragment tzpd = new TimeZonePickerDialogFragment();

tzpd.setArguments(bundle);

tzpd.setOnTimeZoneSetListener(SampleTimeZoneBasicUsage.this);

tzpd.show(fm, FRAG_TAG_TIME_ZONE_PICKER);

  
}
 
}
);

Date Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

DatePickerBuilder dpb = new DatePickerBuilder()

  .setFragmentManager(getSupportFragmentManager())

  .setStyleResId(R.style.BetterPickersDialogFragment)

  .setYearOptional(true);

dpb.show();

  
}
 
}
);

Expiration Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

ExpirationPickerBuilder epb = new ExpirationPickerBuilder()

 .setFragmentManager(getSupportFragmentManager())

 .setStyleResId(R.style.BetterPickersDialogFragment)

 .setMinYear(2000);

epb.show();

  
}
 
}
);

HMS Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

HmsPickerBuilder hpb = new HmsPickerBuilder()

  .setFragmentManager(getSupportFragmentManager())

  .setStyleResId(R.style.BetterPickersDialogFragment);

hpb.show();

  
}
 
}
);

Number Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

NumberPickerBuilder npb = new NumberPickerBuilder()

  .setFragmentManager(getSupportFragmentManager())

  .setStyleResId(R.style.BetterPickersDialogFragment)

  .setLabelText("LBS.");

npb.show();
 
}
 
}
);

Time Picker

button.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {

TimePickerBuilder tpb = new TimePickerBuilder()

  .setFragmentManager(getSupportFragmentManager())

  .setStyleResId(R.style.BetterPickersDialogFragment);

tpb.show();

  
}
 
}
);

Theming

For a demonstration of theming, see the sample/ folder.

Calendar Date Picker / Radial Time Picker

  1. Use attributes that allow you to customize pickers

    bpHeaderBackgroundColor :: bpHeaderUnselectedTextColor :: bpHeaderSelectedTextColor :: bpBodyBackgroundColor :: bpBodySelectedTextColor :: bpBodyUnselectedTextColor :: bpButtonsBackgroundColor :: bpButtonsTextColor :: -- Calendar Date Picker bpPreHeaderBackgroundColor :: bpDisabledDayTextColor :: -- Radial Time Picker bpRadialBackgroundColor :: bpRadialTextColor :: bpRadialPointerColor :: bpAmPmCircleColor ::

  2. Create your own custom theme in styles.xml:

```xml <style name="MyCustomBetterPickersDialogs" parent="BetterPickersRadialTimePickerDialog.PrimaryColor">
  <item name="bpPreHeaderBackgroundColor">@color/holo_red_dark</item>
  <item name="bpHeaderBackgroundColor">@color/holo_red_light</item>
  <item name="bpHeaderSelectedTextColor">@color/holo_orange_dark</item>
  <item name="bpHeaderUnselectedTextColor">@android:color/white</item>

<item name="bpBodyBackgroundColor">@color/holo_blue_dark</item>
  <item name="bpBodySelectedTextColor">@color/holo_orange_dark</item>
  <item name="bpBodyUnselectedTextColor">@android:color/white</item>

<item name="bpRadialBackgroundColor">@color/holo_orange_dark</item>
  <item name="bpRadialTextColor">@color/holo_purple</item>
  <item name="bpRadialPointerColor">@android:color/black</item>

<item name="bpButtonsBackgroundColor">@color/holo_green_dark</item>
  <item name="bpButtonsTextColor">@color/holo_orange_dark</item> </style> ``` 
  1. Instantiate your DialogFragment using your custom theme:
RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment()

  .setOnTimeSetListener(SampleRadialTimeThemeCustom.this)

  .setThemeCustom(R.style.MyCustomBetterPickersDialogs);
 rtpd.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);
  1. Result

Date Picker / Expiration Picker / HMS Picker / Number Picker / Time Picker

  1. You can use your own themes if you'd like to change certain attributes. BetterPickers currently allows for customization of the following attributes:

    bpDialogBackground :: the drawable (preferably a 9-patch) used as a window background for the DialogFragment bpTextColor :: the color (optionally state list) for all text in the DialogFragment bpDeleteIcon :: the drawable (optionally state list) for the delete button bpCheckIcon :: the drawable (optionally state list) for the check button in the DateDialogPicker bpKeyBackground :: the drawable (optionally state list) for the keyboard buttons bpButtonBackground :: the drawable (optionally state list) for the Set, Cancel, and Delete buttons bpDividerColor :: the color used for the DialogFragment dividers bpKeyboardIndicatorColor :: the color used for the ViewPagerIndicator on the DateDialogPicker

  2. Create your own custom theme in styles.xml:

<style name="MyCustomBetterPickerTheme">
  <item name="bpDialogBackground">@drawable/custom_dialog_background</item>
  <item name="bpTextColor">@color/custom_text_color</item>
  <item name="bpDeleteIcon">@drawable/ic_backspace_custom</item>
  <item name="bpCheckIcon">@drawable/ic_check_custom</item>
  <item name="bpKeyBackground">@drawable/key_background_custom</item>
  <item name="bpButtonBackground">@drawable/button_background_custom</item>
  <item name="bpDividerColor">@color/custom_divider_color</item>
  <item name="bpKeyboardIndicatorColor">@color/custom_keyboard_indicator_color</item> </style>
  1. Instantiate your DialogFragment using your custom theme:
DatePickerBuilder dpb = new DatePickerBuilder()
  .setFragmentManager(getSupportFragmentManager())
  .setStyleResId(R.style.MyCustomBetterPickerTheme);
 dpb.show();

Actionbarsherlock compatibility

If you use actionbarsherlock which is not compatible with appcompat-v7 you can use the latest version of the library on the 1.x.x branch.

You can view the readme here

ChangeLog

Change log file is available here

Contribution

Pull requests are welcome!

Feel free to contribute to BetterPickers.

If you've fixed a bug or have a feature you've added, just create a pull request.

If you've found a bug, want a new feature, or have other questions, file an issue. We will try to answer as soon as possible.

Applications using BetterPickers

Please send a pull request if you would like to be added here.

Icon Application
Trello
Navig'Tours
Sleep Well
Dayon Alarm
Driving Timer
TVShow Time

Credits

Thanks to Derek Brameyer for the initial version.

Thanks to JakeWharton for his work on ViewPagerIndicator.

Thanks to OAK and WillowTree Apps for Maven assistance and possible future improvements.

Thanks to all contributors !

License

Copyright 2013 Derek Brameyer, Code-Troopers  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

material-dialogs library allows you to use a consistently Material themed dialog on all versions of Android, along with specific customizations that make it easier to brand the dialog.

Navigation Drawer Activity with material design style and simplified methods.

Every major open-source project has its own style guide: a set of conventions (sometimes arbitrary) about how to write code for that project. It is much easier to understand a large codebase when all the code in it is in a consistent style.

"Style" covers a lot of ground, from "use camelCase for variable names" to "never use global variables" to "never use exceptions." This project holds the style guidelines we use for Google code. If you are modifying a project that originated at Google, you may be pointed to this page to see the style guides that apply to that project.

This library display hierarchical data (e.g. comments) in a list view, so that the user can collapse and expand elements. Every element is indented accordingly to its level in the hierarchy.

Floating Action Menu for Android. Inspired by the Google Plus floating menu.

PrettySharedPreferences is a lightweight library for help you deal with SharedPreferences more easy and reduce most of boilplace code.

Features:

  • Easy to use
  • Reduce a lot of boilerplate code

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes