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