Skip to content

Commit

Permalink
fix AbdelrahmanBayoumi#30 Prayer Times Settings finished
Browse files Browse the repository at this point in the history
  • Loading branch information
sharafabacery committed Sep 28, 2024
1 parent 1ed38d3 commit b8385ab
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.bayoumi.models.settings.PrayerTimeSettings;
import com.bayoumi.models.settings.Settings;
import com.bayoumi.util.Utility;
import com.bayoumi.util.gui.IntegerSpinner;
import com.bayoumi.util.time.ArabicNumeralDiscrimination;
import com.bayoumi.util.time.Utilities;
import com.jfoenix.controls.JFXCheckBox;
import com.jfoenix.controls.JFXRadioButton;
import javafx.collections.FXCollections;
Expand All @@ -13,10 +16,11 @@
import javafx.scene.control.*;

import java.net.URL;
import java.util.Calendar;
import java.util.ResourceBundle;

public class PrayerCalculationsController implements Initializable {

private ResourceBundle bundle;
private PrayerTimeSettings prayerTimeSettings;
@FXML
private Label calculationMethodText, asrMadhabText, daylightSavingNote;
Expand All @@ -30,14 +34,40 @@ public class PrayerCalculationsController implements Initializable {
public JFXCheckBox summerTiming;
@FXML
private Spinner<Integer> fajrAdjusment, dhuhrAdjusment, sunriseAdjusment, asrAdjusment,maghribAdjusment,ishaAdjusment;
@FXML
public Label prayerAdjutment;
@FXML
public Label fajrText,sunriseText,dhuhrText,asrText,maghribText,ishaText;
@FXML
public Label minPluralityFajr,minPluralitySunrise,minPluralityDhuhr,minPluralityAsr,minPluralityMaghrib,minPluralityIsha;

private void updateBundle(ResourceBundle bundle) {
this.bundle=bundle;
calculationMethodText.setText(Utility.toUTF(bundle.getString("calculationMethod")));
asrMadhabText.setText(Utility.toUTF(bundle.getString("asrMadhab")));
daylightSavingNote.setText(Utility.toUTF(bundle.getString("daylightSavingNote")));
summerTiming.setText(Utility.toUTF(bundle.getString("extraOneHourDayLightSaving")));
standardJuristic.setText(Utility.toUTF(bundle.getString("asrMadhabJumhoor")));
hanafiRadioButton.setText(Utility.toUTF(bundle.getString("hanafi")));
minPluralityFajr.setText(Utility.toUTF(bundle.getString("oneMinute")));
minPluralitySunrise.setText(Utility.toUTF(bundle.getString("oneMinute")));
minPluralityDhuhr.setText(Utility.toUTF(bundle.getString("oneMinute")));
minPluralityAsr.setText(Utility.toUTF(bundle.getString("oneMinute")));
minPluralityMaghrib.setText(Utility.toUTF(bundle.getString("oneMinute")));
minPluralityIsha.setText(Utility.toUTF(bundle.getString("oneMinute")));

prayerAdjutment.setText(Utility.toUTF(bundle.getString("prayerAdjutment")));
fajrText.setText(Utility.toUTF(bundle.getString("fajr")));
sunriseText.setText(Utility.toUTF(bundle.getString("sunrise")));
if (Utilities.isFriday()) {
dhuhrText.setText(Utility.toUTF(bundle.getString("jummah")));
} else {
dhuhrText.setText(Utility.toUTF(bundle.getString("dhuhr")));
}
asrText.setText(Utility.toUTF(bundle.getString("asr")));
maghribText.setText(Utility.toUTF(bundle.getString("maghrib")));
ishaText.setText(Utility.toUTF(bundle.getString("isha")));

methodComboBox.setConverter(PrayerTimeSettings.Method.getStringConverter(Settings.getInstance().getLanguage().equals(Language.Arabic)));
methodComboBox.setValue(prayerTimeSettings.getMethod());
}
Expand All @@ -52,31 +82,95 @@ public void setData() {
standardJuristic.setSelected(true);
}
summerTiming.setSelected(prayerTimeSettings.isSummerTiming());

fajrAdjusment.getValueFactory().setValue(prayerTimeSettings.getFajrAdjusment());
dhuhrAdjusment.getValueFactory().setValue(prayerTimeSettings.getDhuhrAdjusment());
sunriseAdjusment.getValueFactory().setValue(prayerTimeSettings.getSunriseAdjusment());
asrAdjusment.getValueFactory().setValue(prayerTimeSettings.getAsrAdjusment());
maghribAdjusment.getValueFactory().setValue(prayerTimeSettings.getMaghribAdjusment());
ishaAdjusment.getValueFactory().setValue(prayerTimeSettings.getIshaAdjusment());

updateBundle(LanguageBundle.getInstance().getResourceBundle());
}

@Override
public void initialize(URL location, ResourceBundle resources) {
methodComboBox.setItems(FXCollections.observableArrayList(PrayerTimeSettings.Method.getListOfMethods()));
LanguageBundle.getInstance().addObserver((o, arg) -> updateBundle(LanguageBundle.getInstance().getResourceBundle()));

fajrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
IntegerSpinner.init(fajrAdjusment);
IntegerSpinner.init(sunriseAdjusment);
IntegerSpinner.init(dhuhrAdjusment);
IntegerSpinner.init(asrAdjusment);
IntegerSpinner.init(maghribAdjusment);
IntegerSpinner.init(ishaAdjusment);

fajrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
fajrAdjusment.editableProperty().setValue(false);
fajrAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralityFajr.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setFajrAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

});


dhuhrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
dhuhrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
dhuhrAdjusment.editableProperty().setValue(false);
dhuhrAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralityDhuhr.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setDhuhrAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

sunriseAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
});

sunriseAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
sunriseAdjusment.editableProperty().setValue(false);
sunriseAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralitySunrise.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setSunriseAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

});

asrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
asrAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
asrAdjusment.editableProperty().setValue(false);
asrAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralityAsr.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setAsrAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

maghribAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
});

maghribAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
maghribAdjusment.editableProperty().setValue(false);
maghribAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralityMaghrib.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setMaghribAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

});

ishaAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 1));
ishaAdjusment.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(-10, 10, 0));
ishaAdjusment.editableProperty().setValue(false);
ishaAdjusment.valueProperty().addListener((observable, oldValue, newValue) ->{
minPluralityIsha.setText(ArabicNumeralDiscrimination.minutesArabicPlurality(bundle,newValue));
if(!newValue.equals(oldValue)){
prayerTimeSettings.setIshaAdjusment(newValue);
prayerTimeSettings.handleNotifyObservers();
}

});

}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class AzkarSettingsController implements Initializable, SettingsInterface
@FXML
private Label minPlurality, hourPlurality, choosePeriod, zakrAppearEvery, theSoundAndLocationOfTheAlertForAzkar,
morningAndNightAzkarTitle, reminderOfMorningAzkarLabel, afterFajrPrayerLabel, reminderOfNightAzkarLabel,
afterAsrPrayerLabel, minuteLabelForMorningAzkar, minuteLabelForNightAzkar,secondPlurality;
afterAsrPrayerLabel, minuteLabelForMorningAzkar, minuteLabelForNightAzkar,secondPlurality,zakrDurationEvery;


