diff --git a/vector/sampledata/matrix.json b/vector/sampledata/matrix.json new file mode 100644 index 00000000..5a806c87 --- /dev/null +++ b/vector/sampledata/matrix.json @@ -0,0 +1,29 @@ +{ + "data": [ + { + "displayName": "benoit", + "mxid": "@benoit:matrix.org", + "message": "Hello!" + }, + { + "displayName": "ganfra", + "mxid": "@ganfra:matrix.org", + "message": "How are you?" + }, + { + "displayName": "Manu", + "mxid": "@manu:matrix.org", + "message": "Great weather today!" + }, + { + "displayName": "Giom", + "mxid": "@giom:matrix.org", + "message": "Let's do a picnic" + }, + { + "displayName": "Nad", + "mxid": "@nadonomy:matrix.org", + "message": "Yes, great idea" + } + ] +} diff --git a/vector/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt b/vector/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt new file mode 100644 index 00000000..3ecc707d --- /dev/null +++ b/vector/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotredesign.core.platform + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.Checkable +import androidx.constraintlayout.widget.ConstraintLayout + +class CheckableConstraintLayout : ConstraintLayout, Checkable { + + private var mChecked = false + + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) + + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + + override fun isChecked(): Boolean { + return mChecked + } + + override fun setChecked(b: Boolean) { + if (b != mChecked) { + mChecked = b + refreshDrawableState() + } + } + + override fun toggle() { + isChecked = !mChecked + } + + public override fun onCreateDrawableState(extraSpace: Int): IntArray { + val drawableState = super.onCreateDrawableState(extraSpace + 1) + if (isChecked) { + View.mergeDrawableStates(drawableState, CHECKED_STATE_SET) + } + return drawableState + } + + companion object { + private val CHECKED_STATE_SET = intArrayOf(android.R.attr.state_checked) + } +} \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupListFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupListFragment.kt index 8970935e..ba65cf72 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupListFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupListFragment.kt @@ -25,12 +25,9 @@ import im.vector.riotredesign.R import im.vector.riotredesign.core.extensions.observeEvent import im.vector.riotredesign.core.platform.StateView import im.vector.riotredesign.core.platform.VectorBaseFragment -import im.vector.riotredesign.features.home.HomeModule import im.vector.riotredesign.features.home.HomeNavigator import kotlinx.android.synthetic.main.fragment_group_list.* import org.koin.android.ext.android.inject -import org.koin.android.scope.ext.android.bindScope -import org.koin.android.scope.ext.android.getOrCreateScope class GroupListFragment : VectorBaseFragment(), GroupSummaryController.Callback { diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupSummaryItem.kt b/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupSummaryItem.kt index b9afe738..16749849 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupSummaryItem.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/group/GroupSummaryItem.kt @@ -23,7 +23,7 @@ import com.airbnb.epoxy.EpoxyModelClass import im.vector.riotredesign.R import im.vector.riotredesign.core.epoxy.VectorEpoxyHolder import im.vector.riotredesign.core.epoxy.VectorEpoxyModel -import im.vector.riotredesign.core.platform.CheckableFrameLayout +import im.vector.riotredesign.core.platform.CheckableConstraintLayout import im.vector.riotredesign.features.home.AvatarRenderer @EpoxyModelClass(layout = R.layout.item_group) @@ -46,7 +46,7 @@ abstract class GroupSummaryItem : VectorEpoxyModel() { class Holder : VectorEpoxyHolder() { val avatarImageView by bind(R.id.groupAvatarImageView) val groupNameView by bind(R.id.groupNameView) - val rootView by bind(R.id.itemGroupLayout) + val rootView by bind(R.id.itemGroupLayout) } } \ No newline at end of file diff --git a/vector/src/main/res/layout/fragment_home_drawer.xml b/vector/src/main/res/layout/fragment_home_drawer.xml index 00371513..e0a4b60a 100644 --- a/vector/src/main/res/layout/fragment_home_drawer.xml +++ b/vector/src/main/res/layout/fragment_home_drawer.xml @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" - android:padding="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -21,6 +20,8 @@ android:id="@+id/homeDrawerHeaderAvatarView" android:layout_width="64dp" android:layout_height="64dp" + android:layout_marginStart="@dimen/layout_horizontal_margin" + android:layout_marginLeft="@dimen/layout_horizontal_margin" android:layout_marginTop="24dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -30,33 +31,41 @@ android:id="@+id/homeDrawerUsernameView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" + android:layout_marginTop="24dp" android:textColor="@android:color/white" + android:textSize="15sp" app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView" app:layout_constraintTop_toBottomOf="@+id/homeDrawerHeaderAvatarView" - tools:text="@tools:sample/full_names" /> + tools:text="@sample/matrix.json/data/displayName" /> + tools:text="@sample/matrix.json/data/mxid" /> + + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> @@ -64,7 +73,7 @@ android:id="@+id/homeDrawerGroupListContainer" android:layout_width="0dp" android:layout_height="0dp" - android:background="@android:color/white" + android:background="#FAFAFA" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/vector/src/main/res/layout/item_group.xml b/vector/src/main/res/layout/item_group.xml index 35a98940..63177c1f 100644 --- a/vector/src/main/res/layout/item_group.xml +++ b/vector/src/main/res/layout/item_group.xml @@ -1,60 +1,65 @@ - - - + tools:background="#FAFAFA"> - + - + - + + - + - - - \ No newline at end of file + \ No newline at end of file