mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Make fa icons visible for chosen actions
In the actions / apps fragment of the launchers settings. The terminology has to be improved and kept the same everywhere in the app, as it also improves the codes readability and quality. I shall do that soon.
This commit is contained in:
parent
e728fca0ee
commit
2ab8bec8c0
5 changed files with 78 additions and 45 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.finnmglas.launcher.choose.other
|
package com.finnmglas.launcher.choose.other
|
||||||
|
|
||||||
class OtherInfo(label: String, data: String) {
|
class OtherInfo(label: String, data: String, icon: String) {
|
||||||
var label: CharSequence? = label
|
var label: CharSequence? = label
|
||||||
var data: CharSequence? = data
|
var data: CharSequence? = data
|
||||||
|
var icon: CharSequence? = icon
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ class OtherRecyclerAdapter(val activity: Activity):
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
|
||||||
View.OnClickListener {
|
View.OnClickListener {
|
||||||
var textView: TextView = itemView.findViewById(R.id.row_other_name)
|
var textView: TextView = itemView.findViewById(R.id.row_other_name)
|
||||||
|
var iconView: FontAwesome = itemView.findViewById(R.id.row_other_fa_icon)
|
||||||
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
|
@ -34,9 +35,10 @@ class OtherRecyclerAdapter(val activity: Activity):
|
||||||
|
|
||||||
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
||||||
val otherLabel = othersList[i].label.toString()
|
val otherLabel = othersList[i].label.toString()
|
||||||
val otherData = othersList[i].data.toString()
|
val icon = othersList[i].icon.toString()
|
||||||
|
|
||||||
viewHolder.textView.text = otherLabel
|
viewHolder.textView.text = otherLabel
|
||||||
|
viewHolder.iconView.text = icon
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int { return othersList.size }
|
override fun getItemCount(): Int { return othersList.size }
|
||||||
|
@ -49,8 +51,14 @@ class OtherRecyclerAdapter(val activity: Activity):
|
||||||
|
|
||||||
init {
|
init {
|
||||||
othersList = ArrayList()
|
othersList = ArrayList()
|
||||||
othersList.add(OtherInfo("Launcher Settings", "launcher:settings"))
|
othersList.add(
|
||||||
othersList.add(OtherInfo("Launcher AppsList", "launcher:choose"))
|
OtherInfo("Launcher Settings",
|
||||||
|
"launcher:settings",
|
||||||
|
activity.getString(R.string.fas_settings)))
|
||||||
|
othersList.add(
|
||||||
|
OtherInfo("Launcher AppsList",
|
||||||
|
"launcher:choose",
|
||||||
|
activity.getString(R.string.fas_bars)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
|
|
@ -27,6 +27,7 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
|
||||||
View.OnClickListener {
|
View.OnClickListener {
|
||||||
var textView: TextView = itemView.findViewById(R.id.row_action_name)
|
var textView: TextView = itemView.findViewById(R.id.row_action_name)
|
||||||
|
var fontAwesome: FontAwesome = itemView.findViewById(R.id.row_app_fa_icon)
|
||||||
var img: ImageView = itemView.findViewById(R.id.row_app_icon) as ImageView
|
var img: ImageView = itemView.findViewById(R.id.row_app_icon) as ImageView
|
||||||
var chooseButton: Button = itemView.findViewById(R.id.row_choose_button)
|
var chooseButton: Button = itemView.findViewById(R.id.row_choose_button)
|
||||||
var removeAction: FontAwesome = itemView.findViewById(R.id.row_remove_action)
|
var removeAction: FontAwesome = itemView.findViewById(R.id.row_remove_action)
|
||||||
|
@ -48,20 +49,44 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
val content = actionsList[i].content
|
val content = actionsList[i].content
|
||||||
|
|
||||||
viewHolder.textView.text = actionText
|
viewHolder.textView.text = actionText
|
||||||
try {
|
|
||||||
viewHolder.img.setImageDrawable(activity.packageManager.getApplicationIcon(content.toString()))
|
|
||||||
viewHolder.img.setOnClickListener{ chooseApp(actionName.toString()) }
|
|
||||||
|
|
||||||
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
|
viewHolder.removeAction.setOnClickListener{
|
||||||
|
val sharedPref = activity.getSharedPreferences(
|
||||||
|
activity.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||||
|
|
||||||
viewHolder.removeAction.setOnClickListener{
|
val editor : SharedPreferences.Editor = sharedPref.edit()
|
||||||
val sharedPref = activity.getSharedPreferences(
|
editor.putString("action_$actionName", "") // clear it
|
||||||
activity.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
editor.apply()
|
||||||
|
|
||||||
val editor : SharedPreferences.Editor = sharedPref.edit()
|
viewHolder.fontAwesome.visibility = View.INVISIBLE
|
||||||
editor.putString("action_$actionName", "") // clear it
|
viewHolder.img.visibility = View.INVISIBLE
|
||||||
editor.apply()
|
viewHolder.removeAction.visibility = View.GONE
|
||||||
|
viewHolder.chooseButton.visibility = View.VISIBLE
|
||||||
|
viewHolder.chooseButton.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||||
|
if (getSavedTheme(activity) =="custom")
|
||||||
|
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content!!.startsWith("launcher")) {
|
||||||
|
// Set fontAwesome icon
|
||||||
|
viewHolder.fontAwesome.visibility = View.VISIBLE
|
||||||
|
viewHolder.fontAwesome.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||||
|
|
||||||
|
when (content.split(":")[1]) {
|
||||||
|
"settings" ->
|
||||||
|
viewHolder.fontAwesome.text = activity.getString(R.string.fas_settings)
|
||||||
|
"choose" ->
|
||||||
|
viewHolder.fontAwesome.text = activity.getString(R.string.fas_bars)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Set image icon (by packageName)
|
||||||
|
try {
|
||||||
|
viewHolder.img.setImageDrawable(activity.packageManager.getApplicationIcon(content.toString()))
|
||||||
|
viewHolder.img.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||||
|
|
||||||
|
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
|
||||||
|
|
||||||
|
} catch (e : Exception) { // the button is shown, user asked to select an action
|
||||||
viewHolder.img.visibility = View.INVISIBLE
|
viewHolder.img.visibility = View.INVISIBLE
|
||||||
viewHolder.removeAction.visibility = View.GONE
|
viewHolder.removeAction.visibility = View.GONE
|
||||||
viewHolder.chooseButton.visibility = View.VISIBLE
|
viewHolder.chooseButton.visibility = View.VISIBLE
|
||||||
|
@ -69,14 +94,6 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
if (getSavedTheme(activity) =="custom")
|
if (getSavedTheme(activity) =="custom")
|
||||||
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e : Exception) {
|
|
||||||
viewHolder.img.visibility = View.INVISIBLE
|
|
||||||
viewHolder.removeAction.visibility = View.GONE
|
|
||||||
viewHolder.chooseButton.visibility = View.VISIBLE
|
|
||||||
viewHolder.chooseButton.setOnClickListener{ chooseApp(actionName.toString()) }
|
|
||||||
if (getSavedTheme(activity) =="custom")
|
|
||||||
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,18 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<com.finnmglas.launcher.extern.FontAwesome
|
||||||
|
android:id="@+id/row_app_fa_icon"
|
||||||
|
android:layout_width="@dimen/app_icon_side"
|
||||||
|
android:layout_height="@dimen/app_icon_side"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="30sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/row_choose_button"
|
||||||
|
app:layout_constraintHorizontal_bias="0.2"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/row_choose_button"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/row_app_icon"
|
android:id="@+id/row_app_icon"
|
||||||
android:layout_width="@dimen/app_icon_side"
|
android:layout_width="@dimen/app_icon_side"
|
||||||
|
|
|
@ -3,39 +3,34 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="15sp">
|
||||||
|
|
||||||
|
<com.finnmglas.launcher.extern.FontAwesome
|
||||||
|
android:id="@+id/row_other_fa_icon"
|
||||||
|
android:layout_width="40sp"
|
||||||
|
android:layout_height="40sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text=""
|
||||||
|
android:textSize="35sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/row_other_name"
|
android:id="@+id/row_other_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="60sp"
|
||||||
|
android:layout_marginLeft="60sp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/row_other_button"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/row_other_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/settings_choose_btn"
|
|
||||||
android:textAllCaps="false"
|
|
||||||
android:visibility="invisible"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/row_other_icon"
|
|
||||||
android:layout_width="@dimen/app_icon_side"
|
|
||||||
android:layout_height="@dimen/app_icon_side"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="@id/row_other_button"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/row_other_button"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Reference in a new issue