Skip to content

Commit 653a9cd

Browse files
committed
Prepare for 1.5.0 release, added many translation, fixed bugs.
Added homepage choice.
1 parent fb792ff commit 653a9cd

30 files changed

Lines changed: 20334 additions & 155 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
2424

2525
android {
2626
compileSdkVersion 27
27-
buildToolsVersion '27.0.1'
27+
buildToolsVersion '27.0.2'
2828

2929
defaultConfig {
3030
applicationId "com.djonique.birdays"
@@ -58,7 +58,7 @@ repositories {
5858
maven { url 'https://maven.fabric.io/public' }
5959
}
6060

61-
def androidSupportVersion = '27.0.1'
61+
def androidSupportVersion = '27.0.2'
6262
def firebaseVersion = '11.4.2'
6363
def butterKnifeVersion = '8.8.1'
6464

app/src/main/java/com/djonique/birdays/activities/HelpActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.djonique.birdays.activities;
1818

19+
import android.content.ActivityNotFoundException;
1920
import android.content.DialogInterface;
2021
import android.content.Intent;
2122
import android.content.SharedPreferences;
@@ -48,6 +49,7 @@ public class HelpActivity extends AppCompatActivity {
4849
private static final String SAMSUNG = "samsung";
4950
private static final String XIAOMI = "xiaomi";
5051
private static final String ALERT_SHOWED = "ALERT_SHOWED";
52+
private static final String ACTIVITY_NOT_FOUND_EXCEPTION = "ActivityNotFoundException";
5153

5254
@BindView(R.id.button_help_whitelist)
5355
AppCompatButton btnOpenWhitelist;
@@ -138,7 +140,11 @@ public void onClick(DialogInterface dialog, int which) {
138140
@OnClick(R.id.button_help_whitelist)
139141
void openBatteryOptimization() {
140142
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
141-
startActivity(Intent.createChooser(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), null));
143+
try {
144+
startActivity(Intent.createChooser(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), null));
145+
} catch (ActivityNotFoundException e) {
146+
Toast.makeText(this, ACTIVITY_NOT_FOUND_EXCEPTION, Toast.LENGTH_LONG).show();
147+
}
142148
} else {
143149
Toast.makeText(this, R.string.help_whitelist_error, Toast.LENGTH_LONG).show();
144150
}

app/src/main/java/com/djonique/birdays/activities/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public boolean onQueryTextChange(String newText) {
132132
Ad.showBannerAd(container, adView, fab);
133133
}
134134

135-
// App starts from AllFragment
136-
viewPager.setCurrentItem(1);
135+
// Start page
136+
viewPager.setCurrentItem(Integer.parseInt(preferences.getString(Constants.START_PAGE, "1")));
137137
}
138138

139139
@Override

app/src/main/java/com/djonique/birdays/activities/SettingsActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ public boolean onPreferenceClick(Preference preference) {
310310
}
311311
});
312312

313+
/*
314+
* Start page
315+
*/
316+
findPreference(getString(R.string.start_page_key)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
317+
@Override
318+
public boolean onPreferenceChange(Preference preference, Object newValue) {
319+
((ListPreference) preference).setValue(newValue.toString());
320+
preference.setSummary(((ListPreference) preference).getEntry());
321+
return true;
322+
}
323+
});
324+
313325
/*
314326
* Displayed age
315327
*/

app/src/main/java/com/djonique/birdays/alarm/AlarmReceiver.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@
3838

