Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit 0f14285

Browse files
authored
Merge branch 'beta' into patch-12
2 parents f5ad921 + 18b506f commit 0f14285

52 files changed

Lines changed: 598 additions & 204 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/chat/rocket/android/authentication/loginoptions/presentation/LoginOptionsView.kt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,26 @@ interface LoginOptionsView : LoadingView, MessageView {
113113

114114
// CAS account.
115115
/**
116-
* Shows the CAS button if the sign in/sign out via CAS protocol is enabled by the server
117-
* settings.
116+
* Adds a CAS button into accounts container.
118117
*
119-
* REMARK: We must set up the CAS button listener before showing it [setupCasButtonListener].
118+
* @param casUrl The CAS url.
119+
* @param casToken The CAS token
120+
* @param serviceName The SAML service name.
121+
* @param serviceNameColor The SAML service name color (just stylizing).
122+
* @param buttonColor The SAML button color (just stylizing).
120123
* @see [showAccountsView]
121124
*/
122-
fun enableLoginByCas()
123-
124-
/**
125-
* Setups the CAS button.
126-
*
127-
* @param casUrl The CAS URL to authenticate with.
128-
* @param casToken The requested token to be sent to the CAS server.
129-
*/
130-
fun setupCasButtonListener(casUrl: String, casToken: String)
125+
fun addCasButton(
126+
caslUrl: String,
127+
casToken: String,
128+
serviceName: String,
129+
serviceNameColor: Int,
130+
buttonColor: Int
131+
)
131132

132133
// Custom OAuth account.
133134
/**
134-
* Adds a custom OAuth button in the accounts container.
135+
* Adds a custom OAuth button into accounts container.
135136
*
136137
* @customOauthUrl The custom OAuth url.
137138
* @state A random string generated by the app, which you'll verify later
@@ -151,12 +152,13 @@ interface LoginOptionsView : LoadingView, MessageView {
151152

152153
// SAML account.
153154
/**
154-
* Adds a SAML button in the accounts container.
155+
* Adds a SAML button into accounts container.
155156
*
156-
* @samlUrl The SAML url.
157-
* @serviceName The SAML service name.
158-
* @serviceNameColor The SAML service name color (just stylizing).
159-
* @buttonColor The SAML button color (just stylizing).
157+
* @param samlUrl The SAML url.
158+
* @param samlToken The SAML token.
159+
* @param serviceName The SAML service name.
160+
* @param serviceNameColor The SAML service name color (just stylizing).
161+
* @param buttonColor The SAML button color (just stylizing).
160162
* @see [showAccountsView]
161163
*/
162164
fun addSamlButton(

app/src/main/java/chat/rocket/android/authentication/loginoptions/ui/LoginOptionsFragment.kt

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ private const val GITLAB_OAUTH_URL = "gitlab_oauth_url"
4040
private const val WORDPRESS_OAUTH_URL = "wordpress_oauth_url"
4141
private const val CAS_LOGIN_URL = "cas_login_url"
4242
private const val CAS_TOKEN = "cas_token"
43+
private const val CAS_SERVICE_NAME = "cas_service_name"
44+
private const val CAS_SERVICE_NAME_TEXT_COLOR = "cas_service_name_text_color"
45+
private const val CAS_SERVICE_BUTTON_COLOR = "cas_service_button_color"
4346
private const val CUSTOM_OAUTH_URL = "custom_oauth_url"
4447
private const val CUSTOM_OAUTH_SERVICE_NAME = "custom_oauth_service_name"
4548
private const val CUSTOM_OAUTH_SERVICE_NAME_TEXT_COLOR = "custom_oauth_service_name_text_color"
@@ -69,6 +72,9 @@ fun newInstance(
6972
wordpressOauthUrl: String? = null,
7073
casLoginUrl: String? = null,
7174
casToken: String? = null,
75+
casServiceName: String? = null,
76+
casServiceNameTextColor: Int = 0,
77+
casServiceButtonColor: Int = 0,
7278
customOauthUrl: String? = null,
7379
customOauthServiceName: String? = null,
7480
customOauthServiceNameTextColor: Int = 0,
@@ -95,6 +101,9 @@ fun newInstance(
95101
putString(WORDPRESS_OAUTH_URL, wordpressOauthUrl)
96102
putString(CAS_LOGIN_URL, casLoginUrl)
97103
putString(CAS_TOKEN, casToken)
104+
putString(CAS_SERVICE_NAME, casServiceName)
105+
putInt(CAS_SERVICE_NAME_TEXT_COLOR, casServiceNameTextColor)
106+
putInt(CAS_SERVICE_BUTTON_COLOR, casServiceButtonColor)
98107
putString(CUSTOM_OAUTH_URL, customOauthUrl)
99108
putString(CUSTOM_OAUTH_SERVICE_NAME, customOauthServiceName)
100109
putInt(CUSTOM_OAUTH_SERVICE_NAME_TEXT_COLOR, customOauthServiceNameTextColor)
@@ -127,6 +136,9 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
127136
private var wordpressOauthUrl: String? = null
128137
private var casLoginUrl: String? = null
129138
private var casToken: String? = null
139+
private var casServiceName: String? = null
140+
private var casServiceNameTextColor: Int = 0
141+
private var casServiceButtonColor: Int = 0
130142
private var customOauthUrl: String? = null
131143
private var customOauthServiceName: String? = null
132144
private var customOauthServiceTextColor: Int = 0
@@ -157,6 +169,9 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
157169
wordpressOauthUrl = bundle.getString(WORDPRESS_OAUTH_URL)
158170
casLoginUrl = bundle.getString(CAS_LOGIN_URL)
159171
casToken = bundle.getString(CAS_TOKEN)
172+
casServiceName = bundle.getString(CAS_SERVICE_NAME)
173+
casServiceNameTextColor = bundle.getInt(CAS_SERVICE_NAME_TEXT_COLOR)
174+
casServiceButtonColor = bundle.getInt(CAS_SERVICE_BUTTON_COLOR)
160175
customOauthUrl = bundle.getString(CUSTOM_OAUTH_URL)
161176
customOauthServiceName = bundle.getString(CUSTOM_OAUTH_SERVICE_NAME)
162177
customOauthServiceTextColor = bundle.getInt(CUSTOM_OAUTH_SERVICE_NAME_TEXT_COLOR)
@@ -200,6 +215,7 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
200215
setupCas()
201216
setupCustomOauth()
202217
setupSaml()
218+
setupAccountsView()
203219
setupLoginWithEmailView()
204220
setupCreateNewAccountView()
205221
}
@@ -235,19 +251,17 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
235251
setupWordpressButtonListener(wordpressOauthUrl.toString(), state.toString())
236252
enableLoginByWordpress()
237253
}
238-
239-
if (totalSocialAccountsEnabled > 0) {
240-
showAccountsView()
241-
if (totalSocialAccountsEnabled > 3) {
242-
setupExpandAccountsView()
243-
}
244-
}
245254
}
246255

247256
private fun setupCas() {
248-
if (casLoginUrl != null && casToken != null) {
249-
setupCasButtonListener(casLoginUrl.toString(), casToken.toString())
250-
enableLoginByCas()
257+
if (casLoginUrl != null && casToken != null && casServiceName != null) {
258+
addCasButton(
259+
casLoginUrl.toString(),
260+
casToken.toString(),
261+
casServiceName.toString(),
262+
casServiceNameTextColor,
263+
casServiceButtonColor
264+
)
251265
}
252266
}
253267

@@ -275,6 +289,15 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
275289
}
276290
}
277291

