diff --git a/app/src/Samsung/res/drawable-nodpi/bg_splash.png b/app/src/Samsung/res/drawable-nodpi/bg_splash.png old mode 100755 new mode 100644 index 433a83e9ecb73302fc0edc41f8f79dc980bdba4a..a7a449158c5860f300ed4ace989a33d8a1710e37 Binary files a/app/src/Samsung/res/drawable-nodpi/bg_splash.png and b/app/src/Samsung/res/drawable-nodpi/bg_splash.png differ diff --git a/app/src/Samsung/res/drawable/app_background.xml b/app/src/Samsung/res/drawable/app_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..dfb6a23c12634dd1754a653de27005269503a647 --- /dev/null +++ b/app/src/Samsung/res/drawable/app_background.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/SamsungDev/res/drawable-nodpi/bg_splash.png b/app/src/SamsungDev/res/drawable-nodpi/bg_splash.png old mode 100755 new mode 100644 index 433a83e9ecb73302fc0edc41f8f79dc980bdba4a..a7a449158c5860f300ed4ace989a33d8a1710e37 Binary files a/app/src/SamsungDev/res/drawable-nodpi/bg_splash.png and b/app/src/SamsungDev/res/drawable-nodpi/bg_splash.png differ diff --git a/app/src/SamsungDev/res/drawable/app_background.xml b/app/src/SamsungDev/res/drawable/app_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..1561fc6c7830dc7bd230d536c1de84697103a47f --- /dev/null +++ b/app/src/SamsungDev/res/drawable/app_background.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/SamsungPreProd/res/drawable-nodpi/bg_splash.png b/app/src/SamsungPreProd/res/drawable-nodpi/bg_splash.png old mode 100755 new mode 100644 index 433a83e9ecb73302fc0edc41f8f79dc980bdba4a..a7a449158c5860f300ed4ace989a33d8a1710e37 Binary files a/app/src/SamsungPreProd/res/drawable-nodpi/bg_splash.png and b/app/src/SamsungPreProd/res/drawable-nodpi/bg_splash.png differ diff --git a/app/src/SamsungPreProd/res/drawable/app_background.xml b/app/src/SamsungPreProd/res/drawable/app_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..1561fc6c7830dc7bd230d536c1de84697103a47f --- /dev/null +++ b/app/src/SamsungPreProd/res/drawable/app_background.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/Spotify/res/drawable/app_background.png b/app/src/Spotify/res/drawable/app_background.png new file mode 100644 index 0000000000000000000000000000000000000000..2015ce482b6e0904afd886e4c3910197cd0a78de Binary files /dev/null and b/app/src/Spotify/res/drawable/app_background.png differ diff --git a/app/src/Superapp/res/drawable/app_background.png b/app/src/Superapp/res/drawable/app_background.png new file mode 100644 index 0000000000000000000000000000000000000000..2015ce482b6e0904afd886e4c3910197cd0a78de Binary files /dev/null and b/app/src/Superapp/res/drawable/app_background.png differ diff --git a/app/src/dev/res/drawable/app_background.png b/app/src/dev/res/drawable/app_background.png new file mode 100644 index 0000000000000000000000000000000000000000..2015ce482b6e0904afd886e4c3910197cd0a78de Binary files /dev/null and b/app/src/dev/res/drawable/app_background.png differ diff --git a/app/src/main/assets/ringtones/aqua.mp3 b/app/src/main/assets/ringtones/aqua.mp3 deleted file mode 100644 index eade4b71712e5a37d8495678573152f2c9a66fe0..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/aqua.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/cheerful.mp3 b/app/src/main/assets/ringtones/cheerful.mp3 deleted file mode 100644 index c9a66e24ceb6035638e2064c17de269f6166e206..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/cheerful.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/discreet.mp3 b/app/src/main/assets/ringtones/discreet.mp3 deleted file mode 100644 index 9900d9b96539d026a5429312304a5417c701b161..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/discreet.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/important_stuff.mp3 b/app/src/main/assets/ringtones/important_stuff.mp3 deleted file mode 100644 index 0db04b3ecf3f1b24429234a41fb39f1e5d0419e2..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/important_stuff.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/nynja.mp3 b/app/src/main/assets/ringtones/nynja.mp3 deleted file mode 100644 index de5759baa950b38d87a9986a6bdf74336f62faef..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/nynja.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/optimistic.mp3 b/app/src/main/assets/ringtones/optimistic.mp3 deleted file mode 100644 index f0d434ce223d79dbfd8be731348cfce8cf509a28..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/optimistic.mp3 and /dev/null differ diff --git a/app/src/main/assets/ringtones/sunrise.mp3 b/app/src/main/assets/ringtones/sunrise.mp3 deleted file mode 100644 index 6e6baf0acf6175adbc79971be84bc5a56fee372e..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ringtones/sunrise.mp3 and /dev/null differ diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/DataManager.java b/app/src/main/java/com/nynja/mobile/communicator/data/DataManager.java index 9b2d0ef5c5f6d110160884c0c91bc718c75170de..d4fd29b4e66de6a007007f192e9be61cfe31019b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/DataManager.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/DataManager.java @@ -4460,8 +4460,9 @@ public class DataManager { return FileUtils.getAlertSoundsList(mContext, getSettingNotifications().getAlertSound()); } - public List getRingtonesFileNamesFromAssetsSubfolder() { - return FileUtils.getFileNamesFromAssetsSubfolder(mContext, Consts.RINGER_SOUND_FOLDER_NAME); + public HashMap getRingtonesFileNamesFromAssetsSubfolder() { + return FileUtils.getFileRingtonesNamesFromRaw(mContext); + //return FileUtils.getFileNamesFromAssetsSubfolder(mContext, Consts.RINGER_SOUND_FOLDER_NAME); } public AuthCodeReceiverClient getAuthCodeReceiverClient() { @@ -5806,7 +5807,8 @@ public class DataManager { } public void playDemoRingerSound(@NotNull String ringerSound) { - mNynjaSoundManager.playSound(ringerSound, false, NynjaSoundManager.Stream.MUSIC); +// mNynjaSoundManager.playSound(ringerSound, false, NynjaSoundManager.Stream.MUSIC); + mNynjaSoundManager.playSound(Uri.parse(ringerSound), false, NynjaSoundManager.Stream.MUSIC); if (mNotificationHelper.ringerSoundChange(mSettingNotifications, ringerSound)) { mPreferenceHelper.setSettingNotifications(mSettingNotifications); } @@ -5896,7 +5898,15 @@ public class DataManager { } public void playCallRinging() { - mNynjaSoundManager.playCallRinging(mSettingNotifications.getRingerSound()); + Uri soundUri = null; + try { + soundUri = Uri.parse(mSettingNotifications.getRingerSound()); + } catch (Exception ex) { + Timber.e(ex); + } + if (soundUri != null) { + mNynjaSoundManager.playCallRinging(soundUri); + } } public NynjaSoundManager.Mode getNynjaSoundManagerRingerMode() { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/DownloadFileService.kt b/app/src/main/java/com/nynja/mobile/communicator/data/DownloadFileService.kt index d33b077baf050ff9642e37bc0ff7d9b6dbe9b576..4b0b2dbcc419c906d0b33060bf6e98f4aead93a0 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/DownloadFileService.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/data/DownloadFileService.kt @@ -70,9 +70,10 @@ class DownloadFileService : Service() { val launchIntent = MainActivity.getLaunchIntent(mDataManager.context) val title = mDataManager.context.getString(R.string.notification_downloading) val text = mDataManager.context.getString(R.string.notification_file) - val notification = mNotificationHelper.buildNotification(Push.DOWNLOADING, null, launchIntent, - mDataManager.settingNotifications, 0, text, true, title, true, - true, mDataManager.conferenceSDK.hasCallInProgress(), false, null) + val notification = mNotificationHelper.buildNotification(NotificationHelper.DOWNLOADING, null, + launchIntent, mDataManager.settingNotifications, 0, + text, true, title, true, true, + mDataManager.conferenceSDK.hasCallInProgress(), false, null) startForeground(ONGOING_NOTIFICATION_ID, notification) // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java index e6b368ae55f35775c1e15870658805578693b5b3..2dea4d560a0e7aba9973286ed054b53ebe3f8ef3 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java @@ -108,8 +108,8 @@ public class FireBaseMessagingService extends FirebaseMessagingService { if(model == null) break; Timber.i(model.toString()); if (mDataManager.getSettingNotifications().isCallNotifications()) { -// boolean isMainActivityIsActive = mDataManager.isMainActivityIsActive(); - boolean isMainActivityIsActive = !mDataManager.isInBackground(); + boolean isMainActivityIsActive = mDataManager.isMainActivityIsActive(); +// boolean isMainActivityIsActive = !mDataManager.isInBackground(); if (!isMainActivityIsActive) { mDataManager.reconnectConference(); } @@ -270,9 +270,10 @@ public class FireBaseMessagingService extends FirebaseMessagingService { "; isDeviceLocked=" + (isDeviceLocked ? "true" : "false")); if (context instanceof FireBaseMessagingService) { mNotificationHelper.createCallPushNotification(context, from, callId, - !hasActiveCall, - mDataManager.getSettingNotifications(), - true); + isMainActivityIsActive, + !hasActiveCall, + mDataManager.getSettingNotifications(), + true); } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/UploadFileService.kt b/app/src/main/java/com/nynja/mobile/communicator/data/UploadFileService.kt index f7f5f4e9b6eb128c23c799bb4a63c9e9524ebf01..91bff93650be853dc968868884ca10a1661d1a07 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/UploadFileService.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/data/UploadFileService.kt @@ -63,9 +63,10 @@ class UploadFileService : Service() { val launchIntent = MainActivity.getLaunchIntent(mDataManager.context) val title = mDataManager.context.getString(R.string.notification_uploading) val text = mDataManager.context.getString(R.string.notification_file) - val notification = mNotificationHelper.buildNotification(Push.UPLOADING, null, launchIntent, - mDataManager.settingNotifications, 0, text, true, title, true, - true, mDataManager.conferenceSDK.hasCallInProgress(), false, null) + val notification = mNotificationHelper.buildNotification(NotificationHelper.UPLOADING, null, + launchIntent, mDataManager.settingNotifications, 0, + text, true, title, true, true, + mDataManager.conferenceSDK.hasCallInProgress(), false, null) startForeground(ONGOING_NOTIFICATION_ID, notification) } else if (intent != null && STOP_UPLOAD_FOREGROUND_ACTION == intent.action) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/audio/NynjaSoundManager.kt b/app/src/main/java/com/nynja/mobile/communicator/data/audio/NynjaSoundManager.kt index 31437a93cfcf5cc45a11e7defb351f8daf072b2b..b3a9ed2c02ef371419da755bbe62e3d73f4b0616 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/audio/NynjaSoundManager.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/data/audio/NynjaSoundManager.kt @@ -160,7 +160,7 @@ class NynjaSoundManager(context: Context) { playSound(SOUND_RING_BACK_FILE_NAME, true, NynjaSoundManager.Stream.VOICE_CALL) } - fun playCallRinging(@NotNull soundFileName: String) { + fun playCallRinging(@NotNull soundFileName: Uri) { playCallRinging(soundFileName, true) } @@ -172,7 +172,7 @@ class NynjaSoundManager(context: Context) { return (mAudioManager.ringerMode != AudioManager.RINGER_MODE_SILENT && mInAppVibrate); } - fun playCallRinging(@NotNull soundFileName: String, registerObserver: Boolean) { + fun playCallRinging(@NotNull soundFileName: Uri, registerObserver: Boolean) { if (canPlayRingingSound()) { playSound(soundFileName, true, NynjaSoundManager.Stream.RINGER) } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/db/DbHelper.java b/app/src/main/java/com/nynja/mobile/communicator/data/db/DbHelper.java index 8ed7216650e2223891d45a2469f17a95458ad0af..2f4b3cf1d2bc01714f8925af22e07cf8911255b0 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/db/DbHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/db/DbHelper.java @@ -383,7 +383,9 @@ public class DbHelper { cursor.close(); } } - auth.settings = getAuthFeatures(auth); + if (auth != null) { + auth.settings = getAuthFeatures(auth); + } return auth; } @@ -2085,10 +2087,12 @@ public class DbHelper { cursor.close(); } } - setMessageDesc(message); - checkStarMessage(message); - if (isAddReplied && message.isReply()) { - addRepliedToMessage(message); + if (message != null) { + setMessageDesc(message); + checkStarMessage(message); + if (isAddReplied && message.isReply()) { + addRepliedToMessage(message); + } } return message; } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/db/PreferenceHelper.java b/app/src/main/java/com/nynja/mobile/communicator/data/db/PreferenceHelper.java index fc0218451e0c2e5e4d6474eb5c67bc58b8edde2c..3194807e6fba3757b7333d02b83bec99dc8c5302 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/db/PreferenceHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/db/PreferenceHelper.java @@ -160,19 +160,21 @@ public class PreferenceHelper { } public void setSettingNotifications(SettingNotifications sn) { - mSharedPreferences.edit().putBoolean(NOTIFICATION_IN_APP_VIBRATE, sn.isInAppVibrate()).apply(); - mSharedPreferences.edit().putString(NOTIFICATION_ALERT_SOUND, sn.getAlertSound()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_SOUND, sn.isSound()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_CALL_NOTIFICATION, sn.isCallNotifications()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_NEW_MESSAGE_ALERTS, sn.isNewMessageAlerts()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATIONS_MUTE_DURING_CALL, sn.isMutedDuringCall()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_INCOMING_SOUND, sn.isIncomingSoundInMutedChat()).apply(); - mSharedPreferences.edit().putString(NOTIFICATION_RINGER_SOUND, sn.getRingerSound()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_SENT_MESSAGE_SOUND, sn.isSentMessageSound()).apply(); - mSharedPreferences.edit().putString(NOTIFICATION_DEFAULT_SOUND, sn.getDefaultNotificationSound()).apply(); - mSharedPreferences.edit().putLong(NOTIFICATION_PREFERENCE_VERSION, sn.getVersion()).apply(); - mSharedPreferences.edit().putBoolean(NOTIFICATION_APP_ICON_BADGES_CLEARED, sn.isBadgesCleared()).apply(); - mSharedPreferences.edit().putLong(NOTIFICATION_RINGER_SOUND_INDEX, sn.getRingerSoundIndex()).apply(); + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putBoolean(NOTIFICATION_IN_APP_VIBRATE, sn.isInAppVibrate()).apply(); + editor.putString(NOTIFICATION_ALERT_SOUND, sn.getAlertSound()).apply(); + editor.putBoolean(NOTIFICATION_SOUND, sn.isSound()).apply(); + editor.putBoolean(NOTIFICATION_CALL_NOTIFICATION, sn.isCallNotifications()).apply(); + editor.putBoolean(NOTIFICATION_NEW_MESSAGE_ALERTS, sn.isNewMessageAlerts()).apply(); + editor.putBoolean(NOTIFICATIONS_MUTE_DURING_CALL, sn.isMutedDuringCall()).apply(); + editor.putBoolean(NOTIFICATION_INCOMING_SOUND, sn.isIncomingSoundInMutedChat()).apply(); + editor.putString(NOTIFICATION_RINGER_SOUND, sn.getRingerSound()).apply(); + editor.putBoolean(NOTIFICATION_SENT_MESSAGE_SOUND, sn.isSentMessageSound()).apply(); + editor.putString(NOTIFICATION_DEFAULT_SOUND, sn.getDefaultNotificationSound()).apply(); + editor.putLong(NOTIFICATION_PREFERENCE_VERSION, sn.getVersion()).apply(); + editor.putBoolean(NOTIFICATION_APP_ICON_BADGES_CLEARED, sn.isBadgesCleared()).apply(); + editor.putLong(NOTIFICATION_RINGER_SOUND_INDEX, sn.getRingerSoundIndex()).apply(); + editor.commit(); } public SettingNotifications getSettingNotifications() { @@ -190,7 +192,7 @@ public class PreferenceHelper { String defaultNotificationSound = mSharedPreferences.getString(NOTIFICATION_DEFAULT_SOUND, Consts.NotificationSounds.NYNJA.getDisplayName()); Long version = mSharedPreferences.getLong(NOTIFICATION_PREFERENCE_VERSION, 0L); boolean isBadgesCleared = mSharedPreferences.getBoolean(NOTIFICATION_APP_ICON_BADGES_CLEARED, false); - Long ringerSoundIndex = mSharedPreferences.getLong(NOTIFICATION_PREFERENCE_VERSION, 0L); + Long ringerSoundIndex = mSharedPreferences.getLong(NOTIFICATION_RINGER_SOUND_INDEX, 0L); mSettingNotifications = new SettingNotifications(newMessgeAlerts, callNotification, sound, alertSound, inAppVibrate, isMutedDuringCall, isIncomingSoundInMutedChat, ringerSound, isSentMessageSound, defaultNotificationSound, diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/models/SettingNotifications.kt b/app/src/main/java/com/nynja/mobile/communicator/data/models/SettingNotifications.kt index 8333e5aa82770a1ac0ab9c34382373f2f265b0a9..3fce7b160262de241ce320443030be4574b6b063 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/models/SettingNotifications.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/data/models/SettingNotifications.kt @@ -22,8 +22,8 @@ class SettingNotifications (var isNewMessageAlerts: Boolean, private var version: Long = 0L companion object { - const val VERSION = 5 - const val RESET_VERSION = 5 + const val VERSION: Long = 6 + const val RESET_VERSION: Long = 5 fun defaultVersion(): Long = VERSION.toLong() } @@ -40,4 +40,11 @@ class SettingNotifications (var isNewMessageAlerts: Boolean, return this.version == VERSION.toLong() } + fun isUpgradeVersion(): Boolean { + return this.version < VERSION.toLong() + } + + fun isDowngradeVersion(): Boolean { + return this.version > VERSION.toLong() + } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/models/mqtt/Push.java b/app/src/main/java/com/nynja/mobile/communicator/data/models/mqtt/Push.java index d5e4bbac6e748af569ccc03154c656ebc8b9c8b4..684cdf61c8b623111f10833a935d113387a6d90c 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/models/mqtt/Push.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/models/mqtt/Push.java @@ -21,22 +21,10 @@ public class Push extends BaseParcelMQTT { public final static String FRIEND = "friend"; public final static String MESSAGE = "message"; public final static String REQUEST_FRIEND = "request"; - public final static String CONFERENCE = "media_playback_channel"; - public final static String UPLOADING = "uploading"; - public final static String DOWNLOADING = "downloading"; - - public final static String DEFAULT_V_01 = "DEFAULT_v_01"; - public final static String FRIEND_V_01 = "friend_v_01"; - public final static String MESSAGE_V_01 = "message_v_01"; - public final static String REQUEST_FRIEND_V_01 = "request_v_01"; - public final static String CONFERENCE_V_01 = "media_playback_channel_v_01"; private static final String MESSAGE_DELETE = "message_delete"; private static final String HISTORY_DELETE = "history_delete"; - public final static int CHANNEL_VERSION = 4; - - @Either({Contact.class, Room.class, String.class}) @Order(1) public Object model; @Order(2) public String type; @@ -50,10 +38,6 @@ public class Push extends BaseParcelMQTT { public Push() { } - public static String getChannelId(String channelPrefix) { - return channelPrefix + CHANNEL_VERSION; - } - @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/models/nynjamodels/MessageModel.java b/app/src/main/java/com/nynja/mobile/communicator/data/models/nynjamodels/MessageModel.java index 0225b1fd4f4e629fa56ff15174b6c922005378b0..c4822f324cdad42ce42a6f90e2da70b4276f1b20 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/models/nynjamodels/MessageModel.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/models/nynjamodels/MessageModel.java @@ -333,10 +333,12 @@ public class MessageModel extends BaseNynjaModel implements Cloneable { } public boolean isMyMessage(@NonNull String myRosterID) { + if (myRosterID == null || from == null) return false; return myRosterID.equalsIgnoreCase(from); } public boolean isMyselfMessage(@NonNull String myRosterID) { + if (myRosterID == null || from == null || to == null) return false; return myRosterID.equalsIgnoreCase(from) && myRosterID.equalsIgnoreCase(to); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java index 9e3b3ee8cc29ace888d557c56e347aee221c2e81..0e7458d09176fd3b891763243f0333c974753f6a 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java @@ -49,7 +49,7 @@ public abstract class ConferenceSDKPresenter extends Bas @Override public void onConferenceMembersUpdate(ActiveConferenceCall activeConferenceCall) {} - @Override public void onStateChangedForCall(NYNCall iConference) {} + @Override public void onStateChangedForCall(int membersCount) {} @Override public void onAcceptedElsewhereConference(String conferenceId) {} diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java index 4b7d023f763963f5a478d341899f5f74647189d4..37770d85ee8ec3490175fd1878f8e3643de21e3b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java @@ -34,7 +34,7 @@ public interface ConferenceSDKListener { void onConferenceMembersUpdate(ActiveConferenceCall activeConferenceCall); - void onStateChangedForCall(NYNCall iConference); + void onStateChangedForCall(int membersCount); void onAcceptedElsewhereConference(String conferenceId); diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index f45a7dde97b3ff02451dff5a36830502f4e99586..2f839275ce12ee77cfc1d6dfcfbf9d0ee345bfe0 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -814,24 +814,26 @@ public class ConferenceSDKModule extends BaseSDKModule { public void didChangeCallState(NYNCall iConference, NYNCallState newState) { if (iConference == null) return; final String callId = iConference.callId(); - if (mHandler != null) mHandler.post( () -> { - if (!hasCreatedActiveCall()) return; - if (mActiveConference.mConference == null) return; - if (mActiveConference.mConference.callId().contentEquals(callId)) { - Timber.d("didChangeCallState(): callId=" + callId + - "; state=" + newState.toString()); - onChangeCallState(iConference, newState); - } - }); + Timber.d("didChangeCallState(): callId=" + callId + + "; state=" + newState.toString()); + if (!hasCreatedActiveCall()) return; + if (mActiveConference.mConference == null) return; + if (mActiveConference.mConference.callId().contentEquals(callId)) { + if (mHandler != null) mHandler.post( () -> { + onChangeCallState(newState); + }); + } } @Override public void didEndCall(NYNCall iConference) { - if (iConference != null && - hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(iConference.callId())) { - Timber.d("didEndCall(): callId=" + iConference.callId()); - onConferenceEnded(iConference.callId()); + if (iConference != null) { + String callId = iConference.callId(); + Timber.d("didEndCall(): callId=" + callId); + if (hasCreatedActiveCall() && mActiveConference.mConference != null + && mActiveConference.mConference.callId().contentEquals(callId)) { + onConferenceEnded(callId); + } } } @@ -855,73 +857,86 @@ public class ConferenceSDKModule extends BaseSDKModule { @Override public void onScreenShareStarted(NYNCall call) { + if (call == null) return; if (call != null) { - Timber.d("onScreenShareStarted(): callId=" + call.callId()); - onOwnScreenShareStarted(call); + String callId = call.callId(); + int pCount = call.getParticipantsCount(); + + Timber.d("onScreenShareStarted(): callId=" + callId); + onOwnScreenShareStarted(callId, pCount); } } @Override public void onScreenShareStopped(NYNCall call) { if (call != null) { + String callId = call.callId(); + int pCount = call.getParticipantsCount(); + Timber.d("onScreenShareStopped(): callId=" + call.callId()); - onOwnScreenShareStopped(call); + onOwnScreenShareStopped(callId, pCount); } } @Override public void onRemoteScreenShareTrackAdded(NYNCall call, String trackId, String participantId) { if (call != null) { - Timber.d("onRemoteScreenShareTrackAdded(): callId=" + call.callId() + + String callId = call.callId(); + Timber.d("onRemoteScreenShareTrackAdded(): callId=" + callId + "; trackId=" + trackId + "; participantId=" + participantId); - onRemoteScreenShareAdded(call.callId(), trackId, participantId); + onRemoteScreenShareAdded(callId, trackId, participantId); } } @Override public void onRemoteScreenShareTrackRemoved(NYNCall call, String trackId, String participantId) { if (call != null) { - Timber.d("onRemoteScreenShareTrackRemoved(): callId=" + call.callId() + + String callId = call.callId(); + Timber.d("onRemoteScreenShareTrackRemoved(): callId=" + callId + "; trackId=" + trackId + "; participantId=" + participantId); - onRemoteScreenShareRemoved(call.callId(), trackId, participantId); + onRemoteScreenShareRemoved(callId, trackId, participantId); } } @Override public void onRemoteVideoTrackAdded(NYNCall call, String trackId, String participantId) { if (call != null) { + String callId = call.callId(); boolean isConference = call.isConference(); - Timber.d("onRemoteVideoTrackAdded(): callId=" + call.callId() + + Timber.d("onRemoteVideoTrackAdded(): callId=" + callId + "; trackId=" + trackId + "; participantId=" + participantId + "; isConference=" + (isConference ? "true" : "false")); - onRemoteVideoAdded(call.callId(), trackId, participantId, isConference); + onRemoteVideoAdded(callId, trackId, participantId, isConference); } } @Override public void onRemoteVideoTrackRemoved(NYNCall call, String trackId, String participantId) { if (call != null) { + String callId = call.callId(); boolean isConference = call.isConference(); - Timber.d("onRemoteVideoTrackRemoved(): callId=" + call.callId() + + Timber.d("onRemoteVideoTrackRemoved(): callId=" + callId + "; trackId=" + trackId + "; participantId=" + participantId + "; isConference=" + (isConference ? "true" : "false")); - onRemoteVideoRemoved(call.callId(), trackId, participantId, isConference); + onRemoteVideoRemoved(callId, trackId, participantId, isConference); } } @Override public void onLocalVideoCapturerStarted(NYNCall call) { if (call != null) { - Timber.d("onLocalVideoCapturerStarted(): callId=" + call.callId()); - onLocalVideoStarted(call.callId()); + String callId = call.callId(); + Timber.d("onLocalVideoCapturerStarted(): callId=" + callId); + onLocalVideoStarted(callId); } } @Override public void onLocalVideoCapturerStopped(NYNCall call) { if (call != null) { - Timber.d("onLocalVideoCapturerStopped(): callId=" + call.callId()); - onLocalVideoStopped(call.callId()); + String callId = call.callId(); + Timber.d("onLocalVideoCapturerStopped(): callId=" + callId); + onLocalVideoStopped(callId); } } @@ -956,24 +971,28 @@ public class ConferenceSDKModule extends BaseSDKModule { @Override public void startScreenShareFailed(NYNCall call, int code) { if (call != null) { - Timber.d("startScreenShareFailed(): callId=" + call.callId()); - onStartCapturerFailed(call, code, false); + String callId = call.callId(); + Timber.d("startScreenShareFailed(): callId=" + callId); + onStartCapturerFailed(callId, code, false); } } @Override public void screenShareEnded(NYNCall call) { if (call != null) { - Timber.d("screenShareEnded(): callId=" + call.callId()); - onOwnScreenShareStopped(call); + String callId = call.callId(); + int pCount = call.getParticipantsCount(); + Timber.d("screenShareEnded(): callId=" + callId); + onOwnScreenShareStopped(callId, pCount); } } @Override public void startCameraFailed(NYNCall call, int code) { if (call != null) { - Timber.d("startCameraFailed(): callId=" + call.callId()); - onStartCapturerFailed(call, code, true); + String callId = call.callId(); + Timber.d("startCameraFailed(): callId=" + callId); + onStartCapturerFailed(callId, code, true); } } }; @@ -1220,10 +1239,10 @@ public class ConferenceSDKModule extends BaseSDKModule { } private synchronized void onActiveSpeakersUpdated(NYNCall call) { + if (call == null) return; if (!hasCreatedActiveCall()) return; if (mActiveConference.mConference == null) return; if (!mActiveConference.mConference.isConference()) return; - if (call == null) return; if (!mActiveConference.mConference.callId().contentEquals(call.callId())) return; String activeSpeakers = ""; ArrayList participantIds = new ArrayList<>(); @@ -1244,6 +1263,7 @@ public class ConferenceSDKModule extends BaseSDKModule { } private synchronized void onMuteStateChangedByHost(NYNCall call, boolean isMuted) { + if (call == null) return; if (!hasCreatedActiveCall()) return; if (mActiveConference.mConference == null) return; if (!mActiveConference.mConference.isConference()) return; @@ -1261,7 +1281,7 @@ public class ConferenceSDKModule extends BaseSDKModule { } } - private void onCallStateHandle(NYNCall call, boolean forceFireEvent) { + private void onCallStateHandle(NYNCall call, boolean isActiveCall, boolean forceFireEvent) { if (call != null) { String callId = call.callId(); String roomId = (call.isConference() ? call.getChatRoomId() : @@ -1279,8 +1299,7 @@ public class ConferenceSDKModule extends BaseSDKModule { } } if (!forceFireEvent) { - if ((hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(callId))) { + if (isActiveCall) { return; } else if (call.isOutgoing()) { return; @@ -1295,9 +1314,8 @@ public class ConferenceSDKModule extends BaseSDKModule { } } - private void onCallEndedHandle(NYNCall call, boolean forceFireEvent) { + private void onCallEndedHandle(NYNCall call, String callId, boolean forceFireEvent) { if (call != null) { - String callId = call.callId(); String roomId = (call.isConference() ? call.getChatRoomId() : (call.isOutgoing() ? call.callee() : call.caller())); if (mMyAcceptedElsewhereCalls.containsKey(callId)) { @@ -1319,7 +1337,9 @@ public class ConferenceSDKModule extends BaseSDKModule { } private synchronized void onSignalCallCompleted(NYNCall call) { - onCallEndedHandle(call, false); + if (call == null) return; + String callId = call.callId(); + onCallEndedHandle(call, callId, false); trackCallStatus(call, true); } @@ -1529,6 +1549,10 @@ public class ConferenceSDKModule extends BaseSDKModule { @Override public void stateChangedForCall(NYNCall call) { + if (call == null) { + Timber.d("stateChangedForCall(): with NULL call bject!!!"); + return; + } onStateChangedForCall(call); } @@ -1575,10 +1599,10 @@ public class ConferenceSDKModule extends BaseSDKModule { @Override public void receivedCompletedCall(NYNCall call) { - String callId = (call != null ? call.callId(): null); - Timber.d("receivedCompletedCall(): call with \'CallId\'=\'%s", callId); - onCallEndedHandle(call, true); - if (call != null && callId != null && + if (call == null) return; + String callId = call.callId(); + onCallEndedHandle(call, callId, true); + if (callId != null && hasCreatedActiveCall() && mActiveConference.mConference != null && mActiveConference.mConference.callId().contentEquals(callId)) { onConferenceEnded(callId); @@ -1847,12 +1871,10 @@ public class ConferenceSDKModule extends BaseSDKModule { } } - private void onOwnScreenShareStarted(NYNCall call) { - if (call != null && - hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(call.callId())) { - Timber.d("onOwnScreenShareStarted(): callId=" + call.callId()); - int pCount = call.getParticipantsCount(); + private void onOwnScreenShareStarted(String callId, int pCount) { + if (hasCreatedActiveCall() && mActiveConference.mConference != null + && mActiveConference.mConference.callId().contentEquals(callId)) { + Timber.d("onOwnScreenShareStarted(): callId=" + callId); if (pCount > 0) { Map values = new HashMap<>(); values.put("Screen Share", pCount); @@ -1860,16 +1882,14 @@ public class ConferenceSDKModule extends BaseSDKModule { } else { AppsTrackerUtils.getCleverTapInstance().trackEvent(getContext(), AppsTrackerConsts.ATEventScreenShareStarted); } - onScreenShareState(call.callId(), true); + onScreenShareState(callId, true); } } - private void onOwnScreenShareStopped(NYNCall call) { - if (call != null && - hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(call.callId())) { - Timber.d("onOwnScreenShareStopped(): callId=" + call.callId()); - int pCount = call.getParticipantsCount(); + private void onOwnScreenShareStopped(String callId, int pCount) { + if (hasCreatedActiveCall() && mActiveConference.mConference != null + && mActiveConference.mConference.callId().contentEquals(callId)) { + Timber.d("onOwnScreenShareStopped(): callId=" + callId); if (pCount > 0) { Map values = new HashMap<>(); values.put("Screen Share", pCount); @@ -1877,14 +1897,14 @@ public class ConferenceSDKModule extends BaseSDKModule { } else { AppsTrackerUtils.getCleverTapInstance().trackEvent(getContext(), AppsTrackerConsts.ATEventScreenShareDidEnd); } - onScreenShareState(call.callId(), false); + onScreenShareState(callId, false); } } - private void onStartCapturerFailed(NYNCall call, int code, boolean isCamera) { - if (call != null && + private void onStartCapturerFailed(String callId, int code, boolean isCamera) { + if (callId != null && hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(call.callId())) { + && mActiveConference.mConference.callId().contentEquals(callId)) { for (ConferenceSDKListener conferenceListener : mConferenceSDKListener) { if (code == -47) { if (isCamera) { @@ -1903,7 +1923,7 @@ public class ConferenceSDKModule extends BaseSDKModule { } } - private void onChangeCallState(NYNCall call, NYNCallState newState) { + private void onChangeCallState(NYNCallState newState) { for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) { conferenceSDKListener.onConferenceStateChanged(mActiveConference); } @@ -2462,11 +2482,8 @@ public class ConferenceSDKModule extends BaseSDKModule { mCallManager.hasRunningCallWithContact(roomId))); } - public NYNCall getConferenceCallWithRoom(String roomId) { - if (hasRunningCallWithRoom(roomId)) { - return mCallManager.getCallForRunningCallWithRoom(roomId); - } - return null; + public int getConferenceCallRoomMembers(String roomId) { + return getConferenceMembersCount(mCallManager.getCallForRunningCallWithRoom(roomId)); } public void createNewConference(String roomId, boolean isVideoConference) { @@ -2897,7 +2914,7 @@ public class ConferenceSDKModule extends BaseSDKModule { "; delayed=" + (delayed?"true": "false")); final String name = mActiveConference.getCallerName(); new Handler(Looper.getMainLooper()).post(() -> { - mNotificationHelper.createCallPushNotification(getContext(), name, callId, true, + mNotificationHelper.createCallPushNotification(getContext(), name, callId, true, true, mSettingNotifications, false); }); return true; @@ -3039,7 +3056,7 @@ public class ConferenceSDKModule extends BaseSDKModule { if (startActivity) { if (Consts.SHOW_INCOMING_CALLS_AS_POPUP_NOTIFICATIONS) { new Handler(Looper.getMainLooper()).post(() -> { - mNotificationHelper.createCallPushNotification(getContext(), mActiveConference.getCallerName(), callId, true, + mNotificationHelper.createCallPushNotification(getContext(), mActiveConference.getCallerName(), callId, true, true, mSettingNotifications, false); }); } else if (!startIncommingConferenceActivity(delayed, callId, null)) { @@ -3234,11 +3251,26 @@ public class ConferenceSDKModule extends BaseSDKModule { removeCallFromElsewhereCallsList(callId, true); } - private synchronized void onStateChangedForCall(NYNCall iConference) { - onCallStateHandle(iConference, false); - for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) { - conferenceSDKListener.onStateChangedForCall(iConference); + private int getConferenceMembersCount(NYNCall iConference) { + int membersCount = 1; + if (iConference != null && iConference.isConference()) { + membersCount = iConference.membersCount(); } + return membersCount; + } + + private synchronized void onStateChangedForCall(NYNCall iConference) { + String callId = iConference.callId(); + final int membersCount = getConferenceMembersCount(iConference); + boolean isActiveCall = ((hasCreatedActiveCall() && mActiveConference.mConference != null + && mActiveConference.mConference.callId().contentEquals(callId))); + onCallStateHandle(iConference, isActiveCall, false); + + mHandler.post(() -> { + for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) { + conferenceSDKListener.onStateChangedForCall(membersCount); + } + }); } private synchronized void onAcceptedCall(NYNCall call) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java index 3eb8178a7724c01d911f91dd2ca7e7c02e595f9a..90b7ab46dddfcd96c2564316a2c2252c95575afd 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java @@ -133,7 +133,6 @@ public class ConferenceService extends Service implements SensorEventListener { Intent launchIntent = MainActivity.getLaunchIntent(this, true); launchIntent.putExtra(IS_INTENT_FROM_CALL_SERVICE, true); - launchIntent.putExtra(IS_CALL_ACTIVE, true); Notification notification = mNotificationHelper.buildNotification(Push.CALLING, null, launchIntent, mDataManager.getSettingNotifications(), 0, contentText, true, title, true, diff --git a/app/src/main/java/com/nynja/mobile/communicator/injection/ApplicationComponent.java b/app/src/main/java/com/nynja/mobile/communicator/injection/ApplicationComponent.java index 3badf826f4c131e4002f9a40ebf14fa5888d1b8b..dd737951513b66b0b3b39049cb90f384305ea02b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/injection/ApplicationComponent.java +++ b/app/src/main/java/com/nynja/mobile/communicator/injection/ApplicationComponent.java @@ -12,6 +12,7 @@ import com.nynja.mobile.communicator.data.FireBaseMessagingService; import com.nynja.mobile.communicator.data.GooglePlacesService; import com.nynja.mobile.communicator.data.NynjaKeyboardManager; import com.nynja.mobile.communicator.data.RxBus; +import com.nynja.mobile.communicator.data.db.PreferenceHelper; import com.nynja.mobile.communicator.data.sdk.NynjaSDKManager; import com.nynja.mobile.communicator.data.sdk.calls.ConferenceService; import com.nynja.mobile.communicator.data.db.DbHelper; @@ -74,6 +75,8 @@ public interface ApplicationComponent { NotificationHelper notificationHelper(); + PreferenceHelper preferenceHelper(); + void inject(FireBaseInstanceIDService fbInstanceIDService); void inject(FireBaseMessagingService fbMessagingService); diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChatPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChatPresenter.java index 97f0ac33bea1f49f68400988a209e4e55dd2c7b5..53eda70485be8bec49e56e8f0ec2e0d9369c12d2 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChatPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChatPresenter.java @@ -125,9 +125,7 @@ import kotlin.jvm.Synchronized; import ru.terrakok.cicerone.result.ResultListener; import timber.log.Timber; -import static com.nynja.mobile.communicator.data.FragmentTransferObject.Type.OpenAudioConferenceCreate; import static com.nynja.mobile.communicator.data.FragmentTransferObject.Type.OpenChooseUsersAdminAddUsersEditMode; -import static com.nynja.mobile.communicator.data.FragmentTransferObject.Type.OpenVideoConferenceCreate; import static com.nynja.mobile.communicator.data.models.events.local.Event.Type; import static com.nynja.mobile.communicator.mvp.presenters.ChatLanguagePresenter.LANGUAGE_LIST_REQUEST_CODE; import static com.nynja.mobile.communicator.utils.Consts.LIMIT_MESSAGE_TO_CHAT; @@ -574,7 +572,7 @@ public class ChatPresenter extends BaseChatPresenter { processUnreadState(); } updateConferenceCallBanner(mDataManager.getConferenceSDK() - .getConferenceCallWithRoom(mRoom.id)); + .getConferenceCallRoomMembers(mRoom.id)); } }, Timber::e)); //Subscribe to Amazon event @@ -1003,15 +1001,17 @@ public class ChatPresenter extends BaseChatPresenter { } } - @Override public void onStateChangedForCall(NYNCall iConference) { - updateConferenceCallBanner(iConference); + @Override public void onStateChangedForCall(int membersCount) { + updateConferenceCallBanner(membersCount); } @Override public void onRoomCallStateChanges(String roomId, boolean active) { if (roomId == null) return; if (mRoom == null || StringUtils.isEmpty(mRoom.id)) return; if (!roomId.contentEquals(mRoom.id)) return; - updateConferenceCallBanner(mDataManager.getConferenceSDK().getConferenceCallWithRoom(mRoom.id), active); + + int membersCount = mDataManager.getConferenceSDK().getConferenceCallRoomMembers(mRoom.id); + updateConferenceCallBanner(membersCount, active); } @Override public void showRequestPermissionForReJoinCall(RejoinConferenceCallData rejoinData) { @@ -1023,21 +1023,17 @@ public class ChatPresenter extends BaseChatPresenter { mDataManager.getConferenceSDK().continueJoinConference(rejoinData); } - private void updateConferenceCallBanner(NYNCall iConference) { - updateConferenceCallBanner(iConference, false); + private void updateConferenceCallBanner(int membersCount) { + updateConferenceCallBanner(membersCount, false); } - private void updateConferenceCallBanner(NYNCall iConference, boolean activeConference) { + private void updateConferenceCallBanner(int membersCount, boolean activeConference) { if (mRoom == null) return; int total = mRoom.getRoomStatus()[0]; - int active = 1; - if (iConference != null && iConference.isConference()) { - active = iConference.membersCount(); - } boolean show = (!isConferenceActive() && (hasRunningCallForCurrentRoom() || activeConference) && (mRoom.isGroupOrCalllChat())); - getViewState().updateConferenceCallBanner(show, total, active); + getViewState().updateConferenceCallBanner(show, total, membersCount); } private void subscribeOnNewData() { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt index 78b044939568d790bff80f4b277c5f7104726863..f5738617aed7887aaa1730af067f0e1324efafd4 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt @@ -660,11 +660,9 @@ class MainActivityPresenter : ConferenceSDKPresenter() { viewState.onConferenceStateChanged(activeConferenceCall) } - override fun onStateChangedForCall(iConference: NYNCall?) { + override fun onStateChangedForCall(membersCount: Int) { if (attachedViews.size == 0) return - if (iConference != null) { - viewState.onStateChangedForCall(iConference.callId()) - } + viewState.onStateChangedForCall(membersCount) } override fun onAcceptedElsewhereConference(conferenceId: String) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/NotificationChannelsPresenter.kt b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/NotificationChannelsPresenter.kt index 41003eb4563b7685581a8fd63a40492dd2fd6d25..dd825fc3032b504c22913656ae7b76eebdc641f2 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/NotificationChannelsPresenter.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/NotificationChannelsPresenter.kt @@ -4,6 +4,7 @@ import com.arellomobile.mvp.InjectViewState import com.nynja.mobile.communicator.R import com.nynja.mobile.communicator.data.models.mqtt.Push import com.nynja.mobile.communicator.mvp.view.NotificationChannelsView +import com.nynja.mobile.communicator.utils.NotificationHelper import com.nynja.mobile.communicator.utils.navigation.navigators.HomeNavigator import com.nynja.mobile.communicator.utils.navigation.navigators.NynjaNavigator @@ -27,24 +28,23 @@ class NotificationChannelsPresenter : BasePresenter() } fun navigateToMainChannelSettings() { - openChannelSettings(Push.getChannelId(Push.DEFAULT_V_01)) + openChannelSettings(NotificationHelper.getChannelId(NotificationHelper.DEFAULT_V_01)) } fun navigateToMessageChannelSettings() { - openChannelSettings(Push.getChannelId(Push.MESSAGE_V_01)) + openChannelSettings(NotificationHelper.getChannelId(NotificationHelper.MESSAGE_V_01)) } fun navigateToFriendsChannelSettings() { - openChannelSettings(Push.getChannelId(Push.FRIEND_V_01)) + openChannelSettings(NotificationHelper.getChannelId(NotificationHelper.FRIEND_V_01)) } fun navigateToRequestsChannelSettings() { - openChannelSettings(Push.getChannelId(Push.REQUEST_FRIEND_V_01)) + openChannelSettings(NotificationHelper.getChannelId(NotificationHelper.REQUEST_FRIEND_V_01)) } fun navigateToConferenceChannelSettings() { - openChannelSettings(Push.getChannelId(Push.CONFERENCE_V_01) + - mDataManager.settingNotifications.ringerSoundIndex) + openChannelSettings(NotificationHelper.getdRingingChannelId(mDataManager.settingNotifications)) } fun openChannelSettings(channel: String) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ReportAProblemPresenter.kt b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ReportAProblemPresenter.kt index 1ce09b8b82fc8e0be2695db6fb1c6e6c1202ef4d..dcd6b221a71eee08b3e8e9ce52a8c2a4cf6a74fe 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ReportAProblemPresenter.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ReportAProblemPresenter.kt @@ -3,6 +3,7 @@ package com.nynja.mobile.communicator.mvp.presenters import android.os.Handler import com.arellomobile.mvp.InjectViewState import com.nynja.mobile.communicator.BuildConfig +import com.nynja.mobile.communicator.R import com.nynja.mobile.communicator.data.NynjaAwsManager import com.nynja.mobile.communicator.data.actions.CollectLatestLogFilesForReportAction import com.nynja.mobile.communicator.data.amazon.AwsTransfer @@ -17,6 +18,8 @@ import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers import timber.log.Timber import java.io.File +import android.content.Context + @InjectViewState class ReportAProblemPresenter : BasePresenter() { @@ -26,16 +29,17 @@ class ReportAProblemPresenter : BasePresenter() { return arrayOf(Io::class.java) } - fun sendClick(description: String?) { + fun sendClick(description: String?, context: Context) { if (StringUtils.isNotEmpty(description)) { Timber.e("\n=====================================================================\r\n" + "### Problem Description: \n" + description + "\n" + Utils.getApplicationInfo() + "\n=====================================================================\r\n") + send() + }else { + DialogFactory.showAlert(context, R.string.report_a_problem_empty_description) } - - send() } private fun send() { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/RingtonesPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/RingtonesPresenter.java index 6a79312a2d5fcde5af7b3e049d06df7c438f7d51..69c727206b6dbbb18374768f86557f3a43da0386 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/RingtonesPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/RingtonesPresenter.java @@ -3,10 +3,12 @@ package com.nynja.mobile.communicator.mvp.presenters; import com.arellomobile.mvp.InjectViewState; import com.nynja.mobile.communicator.data.models.RingtoneSound; import com.nynja.mobile.communicator.mvp.view.RingtonesView; +import com.nynja.mobile.communicator.utils.FileUtils; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; /** @@ -18,10 +20,10 @@ public class RingtonesPresenter extends BasePresenter { public void loadRingtoneSounds() { List ringtoneSounds = new ArrayList<>(); String currentSound = mDataManager.getSettingNotifications().getRingerSound(); - - List fileNames = mDataManager.getRingtonesFileNamesFromAssetsSubfolder(); - for (int i = 0; i < fileNames.size(); i++) { - ringtoneSounds.add(new RingtoneSound(fileNames.get(i), getRingtoneDisplayName(fileNames.get(i)), fileNames.get(i).equals(currentSound))); + HashMap fileNames = mDataManager.getRingtonesFileNamesFromAssetsSubfolder(); + for (String key : fileNames.keySet()) { + ringtoneSounds.add(new RingtoneSound(fileNames.get(key), key, + (currentSound != null && currentSound.equals(fileNames.get(key))))); } getViewState().setItems(ringtoneSounds); @@ -34,7 +36,7 @@ public class RingtonesPresenter extends BasePresenter { private String getRingtoneDisplayName(@NotNull String fileName) { int start = fileName.lastIndexOf("/") + 1; - int end = fileName.indexOf("."); + int end = fileName.indexOf(".", start); String result = fileName.substring(start, end); result = result.replaceAll("_", " "); diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/UserProfilePresenter.kt b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/UserProfilePresenter.kt index 519cc97715b1ceab400d38f971486a5c29bc4e12..d3b7fc96f52bdcb25fa26ad537bb44a0ad99bba8 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/UserProfilePresenter.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/UserProfilePresenter.kt @@ -308,7 +308,6 @@ class UserProfilePresenter : BasePresenter() { } models.add(VHModel(VHModel.PROFILE_CONTACT_ITEM, mAccount)) } - models.add(VHModel(VHModel.EMPTY, null)) return models } diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/view/MainActivityView.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/view/MainActivityView.java index 604679b0e03685794392496c507039d4fc1e317a..4cd06c29eabdc23c171fd8532c3211e1d30ccf1d 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/view/MainActivityView.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/view/MainActivityView.java @@ -41,7 +41,7 @@ public interface MainActivityView extends JoinGroupView { void onConferenceStateChanged(ActiveConferenceCall activeConferenceCall); - void onStateChangedForCall(String callId); + void onStateChangedForCall(int membersCount); void onAcceptedElsewhereConference(String conferenceId); diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java index e2388cf0ea57037cea0b6cf631461d8fc42ba300..62c3d104e670113399d7b9cdb05cfd98ae390742 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java @@ -317,6 +317,7 @@ public class MainActivity extends BaseActivity implements MainActivityView, //TODO need refactoring private void handleIntent() { if (getIntent() == null || getIntent().getExtras() == null) { + Timber.d("MainActivity::handleIntent(): intent OR iontent Extras is NULL!!!"); mPresenter.isComingFromLink(); return; } @@ -324,6 +325,7 @@ public class MainActivity extends BaseActivity implements MainActivityView, if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.getType() != null) { if (!mPresenter.isLogIn()) { mPresenter.navigateToWelcome(); + Timber.d("MainActivity::handleIntent(): NOT logged-in!!!"); return; } if (intent.getType() != null) { @@ -622,7 +624,7 @@ public class MainActivity extends BaseActivity implements MainActivityView, } @Override - public void onStateChangedForCall(String callId) { + public void onStateChangedForCall(int membersCount) { runOnUiThread(() -> { onCallsStateChanged(); }); diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/calls/IncomeCallActivity.java b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/calls/IncomeCallActivity.java index 4e1163dbd87b99f43427e85f2f8c76289b1f1cab..e9781ef2101b2b320ca35c6d31555f2a6dc75a17 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/calls/IncomeCallActivity.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/calls/IncomeCallActivity.java @@ -73,6 +73,7 @@ public class IncomeCallActivity extends BaseActivity implements IncomeCallView { } @Override protected void onCreate(Bundle savedInstanceState) { + Timber.d("IncomeCallActivity::onCreate()"); getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); super.onCreate(savedInstanceState); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); @@ -84,6 +85,7 @@ public class IncomeCallActivity extends BaseActivity implements IncomeCallView { @Override protected void onDestroy() { releaseWakeLockActivity(); + Timber.d("IncomeCallActivity::onDestroy()"); super.onDestroy(); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java index af28f6a56fc9f9f077a8fd803c0d2e2d2ccf51d0..07daac9674a1d5f3b165fcd8a4e9a0605fdc98b9 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java @@ -511,6 +511,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (!activeConferenceCall.mConference.isConference()) return; if (!activeConferenceCall.mConference.isRunning()) return; if (!activeConferenceCall.isVideoEnabled) return; + if (mConfParticipantsAdapter == null) return; if (StringUtils.isNotEmpty(trackId)) { Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderer()"); diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/contacts/SearchByNickFragment.kt b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/contacts/SearchByNickFragment.kt index 72056808d2c469eacec77ea86a97ed56f4e9efec..26f6ceda99ee32b55d5e64b95b6d85b3e53b0345 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/contacts/SearchByNickFragment.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/contacts/SearchByNickFragment.kt @@ -86,6 +86,10 @@ class SearchByNickFragment : BaseFragment(), SearchByNickView { .observeOn(AndroidSchedulers.mainThread()) .subscribe({ text -> validateUsername(text) }, { it -> Timber.e(it) })) + activity!!.let { + Utils.showKeyboard(it, mUsernameEt) + } + mUsernameEt.setOnEditorActionListener { v, _, _ -> validateUsername(v.text.toString()) false diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/profile/UserProfileFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/profile/UserProfileFragment.java index b8276ad6a8a6b72d7d33a8f8b1ed899250c15d3e..33d7891c3415ab83b2889a4eff76621ddd3dd83b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/profile/UserProfileFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/profile/UserProfileFragment.java @@ -136,6 +136,16 @@ public class UserProfileFragment extends BaseFragment implements UserProfileView float percentage = (float) Math.abs(offset) / (float) maxScroll; handleToolbarTitleVisibility(percentage); }); + + view.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { + int height = bottom - top; + int old_height = oldBottom - oldTop; + if (height != old_height) { + mAppBarLayout.setExpanded(true, true); + mNynjaHeaderView.setBackgroundAndDividerAlpha(0f); + } + }); + mNynjaHeaderView.setBackgroundAndDividerAlpha(0f); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/settings/ReportAProblemFragment.kt b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/settings/ReportAProblemFragment.kt index fd0580f2d91be3d036fb08a0585e6dad3a1718dd..c3e4aa125d08a2076201fe2d5af14e41db13c124 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/settings/ReportAProblemFragment.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/settings/ReportAProblemFragment.kt @@ -51,7 +51,7 @@ class ReportAProblemFragment : BaseFragment(), ReportAProblemView { @OnClick(R.id.f_report_a_problem_btn_send) fun onSaveButtonClick() { - mPresenter.sendClick(description.text.toString().trim()) + mPresenter.sendClick(description.text.toString().trim(), context) } override fun showInternetError() { diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/Consts.java b/app/src/main/java/com/nynja/mobile/communicator/utils/Consts.java index 8e208eef6ca97aec58df2b56077db59d195e56bc..f4a3e9eda834ac7a5a15c11df4e7781f947d85f1 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/Consts.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/Consts.java @@ -69,15 +69,24 @@ public interface Consts { } } + public static String[] mRingingSounds = { + "aqua.mp3", + "cheerful.mp3", + "discreet.mp3", + "important_stuff.mp3", + "nynja_ringing.mp3", + "optimistic.mp3", + "sunrise.mp3" + }; public enum NotificationRingingSounds { - SUNRUSE("sunrise", R.raw.sunrise), - AQUA("aqua", R.raw.aqua), - CHEERFUL("cheerful", R.raw.cheerful), - DISCREET("discreet", R.raw.discreet), - IMPORTAN_STUFF("important_stuff", R.raw.important_stuff), - NYNJA("nynja", R.raw.nynja_ringing), - OPTIMISTIC("optimistic", R.raw.optimistic); + AQUA(mRingingSounds[0], R.raw.aqua), + CHEERFUL(mRingingSounds[1], R.raw.cheerful), + DISCREET(mRingingSounds[2], R.raw.discreet), + IMPORTAN_STUFF(mRingingSounds[3], R.raw.important_stuff), + NYNJA(mRingingSounds[4], R.raw.nynja_ringing), + OPTIMISTIC(mRingingSounds[5], R.raw.optimistic), + SUNRUSE(mRingingSounds[6], R.raw.sunrise); private String name; private int id; diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/FileUtils.java b/app/src/main/java/com/nynja/mobile/communicator/utils/FileUtils.java index f2b0e2d2a7d23156868d8ac6083fc8fdcaa0df69..b8acaf60139f70496de02a24dbd873732aa9fcc6 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/FileUtils.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/FileUtils.java @@ -33,6 +33,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URI; import java.security.InvalidKeyException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -653,6 +654,26 @@ public class FileUtils { return list; } + public static HashMap getFileRingtonesNamesFromRaw(@NonNull Context context) { + String[] fileNames; + HashMap fileNamesWithFolderPrefix = new HashMap<>(); + String folder = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() + "/"; + try { + fileNames = Consts.mRingingSounds; + if (fileNames.length > 0) { + for (String file : fileNames) { + String name = FileUtils.getFileName(file); + String path = folder + Consts.NotificationRingingSounds.getIdByName(name); + fileNamesWithFolderPrefix.put(name, path); + } + } + } catch (Exception e) { + Timber.e(e); + } + + return fileNamesWithFolderPrefix; + } + public static List getFileNamesFromAssetsSubfolder(@NonNull Context context, @NonNull String folder) { String[] fileNames; List fileNamesWithFolderPrefix = new ArrayList<>(); @@ -853,12 +874,12 @@ public class FileUtils { @NonNull public static String getFileName(String fullPath) { final int lastIndexOf = fullPath.lastIndexOf('/'); - return lastIndexOf > 0 ? fullPath.substring(lastIndexOf+1) : fullPath; + return lastIndexOf >= 0 ? fullPath.substring(lastIndexOf+1) : fullPath; } @NonNull public static String getFileNameWithoutExt(String fullPath) { final int lastIndexOf = fullPath.lastIndexOf('/'); - String name = lastIndexOf > 0 ? fullPath.substring(lastIndexOf+1) : fullPath;; + String name = lastIndexOf >= 0 ? fullPath.substring(lastIndexOf+1) : fullPath;; int pos = name.lastIndexOf("."); if (pos > 0) { name = name.substring(0, pos); diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java index 4a258b57111148fa5d2755e52171283832a7737a..29ef622f6e22b07f7ade6a66f0ae53e57de3d663 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java @@ -23,9 +23,9 @@ import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; +import com.nynja.mobile.communicator.NynjaApp; import com.nynja.mobile.communicator.R; import com.nynja.mobile.communicator.data.DescManager; -import com.nynja.mobile.communicator.data.FireBaseMessagingService; import com.nynja.mobile.communicator.data.NotificationDismissReceiver; import com.nynja.mobile.communicator.data.audio.NynjaSoundManager; import com.nynja.mobile.communicator.data.models.PushNotificationCounter; @@ -57,6 +57,19 @@ import timber.log.Timber; @Singleton public class NotificationHelper extends ContextWrapper { + public final static String CONFERENCE = "media_playback_channel"; + public final static String UPLOADING = "uploading"; + public final static String DOWNLOADING = "downloading"; + + public final static String DEFAULT_V_01 = "DEFAULT_v_01"; + public final static String FRIEND_V_01 = "friend_v_01"; + public final static String MESSAGE_V_01 = "message_v_01"; + public final static String REQUEST_FRIEND_V_01 = "request_v_01"; + public final static String CONFERENCE_V_01 = "media_playback_channel_v_01"; + + public final static int CHANNEL_VERSION = 4; + public final static int CALLS_CHANNEL_VERSION = 1; + private final static String STICKER = "Sticker"; private final static int SUMMARY_ID = 0; @@ -71,6 +84,15 @@ public class NotificationHelper extends ContextWrapper { private NotificationManager mManager; private NynjaSoundManager mNynjaSoundManager; + public static String getChannelId(String channelPrefix) { + return channelPrefix + CHANNEL_VERSION; + } + + @NonNull + public static String getdRingingChannelId(SettingNotifications settingNotifications) { + return (CONFERENCE_V_01 + CALLS_CHANNEL_VERSION + settingNotifications.getRingerSoundIndex()); + } + @Inject public NotificationHelper(@ApplicationContext Context base, NynjaSoundManager soundManager) { super(base); mNynjaSoundManager = soundManager; @@ -82,11 +104,45 @@ public class NotificationHelper extends ContextWrapper { deleteChannelsIfExist(settingNotifications); } else if (settingNotifications.isLatestVersion()) { return; + } else if (settingNotifications.isUpgradeVersion()) { + onUpgrade(settingNotifications, + settingNotifications.getVersion(), + SettingNotifications.VERSION); + } else if (settingNotifications.isDowngradeVersion()) { + deleteChannelsIfExist(settingNotifications); } initChannels(settingNotifications); } + private void onUpgrade(SettingNotifications settingNotifications, + long oldVersion, long newVersion) { + if (oldVersion == 0) { + initChannels(settingNotifications); + } else { + for (long i = oldVersion; i < newVersion; i++) { + if (i == 5) { + upgrade_to_6(settingNotifications); + } + } + } + } + + @TargetApi(Build.VERSION_CODES.O) + private void upgrade_to_6(SettingNotifications settingNotifications) { + getManager().deleteNotificationChannel(CONFERENCE_V_01); + getManager().deleteNotificationChannel(CONFERENCE_V_01); + getManager().deleteNotificationChannel(getChannelId(CONFERENCE_V_01)); + // delete current ringing sound channels + for (long i = settingNotifications.getRingerSoundIndex(); i > 0; i--) { + String id = getChannelId(CONFERENCE_V_01)+i; + getManager().deleteNotificationChannel(id); + } + settingNotifications.setRingerSoundIndex(0L); + updateRingerSoundAndCreateChannel(settingNotifications); + NynjaApp.getComponent().preferenceHelper().setSettingNotifications(settingNotifications); + } + private void initChannels(SettingNotifications settingNotifications) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return; deleteChannelsIfExist(settingNotifications); @@ -95,36 +151,34 @@ public class NotificationHelper extends ContextWrapper { boolean isVibrationEnabled = settingNotifications.isInAppVibrate(); String alertSound = settingNotifications.getAlertSound(); - NotificationChannel channel = buildChannel(Push.getChannelId(Push.DEFAULT_V_01), + NotificationChannel channel = buildChannel(getChannelId(DEFAULT_V_01), NOTIFICATION_CHANNEL_DEFAULT, "Default channel", isSoundEnabled, isVibrationEnabled, null); channel.setShowBadge(true); getManager().createNotificationChannel(channel); - channel = buildChannel(Push.getChannelId(Push.MESSAGE_V_01), + channel = buildChannel(getChannelId(MESSAGE_V_01), NOTIFICATION_CHANNEL_MESSAGE, "Message channel", isSoundEnabled, isVibrationEnabled, null); channel.setShowBadge(true); getManager().createNotificationChannel(channel); - channel = buildChannel(Push.getChannelId(Push.FRIEND_V_01), + channel = buildChannel(getChannelId(FRIEND_V_01), NOTIFICATION_CHANNEL_FRIEND, "Friend channel", isSoundEnabled, isVibrationEnabled, null); channel.setShowBadge(true); getManager().createNotificationChannel(channel); - channel = buildChannel(Push.getChannelId(Push.REQUEST_FRIEND_V_01), + channel = buildChannel(getChannelId(REQUEST_FRIEND_V_01), NOTIFICATION_CHANNEL_REQUEST, "Request channel", isSoundEnabled, isVibrationEnabled, null); channel.setShowBadge(true); getManager().createNotificationChannel(channel); - buildRingingChannel(settingNotifications); - channel = buildChannel(Push.CALLING, NOTIFICATION_CHANNEL_CALLING, "Calling channel", false, false, @@ -133,14 +187,16 @@ public class NotificationHelper extends ContextWrapper { channel.setShowBadge(false); getManager().createNotificationChannel(channel); - channel = buildChannel(Push.getChannelId(Push.UPLOADING), + buildRingingChannel(settingNotifications); + + channel = buildChannel(getChannelId(UPLOADING), NOTIFICATION_CHANNEL_UPLOADING, "Uploding", false, false, null); channel.setShowBadge(false); getManager().createNotificationChannel(channel); - channel = buildChannel(Push.getChannelId(Push.DOWNLOADING), + channel = buildChannel(getChannelId(DOWNLOADING), NOTIFICATION_CHANNEL_DOWNLOADING, "Downloading", false, false, null); @@ -156,27 +212,27 @@ public class NotificationHelper extends ContextWrapper { getManager().deleteNotificationChannel(Push.MESSAGE); getManager().deleteNotificationChannel(Push.FRIEND); getManager().deleteNotificationChannel(Push.REQUEST_FRIEND); - getManager().deleteNotificationChannel(Push.CONFERENCE); getManager().deleteNotificationChannel(Push.CALLING); - getManager().deleteNotificationChannel(Push.UPLOADING); - getManager().deleteNotificationChannel(Push.DOWNLOADING); + getManager().deleteNotificationChannel(CONFERENCE); + getManager().deleteNotificationChannel(UPLOADING); + getManager().deleteNotificationChannel(DOWNLOADING); // channel version 1 ... - getManager().deleteNotificationChannel(Push.DEFAULT_V_01); - getManager().deleteNotificationChannel(Push.MESSAGE_V_01); - getManager().deleteNotificationChannel(Push.FRIEND_V_01); - getManager().deleteNotificationChannel(Push.REQUEST_FRIEND_V_01); - getManager().deleteNotificationChannel(Push.CONFERENCE_V_01); + getManager().deleteNotificationChannel(DEFAULT_V_01); + getManager().deleteNotificationChannel(MESSAGE_V_01); + getManager().deleteNotificationChannel(FRIEND_V_01); + getManager().deleteNotificationChannel(REQUEST_FRIEND_V_01); + getManager().deleteNotificationChannel(CONFERENCE_V_01); // latest channel version ... - getManager().deleteNotificationChannel(Push.getChannelId(Push.DEFAULT_V_01)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.MESSAGE_V_01)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.FRIEND_V_01)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.REQUEST_FRIEND_V_01)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.CONFERENCE_V_01)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.UPLOADING)); - getManager().deleteNotificationChannel(Push.getChannelId(Push.DOWNLOADING)); + getManager().deleteNotificationChannel(getChannelId(DEFAULT_V_01)); + getManager().deleteNotificationChannel(getChannelId(MESSAGE_V_01)); + getManager().deleteNotificationChannel(getChannelId(FRIEND_V_01)); + getManager().deleteNotificationChannel(getChannelId(REQUEST_FRIEND_V_01)); + getManager().deleteNotificationChannel(getChannelId(CONFERENCE_V_01)); + getManager().deleteNotificationChannel(getChannelId(UPLOADING)); + getManager().deleteNotificationChannel(getChannelId(DOWNLOADING)); // delete current ringing sound channel deleteRingingChannel(settingNotifications); @@ -222,23 +278,27 @@ public class NotificationHelper extends ContextWrapper { return channel; } + public void updateRingerSoundAndCreateChannel(SettingNotifications settingNotifications) { + Timber.d("updateRingerSoundAndCreateChannel()"); + deleteRingingChannel(settingNotifications); + settingNotifications.setRingerSoundIndex(settingNotifications.getRingerSoundIndex() + 1); + buildRingingChannel(settingNotifications); + } + public synchronized boolean ringerSoundChange(SettingNotifications settingNotifications, @NotNull String ringerSound) { String rSound = settingNotifications.getRingerSound(); + Timber.d("ringerSoundChange(): check 1: channel old_name=%s, new_name=%s", + rSound, ringerSound); if (!StringUtils.isEqual(ringerSound, rSound)) { - deleteRingingChannel(settingNotifications); + Timber.d("ringerSoundChange(): check 2: channel old_id=%d", + settingNotifications.getRingerSoundIndex()); settingNotifications.setRingerSound(ringerSound); - settingNotifications.setRingerSoundIndex(settingNotifications.getRingerSoundIndex() + 1); - buildRingingChannel(settingNotifications); + updateRingerSoundAndCreateChannel(settingNotifications); return true; } return false; } - @NonNull - private String getdRingingChannelId(SettingNotifications settingNotifications) { - return Push.getChannelId(Push.CONFERENCE_V_01)+settingNotifications.getRingerSoundIndex(); - } - @TargetApi(Build.VERSION_CODES.O) @NonNull private void buildRingingChannel(SettingNotifications settingNotifications) { @@ -250,6 +310,8 @@ public class NotificationHelper extends ContextWrapper { settingNotifications.isSound(), settingNotifications.isInAppVibrate(), notificationSoundUri); channel.setShowBadge(false); + Timber.d("buildRingingChannel(): new channel: channel id=%s, sound=%s", + id, notificationSoundUri.toString()); getManager().createNotificationChannel(channel); } @@ -272,13 +334,14 @@ public class NotificationHelper extends ContextWrapper { PendingIntent answerPendingIntent, PendingIntent rejectPendingIntent, boolean isMainActivityIsActive, + boolean sendNotification, SettingNotifications settingNotifications) { Uri notificationSoundUri = getCallNotificationSoundUri(settingNotifications.getRingerSound()); Timber.i("Push.CALLING: createCallPushNotification(): check XXX1"); Notification notification = buildCallNotification(context, intent, answerPendingIntent, rejectPendingIntent, - settingNotifications, from, notificationSoundUri); - if (isMainActivityIsActive) { + settingNotifications, from, isMainActivityIsActive, notificationSoundUri); + if (sendNotification) { Timber.i("Push.CALLING: createCallPushNotification(): check XXX2"); sendRingingNotify(notification, ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); Timber.i("Push.CALLING: createCallPushNotification(): check XXX3"); @@ -300,11 +363,12 @@ public class NotificationHelper extends ContextWrapper { public synchronized Notification createCallPushNotification(Context context, String from, String callId, boolean isMainActivityIsActive, + boolean sendNotification, SettingNotifications settingNotifications, boolean isPush) { Timber.i((isPush?"Push.CALLING": "Grpc.CALLING")+": createCallPushNotification() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); if (!NotificationManagerCompat.from(context).areNotificationsEnabled()) { - Timber.i((isPush?"Push.CALLING": "Grpc.CALLING")+": createCallPushNotification() Notifications are not enabledby the System !!!"); + Timber.i((isPush?"Push.CALLING": "Grpc.CALLING")+": createCallPushNotification() Notifications are not enabled by the System !!!"); return null; } Intent fullScreenIntent = MainActivity.getLaunchIntent(context, false, true); @@ -335,6 +399,7 @@ public class NotificationHelper extends ContextWrapper { answerPendingIntent, rejectPendingIntent, isMainActivityIsActive, + sendNotification, settingNotifications); } @@ -441,7 +506,7 @@ public class NotificationHelper extends ContextWrapper { if (Push.MESSAGE.equalsIgnoreCase(type)) { builder.setCategory(Notification.CATEGORY_MESSAGE); } - if (type != null && (type.contentEquals(Push.DOWNLOADING) || type.contentEquals(Push.UPLOADING))) { + if (type != null && (type.contentEquals(DOWNLOADING) || type.contentEquals(UPLOADING))) { builder.setProgress(10, 1, true); } } @@ -487,16 +552,17 @@ public class NotificationHelper extends ContextWrapper { @NonNull public synchronized Notification buildCallNotification(Context context, - Intent fullScreenIntent, - PendingIntent answerPendingIntent, - PendingIntent rejectPendingIntent, - SettingNotifications settingNotifications, - String from, - Uri notificationSoundUri) { + Intent fullScreenIntent, + PendingIntent answerPendingIntent, + PendingIntent rejectPendingIntent, + SettingNotifications settingNotifications, + String from, + boolean isMainActivityIsActive, + Uri notificationSoundUri) { String type = getdRingingChannelId(settingNotifications); boolean notificationsEnabled = areNotificationsEnabled(context, getManager(), type); if (!notificationsEnabled) { - Timber.w("buildCallNotification(): 'Calls' Notifications are DISABLED!!!!"); + Timber.w("buildCallNotification(): 'Calls' Notifications are DISABLED! Should be created later."); return null; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -523,6 +589,7 @@ public class NotificationHelper extends ContextWrapper { .setCategory(NotificationCompat.CATEGORY_CALL) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setOngoing(true) + .setGroupAlertBehavior(Notification.GROUP_ALERT_ALL) .addExtras(args); @@ -540,37 +607,52 @@ public class NotificationHelper extends ContextWrapper { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); - notificationBuilder.setPriority(NotificationManager.IMPORTANCE_MAX); - //notificationBuilder.setPriority(NotificationManager.IMPORTANCE_HIGH); } else { notificationBuilder.setContentIntent(fullScreenPendingIntent); } Notification notification = notificationBuilder.build(); - + Timber.d("ZZZZZZ 1"); if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)) { + Timber.d("ZZZZZZ 2"); if (settingNotifications.isSound() && mNynjaSoundManager.canPlayRingingSound()) { + Timber.d("ZZZZZZ 3"); notification.sound = notificationSoundUri; notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR); } else { + Timber.d("ZZZZZZ 4"); notification.sound = null; notification.defaults = 0; notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_NO_CLEAR); } + Timber.d("ZZZZZZ 5"); if (settingNotifications.isInAppVibrate() && mNynjaSoundManager.canVibrateWhenRingingSound()) { + Timber.d("ZZZZZZ 6"); notification.defaults |= Notification.DEFAULT_VIBRATE; } } else { if (settingNotifications.isSound() && mNynjaSoundManager.canPlayRingingSound()) { + Timber.d("ZZZZZZ 7: ntfn flag=%d, isSound=%s, canPlayRingingSound=%s", + notification.flags, settingNotifications.isSound()?"true":"false", + mNynjaSoundManager.canPlayRingingSound()?"true":"false"); notification.sound = notificationSoundUri; - notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_NO_CLEAR); + if (isMainActivityIsActive) { + notification.flags |= (Notification.FLAG_INSISTENT); + } + } else { + notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR); + } } else { + Timber.d("ZZZZZZ 8"); notification.sound = null; notification.defaults = 0; notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_NO_CLEAR); notification.defaults &= Notification.DEFAULT_VIBRATE; } } + Timber.d("ZZZZZZ 9"); notification.ledARGB = Color.RED; notification.ledOnMS = 300; notification.ledOffMS = 1000; @@ -659,22 +741,22 @@ public class NotificationHelper extends ContextWrapper { // method to handle the old clients with old setup for the notification channels private String handleChannelIdToLatestOne(String id) { - if (id == null) id = Push.getChannelId(Push.DEFAULT_V_01); + if (id == null) id = getChannelId(DEFAULT_V_01); switch (id) { case Push.MESSAGE: - return Push.getChannelId(Push.MESSAGE_V_01); + return getChannelId(MESSAGE_V_01); case Push.DEFAULT: - return Push.getChannelId(Push.DEFAULT_V_01); + return getChannelId(DEFAULT_V_01); case Push.FRIEND: - return Push.getChannelId(Push.FRIEND_V_01); + return getChannelId(FRIEND_V_01); case Push.REQUEST_FRIEND: - return Push.getChannelId(Push.REQUEST_FRIEND_V_01); - case Push.CONFERENCE: - return Push.getChannelId(Push.CONFERENCE_V_01); - case Push.DOWNLOADING: - return Push.getChannelId(Push.DOWNLOADING); - case Push.UPLOADING: - return Push.getChannelId(Push.UPLOADING); + return getChannelId(REQUEST_FRIEND_V_01); + case CONFERENCE: + return getChannelId(CONFERENCE_V_01); + case DOWNLOADING: + return getChannelId(DOWNLOADING); + case UPLOADING: + return getChannelId(UPLOADING); } return id; @@ -706,19 +788,11 @@ public class NotificationHelper extends ContextWrapper { } private String getCallNotificationSoundName( String soundName) { - soundName = soundName == null ? "" : soundName; - if (Consts.NOTIFICATION_SOUND_NO_SOUND.equalsIgnoreCase(soundName)) { - return null; + if (StringUtils.isEmpty(soundName)) { + String basePath = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/"; + return (basePath + R.raw.nynja_ringing); } - - String basePath = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/"; - String name = FileUtils.getFileNameWithoutExt(soundName); - String path = basePath + Consts.NotificationRingingSounds.getIdByName(name); - if (path == null) { - path = basePath + R.raw.nynja_ringing; - } - - return path; + return soundName; } public Uri getCallNotificationSoundUri( String soundName) { @@ -733,14 +807,15 @@ public class NotificationHelper extends ContextWrapper { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (!manager.areNotificationsEnabled()) { - Timber.i("Push.CALLING: areNotificationsEnabled(): check 2"); + Timber.i("Push.CALLING: areNotificationsEnabled(): check 2: Notifications are NOT enabled!"); return false; } if(StringUtils.isNotEmpty(channelId)) { - Timber.i("Push.CALLING: areNotificationsEnabled(): check 3"); + Timber.i("Push.CALLING: areNotificationsEnabled(): check 3: channelId=%s", channelId); NotificationChannel channel = manager.getNotificationChannel(channelId); if (channel != null) { - Timber.i("Push.CALLING: areNotificationsEnabled(): check 4"); + Timber.i("Push.CALLING: areNotificationsEnabled(): check 4: channel name=%s, id=%s, sound=%s ", + channel.getName(), channel.getId(), channel.getSound().toString()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { Timber.i("Push.CALLING: areNotificationsEnabled(): Importance=" + channel.getImportance()); //return channel.getImportance() >= NotificationManager.IMPORTANCE_HIGH; @@ -749,6 +824,7 @@ public class NotificationHelper extends ContextWrapper { } return channel.getImportance() != NotificationManager.IMPORTANCE_NONE; } + Timber.w("Push.CALLING: areNotificationsEnabled(): channel NOT FOUND OR NOT CREATEDT YET !!!!"); return true; } return false; diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml index 5141411fadc3ae70fe9e9633ea76be0b37771780..9252d87704a81d8d7f1bf43608b782611338dc98 100644 --- a/app/src/main/res/layout/activity_splash.xml +++ b/app/src/main/res/layout/activity_splash.xml @@ -6,10 +6,4 @@ android:layout_height="match_parent" tools:context="com.nynja.mobile.communicator.ui.activities.SplashActivity"> - - diff --git a/app/src/main/res/layout/fragment_user_profile.xml b/app/src/main/res/layout/fragment_user_profile.xml index 73b96e3c31337884d33aa3daade29d5b53110ff5..759a3b4a2863d8814f5821af76799c853c1104f9 100644 --- a/app/src/main/res/layout/fragment_user_profile.xml +++ b/app/src/main/res/layout/fragment_user_profile.xml @@ -44,7 +44,7 @@ Description* Ask Nynja a question Email Support + The description is empty.\nPlease provide a description for the problem. This conference has not been started yet. Please wait for the conference to be started.\nYou can return to home screen and you will be notified when the conference starts diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index cc31e962dc3c4e076481e5f05c6550eed4eb8247..da436efc6d8790170a0a9bb6a70697dcd9fd3585 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1219,6 +1219,7 @@ Description* Ask Nynja a question Email Support + The description is empty.\nPlease provide a description for the problem. This conference has not been started yet. Please wait for the conference to be started.\nYou can return to home screen and you will be notified when the conference starts diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 58547c814f7c170b6611b4ec5f369f9891531fa7..3c77b53ff4cda85ef29b0358d62fe627d26c0a58 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1219,6 +1219,7 @@ Description* Ask Nynja a question Email Support + The description is empty. Please provide a description for the problem. This conference has not been started yet. Please wait for the conference to be started.\nYou can return to home screen and you will be notified when the conference starts diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index 9c418979cbaff0edbafb963ee4765ae1392ce58c..35462a0ba4776aa82cf3eb6f572e77ac90d7d2fd 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -9,7 +9,7 @@ @color/colorPrimaryDark @color/colorAccent false - + @drawable/app_background @color/colorPrimary @null @style/Nynja.Dialog @@ -21,7 +21,6 @@ @transition/cheeses_enter @transition/cheeses_enter @android:color/transparent - @drawable/bg_splash