From 24fa1d1509aa752bf64975e3196857b2803ca4e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Denis=20=C3=87erri?=
<64997243+deniscerri@users.noreply.github.com>
Date: Sat, 4 Mar 2023 12:23:59 +0100
Subject: [PATCH] implemented custom command
---
.idea/assetWizardSettings.xml | 4 +-
app/build.gradle | 2 +-
.../1.json | 30 +++-
app/src/main/AndroidManifest.xml | 15 +-
.../ytdlnis/adapter/TemplatesAdapter.kt | 77 +++++++++
.../deniscerri/ytdlnis/database/DBManager.kt | 2 +-
.../database/dao/CommandTemplateDao.kt | 25 ++-
.../database/models/TemplateShortcut.kt | 12 ++
.../repository/CommandTemplateRepository.kt | 45 ++++++
.../viewmodel/CommandTemplateViewModel.kt | 69 +++++++++
.../ConfigureDownloadBottomSheetDialog.kt | 29 +++-
.../downloadcard/DownloadBottomSheetDialog.kt | 29 +++-
.../downloadcard/DownloadCommandFragment.kt | 83 ++++++++--
.../downloadcard/DownloadFragmentAdapter.kt | 15 +-
.../ui/more/CommandTemplatesActivity.kt | 101 ++++++++++++
...CommandActivity.kt => TerminalActivity.kt} | 6 +-
.../com/deniscerri/ytdlnis/util/UiUtil.kt | 137 ++++++++++++++++
.../deniscerri/ytdlnis/work/DownloadWorker.kt | 5 +-
app/src/main/res/drawable/ic_clipboard.xml | 5 +
app/src/main/res/drawable/ic_shortcut.xml | 5 +
.../res/layout/activity_command_templates.xml | 66 +++++++-
.../main/res/layout/activity_download_log.xml | 2 +-
.../res/layout/activity_download_log_list.xml | 2 +-
.../res/layout/activity_download_queue.xml | 2 +-
...stom_command.xml => activity_terminal.xml} | 2 +-
.../main/res/layout/command_template_item.xml | 53 +++++++
.../res/layout/create_command_template.xml | 146 ++++++++++++++++++
.../main/res/layout/download_bottom_sheet.xml | 2 +-
.../res/layout/fragment_download_command.xml | 35 +++--
app/src/main/res/layout/input_chip.xml | 7 +
app/src/main/res/layout/suggestion_chip.xml | 8 +
.../main/res/layout/template_shortcuts.xml | 87 +++++++++++
.../main/res/menu/command_templates_menu.xml | 13 ++
app/src/main/res/values/strings.xml | 7 +
34 files changed, 1050 insertions(+), 78 deletions(-)
create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/adapter/TemplatesAdapter.kt
create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/database/models/TemplateShortcut.kt
create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/database/repository/CommandTemplateRepository.kt
create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/database/viewmodel/CommandTemplateViewModel.kt
create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/ui/more/CommandTemplatesActivity.kt
rename app/src/main/java/com/deniscerri/ytdlnis/ui/more/{CustomCommandActivity.kt => TerminalActivity.kt} (97%)
create mode 100644 app/src/main/res/drawable/ic_clipboard.xml
create mode 100644 app/src/main/res/drawable/ic_shortcut.xml
rename app/src/main/res/layout/{activity_custom_command.xml => activity_terminal.xml} (98%)
create mode 100644 app/src/main/res/layout/command_template_item.xml
create mode 100644 app/src/main/res/layout/create_command_template.xml
create mode 100644 app/src/main/res/layout/input_chip.xml
create mode 100644 app/src/main/res/layout/suggestion_chip.xml
create mode 100644 app/src/main/res/layout/template_shortcuts.xml
create mode 100644 app/src/main/res/menu/command_templates_menu.xml
diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
index 52269cb2..b16f267c 100644
--- a/.idea/assetWizardSettings.xml
+++ b/.idea/assetWizardSettings.xml
@@ -320,7 +320,7 @@
@@ -330,7 +330,7 @@
diff --git a/app/build.gradle b/app/build.gradle
index 65d3b770..d72b64d4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -125,7 +125,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$appCompatVer"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
- implementation 'com.google.android.material:material:1.8.0'
+ implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
diff --git a/app/schemas/com.deniscerri.ytdlnis.database.DBManager/1.json b/app/schemas/com.deniscerri.ytdlnis.database.DBManager/1.json
index bfef4c81..86981c48 100644
--- a/app/schemas/com.deniscerri.ytdlnis.database.DBManager/1.json
+++ b/app/schemas/com.deniscerri.ytdlnis.database.DBManager/1.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
- "identityHash": "2a124f7c327413ab152e18a9e4a66ef7",
+ "identityHash": "6d6dea309a9207aaaedcc2a745ae2a2a",
"entities": [
{
"tableName": "results",
@@ -339,12 +339,38 @@
},
"indices": [],
"foreignKeys": []
+ },
+ {
+ "tableName": "templateShortcuts",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `content` TEXT NOT NULL)",
+ "fields": [
+ {
+ "fieldPath": "id",
+ "columnName": "id",
+ "affinity": "INTEGER",
+ "notNull": true
+ },
+ {
+ "fieldPath": "content",
+ "columnName": "content",
+ "affinity": "TEXT",
+ "notNull": true
+ }
+ ],
+ "primaryKey": {
+ "autoGenerate": true,
+ "columnNames": [
+ "id"
+ ]
+ },
+ "indices": [],
+ "foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2a124f7c327413ab152e18a9e4a66ef7')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6d6dea309a9207aaaedcc2a745ae2a2a')"
]
}
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 309ac0aa..0adb2c90 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -95,7 +95,7 @@
-
+
+
+
+
+
+
+
+
(AsyncDifferConfig.Builder(DIFF_CALLBACK).build()) {
+ private val onItemClickListener: OnItemClickListener
+ private val activity: Activity
+
+ init {
+ this.onItemClickListener = onItemClickListener
+ this.activity = activity
+ }
+
+ class ViewHolder(itemView: View, onItemClickListener: OnItemClickListener?) : RecyclerView.ViewHolder(itemView) {
+ val item: ConstraintLayout
+
+ init {
+ item = itemView.findViewById(R.id.command_template_item_constraint)
+ }
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+ val cardView = LayoutInflater.from(parent.context)
+ .inflate(R.layout.command_template_item, parent, false)
+ return ViewHolder(cardView, onItemClickListener)
+ }
+
+ override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+ val item = getItem(position)
+ val card = holder.item
+
+ val title = card.findViewById(R.id.title)
+ title.text = item?.title
+
+ val content = card.findViewById(R.id.content)
+ content.text = item?.content
+
+ val check = card.findViewById