public void updateBundle(ResourceBundle bundle) {
Expand All @@ -94,6 +94,7 @@ public void updateBundle(ResourceBundle bundle) {
lowFrequency.setText(Utility.toUTF(bundle.getString("azkar.period.low")));
rearFrequency.setText(Utility.toUTF(bundle.getString("azkar.period.rear")));
zakrAppearEvery.setText(Utility.toUTF(bundle.getString("settings.azkar.zakrAppearEvery")) + ":");
zakrDurationEvery.setText(Utility.toUTF(bundle.getString("settings.azkar.zakrDurationEvery")) + ":");
stopAzkar.setText(Utility.toUTF(bundle.getString("settings.azkar.stopTheAutomaticAppearanceOfAzkar")));
goToAzkarDBButton.setText(Utility.toUTF(bundle.getString("settings.azkar.azkarDatabase")));
showZekrButton.setText(Utility.toUTF(bundle.getString("settings.azkar.showZekr")));
Expand Down
8 changes: 8 additions & 0 deletions Azkar/src/main/java/com/bayoumi/util/time/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public static boolean isFriday(Date date) {
return cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
}

public static boolean isFriday() {
Calendar cal = Calendar.getInstance();
cal.setTime(
new Date()
);
return cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY;
}

public static String findDifference(Date d1, Date d2) {
try {
// Calculate time difference
Expand Down
2 changes: 2 additions & 0 deletions Azkar/src/main/resources/bundles/language_ar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ extraOneHourDayLightSaving=زيادة (+1 ساعة) على أي حال
asrMadhabJumhoor=شافعي، مالكي، حنبلي
hanafi=حنفي
autoSelectionError=خطأ في التحديد التلقائي للموقع.. برجاء المحاولة مرة أخرى!
prayerAdjutment=تعديل ميعاد ميقات الصلاه (بالدقيقه):
autoSelection=اختيار تلقائي
# === other settings ===
language=اللغة
Expand Down Expand Up @@ -129,6 +130,7 @@ settings.azkar.reminderOfNightAzkar=تذكير بأذكار المساء
settings.azkar.afterFajrPrayer=(بعد صلاة الفجر)
settings.azkar.afterAsrPrayer=(بعد صلاة العصر)
settings.azkar.changeFontSize=تغيير حجم الخط
settings.azkar.zakrDurationEvery=وقت ظهور الذكر ب(الثانيه)
# === Absolute Azkar ===
absoluteAzkar=الأذكار المطلقة
retrieveDefaultAzkar=استرجاع الأذكار الافتراضية
Expand Down
2 changes: 2 additions & 0 deletions Azkar/src/main/resources/bundles/language_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ daylightSavingNote=Daylight saving time is automatically observed by country
extraOneHourDayLightSaving=Extra (+1 hour) anyway
asrMadhabJumhoor=Shafi'i, Maliki, Hanbali
hanafi=Hanafi
prayerAdjutment=Adjust the prayer time (in minutes):
autoSelectionError=Error in automatic location selection.. Please try again!
# === other settings ===
language=Language
Expand Down Expand Up @@ -130,6 +131,7 @@ settings.azkar.reminderOfNightAzkar=Reminder of Night Azkar
settings.azkar.afterFajrPrayer=(After Fajr Prayer)
settings.azkar.afterAsrPrayer=(After Asr Prayer)
settings.azkar.changeFontSize=Change font size
settings.azkar.zakrDurationEvery:Time of appearance of the zekr (second)
# === Absolute Azkar ===
absoluteAzkar=Absolute Azkar
retrieveDefaultAzkar=Retrieve default Azkar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,19 @@
</Separator>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0">
<children>
<HBox alignment="TOP_CENTER" spacing="20.0">
<children>
<Label fx:id="prayerAdjutment" text="تعديل ميعاد ميقات الصلاه (بالدقيقه):" textAlignment="JUSTIFY" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
</styleClass>
</Label>
</children>
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery" text="تعديل ميعاد ميقات صلاه الفجر ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="fajrText" text=" صلاة الفجر:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -95,7 +105,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="fajrAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralityFajr" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -107,7 +117,7 @@
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery4" text="تعديل ميعاد ميقات الشروق ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="sunriseText" text=" الشروق:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -117,7 +127,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="sunriseAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality4" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralitySunrise" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -129,7 +139,7 @@
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery1" text="تعديل ميعاد ميقات صلاه الظهر ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="dhuhrText" text="صلاة الظهر:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -139,7 +149,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="dhuhrAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality1" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralityDhuhr" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -151,7 +161,7 @@
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery2" text="تعديل ميعاد ميقات صلاه العصر ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="asrText" text="صلاة العصر:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -161,7 +171,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="asrAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality2" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralityAsr" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -173,7 +183,7 @@
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery3" text="تعديل ميعاد ميقات صلاه المغرب ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="maghribText" text=" صلاة المغرب:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -183,7 +193,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="maghribAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality3" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralityMaghrib" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -195,7 +205,7 @@
</HBox>
<HBox alignment="CENTER" spacing="20.0">
<children>
<Label fx:id="zakrDurationEvery5" text="تعديل ميعاد ميقات صلاه العشاء ب(الدقيقه):" textAlignment="CENTER" wrapText="true">
<Label fx:id="ishaText" text="صلاة العشاء:" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand All @@ -205,7 +215,7 @@
<HBox alignment="CENTER" spacing="5.0">
<children>
<Spinner fx:id="ishaAdjusment" focusTraversable="false" prefWidth="90.0" />
<Label fx:id="secondPlurality5" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<Label fx:id="minPluralityIsha" text="الدقيقه" textAlignment="CENTER" wrapText="true">
<styleClass>
<String fx:value="_18" />
<String fx:value="font-text-bold" />
Expand Down

0 comments on commit b8385ab

Please sign in to comment.