Skip to content

Commit f5971fa

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents cc94142 + 2057f35 commit f5971fa

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

app/src/main/java/com/sdex/activityrunner/shortcut/AddShortcutDialogActivity.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import android.graphics.Bitmap
77
import android.graphics.drawable.Drawable
88
import android.net.Uri
99
import android.os.Bundle
10+
import android.text.Editable
11+
import android.text.TextWatcher
1012
import android.view.View
1113
import android.widget.PopupMenu
1214
import android.widget.Toast
@@ -17,6 +19,7 @@ import androidx.core.graphics.drawable.toBitmap
1719
import com.bumptech.glide.request.RequestOptions
1820
import com.bumptech.glide.request.target.CustomTarget
1921
import com.bumptech.glide.request.transition.Transition
22+
import com.google.android.material.textfield.TextInputLayout
2023
import com.maltaisn.icondialog.IconDialog
2124
import com.maltaisn.icondialog.IconDialogSettings
2225
import com.maltaisn.icondialog.data.Icon
@@ -60,8 +63,23 @@ class AddShortcutDialogActivity : AppCompatActivity(), IconDialog.Callback {
6063
val activityModel = intent?.serializable<ActivityModel>(ARG_ACTIVITY_MODEL)
6164
val historyModel = intent?.serializable<HistoryModel>(ARG_HISTORY_MODEL)
6265

63-
binding.label.setText(activityModel?.name)
66+
binding.label.addTextChangedListener(object : TextWatcher {
67+
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
68+
}
69+
70+
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
71+
binding.valueLayout.endIconMode =
72+
if (count != 0) TextInputLayout.END_ICON_CLEAR_TEXT
73+
else TextInputLayout.END_ICON_DROPDOWN_MENU
74+
}
75+
76+
override fun afterTextChanged(s: Editable?) {
77+
}
78+
})
79+
binding.label.setText(activityModel?.label)
6480
binding.label.text?.let { binding.label.setSelection(it.length) }
81+
binding.label.setSimpleItems(arrayOf(activityModel?.label, activityModel?.name))
82+
6583

6684
val loader = IconPackLoader(applicationContext)
6785
iconPack = createMaterialDesignIconPack(loader)

app/src/main/res/layout/activity_add_shortcut.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@
3434

3535
<com.google.android.material.textfield.TextInputLayout
3636
android:id="@+id/value_layout"
37-
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
37+
style="?textInputOutlinedExposedDropdownMenuStyle"
3838
android:layout_width="match_parent"
3939
android:layout_height="wrap_content"
4040
android:layout_marginTop="10dp"
41-
app:endIconMode="clear_text"
4241
app:layout_constraintEnd_toEndOf="parent"
4342
app:layout_constraintStart_toStartOf="parent"
4443
app:layout_constraintTop_toBottomOf="@+id/icon">
4544

46-
<com.google.android.material.textfield.TextInputEditText
45+
<com.google.android.material.textfield.MaterialAutoCompleteTextView
4746
android:id="@+id/label"
4847
android:layout_width="match_parent"
49-
android:layout_height="match_parent"
48+
android:layout_height="wrap_content"
5049
android:hint="@string/shortcut_name"
5150
android:inputType="text" />
5251

0 commit comments

Comments
 (0)