PersianDatePicker


Source link: https://github.com/alibehzadian/PersianDatePicker

PersianDatePicker

An Android DatePicker for Persian Calendar

Usage:

  • Add as an Android Library Project:
  • Add this line to root layout element:
xmlns:persianDatePicker="http://schemas.android.com/apk/res-auto"
  • Add PersianDatePicker view:
<ir.smartlab.persindatepicker.PersianDatePicker

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>
  • Add Source and other required things to your Project:
  • Copy all sources to your source tree.
  • Copy /res/layout/sl_persian_date_picker.xml to your /res/layout folder.
  • Add this to your /res/values/attrs.xml:
<declare-styleable name="PersianDatePicker">

<attr name="minYear" format="integer" />

<attr name="maxYear" format="integer" />

<attr name="selectedYear" format="integer" />

<attr name="selectedMonth" format="integer" />

<attr name="selectedDay" format="integer" />

<attr name="displayMonthNames" format="boolean" />

<attr name="yearRange" format="integer" />
  </declare-styleable>

Params:

  • minYear: Min value for year in the picker. Default is current Hijri Shamsi (Jalali) year - yearRange(default is 10).
  • maxYear: Max value for year in the picker. Default is current Hijri Shamsi (Jalali) year + yearRange(default is 10).
  • yearRange: If you set a selected year, available years in picker will be from (selectedYear - yearRange) to (selectedYear + yearRange). Default value is 10.
  • selectedYear: Selected year that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) year.
  • selectedMonth: Selected month that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) year's month.
  • selectedDay: Selected day of month that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) month's day.
  • displayMonthNames: If set to true, months names are displayed, otherwise their number will be shown.
  • displayDescription: If set to true, a TextView below datepicker will show the selected date with more details.

Examples:

  • Display a PersianDatePicker with current Hijri Shamsi (Jalali) values:
<ir.smartlab.persindatepicker.PersianDatePicker

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>
  • Display a PersianDatePicker with selected Hijri Shamsi (Jalali) date:
    <ir.smartlab.persindatepicker.PersianDatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" app:selectedYear="1390" app:selectedMonth="5" app:selectedDay="15" />
  • Display a PersianDatePicker that shows month names:
<ir.smartlab.persindatepicker.PersianDatePicker

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:displayMonthNames="true" />
  • Display a PersianDatePicker that shows years between 1350 and 1450:
<ir.smartlab.persindatepicker.PersianDatePicker

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:maxYear="1450"

app:minYear="1350" />

Java Examples:

  • You can set a java.util.Date object to PersianDatePpicker in java code:
persianDatePicker.setDisplayDate(new Date());
  • you can also set a ir.smartlab.persindatepicker.util.PersianCalendar object:
PersianCalendar persianCalendar = new PersianCalendar();
 persianCalendar.setPersianDate(1393, 6, 28);
 persianDatePicker.setDisplayPersianDate(persianCalendar);
  • You can get displayed date in java.util.Date or ir.smartlab.persindatepicker.util.PersianCalendar:
Date d = persianDatePicker.getDisplayDate();
 // OR PersianCalendar pCal = persianDatePicker.getDisplayPersianDate();

Leap Year:

In Hijri Shamsi some years are leap year, so the last month of year is 30 days (not 29 days). PersianDatePicker take cares of leap years. This means that users will never pick a wrong date.

To Do:

  • Support Persian digits as an option
  • Support typeface settings

Credits:

PersianDatepicker is heavily based on AOSP ( https://source.android.com) and persian-calendar ( https://github.com/mortezaadi/persian-calendar).

Version

1.0

License

Apache License Version 2.0

Resources

Custom EditText for Android to enter credit card numbers.

Provide Funky cuts on image (The Perfect Header for Profile UI)

Library manages lifecycle of Activities and Fragments, their Presenters and ViewStates.

Simple java library for displaying date/time as relative time ago language.

A simple library to make taking screenshots of your apps.

With the Marshmallow release and the new permissions model, taking screenshots of your applications has become just slightly more complicated as you need to deal with permissions on the run.

This library does it all for you regardless of the device you're running it on.

RxJava2 extensions for Android Databindings library.

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