forked from jkuester/unlauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add popup menu for apps in the drawer (jkuester#134)
- Loading branch information
Showing
13 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDisplayNameDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.sduduzog.slimlauncher.ui.dialogs | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.widget.EditText | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.fragment.app.DialogFragment | ||
import com.jkuester.unlauncher.datastore.UnlauncherApp | ||
import com.sduduzog.slimlauncher.R | ||
import com.sduduzog.slimlauncher.datasource.apps.UnlauncherAppsRepository | ||
import kotlinx.android.synthetic.main.customise_apps_fragment.* | ||
|
||
class RenameAppDisplayNameDialog : DialogFragment() { | ||
private lateinit var app: UnlauncherApp | ||
private lateinit var unlauncherAppsRepo: UnlauncherAppsRepository | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
val view = LayoutInflater.from(context).inflate(R.layout.rename_dialog_edit_text, customise_apps_fragment, false) | ||
val editText: EditText = view.findViewById(R.id.rename_editText) | ||
val appName: String = app.displayName | ||
editText.text.append(appName) | ||
val builder = AlertDialog.Builder(requireContext()) | ||
builder.setTitle("Rename $appName") | ||
builder.setView(view) | ||
builder.setPositiveButton("DONE") { _, _ -> | ||
val name = editText.text.toString() | ||
updateApp(name) | ||
} | ||
editText.setOnEditorActionListener { v, _, _ -> | ||
val name = v.text.toString() | ||
updateApp(name) | ||
this@RenameAppDisplayNameDialog.dismiss() | ||
true | ||
} | ||
|
||
return builder.create() | ||
} | ||
|
||
private fun updateApp(newName: String) { | ||
if (newName.isNotEmpty()) { | ||
unlauncherAppsRepo.updateDisplayName(app, newName) | ||
} else { | ||
Toast.makeText(context, "Couldn't save, App name shouldn't be empty", Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
|
||
companion object { | ||
fun getInstance(app: UnlauncherApp, unlauncherAppsRepo : UnlauncherAppsRepository) : RenameAppDisplayNameDialog { | ||
return RenameAppDisplayNameDialog().apply { | ||
this.app = app | ||
this.unlauncherAppsRepo = unlauncherAppsRepo | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="?attr/colorAccent" | ||
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="48" | ||
android:viewportHeight="48"> | ||
<path | ||
android:fillColor="?attr/colorAccent" | ||
android:pathData="m31.45,27.05 l-2.2,-2.2q1.3,-3.55 -1.35,-5.9 -2.65,-2.35 -5.75,-1.2l-2.2,-2.2q0.85,-0.55 1.9,-0.8 1.05,-0.25 2.15,-0.25 3.55,0 6.025,2.475Q32.5,19.45 32.5,23q0,1.1 -0.275,2.175 -0.275,1.075 -0.775,1.875ZM37.9,33.5 L35.9,31.5q2.45,-1.8 4.275,-4.025Q42,25.25 42.85,23q-2.5,-5.55 -7.5,-8.775Q30.35,11 24.5,11q-2.1,0 -4.3,0.4 -2.2,0.4 -3.45,0.95L14.45,10q1.75,-0.8 4.475,-1.4Q21.65,8 24.25,8q7.15,0 13.075,4.075Q43.25,16.15 46,23q-1.3,3.2 -3.35,5.85 -2.05,2.65 -4.75,4.65ZM40.8,44.8 L32.4,36.55q-1.75,0.7 -3.95,1.075T24,38q-7.3,0 -13.25,-4.075T2,23q1,-2.6 2.775,-5.075T9.1,13.2L2.8,6.9l2.1,-2.15L42.75,42.6ZM11.15,15.3q-1.85,1.35 -3.575,3.55Q5.85,21.05 5.1,23q2.55,5.55 7.675,8.775Q17.9,35 24.4,35q1.65,0 3.25,-0.2t2.4,-0.6l-3.2,-3.2q-0.55,0.25 -1.35,0.375T24,31.5q-3.5,0 -6,-2.45T15.5,23q0,-0.75 0.125,-1.5T16,20.15ZM26.4,22.4ZM20.6,25.3Z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="?attr/colorAccent" | ||
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="48" | ||
android:viewportHeight="48"> | ||
<path | ||
android:fillColor="?attr/colorAccent" | ||
android:pathData="M9,39h2.2l22.15,-22.15 -2.2,-2.2L9,36.8ZM39.7,14.7 L33.3,8.3 35.4,6.2q0.85,-0.85 2.1,-0.85t2.1,0.85l2.2,2.2q0.85,0.85 0.85,2.1t-0.85,2.1ZM37.6,16.8L12.4,42L6,42v-6.4l25.2,-25.2ZM32.25,15.75 L31.15,14.65 33.35,16.85Z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="48" | ||
android:viewportHeight="48"> | ||
<path | ||
android:fillColor="?attr/colorAccent" | ||
android:pathData="M13.05,42q-1.25,0 -2.125,-0.875T10.05,39L10.05,10.5L8,10.5v-3h9.4L17.4,6h13.2v1.5L40,7.5v3h-2.05L37.95,39q0,1.2 -0.9,2.1 -0.9,0.9 -2.1,0.9ZM34.95,10.5h-21.9L13.05,39h21.9ZM18.35,34.7h3L21.35,14.75h-3ZM26.65,34.7h3L29.65,14.75h-3ZM13.05,10.5L13.05,39Z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:id="@+id/open" | ||
android:title="@string/open_app" | ||
android:icon="@drawable/ic_open_app"/> | ||
<item | ||
android:id="@+id/info" | ||
android:title="@string/app_info" | ||
android:icon="@drawable/ic_app_info"/> | ||
<item | ||
android:id="@+id/hide" | ||
android:title="@string/hide_app" | ||
android:icon="@drawable/ic_hide_app" /> | ||
<item | ||
android:id="@+id/rename" | ||
android:title="@string/rename_app" | ||
android:icon="@drawable/ic_rename_app" /> | ||
<item | ||
android:id="@+id/uninstall" | ||
android:title="@string/uninstall" | ||
android:icon="@drawable/ic_uninstall_app" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters