From 940377edd142dadd73e5b740bc55492ed828e1e3 Mon Sep 17 00:00:00 2001 From: Grammatopoulos Apostolos Date: Sat, 2 Feb 2019 03:37:49 +0000 Subject: [PATCH] 12/24h, bigger top button, all day duration --- .idea/caches/build_file_checksums.ser | Bin 541 -> 541 bytes .idea/caches/gradle_models.ser | Bin 32081 -> 32081 bytes app/build.gradle | 4 +- .../com/dinodevs/timelinewidget/widget.java | 89 ++++++++++-------- app/src/main/res/layout/widget_timeline.xml | 4 +- app/src/main/res/values/strings.xml | 4 + 6 files changed, 60 insertions(+), 41 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index f44b41517772b1aca5481b838e0234b3503433d0..17cb62ff7cbc8abb1dde93402797b4ee518fa02a 100644 GIT binary patch delta 35 tcmV+;0Nnqb1f2wsm;|f!X&jN9cMu<>?7Iu|hrFGaz==Zfoeh&C0s1AN5dHuF delta 35 tcmV+;0Nnqb1f2wsm;{zx5c!ducMt|kdTdyK(dpuK>k};10a}wI0s0CN4@m$3 diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index be004ab162369d312bec6b1235c080c123bcef98..1ccbf3c68a0b36c8ba6b7e157a3404c4a1fdb3ef 100644 GIT binary patch delta 6349 zcmb7Idr+L!6~EudGqB+u$U;~`fP}EH%lj#?u!KNhmsfKIo%C5yVc>bIUQ`X2BtDzMY_i`@57(GEL|d!tL)w`uVY)Y$1`G8 z2#2#YNO2@9VJT8X%;|($Xhz*67hqM;&n1zNe(Tne0Tgeb z!Za{FmI$t{5O_hG;aBT@?SXJor5It)y$xkw&Q&*~3!>~^V}s3Y-6lERHpNXWSVouY z>iJl^cO4Dx`~@)QB{PRoZYGPvw%zKHF!-oe9PG_v%*c5kQE;~a5svwG$; zY9$FYXoHr1tNW@oS%3Ah<9}koRGdZqA+T>Xr0bd!u9}rd4Mo%{&=thO&vh}eR}nzI zzUhW%({)uV5Z${)(mTpmLn5_)ftvhSK@Iu&J2?UhN^+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XCSMMl$*8TIl^x zQ^XLM+HZ~|CXUg;b6a$VCF=M)1wMJSi%u4x$Gzf*3R*j!)`<&sJ#2f0Mv`UboLdDo zo!v@t-^9B#Jkoi9-*+3#M&v6vXXg~PjrSIq;?=BtK zvyj@oMRM9yw~m$BK;5OGkiO8Bvr+`^098zrr_nRaU-+X0#g38vxI;WDcznnz1lu`g z3-4iFPh01L9)QXU66_(-9@(lT@xtOGt0oyLDp9=&hg|&BVfA}(?Oo9no1?+^ zI^n*x4QWKlF%fOuef>*S(U+1kK1k}`IyE0;_T%`q?N6Z`dl|O&7Equ~_1@9_#mRdc^B01>;B2OkCMwy zmx+!xtXqb`2<@@3V=x;D4Re!D4;suNw<+9dW^1=Q+zy|eTV#vq%i|kX(Que-KP(g+ z6Sdi8ce*!wA30ZVh9m0>EbIhEiKb`V)-m_6=r6B)9++a1(z{?Tec?=i+zmRkxka>D z1%VBEwaj8ZWpBk=7uvwbH*8(AI5|U1S?RxwF;|F9bBy02ItX&I@@19>*3Z-EFWEuS z(AJJa112`G?($!ap*B2Q$=7+(L2p=)|=& ztX1@C+v;!&c&6`^J$7yfnn~rJ->u(^67+qUK2P$;$RYv$fbR8pIFU+cG4xHGzGg~j z<6l+#9sZE8uto=?qc7-`D!D+w3(b26J1A-rS=~nlB!qGg^FA2gU93 al!aW3m2hIyCm1~ti(bK#a0_J*1^y2f%z6O; diff --git a/app/build.gradle b/app/build.gradle index 58a416c..81dfe77 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { targetSdkVersion 27 multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - versionName '1.0.1' - versionCode 20190128 + versionName '1.0.2' + versionCode 20190202 } buildTypes { release { diff --git a/app/src/main/java/com/dinodevs/timelinewidget/widget.java b/app/src/main/java/com/dinodevs/timelinewidget/widget.java index d30fd36..bea2c74 100644 --- a/app/src/main/java/com/dinodevs/timelinewidget/widget.java +++ b/app/src/main/java/com/dinodevs/timelinewidget/widget.java @@ -51,6 +51,16 @@ public class widget extends AbstractPlugin { private long next_event; private String calendarEvents; + private String header_pattern; + private String time_pattern; + + // Constants + private static final String HEADER_PATTERN_12H = "hh:mm a\nEEEE, d MMMM"; + private static final String HEADER_PATTERN_24H = "HH:mm\nEEEE, d MMMM"; + private static final String ELEMENT_PATTERN = "EEEE, d MMMM"; + private static final String TIME_PATTERN_12H = "hh:mm a"; + private static final String TIME_PATTERN_24H = "HH:mm"; + private static final String DATE_PATTERN = "dd/MM/yyyy"; // Set up the widget's layout @@ -128,13 +138,29 @@ public void onClick(View v) { } private void refresh_time(){ + is24h(); TextView time = this.mView.findViewById(R.id.time); - time.setText( dateToString(Calendar.getInstance(),"hh:mm a\nEEEE, d MMMM") ); + time.setText( dateToString(Calendar.getInstance(),header_pattern) ); + } + + boolean is24h; + private void is24h(){ + is24h = Settings.System.getString(mContext.getContentResolver(), "time_12_24").equals("24"); + Log.d(TAG, "Timeline init is24h: " + is24h); + + if (is24h) { + header_pattern = HEADER_PATTERN_24H; + time_pattern = TIME_PATTERN_24H; + } else { + header_pattern = HEADER_PATTERN_12H; + time_pattern = TIME_PATTERN_12H; + } } private void loadCalendarEvents() { eventsList = new ArrayList<>(); next_event = 0; + is24h(); // Load data calendarEvents = Settings.System.getString(mContext.getContentResolver(), "CustomCalendarData"); @@ -179,14 +205,14 @@ private void loadCalendarEvents() { if( next_event==0 ) // Hence this is the next event next_event = calendar.getTimeInMillis(); - start = dateToString( calendar,"hh:mm a" ); + start = dateToString( calendar,time_pattern ); // Insert day separator, or not :P - if( !current_loop_date.equals(dateToString( calendar,"EEEE, d MMMM" )) ){ - current_loop_date = dateToString(calendar, "EEEE, d MMMM"); + if( !current_loop_date.equals(dateToString( calendar,ELEMENT_PATTERN )) ){ + current_loop_date = dateToString(calendar, ELEMENT_PATTERN); // Is it today? - if(current_loop_date.equals(dateToString(Calendar.getInstance(), "EEEE, d MMMM"))){ - current_loop_date = "Today"; + if(current_loop_date.equals(dateToString(Calendar.getInstance(), ELEMENT_PATTERN))){ + current_loop_date = mContext.getResources().getString(R.string.today); } HashMap date_elem = new HashMap<>(); date_elem.put("title", ""); @@ -198,13 +224,24 @@ private void loadCalendarEvents() { // Event has no date, go to next continue; } + + // No end if(!data.getString(3).equals("") && !data.getString(3).equals("null")) { calendar.setTimeInMillis(Long.parseLong(data.getString(3))); - end = " - "+ dateToString(calendar, "hh:mm a"); + end = " - "+ dateToString(calendar, time_pattern); } + + // All day events + if((start.startsWith("00") || start.startsWith("12")) && data.getString(3).equals("null")) { + start = mContext.getResources().getString(R.string.all_day); + end = ""; + } + + // Location if(!data.getString(4).equals("") && !data.getString(4).equals("null")) { location = "\n@ "+data.getString(4); } + event.put("subtitle", start+ end + location ); event.put("dot", mContext.getResources().getString(R.string.bull) ); // adding events to events list @@ -214,7 +251,7 @@ private void loadCalendarEvents() { } catch (JSONException e) { //default HashMap event = new HashMap<>(); - event.put("title", "No events"); + event.put("title", mContext.getResources().getString(R.string.no_events)); //event.put("description", "-"); //event.put("start", "-"); //event.put("end", "-"); @@ -227,8 +264,8 @@ private void loadCalendarEvents() { if(eventsList.isEmpty()){ HashMap elem = new HashMap<>(); - elem.put("title", "\nNo events"); - elem.put("subtitle", "Make sure you use Amazmod on your phone and that your stock calendar has events."); + elem.put("title", "\n"+mContext.getResources().getString(R.string.no_events)); + elem.put("subtitle", mContext.getResources().getString(R.string.no_events_description)); elem.put("dot", "" ); eventsList.add(elem); } @@ -248,7 +285,7 @@ private void toast (String message) { // Convert a date to format private String dateToString (Calendar date) { - return (new SimpleDateFormat("dd/MM/yyyy", Locale.US)).format(date.getTime()); + return (new SimpleDateFormat(DATE_PATTERN, Locale.US)).format(date.getTime()); } private String dateToString (Calendar date, String pattern) { return (new SimpleDateFormat(pattern, Locale.US)).format(date.getTime()); @@ -263,14 +300,12 @@ private String dateToString (Calendar date, String pattern) { private void onShow() { // If view loaded (and was inactive) if (this.mView != null && !this.isActive) { - refresh_time(); - - // If an event expired OR new events - if ( next_event+10*1000 < Calendar.getInstance().getTimeInMillis() || !calendarEvents.equals(Settings.System.getString(mContext.getContentResolver(), "CustomCalendarData")) ) { + // If an event expired OR new events OR changed 12/24h + if ( next_event+10*1000 < Calendar.getInstance().getTimeInMillis() || !calendarEvents.equals(Settings.System.getString(mContext.getContentResolver(), "CustomCalendarData")) || is24h != Settings.System.getString(mContext.getContentResolver(), "time_12_24").equals("24") ) { // Refresh timeline loadCalendarEvents(); } - + refresh_time(); } // Save state @@ -376,24 +411,4 @@ public void onDestroy() { } -} - -/* -abstract class doubleListLayoutAdapter extends SimpleAdapter { - private ArrayList types; - - private doubleListLayoutAdapter(Context context, List> data, int resource, String[] from, int[] to, ArrayList types) { - super(context, data, resource, from, to); - } - - @Override - public int getViewTypeCount() { - return 2; - } - - @Override - public int getItemViewType(int position) { - return getItem(position).; - } -} -*/ +} \ No newline at end of file diff --git a/app/src/main/res/layout/widget_timeline.xml b/app/src/main/res/layout/widget_timeline.xml index e0dd12a..ebf9a97 100644 --- a/app/src/main/res/layout/widget_timeline.xml +++ b/app/src/main/res/layout/widget_timeline.xml @@ -23,8 +23,8 @@ + Today + All Day + No events + Make sure you use Amazmod on your phone and that your stock calendar has events.