@@ -45,17 +45,29 @@ protected void onCreate(Bundle savedInstanceState) {
45
45
}
46
46
47
47
private void setPreferenceView () {
48
+ Preference prefLicense = (Preference ) findPreference ("prefLicense" );
49
+ Preference prefVersion = (Preference ) findPreference ("prefVersion" );
48
50
prefEnableNotifications = (CheckBoxPreference ) findPreference ("prefEnableNotifications" );
49
51
prefSoundNotification = (Preference ) findPreference ("prefSoundNotification" );
50
- initPrefSoundNotification (prefSoundNotification );
51
52
prefHoursNotification = (ListPreference ) findPreference ("prefHoursNotification" );
53
+
54
+ initPrefEnableNotifications (appPreferences .getEnableNotifications ());
55
+ initPrefSoundNotification (prefSoundNotification );
52
56
initPrefHoursNotification (prefHoursNotification );
53
- Preference prefLicense = (Preference ) findPreference ("prefLicense" );
54
57
initPrefLicense (prefLicense );
55
- Preference prefVersion = (Preference ) findPreference ("prefVersion" );
56
58
initPrefVersion (prefVersion );
57
59
}
58
60
61
+ private void initPrefEnableNotifications (Boolean enable ) {
62
+ if (enable ) {
63
+ prefSoundNotification .setEnabled (true );
64
+ prefHoursNotification .setEnabled (true );
65
+ } else {
66
+ prefSoundNotification .setEnabled (false );
67
+ prefHoursNotification .setEnabled (false );
68
+ }
69
+ }
70
+
59
71
private void initPrefSoundNotification (Preference preference ) {
60
72
preference .setSummary (RingtoneManager .getRingtone (this , appPreferences .getSoundNotification ()).getTitle (this ));
61
73
preference .setOnPreferenceClickListener (new android .preference .Preference .OnPreferenceClickListener () {
@@ -76,7 +88,6 @@ public boolean onPreferenceClick(android.preference.Preference preference) {
76
88
private void initPrefHoursNotification (ListPreference listPreference ) {
77
89
listPreference .setEntries (getResources ().getStringArray (R .array .notification_hours ));
78
90
listPreference .setEntryValues (getResources ().getStringArray (R .array .notification_hours_values ));
79
-
80
91
listPreference .setSummary (String .format (getResources ().getString (R .string .settings_interval_description ), appPreferences .getHoursNotification ()));
81
92
}
82
93
@@ -113,13 +124,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
113
124
Preference preference = (Preference ) findPreference (key );
114
125
115
126
if (preference == prefEnableNotifications ) {
116
- if (prefEnableNotifications .isChecked ()) {
117
- prefSoundNotification .setEnabled (true );
118
- prefHoursNotification .setEnabled (true );
119
- } else {
120
- prefSoundNotification .setEnabled (false );
121
- prefHoursNotification .setEnabled (false );
122
- }
127
+ initPrefEnableNotifications (prefEnableNotifications .isChecked ());
123
128
} else if (preference == prefSoundNotification ) {
124
129
preference .setSummary (RingtoneManager .getRingtone (this , appPreferences .getSoundNotification ()).getTitle (this ));
125
130
} else if (preference == prefHoursNotification ) {
0 commit comments