From cf30ccbc4c96d3ccef8a4356fefd99ced40d38e9 Mon Sep 17 00:00:00 2001 From: Soo Hwan Na Date: Wed, 12 Jun 2024 10:37:02 +0900 Subject: [PATCH] TgBot++: clientapp: Android: Update code - Now the fab is used to ask storage permissions - Current setting is shown on every fragment - Upload file entry is added - Make a unified interface for storage permission request - Use nonblocking sockets for the ability to time out - Use new logging lib - Add unified viewmodel for single livedata --- .../.idea/deploymentTargetSelector.xml | 4 +- clientapp/android/app/build.gradle.kts | 20 +-- clientapp/android/app/proguard-rules.pro | 2 +- .../android/app/src/main/AndroidManifest.xml | 2 + .../android/app/src/main/cpp/tgbotclient.cpp | 132 ++++++++++++++---- .../royna/tgbotclient/ClientApplication.kt | 5 + .../com/royna/tgbotclient/MainActivity.kt | 67 ++++----- .../royna/tgbotclient/SocketCommandNative.kt | 10 +- .../tgbotclient/pm/IStoragePermission.kt | 13 ++ .../tgbotclient/pm/StoragePermissionPreR.kt | 37 +++++ .../tgbotclient/pm/StoragePermissionR.kt | 38 +++++ .../tgbotclient/ui/CurrentSettingFragment.kt | 48 +++++++ .../ui/commands/SingleViewModelBase.kt | 27 ++++ .../sendmsg}/TextToChatFragment.kt | 19 ++- .../sendmsg}/TextToChatViewModel.kt | 5 +- .../commands/uploadfile/UploadFileFragment.kt | 75 ++++++++++ .../uploadfile/UploadFileViewModel.kt | 99 +++++++++++++ .../ui/commands/uptime/UptimeFragment.kt | 73 ++++++++++ .../ui/commands/uptime/UptimeViewModel.kt | 49 +++++++ .../ui/settings/TgClientSettings.kt | 59 +++++--- .../tgbotclient/ui/uptime/UptimeFragment.kt | 47 ------- .../tgbotclient/ui/uptime/UptimeViewModel.kt | 28 ---- .../com/royna/tgbotclient/util/Logging.kt | 41 ++++++ .../src/main/res/drawable/black_border.xml | 7 - .../app/src/main/res/drawable/border.xml | 13 ++ .../app/src/main/res/drawable/chat.xml | 9 ++ .../app/src/main/res/drawable/download.xml | 9 ++ .../app/src/main/res/drawable/home.xml | 9 ++ .../src/main/res/drawable/ic_menu_camera.xml | 12 -- .../src/main/res/drawable/ic_menu_gallery.xml | 9 -- .../main/res/drawable/ic_menu_slideshow.xml | 9 -- .../app/src/main/res/drawable/schedule.xml | 9 ++ .../app/src/main/res/drawable/send.xml | 9 ++ .../src/main/res/drawable/side_nav_bar.xml | 9 +- .../app/src/main/res/drawable/upload.xml | 9 ++ .../res/layout/fragment_current_setting.xml | 8 ++ .../layout/fragment_current_setting_child.xml | 36 +++++ ..._to_chat.xml => fragment_send_message.xml} | 22 ++- .../main/res/layout/fragment_upload_file.xml | 49 +++++++ .../src/main/res/layout/fragment_uptime.xml | 15 +- .../main/res/menu/activity_main_drawer.xml | 43 ++++-- .../android/app/src/main/res/menu/main.xml | 1 + .../main/res/navigation/mobile_navigation.xml | 16 ++- .../app/src/main/res/values/dimens.xml | 3 + .../app/src/main/res/values/strings.xml | 17 ++- .../app/src/main/res/xml/preference_main.xml | 5 + clientapp/android/gradle/libs.versions.toml | 10 +- src/socket/include/TgBotSocket_Export.hpp | 3 +- .../impl/bot/TgBotSocketFileHelper.hpp | 2 +- 49 files changed, 991 insertions(+), 252 deletions(-) create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/pm/IStoragePermission.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/pm/StoragePermissionPreR.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/pm/StoragePermissionR.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/CurrentSettingFragment.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/commands/SingleViewModelBase.kt rename clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/{text_to_chat => commands/sendmsg}/TextToChatFragment.kt (79%) rename clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/{text_to_chat => commands/sendmsg}/TextToChatViewModel.kt (93%) create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/commands/uploadfile/UploadFileFragment.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/commands/uploadfile/UploadFileViewModel.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/commands/uptime/UptimeFragment.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/commands/uptime/UptimeViewModel.kt delete mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/uptime/UptimeFragment.kt delete mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/ui/uptime/UptimeViewModel.kt create mode 100644 clientapp/android/app/src/main/java/com/royna/tgbotclient/util/Logging.kt delete mode 100644 clientapp/android/app/src/main/res/drawable/black_border.xml create mode 100644 clientapp/android/app/src/main/res/drawable/border.xml create mode 100644 clientapp/android/app/src/main/res/drawable/chat.xml create mode 100644 clientapp/android/app/src/main/res/drawable/download.xml create mode 100644 clientapp/android/app/src/main/res/drawable/home.xml delete mode 100644 clientapp/android/app/src/main/res/drawable/ic_menu_camera.xml delete mode 100644 clientapp/android/app/src/main/res/drawable/ic_menu_gallery.xml delete mode 100644 clientapp/android/app/src/main/res/drawable/ic_menu_slideshow.xml create mode 100644 clientapp/android/app/src/main/res/drawable/schedule.xml create mode 100644 clientapp/android/app/src/main/res/drawable/send.xml create mode 100644 clientapp/android/app/src/main/res/drawable/upload.xml create mode 100644 clientapp/android/app/src/main/res/layout/fragment_current_setting.xml create mode 100644 clientapp/android/app/src/main/res/layout/fragment_current_setting_child.xml rename clientapp/android/app/src/main/res/layout/{fragment_text_to_chat.xml => fragment_send_message.xml} (69%) create mode 100644 clientapp/android/app/src/main/res/layout/fragment_upload_file.xml diff --git a/clientapp/android/.idea/deploymentTargetSelector.xml b/clientapp/android/.idea/deploymentTargetSelector.xml index 62142c75..2acdd2df 100644 --- a/clientapp/android/.idea/deploymentTargetSelector.xml +++ b/clientapp/android/.idea/deploymentTargetSelector.xml @@ -4,10 +4,10 @@