mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Fix selection of Librem sound
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
ed1eeac710
commit
cd3e403dcb
@ -96,8 +96,6 @@ public class RingtoneSelectionController extends BaseController implements Flexi
|
|||||||
super.onViewBound(view);
|
super.onViewBound(view);
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
adapter = new FlexibleAdapter<>(abstractFlexibleItemList, getActivity(), false);
|
adapter = new FlexibleAdapter<>(abstractFlexibleItemList, getActivity(), false);
|
||||||
|
|
||||||
@ -118,6 +116,7 @@ public class RingtoneSelectionController extends BaseController implements Flexi
|
|||||||
protected void onAttach(@NonNull View view) {
|
protected void onAttach(@NonNull View view) {
|
||||||
super.onAttach(view);
|
super.onAttach(view);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
if (getActionBar() != null) {
|
if (getActionBar() != null) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
@ -165,12 +164,14 @@ public class RingtoneSelectionController extends BaseController implements Flexi
|
|||||||
boolean foundDefault = false;
|
boolean foundDefault = false;
|
||||||
|
|
||||||
String preferencesString = null;
|
String preferencesString = null;
|
||||||
if ((TextUtils.isEmpty((preferencesString = appPreferences.getCallRingtoneUri())))
|
if ((callNotificationSounds && TextUtils.isEmpty((preferencesString = appPreferences.getCallRingtoneUri())))
|
||||||
|| TextUtils.isEmpty((preferencesString = appPreferences.getMessageRingtoneUri()))) {
|
|| (!callNotificationSounds && TextUtils.isEmpty((preferencesString = appPreferences
|
||||||
|
.getMessageRingtoneUri())))) {
|
||||||
((NotificationSoundItem) abstractFlexibleItemList.get(1)).setSelected(true);
|
((NotificationSoundItem) abstractFlexibleItemList.get(1)).setSelected(true);
|
||||||
foundDefault = true;
|
foundDefault = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
RingtoneManager manager = new RingtoneManager(getActivity());
|
RingtoneManager manager = new RingtoneManager(getActivity());
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ public class RingtoneSelectionController extends BaseController implements Flexi
|
|||||||
} else if (completeNotificationUri.equals(ringtoneSettings.getRingtoneUri().toString())) {
|
} else if (completeNotificationUri.equals(ringtoneSettings.getRingtoneUri().toString())) {
|
||||||
notificationSoundItem.setSelected(true);
|
notificationSoundItem.setSelected(true);
|
||||||
foundDefault = true;
|
foundDefault = true;
|
||||||
} else if (completeNotificationUri.equals(ringtoneString)) {
|
} else if (ringtoneSettings.getRingtoneUri().toString().equals(ringtoneString)) {
|
||||||
((NotificationSoundItem) abstractFlexibleItemList.get(1)).setSelected(true);
|
((NotificationSoundItem) abstractFlexibleItemList.get(1)).setSelected(true);
|
||||||
foundDefault = true;
|
foundDefault = true;
|
||||||
}
|
}
|
||||||
@ -243,23 +244,25 @@ public class RingtoneSelectionController extends BaseController implements Flexi
|
|||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
RingtoneSettings ringtoneSettings = new RingtoneSettings();
|
if (adapter.getSelectedPositions().get(0) != position) {
|
||||||
ringtoneSettings.setRingtoneName(notificationSoundItem.getNotificationSoundName());
|
RingtoneSettings ringtoneSettings = new RingtoneSettings();
|
||||||
ringtoneSettings.setRingtoneUri(ringtoneUri);
|
ringtoneSettings.setRingtoneName(notificationSoundItem.getNotificationSoundName());
|
||||||
|
ringtoneSettings.setRingtoneUri(ringtoneUri);
|
||||||
|
|
||||||
if (callNotificationSounds) {
|
if (callNotificationSounds) {
|
||||||
try {
|
try {
|
||||||
appPreferences.setCallRingtoneUri(LoganSquare.serialize(ringtoneSettings));
|
appPreferences.setCallRingtoneUri(LoganSquare.serialize(ringtoneSettings));
|
||||||
toggleSelection(position);
|
toggleSelection(position);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to store selected ringtone for calls");
|
Log.e(TAG, "Failed to store selected ringtone for calls");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
appPreferences.setMessageRingtoneUri(LoganSquare.serialize(ringtoneSettings));
|
appPreferences.setMessageRingtoneUri(LoganSquare.serialize(ringtoneSettings));
|
||||||
toggleSelection(position);
|
toggleSelection(position);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to store selected ringtone for calls");
|
Log.e(TAG, "Failed to store selected ringtone for calls");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user