浏览代码

Theme ConversationInfoController

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Álvaro Brey 2 年之前
父节点
当前提交
b66ec4a150

+ 63 - 31
app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt

@@ -73,6 +73,7 @@ import com.nextcloud.talk.models.json.participants.Participant.ActorType.GROUPS
 import com.nextcloud.talk.models.json.participants.Participant.ActorType.USERS
 import com.nextcloud.talk.models.json.participants.Participant.ActorType.USERS
 import com.nextcloud.talk.models.json.participants.ParticipantsOverall
 import com.nextcloud.talk.models.json.participants.ParticipantsOverall
 import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
 import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
+import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.DateConstants
 import com.nextcloud.talk.utils.DateConstants
 import com.nextcloud.talk.utils.DateUtils
 import com.nextcloud.talk.utils.DateUtils
@@ -112,6 +113,9 @@ class ConversationInfoController(args: Bundle) :
     @Inject
     @Inject
     lateinit var eventBus: EventBus
     lateinit var eventBus: EventBus
 
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     private val conversationToken: String?
     private val conversationToken: String?
     private val conversationUser: User?
     private val conversationUser: User?
     private val hasAvatarSpacing: Boolean
     private val hasAvatarSpacing: Boolean
@@ -181,6 +185,34 @@ class ConversationInfoController(args: Bundle) :
         }
         }
 
 
         fetchRoomInfo()
         fetchRoomInfo()
