Skip to content

Commit a04822f

Browse files
fix: Status notification warning popup (#2126)
Refactoring of warning/confirmation popups. The status notification warning popup appears when the user launches the app after upgrading. The gradle file is changed for easier handling of '-PR', '-SNAPSHOT' and '-DEV' sync engine injections.
1 parent c36cde5 commit a04822f

File tree

14 files changed

+145
-168
lines changed

14 files changed

+145
-168
lines changed

app/build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ext {
2222
playServicesVersion = '15.0.1'
2323
audioVersion = System.getenv("AUDIO_VERSION") ?: '1.209.0@aar'
2424
stethoVersion = '1.5.0'
25-
zMessagingVersion = "141.0.2273"
25+
zMessagingVersion = "141.0.2275"
2626
paging_version = "1.0.0"
2727

2828
avsVersion = '4.9.170@aar'
@@ -36,7 +36,17 @@ ext {
3636
customAvsName = 'avs'
3737
customAvsGroup = 'com.wearezeta.avs'
3838

39-
zMessagingDevVersion = System.getenv("LOCAL_ZMESSAGING_VERSION") ?: ((System.getenv("ZMESSAGING_VERSION") ?: zMessagingVersion) + '-DEV')
39+
zMessagingDevVersion = ''
40+
if (System.getenv("LOCAL_ZMESSAGING_VERSION") != null) {
41+
zMessagingDevVersion = System.getenv("LOCAL_ZMESSAGING_VERSION")
42+
} else if (System.getenv("ZMESSAGING_VERSION") != null) {
43+
zMessagingDevVersion = System.getenv("ZMESSAGING_VERSION")
44+
} else if (zMessagingVersion.endsWith("-PR") || zMessagingVersion.endsWith("-SNAPSHOT")) {
45+
zMessagingDevVersion = zMessagingVersion
46+
} else {
47+
zMessagingDevVersion = zMessagingVersion + "-DEV"
48+
}
49+
4050
zMessagingReleaseVersion = System.getenv("LOCAL_ZMESSAGING_VERSION") ?: ((System.getenv("ZMESSAGING_VERSION") ?: zMessagingVersion) + '@aar')
4151

4252
}

app/src/main/scala/com/waz/zclient/MainActivity.scala

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,34 @@ class MainActivity extends BaseActivity
143143
}
144144

145145
for {
146-
Some(user) <- userAccountsController.currentUser.head
147-
teamName <- user.teamId.fold(Future.successful(Option.empty[Name]))(teamId => inject[TeamsStorage].get(teamId).map(_.map(_.name)))
146+
Some(self) <- userAccountsController.currentUser.head
147+
teamName <- self.teamId.fold(
148+
Future.successful(Option.empty[Name])
149+
)(teamId =>
150+
inject[TeamsStorage].get(teamId).map(_.map(_.name))
151+
)
148152
prefs <- userPreferences.head
149153
shouldWarn <- prefs(UserPreferences.ShouldWarnStatusNotifications).apply()
150154
avVisible <- usersController.availabilityVisible.head
155+
color <- accentColorController.accentColor.head
151156
} yield {
152-
(shouldWarn && avVisible, user.availability, teamName) match {
157+
(shouldWarn && avVisible, self.availability, teamName) match {
153158
case (true, Availability.Away, Some(name)) =>
154159
inject[MessageNotificationsController].showAppNotification(
155160
ResString(R.string.availability_notification_blocked_title, name.str),
156161
ResString(R.string.availability_notification_blocked)
157162
)
163+
showStatusNotificationWarning(self.availability, color).foreach { dontShowAgain =>
164+
if (dontShowAgain) prefs(UserPreferences.StatusNotificationsBitmask).mutate(_ | self.availability.bitmask)
165+
}
158166
case (true, Availability.Busy, Some(name)) =>
159167
inject[MessageNotificationsController].showAppNotification(
160168
ResString(R.string.availability_notification_changed_title, name.str),
161169
ResString(R.string.availability_notification_changed)
162170
)
171+
showStatusNotificationWarning(self.availability, color).foreach { dontShowAgain =>
172+
if (dontShowAgain) prefs(UserPreferences.StatusNotificationsBitmask).mutate(_ | self.availability.bitmask)
173+
}
163174
case _ =>
164175
}
165176
if (shouldWarn) prefs(UserPreferences.ShouldWarnStatusNotifications) := false

app/src/main/scala/com/waz/zclient/appentry/AppEntryActivity.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ class AppEntryActivity extends BaseActivity {
169169

170170
inject[AccentColorController].accentColor.head.flatMap { color =>
171171
showConfirmationDialog(
172-
title = ContextUtils.getString(R.string.custom_backend_dialog_confirmation_title),
173-
msg = ContextUtils.getString(R.string.custom_backend_dialog_confirmation_message, configUrl.toString),
172+
title = ContextUtils.getString(R.string.custom_backend_dialog_confirmation_title),
173+
msg = ContextUtils.getString(R.string.custom_backend_dialog_confirmation_message, configUrl.toString),
174174
positiveRes = R.string.custom_backend_dialog_connect,
175-
accentColor = Some(color)
175+
negativeRes = android.R.string.cancel,
176+
color = color
176177
)
177178
}.foreach {
178179
case false =>

app/src/main/scala/com/waz/zclient/appentry/SSOFragment.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ trait SSOFragment extends FragmentHelper with DerivedLogTag {
111111
inject[AccentColorController].accentColor.head.flatMap { color =>
112112
showConfirmationDialog(
113113
title = getString(R.string.sso_signin_error_title),
114-
msg = getString(R.string.sso_signin_error_try_again_message, error.code.toString),
115-
accentColor = Some(color)
114+
msg = getString(R.string.sso_signin_error_try_again_message, error.code.toString),
115+
color = color
116116
)
117117
}.map(_ => ())
118118
}

app/src/main/scala/com/waz/zclient/appentry/fragments/VerifyEmailWithCodeFragment.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ class VerifyEmailWithCodeFragment extends FragmentHelper with View.OnClickListen
185185
_ <- resp match {
186186
case Right(Some(am)) =>
187187
(if (!askMarketingConsent) Future.successful(Some(false)) else
188-
showConfirmationDialogWithNeutralButton(
189-
R.string.receive_news_and_offers_request_title,
190-
R.string.receive_news_and_offers_request_body,
191-
R.string.app_entry_dialog_privacy_policy,
188+
showConfirmationDialog(
189+
getString(R.string.receive_news_and_offers_request_title),
190+
getString(R.string.receive_news_and_offers_request_body),
192191
R.string.app_entry_dialog_accept,
193192
R.string.app_entry_dialog_no_thanks,
194-
Some(color)
193+
Some(R.string.app_entry_dialog_privacy_policy),
194+
color
195195
)).map { consent =>
196196
am.setMarketingConsent(consent)
197197
if (consent.isEmpty) inject[BrowserController].openPrivacyPolicy()

app/src/main/scala/com/waz/zclient/appentry/fragments/VerifyTeamEmailFragment.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ case class VerifyTeamEmailFragment() extends CreateTeamFragment{
7373
inject[GlobalModule].prefs(GlobalPreferences.ShowMarketingConsentDialog).apply().flatMap {
7474
case true =>
7575
inject[AccentColorController].accentColor.head.flatMap(color =>
76-
showConfirmationDialogWithNeutralButton(
77-
R.string.receive_news_and_offers_request_title,
78-
R.string.receive_news_and_offers_request_body,
79-
R.string.app_entry_dialog_privacy_policy,
76+
showConfirmationDialog(
77+
getString(R.string.receive_news_and_offers_request_title),
78+
getString(R.string.receive_news_and_offers_request_body),
8079
R.string.app_entry_dialog_accept,
8180
R.string.app_entry_dialog_not_now,
82-
Some(color)
81+
Some(R.string.app_entry_dialog_privacy_policy),
82+
color
8383
)
8484
)
8585
case false => Future.successful(Some(false))

app/src/main/scala/com/waz/zclient/calling/controllers/CallController.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.waz.api.Verification
2323
import com.waz.avs.VideoPreview
2424
import com.waz.content.GlobalPreferences
2525
import com.waz.log.BasicLogging.LogTag.DerivedLogTag
26-
import com.waz.model.{AssetId, LocalInstant, UserData, UserId}
26+
import com.waz.model._
2727
import com.waz.service.ZMessaging.clock
2828
import com.waz.service.call.Avs.VideoState
2929
import com.waz.service.call.{CallInfo, CallingService, GlobalCallingService}
@@ -183,6 +183,7 @@ class CallController(implicit inj: Injector, cxt: WireContext, eventContext: Eve
183183

184184

185185
val conversation = callingZms.zip(callConvId) flatMap { case (z, cId) => z.convsStorage.signal(cId) }
186+
val convMuteStatus = conversation.map(_.muted)
186187
val conversationName = conversation.map(_.displayName)
187188
val conversationMembers = for {
188189
zms <- callingZms
@@ -263,8 +264,18 @@ class CallController(implicit inj: Injector, cxt: WireContext, eventContext: Eve
263264
active
264265
}
265266

267+
private lazy val availability = for {
268+
zms <- callingZms
269+
users <- userStorage
270+
self <- users.signal(zms.selfUserId)
271+
} yield self.availability
272+
266273
onCallStarted.on(Threading.Ui) { _ =>
267-
CallingActivity.start(cxt)
274+
Signal(availability, convMuteStatus).head.foreach {
275+
case (Availability.Away, _) =>
276+
case (Availability.Busy, muted) if muted.isAllMuted =>
277+
case _ => CallingActivity.start(cxt)
278+
}
268279
}(EventContext.Global)
269280

270281
(lastCallAccountId zip isCallEstablished).onChanged.filter(_._2 == true) { case (userId, _) =>

app/src/main/scala/com/waz/zclient/calling/controllers/CallStartController.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class CallStartController(implicit inj: Injector, cxt: WireContext, ec: EventCon
9191
getString(R.string.calling_ongoing_call_title),
9292
getString(if (isJoiningCall) R.string.calling_ongoing_call_join_message else R.string.calling_ongoing_call_start_message),
9393
positiveRes = if (isJoiningCall) R.string.calling_ongoing_call_join_anyway else R.string.calling_ongoing_call_start_anyway,
94-
accentColor = Some(color)
94+
negativeRes = android.R.string.cancel,
95+
color = color
9596
).flatMap {
9697
case true => z.calling.endCall(c.convId, skipTerminating = true).map(_ => (true, true))
9798
case false => Future.successful((false, false))
@@ -110,7 +111,7 @@ class CallStartController(implicit inj: Injector, cxt: WireContext, ec: EventCon
110111
showConfirmationDialog(
111112
getString(R.string.calling__slow_connection__title),
112113
getString(R.string.calling__video_call__slow_connection__message),
113-
accentColor = Some(color)
114+
color = color
114115
)
115116
case _ => Future.successful(true)
116117
}
@@ -121,7 +122,8 @@ class CallStartController(implicit inj: Injector, cxt: WireContext, ec: EventCon
121122
getString(R.string.group_calling_title),
122123
getString(R.string.group_calling_message, members.size.toString),
123124
positiveRes = R.string.group_calling_confirm,
124-
accentColor = Some(color)
125+
negativeRes = android.R.string.cancel,
126+
color = color
125127
)
126128
else
127129
Future.successful(true)

app/src/main/scala/com/waz/zclient/common/controllers/SharingController.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ class SharingController(implicit injector: Injector, wContext: WireContext, even
5959
case TextContent(t) =>
6060
convsUi.sendTextMessages(convs, t, Nil, expiration)
6161
case uriContent =>
62-
convsUi.sendAssetMessages(convs, uriContent.uris.map(UriInput), (s: Long) => showWifiWarningDialog(s, Some(color))(activity), expiration)
62+
convsUi.sendAssetMessages(
63+
convs,
64+
uriContent.uris.map(UriInput),
65+
(s: Long) => showWifiWarningDialog(s, color)(dispatcher, activity),
66+
expiration
67+
)
6368
}
6469
}
6570
}

app/src/main/scala/com/waz/zclient/conversation/ConversationController.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class ConversationController(implicit injector: Injector, context: Context, ec:
186186
ui.sendAssetMessage(
187187
id,
188188
UriInput(uri),
189-
(s: Long) => showWifiWarningDialog(s, Some(color))(activity)
189+
(s: Long) => showWifiWarningDialog(s, color)(dispatcher, activity)
190190
)
191191
)
192192
)
@@ -199,7 +199,7 @@ class ConversationController(implicit injector: Injector, context: Context, ec:
199199
ui.sendMessage(
200200
id,
201201
asset,
202-
(s: Long) => showWifiWarningDialog(s, Some(color))(activity)
202+
(s: Long) => showWifiWarningDialog(s, color)(dispatcher, activity)
203203
)
204204
)
205205
)

0 commit comments

Comments
 (0)