Skip to content

Commit

Permalink
Merge branch 'develop' into improve-preview-cards
Browse files Browse the repository at this point in the history
  • Loading branch information
connyduck committed Dec 17, 2024
2 parents 8f5b7b5 + 8937d0a commit 4b89789
Show file tree
Hide file tree
Showing 39 changed files with 767 additions and 242 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@

### Significant bug fixes

## v27.0

### New features and other improvements

- Tusky has been redesigned with Material 3 https://github.com/tuskyapp/Tusky/pull/4637 https://github.com/tuskyapp/Tusky/pull/4673
- Support for Notification Policies (Mastodon 4.3 feature) https://github.com/tuskyapp/Tusky/pull/4768
- Hashtags at the end of posts are now shown in a separate bar https://github.com/tuskyapp/Tusky/pull/4761
- Full support for folding devices https://github.com/tuskyapp/Tusky/pull/4689
- Improved post rendering in some edge cases https://github.com/tuskyapp/Tusky/pull/4650 https://github.com/tuskyapp/Tusky/pull/4672 https://github.com/tuskyapp/Tusky/pull/4723
- Descriptions can now be added to audio attachments https://github.com/tuskyapp/Tusky/pull/4711
- The screen keyboard now pops up automatically when opening a dialog that contains a textfield https://github.com/tuskyapp/Tusky/pull/4667

### Significant bug fixes

- fixes a bug where Tusky would drop your draft when switching apps https://github.com/tuskyapp/Tusky/pull/4685
- fixes a bug where Tusky would drop media that is being added to a post https://github.com/tuskyapp/Tusky/pull/4662

## v26.2

### Significant bug fixes
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
namespace "com.keylesspalace.tusky"
minSdk 24
targetSdk 34
versionCode 125
versionName "26.2"
versionCode 126
versionName "27.0 beta 1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,8 @@ class ComposeActivity :
)
)