+
+        themeCategories()
+        themeSwitchPreferences()
+    }
+
+    private fun themeSwitchPreferences() {
+        binding.run {
+            listOf(
+                binding.webinarInfoView.conversationInfoLobby,
+                binding.notificationSettingsView.callNotifications,
+                binding.notificationSettingsView.conversationInfoPriorityConversation
+            ).forEach(viewThemeUtils::colorSwitchPreference)
+        }
+    }
+
+    private fun themeCategories() {
+        binding.run {
+            listOf(
+                conversationInfoName,
+                conversationDescription,
+                otherRoomOptions,
+                participantsListCategory,
+                ownOptions,
+                categorySharedItems,
+                binding.webinarInfoView.conversationInfoWebinar,
+                binding.notificationSettingsView.notificationSettingsCategory
+            ).forEach(viewThemeUtils::colorPreferenceCategory)
+        }
     }
     }
 
 
     private fun showSharedItems() {
     private fun showSharedItems() {
@@ -299,7 +331,7 @@ class ConversationInfoController(args: Bundle) :
 
 
         val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
         val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
 
 
-        ncApi?.setLobbyForConversation(
+        ncApi.setLobbyForConversation(
             ApiUtils.getCredentials(conversationUser!!.username, conversationUser.token),
             ApiUtils.getCredentials(conversationUser!!.username, conversationUser.token),
             ApiUtils.getUrlForRoomWebinaryLobby(apiVersion, conversationUser.baseUrl, conversation!!.token),
             ApiUtils.getUrlForRoomWebinaryLobby(apiVersion, conversationUser.baseUrl, conversation!!.token),
             state,
             state,
@@ -343,7 +375,7 @@ class ConversationInfoController(args: Bundle) :
 
 
     override fun onDetach(view: View) {
     override fun onDetach(view: View) {
         super.onDetach(view)
         super.onDetach(view)
-        eventBus?.unregister(this)
+        eventBus.unregister(this)
     }
     }
 
 
     private fun showDeleteConversationDialog(savedInstanceState: Bundle?) {
     private fun showDeleteConversationDialog(savedInstanceState: Bundle?) {
@@ -352,11 +384,11 @@ class ConversationInfoController(args: Bundle) :
                 .setTopColorRes(R.color.nc_darkRed)
                 .setTopColorRes(R.color.nc_darkRed)
                 .setIcon(
                 .setIcon(
                     DisplayUtils.getTintedDrawable(
                     DisplayUtils.getTintedDrawable(
-                        context!!.resources,
+                        context.resources,
                         R.drawable.ic_delete_black_24dp, R.color.bg_default
                         R.drawable.ic_delete_black_24dp, R.color.bg_default
                     )
                     )
                 )
                 )
-                .setPositiveButtonColor(context!!.resources.getColor(R.color.nc_darkRed))
+                .setPositiveButtonColor(context.resources.getColor(R.color.nc_darkRed))
                 .setTitle(R.string.nc_delete_call)
                 .setTitle(R.string.nc_delete_call)
                 .setMessage(R.string.nc_delete_conversation_more)
                 .setMessage(R.string.nc_delete_conversation_more)
                 .setPositiveButton(R.string.nc_delete) { deleteConversation() }
                 .setPositiveButton(R.string.nc_delete) { deleteConversation() }
@@ -409,7 +441,7 @@ class ConversationInfoController(args: Bundle) :
             if (participant.sessionId != null) {
             if (participant.sessionId != null) {
                 userItem.isOnline = !participant.sessionId.equals("0")
                 userItem.isOnline = !participant.sessionId.equals("0")
             } else {
             } else {
-                userItem.isOnline = !participant.sessionIds!!.isEmpty()
+                userItem.isOnline = !participant.sessionIds.isEmpty()
             }
             }
 
 
             if (participant.calculatedActorType == USERS &&
             if (participant.calculatedActorType == USERS &&
@@ -453,7 +485,7 @@ class ConversationInfoController(args: Bundle) :
         val fieldMap = HashMap<String, Boolean>()
         val fieldMap = HashMap<String, Boolean>()
         fieldMap["includeStatus"] = true
         fieldMap["includeStatus"] = true
 
 
-        ncApi?.getPeersForCall(
+        ncApi.getPeersForCall(
             credentials,
             credentials,
             ApiUtils.getUrlForParticipants(
             ApiUtils.getUrlForParticipants(
                 apiVersion,
                 apiVersion,
@@ -504,7 +536,7 @@ class ConversationInfoController(args: Bundle) :
         bundle.putStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS, existingParticipantsId)
         bundle.putStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS, existingParticipantsId)
         bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
         bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
 
 
-        getRouter().pushController(
+        router.pushController(
             (
             (
                 RouterTransaction.with(
                 RouterTransaction.with(
                     ContactsController(bundle)
                     ContactsController(bundle)
@@ -537,11 +569,11 @@ class ConversationInfoController(args: Bundle) :
                 .setTopColorRes(R.color.nc_darkRed)
                 .setTopColorRes(R.color.nc_darkRed)
                 .setIcon(
                 .setIcon(
                     DisplayUtils.getTintedDrawable(
                     DisplayUtils.getTintedDrawable(
-                        context!!.resources,
+                        context.resources,
                         R.drawable.ic_delete_black_24dp, R.color.bg_default
                         R.drawable.ic_delete_black_24dp, R.color.bg_default
                     )
                     )
                 )
                 )
-                .setPositiveButtonColor(context!!.resources.getColor(R.color.nc_darkRed))
+                .setPositiveButtonColor(context.resources.getColor(R.color.nc_darkRed))
                 .setTitle(R.string.nc_clear_history)
                 .setTitle(R.string.nc_clear_history)
                 .setMessage(R.string.nc_clear_history_warning)
                 .setMessage(R.string.nc_clear_history_warning)
                 .setPositiveButton(R.string.nc_delete_all) { clearHistory() }
                 .setPositiveButton(R.string.nc_delete_all) { clearHistory() }
@@ -555,7 +587,7 @@ class ConversationInfoController(args: Bundle) :
     private fun clearHistory() {
     private fun clearHistory() {
         val apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
         val apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
 
 
-        ncApi?.clearChatHistory(
+        ncApi.clearChatHistory(
             credentials,
             credentials,
             ApiUtils.getUrlForChat(apiVersion, conversationUser!!.baseUrl, conversationToken)
             ApiUtils.getUrlForChat(apiVersion, conversationUser!!.baseUrl, conversationToken)
         )
         )
@@ -567,7 +599,7 @@ class ConversationInfoController(args: Bundle) :
                 }
                 }
 
 
                 override fun onNext(genericOverall: GenericOverall) {
                 override fun onNext(genericOverall: GenericOverall) {
-                    Toast.makeText(context, context?.getString(R.string.nc_clear_history_success), Toast.LENGTH_LONG)
+                    Toast.makeText(context, context.getString(R.string.nc_clear_history_success), Toast.LENGTH_LONG)
                         .show()
                         .show()
                 }
                 }
 
 
@@ -606,7 +638,7 @@ class ConversationInfoController(args: Bundle) :
             apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
             apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
         }
         }
 
 
-        ncApi?.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, conversationUser!!.baseUrl, conversationToken))
+        ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, conversationUser!!.baseUrl, conversationToken))
             ?.subscribeOn(Schedulers.io())
             ?.subscribeOn(Schedulers.io())
             ?.observeOn(AndroidSchedulers.mainThread())
             ?.observeOn(AndroidSchedulers.mainThread())
             ?.subscribe(object : Observer<RoomOverall> {
             ?.subscribe(object : Observer<RoomOverall> {
@@ -765,8 +797,8 @@ class ConversationInfoController(args: Bundle) :
             )
             )
             Conversation.ConversationType.ROOM_SYSTEM -> {
             Conversation.ConversationType.ROOM_SYSTEM -> {
                 val layers = arrayOfNulls<Drawable>(2)
                 val layers = arrayOfNulls<Drawable>(2)
-                layers[0] = ContextCompat.getDrawable(context!!, R.drawable.ic_launcher_background)
-                layers[1] = ContextCompat.getDrawable(context!!, R.drawable.ic_launcher_foreground)
+                layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
+                layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground)
                 val layerDrawable = LayerDrawable(layers)
                 val layerDrawable = LayerDrawable(layers)
                 binding.avatarImage.hierarchy.setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable))
                 binding.avatarImage.hierarchy.setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable))
             }
             }
@@ -800,7 +832,7 @@ class ConversationInfoController(args: Bundle) :
         if (participant.type == Participant.ParticipantType.MODERATOR ||
         if (participant.type == Participant.ParticipantType.MODERATOR ||
             participant.type == Participant.ParticipantType.GUEST_MODERATOR
             participant.type == Participant.ParticipantType.GUEST_MODERATOR
         ) {
         ) {
-            ncApi?.demoteAttendeeFromModerator(
+            ncApi.demoteAttendeeFromModerator(
                 credentials,
                 credentials,
                 ApiUtils.getUrlForRoomModerators(
                 ApiUtils.getUrlForRoomModerators(
                     apiVersion,
                     apiVersion,
@@ -815,7 +847,7 @@ class ConversationInfoController(args: Bundle) :
         } else if (participant.type == Participant.ParticipantType.USER ||
         } else if (participant.type == Participant.ParticipantType.USER ||
             participant.type == Participant.ParticipantType.GUEST
             participant.type == Participant.ParticipantType.GUEST
         ) {
         ) {
-            ncApi?.promoteAttendeeToModerator(
+            ncApi.promoteAttendeeToModerator(
                 credentials,
                 credentials,
                 ApiUtils.getUrlForRoomModerators(
                 ApiUtils.getUrlForRoomModerators(
                     apiVersion,
                     apiVersion,
@@ -851,7 +883,7 @@ class ConversationInfoController(args: Bundle) :
         }
         }
 
 
         if (participant.type == Participant.ParticipantType.MODERATOR) {
         if (participant.type == Participant.ParticipantType.MODERATOR) {
-            ncApi?.demoteModeratorToUser(
+            ncApi.demoteModeratorToUser(
                 credentials,
                 credentials,
                 ApiUtils.getUrlForRoomModerators(
                 ApiUtils.getUrlForRoomModerators(
                     apiVersion,
                     apiVersion,
@@ -864,7 +896,7 @@ class ConversationInfoController(args: Bundle) :
                 ?.observeOn(AndroidSchedulers.mainThread())
                 ?.observeOn(AndroidSchedulers.mainThread())
                 ?.subscribe(subscriber)
                 ?.subscribe(subscriber)
         } else if (participant.type == Participant.ParticipantType.USER) {
         } else if (participant.type == Participant.ParticipantType.USER) {
-            ncApi?.promoteUserToModerator(
+            ncApi.promoteUserToModerator(
                 credentials,
                 credentials,
                 ApiUtils.getUrlForRoomModerators(
                 ApiUtils.getUrlForRoomModerators(
                     apiVersion,
                     apiVersion,
@@ -881,7 +913,7 @@ class ConversationInfoController(args: Bundle) :
 
 
     fun removeAttendeeFromConversation(apiVersion: Int, participant: Participant) {
     fun removeAttendeeFromConversation(apiVersion: Int, participant: Participant) {
         if (apiVersion >= ApiUtils.APIv4) {
         if (apiVersion >= ApiUtils.APIv4) {
-            ncApi?.removeAttendeeFromConversation(
+            ncApi.removeAttendeeFromConversation(
                 credentials,
                 credentials,
                 ApiUtils.getUrlForAttendees(
                 ApiUtils.getUrlForAttendees(
                     apiVersion,
                     apiVersion,
@@ -914,7 +946,7 @@ class ConversationInfoController(args: Bundle) :
             if (participant.type == Participant.ParticipantType.GUEST ||
             if (participant.type == Participant.ParticipantType.GUEST ||
                 participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK
                 participant.type == Participant.ParticipantType.USER_FOLLOWING_LINK
             ) {
             ) {
-                ncApi?.removeParticipantFromConversation(
+                ncApi.removeParticipantFromConversation(
                     credentials,
                     credentials,
                     ApiUtils.getUrlForRemovingParticipantFromConversation(
                     ApiUtils.getUrlForRemovingParticipantFromConversation(
                         conversationUser!!.baseUrl,
                         conversationUser!!.baseUrl,
@@ -944,7 +976,7 @@ class ConversationInfoController(args: Bundle) :
                         }
                         }
                     })
                     })
             } else {
             } else {
-                ncApi?.removeParticipantFromConversation(
+                ncApi.removeParticipantFromConversation(
                     credentials,
                     credentials,
                     ApiUtils.getUrlForRemovingParticipantFromConversation(
                     ApiUtils.getUrlForRemovingParticipantFromConversation(
                         conversationUser!!.baseUrl,
                         conversationUser!!.baseUrl,
@@ -987,12 +1019,12 @@ class ConversationInfoController(args: Bundle) :
 
 
         val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
         val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
 
 
-        if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser!!.userId) {
+        if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser.userId) {
             if (participant.attendeePin?.isNotEmpty() == true) {
             if (participant.attendeePin?.isNotEmpty() == true) {
                 val items = mutableListOf(
                 val items = mutableListOf(
                     BasicListItemWithImage(
                     BasicListItemWithImage(
                         R.drawable.ic_lock_grey600_24px,
                         R.drawable.ic_lock_grey600_24px,
-                        context!!.getString(R.string.nc_attendee_pin, participant.attendeePin)
+                        context.getString(R.string.nc_attendee_pin, participant.attendeePin)
                     )
                     )
                 )
                 )
                 MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
                 MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
@@ -1018,7 +1050,7 @@ class ConversationInfoController(args: Bundle) :
             val items = mutableListOf(
             val items = mutableListOf(
                 BasicListItemWithImage(
                 BasicListItemWithImage(
                     R.drawable.ic_delete_grey600_24dp,
                     R.drawable.ic_delete_grey600_24dp,
-                    context!!.getString(R.string.nc_remove_group_and_members)
+                    context.getString(R.string.nc_remove_group_and_members)
                 )
                 )
             )
             )
             MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
             MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
@@ -1038,7 +1070,7 @@ class ConversationInfoController(args: Bundle) :
             val items = mutableListOf(
             val items = mutableListOf(
                 BasicListItemWithImage(
                 BasicListItemWithImage(
                     R.drawable.ic_delete_grey600_24dp,
                     R.drawable.ic_delete_grey600_24dp,
-                    context!!.getString(R.string.nc_remove_circle_and_members)
+                    context.getString(R.string.nc_remove_circle_and_members)
                 )
                 )
             )
             )
             MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
             MaterialDialog(activity!!, BottomSheet(WRAP_CONTENT)).show {
@@ -1057,19 +1089,19 @@ class ConversationInfoController(args: Bundle) :
         val items = mutableListOf(
         val items = mutableListOf(
             BasicListItemWithImage(
             BasicListItemWithImage(
                 R.drawable.ic_lock_grey600_24px,
                 R.drawable.ic_lock_grey600_24px,
-                context!!.getString(R.string.nc_attendee_pin, participant.attendeePin)
+                context.getString(R.string.nc_attendee_pin, participant.attendeePin)
             ),
             ),
             BasicListItemWithImage(
             BasicListItemWithImage(
                 R.drawable.ic_pencil_grey600_24dp,
                 R.drawable.ic_pencil_grey600_24dp,
-                context!!.getString(R.string.nc_promote)
+                context.getString(R.string.nc_promote)
             ),
             ),
             BasicListItemWithImage(
             BasicListItemWithImage(
                 R.drawable.ic_pencil_grey600_24dp,
                 R.drawable.ic_pencil_grey600_24dp,
-                context!!.getString(R.string.nc_demote)
+                context.getString(R.string.nc_demote)
             ),
             ),
             BasicListItemWithImage(
             BasicListItemWithImage(
                 R.drawable.ic_delete_grey600_24dp,
                 R.drawable.ic_delete_grey600_24dp,
-                context!!.getString(R.string.nc_remove_participant)
+                context.getString(R.string.nc_remove_participant)
             )
             )
         )
         )
 
 
@@ -1167,8 +1199,8 @@ class ConversationInfoController(args: Bundle) :
                 return 1
                 return 1
             }
             }
 
 
-            return left.model.displayName!!.toLowerCase(Locale.ROOT).compareTo(
-                right.model.displayName!!.toLowerCase(Locale.ROOT)
+            return left.model.displayName!!.lowercase(Locale.ROOT).compareTo(
+                right.model.displayName!!.lowercase(Locale.ROOT)
             )
             )
         }
         }
     }
     }

+ 2 - 0
app/src/main/res/layout/controller_conversation_info.xml

@@ -23,6 +23,7 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:apc="http://schemas.android.com/apk/res-auto"
     xmlns:apc="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
+    tools:background="@color/white"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
     android:orientation="vertical">
@@ -76,6 +77,7 @@
                         android:layout_width="@dimen/avatar_size_big"
                         android:layout_width="@dimen/avatar_size_big"
                         android:layout_height="@dimen/avatar_size_big"
                         android:layout_height="@dimen/avatar_size_big"
                         android:layout_centerHorizontal="true"
                         android:layout_centerHorizontal="true"
+                        tools:background="@color/hwSecurityRed"
                         apc:roundAsCircle="true" />
                         apc:roundAsCircle="true" />
 
 
                 </RelativeLayout>
                 </RelativeLayout>

+ 1 - 0
app/src/main/res/layout/notification_settings_item.xml

@@ -27,6 +27,7 @@
     android:layout_height="wrap_content">
     android:layout_height="wrap_content">
 
 
     <com.yarolegovich.mp.MaterialPreferenceCategory
     <com.yarolegovich.mp.MaterialPreferenceCategory
+        android:id="@+id/notification_settings_category"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
         android:animateLayoutChanges="true"
         android:animateLayoutChanges="true"