292+
private fun setupAccountsView() {
293+
if (totalSocialAccountsEnabled > 0) {
294+
showAccountsView()
295+
if (totalSocialAccountsEnabled > 3) {
296+
setupExpandAccountsView()
297+
}
298+
}
299+
}
300+
278301
private fun setupLoginWithEmailView() {
279302
if (isLoginFormEnabled) {
280303
showLoginWithEmailButton()
@@ -319,10 +342,17 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
319342
setupButtonListener(button_wordpress, wordpressUrl, state, REQUEST_CODE_FOR_OAUTH)
320343

321344
// CAS service account.
322-
override fun enableLoginByCas() = enableAccountButton(button_cas)
323-
324-
override fun setupCasButtonListener(casUrl: String, casToken: String) =
325-
setupButtonListener(button_cas, casUrl, casToken, REQUEST_CODE_FOR_CAS)
345+
override fun addCasButton(
346+
caslUrl: String,
347+
casToken: String,
348+
serviceName: String,
349+
serviceNameColor: Int,
350+
buttonColor: Int
351+
) {
352+
val button = getCustomServiceButton(serviceName, serviceNameColor, buttonColor)
353+
setupButtonListener(button, caslUrl, casToken, REQUEST_CODE_FOR_CAS)
354+
accounts_container.addView(button)
355+
}
326356

327357
// Custom OAuth account.
328358
override fun addCustomOauthButton(

app/src/main/java/chat/rocket/android/authentication/onboarding/presentation/OnBoardingPresenter.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class OnBoardingPresenter @Inject constructor(
4343
wordpressOauthUrl,
4444
casLoginUrl,
4545
casToken,
46+
casServiceName,
47+
casServiceNameTextColor,
48+
casServiceButtonColor,
4649
customOauthUrl,
4750
customOauthServiceName,
4851
customOauthServiceNameTextColor,
@@ -73,9 +76,8 @@ class OnBoardingPresenter @Inject constructor(
7376
view.showLoading()
7477
try {
7578
withContext(DefaultDispatcher) {
76-
refreshSettingsInteractor.refresh(serverUrl)
77-
7879
setupConnectionInfo(serverUrl)
80+
refreshSettingsInteractor.refresh(serverUrl)
7981

8082
// preparing next fragment before showing it
8183
checkEnabledAccounts(serverUrl)

app/src/main/java/chat/rocket/android/authentication/presentation/AuthenticationNavigator.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity) {
3030
wordpressOauthUrl: String? = null,
3131
casLoginUrl: String? = null,
3232
casToken: String? = null,
33+
casServiceName: String? = null,
34+
casServiceNameTextColor: Int = 0,
35+
casServiceButtonColor: Int = 0,
3336
customOauthUrl: String? = null,
3437
customOauthServiceName: String? = null,
3538
customOauthServiceNameTextColor: Int = 0,
@@ -59,6 +62,9 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity) {
5962
wordpressOauthUrl,
6063
casLoginUrl,
6164
casToken,
65+
casServiceName,
66+
casServiceNameTextColor,
67+
casServiceButtonColor,
6268
customOauthUrl,
6369
customOauthServiceName,
6470
customOauthServiceNameTextColor,

app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerPresenter.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class ServerPresenter @Inject constructor(
5353
wordpressOauthUrl,
5454
casLoginUrl,
5555
casToken,
56+
casServiceName,
57+
casServiceNameTextColor,
58+
casServiceButtonColor,
5659
customOauthUrl,
5760
customOauthServiceName,
5861
customOauthServiceNameTextColor,
@@ -92,8 +95,6 @@ class ServerPresenter @Inject constructor(
9295
withContext(DefaultDispatcher) {
9396
refreshSettingsInteractor.refresh(serverUrl)
9497

95-
setupConnectionInfo(serverUrl)
96-
9798
// preparing next fragment before showing it
9899
checkEnabledAccounts(serverUrl)
99100
checkIfLoginFormIsEnabled()

app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ class ChatRoomAdapter(
291291
R.id.action_menu_msg_react -> {
292292
actionSelectListener?.showReactions(id)
293293
}
294+
R.id.action_message_permalink -> {
295+
actionSelectListener?.copyPermalink(id)
296+
}
294297
else -> {
295298
TODO("Not implemented")
296299
}
@@ -310,5 +313,6 @@ class ChatRoomAdapter(
310313
fun showReactions(id: String)
311314
fun openDirectMessage(roomName: String, message: String)
312315
fun sendMessage(chatRoomId: String, text: String)
316+
fun copyPermalink(id: String)
313317
}
314-
}
318+
}

0 commit comments

Comments
 (0)