var oneMediaWithoutDescription = false
for (media in viewModel.media.value) {
if (media.description.isNullOrEmpty()) {
oneMediaWithoutDescription = true
break
}
val oneMediaWithoutDescription = viewModel.media.value.any { media ->
media.description.isNullOrEmpty()
}
binding.descriptionMissingWarningButton.visibility = if (oneMediaWithoutDescription) View.VISIBLE else View.GONE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class CaptionDialog : DialogFragment() {
dialog?.apply {
window?.setLayout(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT
)
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}
Expand Down
55 changes: 42 additions & 13 deletions app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,64 @@ fun setClickableText(
trailingHashtagView == null || tags.isNullOrEmpty() -> Pair(spannableContent.length, emptyList())
else -> getTrailingHashtags(spannableContent)
}
var inlineHashtagSpanCount = 0
val inlineHashtags = mutableListOf<CharSequence>()

view.text = spannableContent.apply {
styleQuoteSpans(view)
getSpans(0, endOfContent, URLSpan::class.java).forEach { span ->
if (get(getSpanStart(span)) == '#') {
inlineHashtagSpanCount += 1
val start = getSpanStart(span)
if (get(start) == '#') {
inlineHashtags.add(subSequence(start + 1, getSpanEnd(span)))
}
setClickableText(span, this, mentions, tags, listener)
}
}.subSequence(0, endOfContent).trimEnd()

view.movementMethod = NoTrailingSpaceLinkMovementMethod

val showHashtagBar = (trailingHashtags.isNotEmpty() || inlineHashtagSpanCount != tags?.size)
val showHashtagBar = (trailingHashtags.isNotEmpty() || inlineHashtags.size != tags?.size)
// I don't _love_ setting the visibility here, but the alternative is to duplicate the logic in other places
trailingHashtagView?.visible(showHashtagBar)

if (showHashtagBar) {
trailingHashtagView?.apply {
text = SpannableStringBuilder().apply {
tags?.forEachIndexed { index, tag ->
val text = "#${tag.name}"
append(text, getCustomSpanForTag(text, tags, URLSpan(tag.url), listener), 0)
if (index != tags.lastIndex) {
append(" ")
}
}
}
text = buildTrailingHashtagText(
tags?.filterNot { tag -> inlineHashtags.any { it.contentEquals(tag.name, ignoreCase = true) } },
trailingHashtags,
listener,
)
}
}
}

/**
* Build a spanned string containing trailing and out-of-band hashtags for the trailing hashtag view
* @param tagsFromServer The list of hashtags from the server
* @param trailingHashtagsFromContent The list of trailing hashtags scraped from the post content
* @param listener to notify about particular spans that are clicked
*/
private fun buildTrailingHashtagText(tagsFromServer: List<HashTag>?, trailingHashtagsFromContent: List<HashTag>, listener: LinkListener): SpannableStringBuilder {
return SpannableStringBuilder().apply {
// we apply the tags scraped from the content first to preserve the casing
// (tags from the server are often downcased)
val additionalTags = tagsFromServer?.let {
it.filter { serverTag -> trailingHashtagsFromContent.none { serverTag.name.equals(it.name, ignoreCase = true) } }
} ?: emptyList()
appendTags(trailingHashtagsFromContent.plus(additionalTags), listener)
}
}

/**
* Append space-separated url spans for a list of hashtags
* @param tags The tags to append
* @param listener to notify about particular spans that are clicked
*/
private fun SpannableStringBuilder.appendTags(tags: List<HashTag>, listener: LinkListener) {
tags.forEachIndexed { index, tag ->
val text = "#${tag.name}"
append(text, getCustomSpanForTag(text, tags, URLSpan(tag.url), listener), 0)
if (index != tags.lastIndex) {
append(" ")
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/tab_indicator_bottom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="2dp"
android:right="2dp">
<shape
android:shape="rectangle">
<!-- Color is assigned programmatically with the value of "tabIndicatorColor". -->
<solid android:color="@android:color/white"/>
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
<size android:height="3dp"/>
</shape>
</item>
</layer-list>
3 changes: 2 additions & 1 deletion app/src/main/res/layout-sw640dp/fragment_view_thread.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/windowBackgroundColor">

<com.keylesspalace.tusky.view.TuskySwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_compose.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
android:layout_width="52dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:padding="0dp"
android:contentDescription="@string/description_post_language"
android:padding="0dp"
android:textColor="?android:attr/textColorTertiary"
android:textSize="?attr/status_text_large"
android:textStyle="bold"
Expand Down Expand Up @@ -67,10 +67,10 @@
android:layout_gravity="end"
android:contentDescription="@string/hint_media_description_missing"
android:padding="8dp"
app:srcCompat="@drawable/ic_missing_description_24dp"
app:tint="@color/tusky_orange_light"
app:tooltipText="@string/hint_media_description_missing"
android:visibility="invisible" />
app:icon="@drawable/ic_missing_description_24dp"
app:iconTint="@color/tusky_orange_light"
app:tooltipText="@string/hint_media_description_missing" />

</com.google.android.material.appbar.MaterialToolbar>

<androidx.core.widget.NestedScrollView
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
app:contentInsetStart="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:navigationContentDescription="@string/action_open_drawer">

Expand Down Expand Up @@ -78,8 +78,10 @@
style="@style/TuskyTabAppearance"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorSurface"
app:tabGravity="fill"
app:tabIndicatorGravity="top"
app:tabIndicator="@drawable/tab_indicator_bottom"
app:tabMode="scrollable"
app:tabPaddingTop="0dp" />

Expand Down
17 changes: 10 additions & 7 deletions app/src/main/res/layout/dialog_image_description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp">
android:layout_height="wrap_content"
android:minHeight="400dp"
android:orientation="vertical">

<com.ortiz.touchview.TouchImageView
android:id="@+id/imageDescriptionView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="?dialogPreferredPadding"
android:layout_marginTop="?dialogPreferredPadding"
android:layout_marginEnd="?dialogPreferredPadding"
android:layout_weight="1"
android:contentDescription="@string/post_media_image" />

<com.google.android.material.textfield.TextInputLayout
style="@style/TuskyTextInput"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginStart="?dialogPreferredPadding"
android:layout_marginEnd="?dialogPreferredPadding"
android:layout_marginTop="?dialogPreferredPadding"
android:layout_marginEnd="?dialogPreferredPadding"
android:layout_weight="1"
app:counterEnabled="false"
app:counterTextColor="?android:textColorTertiary"
app:hintEnabled="false">
Expand All @@ -31,9 +34,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
tools:hint="Description"
android:importantForAutofill="no"
android:inputType="textCapSentences|textMultiLine|textAutoCorrect" />
android:inputType="textCapSentences|textMultiLine|textAutoCorrect"
tools:hint="Description" />

</com.google.android.material.textfield.TextInputLayout>

Expand Down
Loading

0 comments on commit 4b89789

Please sign in to comment.