Last change for datetime range #370

This commit is contained in:
stom79 2018-12-16 16:59:40 +01:00
parent a37bed8009
commit fd0f02b3a3
2 changed files with 7 additions and 7 deletions

View File

@ -1885,6 +1885,7 @@ public class Helper {
return true; return true;
String dateIni = sharedpreferences.getString(Helper.SET_TIME_FROM, "07:00"); String dateIni = sharedpreferences.getString(Helper.SET_TIME_FROM, "07:00");
String dateEnd = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00"); String dateEnd = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00");
int notification = sharedpreferences.getInt(Helper.SET_NOTIFICATION_ACTION, Helper.ACTION_ACTIVE);
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY); int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE); int minute = now.get(Calendar.MINUTE);
@ -1903,7 +1904,12 @@ public class Helper {
Date dateIniD = formatter.parse(dateIni); Date dateIniD = formatter.parse(dateIni);
Date dateEndD = formatter.parse(dateEnd); Date dateEndD = formatter.parse(dateEnd);
Date currentDateD = formatter.parse(currentDate); Date currentDateD = formatter.parse(currentDate);
return currentDateD.before(dateEndD)&&currentDateD.after(dateIniD); boolean canNotify = false;
if( currentDateD.before(dateEndD) && currentDateD.after(dateIniD) && notification == Helper.ACTION_ACTIVE)
canNotify = true;
else if ( currentDateD.after(dateEndD) && currentDateD.before(dateIniD) && notification == Helper.ACTION_SILENT )
canNotify = true;
return canNotify;
} catch (java.text.ParseException e) { } catch (java.text.ParseException e) {
return true; return true;
} }

View File

@ -145,22 +145,16 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<Button <Button
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
android:id="@+id/settings_time_from" android:id="@+id/settings_time_from"
style="?attr/borderlessColored" style="?attr/borderlessColored"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/settings_time_to" android:text="@string/settings_time_to"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<Button <Button
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
style="?attr/borderlessColored" style="?attr/borderlessColored"
android:id="@+id/settings_time_to" android:id="@+id/settings_time_to"