3939
public class AlarmReceiver extends BroadcastReceiver {
4040

41-
// TODO: 30.11.2017 FireUriExposedException
42-
4341
private static final String CHANNEL_ID = "com.djonique.birdays";
4442

4543
private NotificationManager manager;
44+
private SharedPreferences preferences;
4645

4746
@Override
4847
public void onReceive(Context context, Intent intent) {
4948

5049
manager = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
5150

51+
preferences = PreferenceManager.getDefaultSharedPreferences(context);
52+
5253
// Extras from intent
5354
String name = intent.getStringExtra(Constants.NAME);
5455
String when = intent.getStringExtra(Constants.WHEN);
@@ -62,7 +63,7 @@ public void onReceive(Context context, Intent intent) {
6263

6364
NotificationCompat.Builder builder = buildNotification(context, name, when);
6465

65-
setDefaultsAndRingtone(builder, getRingtoneUri(context));
66+
setDefaultsAndRingtone(builder);
6667

6768
builder.setContentIntent(pendingIntent);
6869

@@ -121,15 +122,17 @@ private NotificationCompat.Builder buildNotification(Context context, String tit
121122
/**
122123
* Avoids FileUriExposedException on Android API 24+
123124
*/
124-
private void setDefaultsAndRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
125+
private void setDefaultsAndRingtone(NotificationCompat.Builder builder) {
126+
String ringtone = preferences.getString(Constants.RINGTONE_KEY,
127+
Settings.System.DEFAULT_NOTIFICATION_URI.toString());
125128
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
126129
try {
127-
setRingtone(builder, ringtoneUri);
130+
setRingtone(builder, Uri.parse(ringtone));
128131
} catch (Exception e) {
129132
builder.setDefaults(NotificationCompat.DEFAULT_ALL);
130133
}
131134
} else {
132-
setRingtone(builder, ringtoneUri);
135+
setRingtone(builder, Uri.parse(ringtone));
133136
}
134137
}
135138

@@ -140,14 +143,4 @@ private void setRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
140143
builder.setDefaults(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_LIGHTS);
141144
builder.setSound(ringtoneUri);
142145
}
143-
144-
/**
145-
* Returns URI for picked in the settings notification tone
146-
*/
147-
private Uri getRingtoneUri(Context context) {
148-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
149-
String ringtone = preferences.getString(Constants.RINGTONE_KEY,
150-
Settings.System.DEFAULT_NOTIFICATION_URI.toString());
151-
return Uri.parse(ringtone);
152-
}
153146
}

app/src/main/java/com/djonique/birdays/backup/ExportHelper.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818

1919
import android.annotation.SuppressLint;
2020
import android.app.Activity;
21-
import android.content.Context;
2221
import android.content.DialogInterface;
2322
import android.os.AsyncTask;
2423
import android.os.Environment;
2524
import android.support.v7.app.AlertDialog;
2625
import android.util.Xml;
27-
import android.widget.Toast;
2826

2927
import com.djonique.birdays.R;
3028
import com.djonique.birdays.database.DbHelper;
@@ -44,8 +42,6 @@
4442

4543
public class ExportHelper {
4644

47-
// TODO: 30.11.2017 Toast in main thread
48-
4945
// XML constants
5046
private static final String RECORDS = "records";
5147
private static final String PERSON = "person";
@@ -63,12 +59,12 @@ public class ExportHelper {
6359
private static final String IO_EXCEPTION = "IOException";
6460
private static final String FILE_NOT_FOUND_EXCEPTION = "FileNotFoundException";
6561

66-
private Context context;
62+
private Activity activity;
6763
private File folder;
6864
private boolean storageAvailable = true;
6965

70-
public ExportHelper(Context context) {
71-
this.context = context;
66+
public ExportHelper(Activity activity) {
67+
this.activity = activity;
7268
}
7369

7470
public void exportRecords() {
@@ -121,36 +117,41 @@ private String writeXml(List<Person> persons) {
121117
xmlSerializer.endDocument();
122118
xmlSerializer.flush();
123119
} catch (IllegalArgumentException e) {
124-
Toast.makeText(context, ILLEGAL_ARGUMENT_EXCEPTION, Toast.LENGTH_LONG).show();
120+
showAlertDialog(activity, ILLEGAL_ARGUMENT_EXCEPTION);
125121
} catch (IllegalStateException e) {
126-
Toast.makeText(context, ILLEGAL_STATE_EXCEPTION, Toast.LENGTH_LONG).show();
122+
showAlertDialog(activity, ILLEGAL_STATE_EXCEPTION);
127123
} catch (IOException e) {
128-
Toast.makeText(context, IO_EXCEPTION, Toast.LENGTH_LONG).show();
124+
showAlertDialog(activity, IO_EXCEPTION);
129125
}
130126
return stringWriter.toString();
131127
}
132128

133-
private void showAlertDialog(Context context, String text) {
134-
AlertDialog.Builder builder = new AlertDialog.Builder(context);
135-
builder.setMessage(text);
136-
builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
129+
private void showAlertDialog(final Activity activity, final String text) {
130+
activity.runOnUiThread(new Runnable() {
137131
@Override
138-
public void onClick(DialogInterface dialog, int which) {
139-
dialog.cancel();
132+
public void run() {
133+
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
134+
builder.setMessage(text);
135+
builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
136+
@Override
137+
public void onClick(DialogInterface dialog, int which) {
138+
dialog.cancel();
139+
}
140+
});
141+
builder.show();
140142
}
141143
});
142-
builder.show();
143144
}
144145

145146
@SuppressLint("StaticFieldLeak")
146147
private class ExportAsyncTask extends AsyncTask<Void, Void, Void> {
147148

148-
ProgressDialogHelper progressDialogHelper = new ProgressDialogHelper(context);
149+
ProgressDialogHelper progressDialogHelper = new ProgressDialogHelper(activity);
149150

150151
@Override
151152
protected void onPreExecute() {
152153
super.onPreExecute();
153-
progressDialogHelper.startProgressDialog(context.getString(R.string.exporting_records));
154+
progressDialogHelper.startProgressDialog(activity.getString(R.string.exporting_records));
154155
}
155156

156157
@SuppressWarnings("ResultOfMethodCallIgnored")
@@ -159,29 +160,24 @@ protected Void doInBackground(Void... params) {
159160
File sd = Environment.getExternalStorageDirectory();
160161
if (isExternalStorageWritable()) {
161162
try {
162-
folder = new File(sd.getPath() + File.separator + context.getString(R.string.app_name));
163+
folder = new File(sd.getPath() + File.separator + activity.getString(R.string.app_name));
163164
if (!folder.exists()) {
164165
folder.mkdir();
165166
}
166167
File backupFile = new File(folder + File.separator + getBackupFileName());
167168
backupFile.createNewFile();
168169
FileOutputStream outputStream = new FileOutputStream(backupFile);
169-
List<Person> persons = new DbHelper(context).query().getPersons();
170+
List<Person> persons = new DbHelper(activity).query().getPersons();
170171
outputStream.write(writeXml(persons).getBytes());
171172
outputStream.close();
172173
} catch (FileNotFoundException e) {
173-
Toast.makeText(context, FILE_NOT_FOUND_EXCEPTION, Toast.LENGTH_LONG).show();
174+
showAlertDialog(activity, FILE_NOT_FOUND_EXCEPTION);
174175
} catch (IOException e) {
175-
Toast.makeText(context, IO_EXCEPTION, Toast.LENGTH_LONG).show();
176+
showAlertDialog(activity, IO_EXCEPTION);
176177
}
177178
} else {
178179
storageAvailable = false;
179-
((Activity) context).runOnUiThread(new Runnable() {
180-
@Override
181-
public void run() {
182-
showAlertDialog(context, context.getString(R.string.ext_storage_error));
183-
}
184-
});
180+
showAlertDialog(activity, activity.getString(R.string.ext_storage_error));
185181
}
186182
return null;
187183
}
@@ -191,7 +187,7 @@ protected void onPostExecute(Void aVoid) {
191187
super.onPostExecute(aVoid);
192188
progressDialogHelper.dismissProgressDialog();
193189
if (storageAvailable) {
194-
showAlertDialog(context, context.getString(R.string.backup_finished) + folder);
190+
showAlertDialog(activity, activity.getString(R.string.backup_finished) + folder);
195191
}
196192
}
197193
}

app/src/main/java/com/djonique/birdays/utils/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface Constants {
3838
String ADDITIONAL_NOTIFICATION_KEY = "additional_notification_key";
3939
String RINGTONE_KEY = "ringtone_key";
4040
String NIGHT_MODE_KEY = "night_mode_key";
41+
String START_PAGE = "start_page_key";
4142
String DISPLAYED_AGE_KEY = "displayed_age_key";
4243

4344
// Intents

app/src/main/java/com/djonique/birdays/widget/WidgetViewsFactory.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.content.Context;
2020
import android.content.Intent;
21-
import android.content.SharedPreferences;
2221
import android.preference.PreferenceManager;
2322
import android.support.v4.content.ContextCompat;
2423
import android.widget.RemoteViews;
@@ -39,7 +38,6 @@ public class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory
3938

4039
private Context context;
4140
private DbHelper dbHelper;
42-
private SharedPreferences preferences;
4341
private List<Person> widgetList;
4442

4543
WidgetViewsFactory(Context context) {
@@ -49,7 +47,6 @@ public class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory
4947
@Override
5048
public void onCreate() {
5149
dbHelper = new DbHelper(context);
52-
preferences = PreferenceManager.getDefaultSharedPreferences(context);
5350
widgetList = new ArrayList<>();
5451
}
5552

app/src/main/res/values-be/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@
151151
<!-- General -->
152152
<string name="general">Общие</string>
153153
<string name="night_mode">Ночной режим</string>
154+
<string name="start_page">Начальная страница</string>
155+
156+
<string-array name="start_page_entries">
157+
<item>Текущий месяц</item>
158+
<item>Все</item>
159+
<item>Известные</item>
160+
</string-array>
161+
154162
<string name="displayed_age">Отображаемый возраст</string>
155163

156164
<string-array name="displayed_age_entries">

app/src/main/res/values-de/strings.xml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<string name="age">Alter:\u0020</string>
3131
<string name="happy_birthday">Alles Gute zum Geburtstag!</string>
3232
<string name="web_search_error">Aktion kann nicht ausgeführt werden, bitte Webbrowser installieren</string>
33-
<string name="delete_record_text">Sind Sie sicher, dass Sie diesen Eintrag löschen möchten:</string>
33+
<string name="delete_record_text">Sind Sie sicher, dass Sie diesen Eintrag löschen möchten:\u0020</string>
3434
<string name="record_deleted">Eintrag gelöscht</string>
3535
<string name="undo">Rückgängig</string>
3636

@@ -84,7 +84,7 @@
8484
<string name="record_edited">Eintrag bearbeitet</string>
8585

8686
<!-- Alarm -->
87-
<string name="security_exception">Sicherheitsbeschränkung, Samsung-Geräte erlauben nur eine begrenzte Anzahl Alarme</string>
87+
<string name="security_exception">SecurityException, Samsung-Geräte erlauben nur eine begrenzte Anzahl Alarme</string>
8888
<string name="channel_name">Geburtstage</string>
8989

9090
<!-- Zodiac signs -->
@@ -114,11 +114,11 @@
114114

115115
<string-array name="additional_notification_entries">
116116
<item>Nie</item>
117-
<item>1 Tag zuvor</item>
118-
<item>2 Tage zuvor</item>
119-
<item>3 Tage zuvor</item>
120-
<item>1 Woche zuvor</item>
121-
<item>2 Wochen zuvor</item>
117+
<item>1 Tag vorher</item>
118+
<item>2 Tage vorher</item>
119+
<item>3 Tage vorher</item>
120+
<item>1 Woche vorher</item>
121+
<item>2 Wochen vorher</item>
122122
</string-array>
123123

124124
<string-array name="additional_notification_delay">
@@ -151,6 +151,14 @@
151151
<!-- General -->
152152
<string name="general">Allgemein</string>
153153
<string name="night_mode">Nachtmodus</string>
154+
<string name="start_page">Startseite</string>
155+
156+
<string-array name="start_page_entries">
157+
<item>Aktueller Monat</item>
158+
<item>Alle</item>
159+
<item>Berühmt</item>
160+
</string-array>
161+
154162
<string name="displayed_age">Alter anzeigen</string>
155163

156164
<string-array name="displayed_age_entries">
@@ -175,15 +183,15 @@
175183
<string name="about_app">Über die App</string>
176184
<string name="menu_github">Quelltext</string>
177185
<string name="privacy_policy">Datenschutzrichtlinien</string>
178-
<string name="software_licenses">Freie Software-Lizenzen</string>
186+
<string name="software_licenses">Open-Source-Lizenzen</string>
179187
<string name="licenses">Lizenzen</string>
180188

181189
<!-- HelpActivity -->
182190
<string name="help_header">Weshalb funktioniert der Alarm nicht?</string>
183191
<string name="help_description">Manche Geräte verfügen über einen Energiesparmodus, der Hintergrundprozesse von Apps blockieren oder Programme am Starten hindern kann.\nDamit der Alarm korrekt funktioniert, sind einige einfache Schritte zu befolgen:\n\n1. Stellen Sie sicher, dass die Benachrichtigungen für die Birdays App aktiviert sind (Einstellungen > Apps > Birdays).\n\n2. Falls Sie Task Manager, Task Killer oder RAM Optimierer installiert haben (z.B. «Battery Saver», «Clean Master»), fügen Sie Birdays zu deren Whitelist hinzu.\n\n3. Deaktivieren Sie den Energiesparmodus oder fügen Sie Birdays zur Whitelist hinzu (Einstellungen > Akku > Akku-Leistungsoptimierung).\nNur für Geräte mit Android 6.0 (Marshmallow) oder höher.</string>
184192
<string name="help_whitelist">Whitelist öffnen</string>
185193
<string name="help_whitelist_error">Nur für Geräte mit Android 6.0 (Marshmallow) oder höher</string>
186-
<string name="help_delay_text">"Bitte beachten Sie, dass Benachrichtigungen auf manchen Geräten mit Verzögerung erscheinen können.\n "</string>
194+
<string name="help_delay_text">Bitte beachten Sie, dass Benachrichtigungen auf manchen Geräten mit Verzögerung erscheinen können.</string>
187195
<string name="help_settings">Einstellungen öffnen</string>
188196
<string name="huawei_header">Für Huawei-Besitzer</string>
189197
<string name="huawei_description">Öffnen Sie «Einstellungen», wählen Sie «Energiesparen» und öffnen Sie «Geschützte Apps». Stellen Sie sicher, dass diese Einstellung für Birdays aktiviert ist.</string>

0 commit comments

Comments
 (0)