Skip to content

Commit

Permalink
Prepare for 1.5.0 release, added many translation, fixed bugs.
Browse files Browse the repository at this point in the history
Added homepage choice.
  • Loading branch information
Djonique committed Dec 10, 2017
1 parent fb792ff commit 653a9cd
Show file tree
Hide file tree
Showing 30 changed files with 20,334 additions and 155 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
buildToolsVersion '27.0.2'

defaultConfig {
applicationId "com.djonique.birdays"
Expand Down Expand Up @@ -58,7 +58,7 @@ repositories {
maven { url 'https://maven.fabric.io/public' }
}

def androidSupportVersion = '27.0.1'
def androidSupportVersion = '27.0.2'
def firebaseVersion = '11.4.2'
def butterKnifeVersion = '8.8.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.djonique.birdays.activities;

import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class HelpActivity extends AppCompatActivity {
private static final String SAMSUNG = "samsung";
private static final String XIAOMI = "xiaomi";
private static final String ALERT_SHOWED = "ALERT_SHOWED";
private static final String ACTIVITY_NOT_FOUND_EXCEPTION = "ActivityNotFoundException";

@BindView(R.id.button_help_whitelist)
AppCompatButton btnOpenWhitelist;
Expand Down Expand Up @@ -138,7 +140,11 @@ public void onClick(DialogInterface dialog, int which) {
@OnClick(R.id.button_help_whitelist)
void openBatteryOptimization() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
startActivity(Intent.createChooser(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), null));
try {
startActivity(Intent.createChooser(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), null));
} catch (ActivityNotFoundException e) {
Toast.makeText(this, ACTIVITY_NOT_FOUND_EXCEPTION, Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(this, R.string.help_whitelist_error, Toast.LENGTH_LONG).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public boolean onQueryTextChange(String newText) {
Ad.showBannerAd(container, adView, fab);
}

// App starts from AllFragment
viewPager.setCurrentItem(1);
// Start page
viewPager.setCurrentItem(Integer.parseInt(preferences.getString(Constants.START_PAGE, "1")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@ public boolean onPreferenceClick(Preference preference) {
}
});

/*
* Start page
*/
findPreference(getString(R.string.start_page_key)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
((ListPreference) preference).setValue(newValue.toString());
preference.setSummary(((ListPreference) preference).getEntry());
return true;
}
});

/*
* Displayed age
*/
Expand Down
25 changes: 9 additions & 16 deletions app/src/main/java/com/djonique/birdays/alarm/AlarmReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@

public class AlarmReceiver extends BroadcastReceiver {

// TODO: 30.11.2017 FireUriExposedException

private static final String CHANNEL_ID = "com.djonique.birdays";

private NotificationManager manager;
private SharedPreferences preferences;

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

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

preferences = PreferenceManager.getDefaultSharedPreferences(context);

// Extras from intent
String name = intent.getStringExtra(Constants.NAME);
String when = intent.getStringExtra(Constants.WHEN);
Expand All @@ -62,7 +63,7 @@ public void onReceive(Context context, Intent intent) {

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

setDefaultsAndRingtone(builder, getRingtoneUri(context));
setDefaultsAndRingtone(builder);

builder.setContentIntent(pendingIntent);

Expand Down Expand Up @@ -121,15 +122,17 @@ private NotificationCompat.Builder buildNotification(Context context, String tit
/**
* Avoids FileUriExposedException on Android API 24+
*/
private void setDefaultsAndRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
private void setDefaultsAndRingtone(NotificationCompat.Builder builder) {
String ringtone = preferences.getString(Constants.RINGTONE_KEY,
Settings.System.DEFAULT_NOTIFICATION_URI.toString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
setRingtone(builder, ringtoneUri);
setRingtone(builder, Uri.parse(ringtone));
} catch (Exception e) {
builder.setDefaults(NotificationCompat.DEFAULT_ALL);
}
} else {
setRingtone(builder, ringtoneUri);
setRingtone(builder, Uri.parse(ringtone));
}
}

Expand All @@ -140,14 +143,4 @@ private void setRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
builder.setDefaults(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_LIGHTS);
builder.setSound(ringtoneUri);
}

/**
* Returns URI for picked in the settings notification tone
*/
private Uri getRingtoneUri(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String ringtone = preferences.getString(Constants.RINGTONE_KEY,
Settings.System.DEFAULT_NOTIFICATION_URI.toString());
return Uri.parse(ringtone);
}
}
56 changes: 26 additions & 30 deletions app/src/main/java/com/djonique/birdays/backup/ExportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Environment;
import android.support.v7.app.AlertDialog;
import android.util.Xml;
import android.widget.Toast;

import com.djonique.birdays.R;
import com.djonique.birdays.database.DbHelper;
Expand All @@ -44,8 +42,6 @@

public class ExportHelper {

// TODO: 30.11.2017 Toast in main thread

// XML constants
private static final String RECORDS = "records";
private static final String PERSON = "person";
Expand All @@ -63,12 +59,12 @@ public class ExportHelper {
private static final String IO_EXCEPTION = "IOException";
private static final String FILE_NOT_FOUND_EXCEPTION = "FileNotFoundException";

private Context context;
private Activity activity;
private File folder;
private boolean storageAvailable = true;

public ExportHelper(Context context) {
this.context = context;
public ExportHelper(Activity activity) {
this.activity = activity;
}

public void exportRecords() {
Expand Down Expand Up @@ -121,36 +117,41 @@ private String writeXml(List<Person> persons) {
xmlSerializer.endDocument();
xmlSerializer.flush();
} catch (IllegalArgumentException e) {
Toast.makeText(context, ILLEGAL_ARGUMENT_EXCEPTION, Toast.LENGTH_LONG).show();
showAlertDialog(activity, ILLEGAL_ARGUMENT_EXCEPTION);
} catch (IllegalStateException e) {
Toast.makeText(context, ILLEGAL_STATE_EXCEPTION, Toast.LENGTH_LONG).show();
showAlertDialog(activity, ILLEGAL_STATE_EXCEPTION);
} catch (IOException e) {
Toast.makeText(context, IO_EXCEPTION, Toast.LENGTH_LONG).show();
showAlertDialog(activity, IO_EXCEPTION);
}
return stringWriter.toString();
}

private void showAlertDialog(Context context, String text) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(text);
builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
private void showAlertDialog(final Activity activity, final String text) {
activity.runOnUiThread(new Runnable() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(text);
builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
builder.show();
}

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

ProgressDialogHelper progressDialogHelper = new ProgressDialogHelper(context);
ProgressDialogHelper progressDialogHelper = new ProgressDialogHelper(activity);

@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialogHelper.startProgressDialog(context.getString(R.string.exporting_records));
progressDialogHelper.startProgressDialog(activity.getString(R.string.exporting_records));
}

@SuppressWarnings("ResultOfMethodCallIgnored")
Expand All @@ -159,29 +160,24 @@ protected Void doInBackground(Void... params) {
File sd = Environment.getExternalStorageDirectory();
if (isExternalStorageWritable()) {
try {
folder = new File(sd.getPath() + File.separator + context.getString(R.string.app_name));
folder = new File(sd.getPath() + File.separator + activity.getString(R.string.app_name));
if (!folder.exists()) {
folder.mkdir();
}
File backupFile = new File(folder + File.separator + getBackupFileName());
backupFile.createNewFile();
FileOutputStream outputStream = new FileOutputStream(backupFile);
List<Person> persons = new DbHelper(context).query().getPersons();
List<Person> persons = new DbHelper(activity).query().getPersons();
outputStream.write(writeXml(persons).getBytes());
outputStream.close();
} catch (FileNotFoundException e) {
Toast.makeText(context, FILE_NOT_FOUND_EXCEPTION, Toast.LENGTH_LONG).show();
showAlertDialog(activity, FILE_NOT_FOUND_EXCEPTION);
} catch (IOException e) {
Toast.makeText(context, IO_EXCEPTION, Toast.LENGTH_LONG).show();
showAlertDialog(activity, IO_EXCEPTION);
}
} else {
storageAvailable = false;
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
showAlertDialog(context, context.getString(R.string.ext_storage_error));
}
});
showAlertDialog(activity, activity.getString(R.string.ext_storage_error));
}
return null;
}
Expand All @@ -191,7 +187,7 @@ protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
progressDialogHelper.dismissProgressDialog();
if (storageAvailable) {
showAlertDialog(context, context.getString(R.string.backup_finished) + folder);
showAlertDialog(activity, activity.getString(R.string.backup_finished) + folder);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface Constants {
String ADDITIONAL_NOTIFICATION_KEY = "additional_notification_key";
String RINGTONE_KEY = "ringtone_key";
String NIGHT_MODE_KEY = "night_mode_key";
String START_PAGE = "start_page_key";
String DISPLAYED_AGE_KEY = "displayed_age_key";

// Intents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.widget.RemoteViews;
Expand All @@ -39,7 +38,6 @@ public class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory

private Context context;
private DbHelper dbHelper;
private SharedPreferences preferences;
private List<Person> widgetList;

WidgetViewsFactory(Context context) {
Expand All @@ -49,7 +47,6 @@ public class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory
@Override
public void onCreate() {
dbHelper = new DbHelper(context);
preferences = PreferenceManager.getDefaultSharedPreferences(context);
widgetList = new ArrayList<>();
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@
<!-- General -->
<string name="general">Общие</string>
<string name="night_mode">Ночной режим</string>
<string name="start_page">Начальная страница</string>

<string-array name="start_page_entries">
<item>Текущий месяц</item>
<item>Все</item>
<item>Известные</item>
</string-array>

<string name="displayed_age">Отображаемый возраст</string>

<string-array name="displayed_age_entries">
Expand Down
26 changes: 17 additions & 9 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string name="age">Alter:\u0020</string>
<string name="happy_birthday">Alles Gute zum Geburtstag!</string>
<string name="web_search_error">Aktion kann nicht ausgeführt werden, bitte Webbrowser installieren</string>
<string name="delete_record_text">Sind Sie sicher, dass Sie diesen Eintrag löschen möchten:</string>
<string name="delete_record_text">Sind Sie sicher, dass Sie diesen Eintrag löschen möchten:\u0020</string>
<string name="record_deleted">Eintrag gelöscht</string>
<string name="undo">Rückgängig</string>

Expand Down Expand Up @@ -84,7 +84,7 @@
<string name="record_edited">Eintrag bearbeitet</string>

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

<!-- Zodiac signs -->
Expand Down Expand Up @@ -114,11 +114,11 @@

<string-array name="additional_notification_entries">
<item>Nie</item>
<item>1 Tag zuvor</item>
<item>2 Tage zuvor</item>
<item>3 Tage zuvor</item>
<item>1 Woche zuvor</item>
<item>2 Wochen zuvor</item>
<item>1 Tag vorher</item>
<item>2 Tage vorher</item>
<item>3 Tage vorher</item>
<item>1 Woche vorher</item>
<item>2 Wochen vorher</item>
</string-array>

<string-array name="additional_notification_delay">
Expand Down Expand Up @@ -151,6 +151,14 @@
<!-- General -->
<string name="general">Allgemein</string>
<string name="night_mode">Nachtmodus</string>
<string name="start_page">Startseite</string>

<string-array name="start_page_entries">
<item>Aktueller Monat</item>
<item>Alle</item>
<item>Berühmt</item>
</string-array>

<string name="displayed_age">Alter anzeigen</string>

<string-array name="displayed_age_entries">
Expand All @@ -175,15 +183,15 @@
<string name="about_app">Über die App</string>
<string name="menu_github">Quelltext</string>
<string name="privacy_policy">Datenschutzrichtlinien</string>
<string name="software_licenses">Freie Software-Lizenzen</string>
<string name="software_licenses">Open-Source-Lizenzen</string>
<string name="licenses">Lizenzen</string>

<!-- HelpActivity -->
<string name="help_header">Weshalb funktioniert der Alarm nicht?</string>
<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>
<string name="help_whitelist">Whitelist öffnen</string>
<string name="help_whitelist_error">Nur für Geräte mit Android 6.0 (Marshmallow) oder höher</string>
<string name="help_delay_text">"Bitte beachten Sie, dass Benachrichtigungen auf manchen Geräten mit Verzögerung erscheinen können.\n "</string>
<string name="help_delay_text">Bitte beachten Sie, dass Benachrichtigungen auf manchen Geräten mit Verzögerung erscheinen können.</string>
<string name="help_settings">Einstellungen öffnen</string>
<string name="huawei_header">Für Huawei-Besitzer</string>
<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>
Expand Down
Loading

0 comments on commit 653a9cd

Please sign in to comment.