From 9df11d6873dd4809fee5c58099449f9c79d32027 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 May 2021 16:41:21 +0200 Subject: [PATCH 01/12] Configure towncrier tool --- tools/towncrier/template.md | 47 +++++++++++++++++++++++++++++++++++++ towncrier.toml | 7 ++++++ 2 files changed, 54 insertions(+) create mode 100644 tools/towncrier/template.md create mode 100644 towncrier.toml diff --git a/tools/towncrier/template.md b/tools/towncrier/template.md new file mode 100644 index 0000000000..fd160682b5 --- /dev/null +++ b/tools/towncrier/template.md @@ -0,0 +1,47 @@ +{% if top_line %} +{{ top_line }} +{{ top_underline * ((top_line)|length)}} +{% elif versiondata.name %} +{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.name + versiondata.version + versiondata.date)|length + 4)}} +{% else %} +{{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.version + versiondata.date)|length + 3)}} +{% endif %} +{% for section, _ in sections.items() %} +{% set underline = underlines[0] %}{% if section %}{{section}} +{{ underline * section|length }}{% set underline = underlines[1] %} +{% endif %} + +{% if sections[section] %} +{% for category, val in definitions.items() if category in sections[section]%} +{% if definitions[category]['name'] == "Features" %} +Features โœจ: +{% elif definitions[category]['name'] == "Bugfixes" %} +Bugfixes ๐Ÿ›: +{% elif definitions[category]['name'] == "Deprecations and Removals" %} +SDK API changes โš ๏ธ: +{% elif definitions[category]['name'] == "Improved Documentation" %} +Improved Documentation ๐Ÿ“š: +{% elif definitions[category]['name'] == "Misc" %} +Other changes: +{% else %} +{{ definitions[category]['name'] }} +{% endif %} +{% if definitions[category]['showcontent'] %} +{% for text, values in sections[section][category].items() %} + - {{ text }} ({{ values|join(', ') }}) +{% endfor %} +{% else %} + - {{ sections[section][category]['']|join(', ') }} +{% endif %} +{% if sections[section][category]|length == 0 %} +No significant changes. +{% else %} +{% endif %} + +{% endfor %} +{% else %} +No significant changes. +{% endif %} +{% endfor %} diff --git a/towncrier.toml b/towncrier.toml new file mode 100644 index 0000000000..09a927b77f --- /dev/null +++ b/towncrier.toml @@ -0,0 +1,7 @@ +[tool.towncrier] +directory = "newsfragment" +filename = "CHANGES.md" +name = "Changes in Element" +# Note: there is a bug, if I use title_format, the title is printed twice +# title_format = "Changes in Element {version} ({project_date})" +template="tools/towncrier/template.md" From 6240910b9063a91959ad694dfc337a1f4cf1aaee Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 May 2021 16:53:26 +0200 Subject: [PATCH 02/12] Configure towncrier tools - Update documentation --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CHANGES.md | 33 -------------------------------- CONTRIBUTING.md | 16 ++++++++++++++-- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 34d7b40a88..501aa6784a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,6 +5,6 @@ - [ ] Changes has been tested on an Android device or Android emulator with API 21 - [ ] UI change has been tested on both light and dark themes - [ ] Pull request is based on the develop branch -- [ ] Pull request updates [CHANGES.md](https://github.com/vector-im/element-android/blob/develop/CHANGES.md) +- [ ] Pull request includes a new file under ./newsfragment. See https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog - [ ] Pull request includes screenshots or videos if containing UI changes - [ ] Pull request includes a [sign off](https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.md#sign-off) diff --git a/CHANGES.md b/CHANGES.md index a28b84410e..97beae1dbe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1379,36 +1379,3 @@ Changes in RiotX 0.1.0 (2019-07-11) First release! Mode details here: https://medium.com/@RiotChat/introducing-the-riotx-beta-for-android-b17952e8f771 - - -======================================================= -+ TEMPLATE WHEN PREPARING A NEW RELEASE + -======================================================= - - -Changes in Element 1.1.X (2021-XX-XX) -=================================================== - -Features โœจ: - - - -Improvements ๐Ÿ™Œ: - - - -Bugfix ๐Ÿ›: - - - -Translations ๐Ÿ—ฃ: - - - -SDK API changes โš ๏ธ: - - - -Build ๐Ÿงฑ: - - - -Test: - - - -Other changes: - - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd32991051..399216ac4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,9 +51,21 @@ If an issue does not exist yet, it may be relevant to open a new issue and let u This project is full Kotlin. Please do not write Java classes. -### CHANGES.md +### Changelog -Please add a line to the top of the file `CHANGES.md` describing your change. +Please create at least one file under ./newsfragment containing details about your change. Towncrier will be used when preparing the release. + +Towncrier says to use the PR number for the filename, but the issue number is also fine. + +Supported filename extensions are: + +- ``.feature``: Signifying a new feature in Element Android or in the Matrix SDK. +- ``.bugfix``: Signifying a bug fix. +- ``.doc``: Signifying a documentation improvement. +- ``.removal``: Signifying a deprecation or removal of public API. Can be used to notifying about API change in the Matrix SDK +- ``.misc``: A ticket has been closed, but it is not of interest to users. + +See https://github.com/twisted/towncrier#news-fragments if you need more details. ### Code quality From 86a861b77930d2291d2d6c3fd875986c4b3f8a55 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 May 2021 16:54:41 +0200 Subject: [PATCH 03/12] Configure towncrier tools - start using it! --- newsfragment/3293.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragment/3293.misc diff --git a/newsfragment/3293.misc b/newsfragment/3293.misc new file mode 100644 index 0000000000..66de1440e7 --- /dev/null +++ b/newsfragment/3293.misc @@ -0,0 +1 @@ +Setup towncrier tool \ No newline at end of file From 4c24fe815cb3e6c0e8db2592930dbea2b3ebc501 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 May 2021 16:55:30 +0200 Subject: [PATCH 04/12] Improve doc --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 399216ac4f..4b61777d3f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ Supported filename extensions are: - ``.bugfix``: Signifying a bug fix. - ``.doc``: Signifying a documentation improvement. - ``.removal``: Signifying a deprecation or removal of public API. Can be used to notifying about API change in the Matrix SDK -- ``.misc``: A ticket has been closed, but it is not of interest to users. +- ``.misc``: A ticket has been closed, but it is not of interest to users. Note that in this case, the content of the file will not be output, but just the issue/PR number. See https://github.com/twisted/towncrier#news-fragments if you need more details. From 2462c871b29e7b3b1b2b65f3cbb8bde32c59697e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 20 May 2021 17:14:35 +0200 Subject: [PATCH 05/12] Update the CI tool. --- tools/travis/check_pr.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/travis/check_pr.sh b/tools/travis/check_pr.sh index 4c0d9611f0..b797244e55 100755 --- a/tools/travis/check_pr.sh +++ b/tools/travis/check_pr.sh @@ -23,7 +23,7 @@ branch=${TRAVIS_BRANCH} # If not on develop, exit, else we cannot get the list of modified files # It is ok to check only when on develop branch if [[ "${branch}" -eq 'develop' ]]; then - echo "Check that the file 'CHANGES.md' has been modified" + echo "Check that a file has been added to /newsfragment" else echo "Not on develop branch" exit 0 @@ -37,9 +37,9 @@ listOfModifiedFiles=`git diff --name-only HEAD ${branch}` # echo ${listOfModifiedFiles} -if [[ ${listOfModifiedFiles} = *"CHANGES.md"* ]]; then - echo "CHANGES.md has been modified!" +if [[ ${listOfModifiedFiles} = *"newsfragment"* ]]; then + echo "A file has been added to /newsfragment!" else - echo "โŒ Please add a line describing your change in CHANGES.md" + echo "โŒ Please add a file describing your changes in /newsfragment. See https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog" exit 1 fi From 0d0b6a88100fb9d10fc878900332067e7eec2305 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 14 May 2021 13:10:13 +0200 Subject: [PATCH 06/12] Fix empty states for spaces --- .../ui/list/GenericEmptyWithActionItem.kt | 92 +++++++++++++++++++ .../explore/SpaceDirectoryController.kt | 24 ++++- .../spaces/explore/SpaceDirectoryFragment.kt | 45 +++++++++ .../spaces/explore/SpaceDirectoryState.kt | 3 +- .../spaces/explore/SpaceDirectoryViewModel.kt | 20 ++++ .../manage/SpaceManageRoomsController.kt | 35 ++++--- .../main/res/drawable/ic_empty_icon_room.xml | 13 +++ .../layout/fragment_room_directory_picker.xml | 2 +- .../res/layout/item_generic_empty_state.xml | 70 ++++++++++++++ .../main/res/menu/menu_space_directory.xml | 15 +++ vector/src/main/res/values/strings.xml | 8 +- 11 files changed, 308 insertions(+), 19 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/core/ui/list/GenericEmptyWithActionItem.kt create mode 100644 vector/src/main/res/drawable/ic_empty_icon_room.xml create mode 100644 vector/src/main/res/layout/item_generic_empty_state.xml create mode 100644 vector/src/main/res/menu/menu_space_directory.xml diff --git a/vector/src/main/java/im/vector/app/core/ui/list/GenericEmptyWithActionItem.kt b/vector/src/main/java/im/vector/app/core/ui/list/GenericEmptyWithActionItem.kt new file mode 100644 index 0000000000..f8eb968268 --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/ui/list/GenericEmptyWithActionItem.kt @@ -0,0 +1,92 @@ +/* + * 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.app.core.ui.list + +import android.content.res.ColorStateList +import android.view.View +import android.widget.Button +import android.widget.ImageView +import android.widget.TextView +import androidx.annotation.ColorInt +import androidx.annotation.DrawableRes +import androidx.core.view.isVisible +import androidx.core.widget.ImageViewCompat +import com.airbnb.epoxy.EpoxyAttribute +import com.airbnb.epoxy.EpoxyModelClass +import im.vector.app.R +import im.vector.app.core.epoxy.VectorEpoxyHolder +import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.extensions.setTextOrHide + +/** + * A generic list item to display when there is no results, with an optional CTA + */ +@EpoxyModelClass(layout = R.layout.item_generic_empty_state) +abstract class GenericEmptyWithActionItem : VectorEpoxyModel() { + + class Action(var title: String) { + var perform: Runnable? = null + } + + @EpoxyAttribute + var title: CharSequence? = null + + @EpoxyAttribute + var description: CharSequence? = null + + @EpoxyAttribute + @DrawableRes + var iconRes: Int = -1 + + @EpoxyAttribute + @ColorInt + var iconTint: Int? = null + + @EpoxyAttribute + var buttonAction: Action? = null + + override fun bind(holder: Holder) { + super.bind(holder) + + holder.titleText.setTextOrHide(title) + holder.descriptionText.setTextOrHide(description) + + if (iconRes != -1) { + holder.imageView.setImageResource(iconRes) + holder.imageView.isVisible = true + if (iconTint != null) { + ImageViewCompat.setImageTintList(holder.imageView, ColorStateList.valueOf(iconTint!!)) + } else { + ImageViewCompat.setImageTintList(holder.imageView, null) + } + } else { + holder.imageView.isVisible = false + } + + holder.actionButton.setTextOrHide(buttonAction?.title) + holder.actionButton.setOnClickListener { + buttonAction?.perform?.run() + } + } + + class Holder : VectorEpoxyHolder() { + val root by bind(R.id.item_generic_root) + val titleText by bind(R.id.emptyItemTitleView) + val descriptionText by bind(R.id.emptyItemMessageView) + val imageView by bind(R.id.emptyItemImageView) + val actionButton by bind