Loading app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ class ApiService { } if (body != null) { builder .addHeader("X-Message", message) .addHeader("X-Message", message.replace("\n", "\\n")) .put(body) } else { builder.put(message.toRequestBody()) Loading app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt +3 −3 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ class DetailAdapter(private val activity: Activity, private val repository: Repo private val tagsView: TextView = itemView.findViewById(R.id.detail_item_tags_text) private val menuButton: ImageButton = itemView.findViewById(R.id.detail_item_menu_button) private val attachmentImageView: ImageView = itemView.findViewById(R.id.detail_item_attachment_image) private val attachmentBoxView: View = itemView.findViewById(R.id.share_content_file_box) private val attachmentIconView: ImageView = itemView.findViewById(R.id.share_content_file_icon) private val attachmentInfoView: TextView = itemView.findViewById(R.id.share_content_file_info) private val attachmentBoxView: View = itemView.findViewById(R.id.detail_item_attachment_file_box) private val attachmentIconView: ImageView = itemView.findViewById(R.id.detail_item_attachment_file_icon) private val attachmentInfoView: TextView = itemView.findViewById(R.id.detail_item_attachment_file_info) fun bind(notification: Notification) { this.notification = notification Loading app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +25 −20 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.textfield.TextInputLayout import io.heckel.ntfy.R import io.heckel.ntfy.app.Application import io.heckel.ntfy.db.Subscription import io.heckel.ntfy.msg.ApiService import io.heckel.ntfy.util.* import kotlinx.coroutines.Dispatchers Loading Loading @@ -109,9 +108,16 @@ class ShareActivity : AppCompatActivity() { validateInput() } // Populate "last topics" val reversedLastTopics = repository.getLastShareTopics().reversed() lastTopicsList.adapter = TopicAdapter(reversedLastTopics) { topicUrl -> // Things that need the database lifecycleScope.launch(Dispatchers.IO) { // Populate "suggested topics" val subscriptions = repository.getSubscriptions() val lastShareTopics = repository.getLastShareTopics() val subscribedTopics = subscriptions .map { topicUrl(it.baseUrl, it.topic) } .subtract(lastShareTopics.toSet()) val suggestedTopics = lastShareTopics.reversed() + subscribedTopics lastTopicsList.adapter = TopicAdapter(suggestedTopics) { topicUrl -> try { val (baseUrl, topic) = splitTopicUrl(topicUrl) topicText.text = topic Loading @@ -127,8 +133,7 @@ class ShareActivity : AppCompatActivity() { } // Add baseUrl auto-complete behavior lifecycleScope.launch(Dispatchers.IO) { baseUrls = repository.getSubscriptions() baseUrls = subscriptions .groupBy { it.baseUrl } .map { it.key } .filterNot { it == appBaseUrl } Loading @@ -136,9 +141,9 @@ class ShareActivity : AppCompatActivity() { val activity = this@ShareActivity activity.runOnUiThread { initBaseUrlDropdown(baseUrls, baseUrlText, baseUrlLayout) useAnotherServerCheckbox.isChecked = if (reversedLastTopics.isNotEmpty()) { useAnotherServerCheckbox.isChecked = if (suggestedTopics.isNotEmpty()) { try { val (baseUrl, _) = splitTopicUrl(reversedLastTopics.first()) val (baseUrl, _) = splitTopicUrl(suggestedTopics.first()) baseUrl != appBaseUrl } catch (_: Exception) { false Loading app/src/main/res/layout/activity_share.xml +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ android:layout_height="wrap_content" android:paddingTop="5dp" android:paddingBottom="3dp" android:text="@string/share_previous_topics" android:text="@string/share_suggested_topics" android:textAlignment="viewStart" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintTop_toBottomOf="@id/share_base_url_layout" app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="13dp"/> Loading app/src/main/res/layout/fragment_detail_item.xml +9 −9 Original line number Diff line number Diff line Loading @@ -87,13 +87,13 @@ app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="10dp" app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_image" app:layout_constraintBottom_toTopOf="@id/share_content_file_box" app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_file_box" app:layout_constraintHorizontal_bias="0.0" android:layout_marginTop="2dp" /> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_tags_text" android:id="@+id/share_content_file_box" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_file_box" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" app:layout_constraintBottom_toTopOf="@id/detail_item_padding_bottom" android:visibility="visible" android:layout_marginTop="2dp" Loading @@ -102,27 +102,27 @@ <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_cancel_gray_24dp" android:id="@+id/share_content_file_icon" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_file_icon" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toStartOf="@+id/share_content_file_info" android:layout_marginEnd="5dp" app:layout_constraintEnd_toStartOf="@+id/detail_item_attachment_file_info" android:layout_marginEnd="5dp" app:layout_constraintBottom_toBottomOf="parent" /> <TextView android:text="attachment.jpg\n58 MB, not downloaded, expires 1/2/2022 10:30 PM" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/share_content_file_info" android:id="@+id/detail_item_attachment_file_info" android:textColor="?android:attr/textColorPrimary" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintStart_toEndOf="@+id/share_content_file_icon" app:layout_constraintStart_toEndOf="@+id/detail_item_attachment_file_icon" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@+id/share_content_file_icon" app:layout_constraintBottom_toBottomOf="@+id/share_content_file_icon"/> app:layout_constraintTop_toTopOf="@+id/detail_item_attachment_file_icon" app:layout_constraintBottom_toBottomOf="@+id/detail_item_attachment_file_icon"/> </androidx.constraintlayout.widget.ConstraintLayout> <TextView android:layout_width="match_parent" android:layout_height="5dp" android:id="@+id/detail_item_padding_bottom" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/share_content_file_box"/> app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"/> </androidx.constraintlayout.widget.ConstraintLayout> Loading
app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ class ApiService { } if (body != null) { builder .addHeader("X-Message", message) .addHeader("X-Message", message.replace("\n", "\\n")) .put(body) } else { builder.put(message.toRequestBody()) Loading
app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt +3 −3 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ class DetailAdapter(private val activity: Activity, private val repository: Repo private val tagsView: TextView = itemView.findViewById(R.id.detail_item_tags_text) private val menuButton: ImageButton = itemView.findViewById(R.id.detail_item_menu_button) private val attachmentImageView: ImageView = itemView.findViewById(R.id.detail_item_attachment_image) private val attachmentBoxView: View = itemView.findViewById(R.id.share_content_file_box) private val attachmentIconView: ImageView = itemView.findViewById(R.id.share_content_file_icon) private val attachmentInfoView: TextView = itemView.findViewById(R.id.share_content_file_info) private val attachmentBoxView: View = itemView.findViewById(R.id.detail_item_attachment_file_box) private val attachmentIconView: ImageView = itemView.findViewById(R.id.detail_item_attachment_file_icon) private val attachmentInfoView: TextView = itemView.findViewById(R.id.detail_item_attachment_file_info) fun bind(notification: Notification) { this.notification = notification Loading
app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +25 −20 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.textfield.TextInputLayout import io.heckel.ntfy.R import io.heckel.ntfy.app.Application import io.heckel.ntfy.db.Subscription import io.heckel.ntfy.msg.ApiService import io.heckel.ntfy.util.* import kotlinx.coroutines.Dispatchers Loading Loading @@ -109,9 +108,16 @@ class ShareActivity : AppCompatActivity() { validateInput() } // Populate "last topics" val reversedLastTopics = repository.getLastShareTopics().reversed() lastTopicsList.adapter = TopicAdapter(reversedLastTopics) { topicUrl -> // Things that need the database lifecycleScope.launch(Dispatchers.IO) { // Populate "suggested topics" val subscriptions = repository.getSubscriptions() val lastShareTopics = repository.getLastShareTopics() val subscribedTopics = subscriptions .map { topicUrl(it.baseUrl, it.topic) } .subtract(lastShareTopics.toSet()) val suggestedTopics = lastShareTopics.reversed() + subscribedTopics lastTopicsList.adapter = TopicAdapter(suggestedTopics) { topicUrl -> try { val (baseUrl, topic) = splitTopicUrl(topicUrl) topicText.text = topic Loading @@ -127,8 +133,7 @@ class ShareActivity : AppCompatActivity() { } // Add baseUrl auto-complete behavior lifecycleScope.launch(Dispatchers.IO) { baseUrls = repository.getSubscriptions() baseUrls = subscriptions .groupBy { it.baseUrl } .map { it.key } .filterNot { it == appBaseUrl } Loading @@ -136,9 +141,9 @@ class ShareActivity : AppCompatActivity() { val activity = this@ShareActivity activity.runOnUiThread { initBaseUrlDropdown(baseUrls, baseUrlText, baseUrlLayout) useAnotherServerCheckbox.isChecked = if (reversedLastTopics.isNotEmpty()) { useAnotherServerCheckbox.isChecked = if (suggestedTopics.isNotEmpty()) { try { val (baseUrl, _) = splitTopicUrl(reversedLastTopics.first()) val (baseUrl, _) = splitTopicUrl(suggestedTopics.first()) baseUrl != appBaseUrl } catch (_: Exception) { false Loading
app/src/main/res/layout/activity_share.xml +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ android:layout_height="wrap_content" android:paddingTop="5dp" android:paddingBottom="3dp" android:text="@string/share_previous_topics" android:text="@string/share_suggested_topics" android:textAlignment="viewStart" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintTop_toBottomOf="@id/share_base_url_layout" app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="13dp"/> Loading
app/src/main/res/layout/fragment_detail_item.xml +9 −9 Original line number Diff line number Diff line Loading @@ -87,13 +87,13 @@ app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="10dp" app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_image" app:layout_constraintBottom_toTopOf="@id/share_content_file_box" app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_file_box" app:layout_constraintHorizontal_bias="0.0" android:layout_marginTop="2dp" /> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_tags_text" android:id="@+id/share_content_file_box" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_file_box" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" app:layout_constraintBottom_toTopOf="@id/detail_item_padding_bottom" android:visibility="visible" android:layout_marginTop="2dp" Loading @@ -102,27 +102,27 @@ <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_cancel_gray_24dp" android:id="@+id/share_content_file_icon" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_file_icon" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toStartOf="@+id/share_content_file_info" android:layout_marginEnd="5dp" app:layout_constraintEnd_toStartOf="@+id/detail_item_attachment_file_info" android:layout_marginEnd="5dp" app:layout_constraintBottom_toBottomOf="parent" /> <TextView android:text="attachment.jpg\n58 MB, not downloaded, expires 1/2/2022 10:30 PM" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/share_content_file_info" android:id="@+id/detail_item_attachment_file_info" android:textColor="?android:attr/textColorPrimary" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintStart_toEndOf="@+id/share_content_file_icon" app:layout_constraintStart_toEndOf="@+id/detail_item_attachment_file_icon" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@+id/share_content_file_icon" app:layout_constraintBottom_toBottomOf="@+id/share_content_file_icon"/> app:layout_constraintTop_toTopOf="@+id/detail_item_attachment_file_icon" app:layout_constraintBottom_toBottomOf="@+id/detail_item_attachment_file_icon"/> </androidx.constraintlayout.widget.ConstraintLayout> <TextView android:layout_width="match_parent" android:layout_height="5dp" android:id="@+id/detail_item_padding_bottom" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/share_content_file_box"/> app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"/> </androidx.constraintlayout.widget.ConstraintLayout>