eltohamy / material-hijri-calendarview

A Material design back port of Android's Hijri CalendarView
https://github.com/eltohamy/material-hijri-calendarview
Apache License 2.0
60 stars 12 forks source link

Adding a way to fix date by adding or decreasing days from the date #13

Closed iballan closed 6 years ago

iballan commented 6 years ago

In some countries the date is calculated depending on the moon position. In this cases, user may have to fix it by specifying a days to be added to the date to fix the calendar: +2 +1 0 -1 -2

eltohamy commented 6 years ago

Thanks for your comment, you can pull this change now. you can set it using mcv_calendarDiff app:mcv_calendarDiff="2" app:mcv_calendarDiff="1" app:mcv_calendarDiff="0" (default value) app:mcv_calendarDiff="-1" app:mcv_calendarDiff="-2"

iballan commented 6 years ago

I actually tried to modify the code to have this feature but could not manage to get it working proporely. Will it be added before Ramadan ?

eltohamy commented 6 years ago

Yes, In the next few days.

iballan commented 6 years ago

Great ! Barakallahu fik

iballan commented 6 years ago

Any news about this issue ?

saqibrazzaq commented 6 years ago

Was this feature added? I also want to adjust dates +- upto 3.

iballan commented 6 years ago

@eltohamy Any news about this issue ?

eltohamy commented 6 years ago

Thanks for your comment,the issue is fixed.You can pull this change now. you can set it setting mcv_calendarDiff attribute in layout xml. app:mcv_calendarDiff="2" app:mcv_calendarDiff="1" app:mcv_calendarDiff="0" (default value) app:mcv_calendarDiff="-1" app:mcv_calendarDiff="-2"

iballan commented 6 years ago

Great 👍 Jazakallahu Khair It can be modified programmatically as well right ?

AmineMessabhia commented 6 years ago

Hello, i actually want to know this as well, can we modify it programatically?

@eltohamy , can you provide an answer please?

AmineMessabhia commented 6 years ago

hey @iballan, i was messing with the code, i created a setter for calendarDiff, but didn't work, i tried even to comment out line 247 in MaterialHijriCalendarView class, maybe that value would override my setter, but also nothing, i got an idea to actually create 5 layouts, each with calendarView with different value for "app:mcv_calendarDiff", but then, i went back to line 247, and i saw the 0 as default value like, if the value isn't set in xml, it would be 0, in there, i gave it "context.getSharedPreferences....." and in my settings i save the offset of hijri date in SharedPreferences, now it is working like a charm.

Hope my comment helps you out.

ibadurrahmantalha commented 4 years ago

can we find app:mcv_calendarDiff value for different location programatically? for example in Pakistan, India and Bangladash it will be -1. and for some places it will be 0. How can we find the app:mcv_calendarDiff value programatically?