Polishing; base URL list properly filled with last topics too
This commit is contained in:
parent
118bff0099
commit
944ee3eb67
3 changed files with 19 additions and 20 deletions
app/src/main
|
@ -27,9 +27,6 @@ class ShareActivity : AppCompatActivity() {
|
|||
// File to share
|
||||
private var fileUri: Uri? = null
|
||||
|
||||
// Lazy-loaded things from Repository
|
||||
private lateinit var baseUrls: List<String>
|
||||
|
||||
// Context-dependent things
|
||||
private lateinit var appBaseUrl: String
|
||||
|
||||
|
@ -67,6 +64,7 @@ class ShareActivity : AppCompatActivity() {
|
|||
appBaseUrl = getString(R.string.app_base_url)
|
||||
|
||||
// UI elements
|
||||
val root: View = findViewById(R.id.share_root_view)
|
||||
contentText = findViewById(R.id.share_content_text)
|
||||
contentImage = findViewById(R.id.share_content_image)
|
||||
contentFileBox = findViewById(R.id.share_content_file_box)
|
||||
|
@ -74,10 +72,10 @@ class ShareActivity : AppCompatActivity() {
|
|||
contentFileIcon = findViewById(R.id.share_content_file_icon)
|
||||
topicText = findViewById(R.id.share_topic_text)
|
||||
baseUrlLayout = findViewById(R.id.share_base_url_layout)
|
||||
//baseUrlLayout.background = window.background
|
||||
baseUrlLayout.background = root.background
|
||||
baseUrlLayout.makeEndIconSmaller(resources) // Hack!
|
||||
baseUrlText = findViewById(R.id.share_base_url_text)
|
||||
//baseUrlText.background = topicText.background
|
||||
baseUrlText.background = root.background
|
||||
useAnotherServerCheckbox = findViewById(R.id.share_use_another_server_checkbox)
|
||||
lastTopicsList = findViewById(R.id.share_last_topics)
|
||||
progress = findViewById(R.id.share_progress)
|
||||
|
@ -117,6 +115,12 @@ class ShareActivity : AppCompatActivity() {
|
|||
.map { topicUrl(it.baseUrl, it.topic) }
|
||||
.subtract(lastShareTopics.toSet())
|
||||
val suggestedTopics = lastShareTopics.reversed() + subscribedTopics
|
||||
val baseUrls = suggestedTopics
|
||||
.mapNotNull {
|
||||
try { splitTopicUrl(it).first }
|
||||
catch (_: Exception) { null }
|
||||
}
|
||||
.filterNot { it == appBaseUrl }
|
||||
lastTopicsList.adapter = TopicAdapter(suggestedTopics) { topicUrl ->
|
||||
try {
|
||||
val (baseUrl, topic) = splitTopicUrl(topicUrl)
|
||||
|
@ -133,11 +137,6 @@ class ShareActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
// Add baseUrl auto-complete behavior
|
||||
baseUrls = subscriptions
|
||||
.groupBy { it.baseUrl }
|
||||
.map { it.key }
|
||||
.filterNot { it == appBaseUrl }
|
||||
.sorted()
|
||||
val activity = this@ShareActivity
|
||||
activity.runOnUiThread {
|
||||
initBaseUrlDropdown(baseUrls, baseUrlText, baseUrlLayout)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" android:paddingStart="15dp" android:paddingEnd="15dp" android:paddingTop="10dp" android:paddingBottom="10dp">
|
||||
android:orientation="horizontal" android:paddingStart="15dp" android:paddingEnd="15dp" android:paddingTop="10dp" android:paddingBottom="10dp" android:id="@+id/share_root_view">
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyle"
|
||||
|
@ -26,7 +26,7 @@
|
|||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toTopOf="parent" android:layout_marginStart="1dp"/>
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_cancel_gray_24dp"
|
||||
|
@ -34,7 +34,7 @@
|
|||
android:scaleType="fitStart"
|
||||
android:adjustViewBounds="true" android:maxHeight="150dp"
|
||||
app:shapeAppearanceOverlay="@style/roundedCornersImageView" android:visibility="visible"
|
||||
app:layout_constraintTop_toBottomOf="@id/share_content_title" android:layout_marginTop="5dp"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/share_content_title" android:layout_marginTop="5dp" android:layout_marginStart="1dp"/>
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/share_content_text"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -80,7 +80,7 @@
|
|||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/share_content_file_box" android:layout_marginTop="20dp"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/share_content_file_box" android:layout_marginTop="20dp" android:layout_marginStart="1dp"/>
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/share_topic_text"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -129,7 +129,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="@string/share_suggested_topics"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
android:focusable="true"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp" app:srcCompat="@drawable/ic_sms_gray_24dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp" app:srcCompat="@drawable/ic_sms_gray_24dp"
|
||||
android:id="@+id/share_item_image"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/share_item_text"
|
||||
|
@ -20,8 +20,8 @@
|
|||
android:layout_height="wrap_content" android:id="@+id/share_item_text"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/share_item_image"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary" android:layout_marginTop="7dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="7dp" android:layout_marginStart="4dp"/>
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary" android:layout_marginTop="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="5dp" android:layout_marginStart="6dp"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue