From 91ec476f9a1510712d9a07a1dc38eff7f51f5d8c Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Sat, 16 Jun 2018 11:52:07 +0200 Subject: [PATCH] Fix a few bugs Signed-off-by: Mario Danic --- .../controllers/RingtoneSelectionController.java | 5 +++-- .../models/json/converters/UriTypeConverter.java | 13 +++++++++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java b/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java index fd4794d85..228860fdd 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java @@ -144,7 +144,8 @@ public class RingtoneSelectionController extends BaseController implements Flexi @SuppressLint("LongLogTag") private void fetchNotificationSounds() { abstractFlexibleItemList = new ArrayList<>(); - abstractFlexibleItemList.add(new NotificationSoundItem("None", null)); + abstractFlexibleItemList.add(new NotificationSoundItem(getResources().getString(R.string.nc_settings_no_ringtone), + null)); String ringtoneString; @@ -242,7 +243,7 @@ public class RingtoneSelectionController extends BaseController implements Flexi mediaPlayer.start(); } - if (adapter.getSelectedPositions().get(0) != position) { + if (adapter.getSelectedPositions().size() == 0 || adapter.getSelectedPositions().get(0) != position) { RingtoneSettings ringtoneSettings = new RingtoneSettings(); ringtoneSettings.setRingtoneName(notificationSoundItem.getNotificationSoundName()); ringtoneSettings.setRingtoneUri(ringtoneUri); diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/UriTypeConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/UriTypeConverter.java index 72a76b8a2..d3d738887 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/converters/UriTypeConverter.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/UriTypeConverter.java @@ -21,17 +21,26 @@ package com.nextcloud.talk.models.json.converters; import android.net.Uri; +import android.text.TextUtils; import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter; public class UriTypeConverter extends StringBasedTypeConverter { @Override public Uri getFromString(String string) { - return Uri.parse(string); + if (!TextUtils.isEmpty(string)) { + return Uri.parse(string); + } else { + return null; + } } @Override public String convertToString(Uri object) { - return object.toString(); + if (object != null) { + return object.toString(); + } else { + return null; + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 66f9cbe45..d90f24f50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -66,6 +66,7 @@ Messages message_ringtone Librem by feandesign + No sound No proxy Username