Spaces:
Runtime error
Runtime error
Thomas Richardson commited on
Commit ·
a495cf3
1
Parent(s): 7376fc9
new requirement
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Android/.gitignore +17 -0
- Android/README.md +52 -0
- Android/app/.gitignore +1 -0
- Android/app/build.gradle +124 -0
- Android/app/proguard-rules.pro +21 -0
- Android/app/src/androidTest/java/com/matthaigh27/chatgptwrapper/ExampleInstrumentedTest.kt +26 -0
- Android/app/src/main/AndroidManifest.xml +63 -0
- Android/app/src/main/gpt_icon-playstore.png +0 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/RisingApplication.kt +45 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/AppDatabase.kt +40 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/dao/ContactDao.kt +19 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/dao/ImageDao.kt +19 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/entity/ContactEntity.kt +11 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/entity/ImageEntity.kt +12 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/AlarmModel.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/AutoTaskModel.kt +31 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ChatMessageModel.kt +11 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ContactModel.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/HelpCommandModel.kt +6 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/HelpPromptModel.kt +22 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ImageModel.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ImageRelatenessModel.kt +6 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/MailModel.kt +10 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chatwidgetprops/MailsProps.kt +20 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chatwidgetprops/ScheduleAlarmProps.kt +23 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/common/Time.kt +7 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/setting/SettingModel.kt +25 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiClient.kt +31 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiResource.kt +9 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiService.kt +41 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/BaseApiRequest.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ComposeMailApiRequest.kt +19 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ImageRelatednessApiRequest.kt +9 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/NotificationApiRequest.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ReadMailApiRequest.kt +14 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/TrainContactsApiRequest.kt +9 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/TrainImageApiRequest.kt +9 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/common/Keys.kt +12 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/common/OpenAISetting.kt +5 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/ApiResponse.kt +7 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/CommonResult.kt +8 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/HelpCommandResult.kt +14 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/ImageRelatenessResult.kt +11 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/TrainImageResult.kt +6 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/FirebaseRepository.kt +55 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/RemoteRepository.kt +209 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/RoomRepository.kt +47 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/SharedPreferencesRepository.kt +26 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/base/BaseActivity.kt +22 -0
- Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/ChatActivity.kt +23 -0
Android/.gitignore
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.iml
|
| 2 |
+
.gradle
|
| 3 |
+
/local.properties
|
| 4 |
+
/.idea
|
| 5 |
+
/.idea/caches
|
| 6 |
+
/.idea/libraries
|
| 7 |
+
/.idea/modules.xml
|
| 8 |
+
/.idea/workspace.xml
|
| 9 |
+
/.idea/navEditor.xml
|
| 10 |
+
/.idea/assetWizardSettings.xml
|
| 11 |
+
.DS_Store
|
| 12 |
+
/build
|
| 13 |
+
/captures
|
| 14 |
+
.externalNativeBuild
|
| 15 |
+
.cxx
|
| 16 |
+
local.properties
|
| 17 |
+
/app/google-services.json
|
Android/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🌍 RisingBrain-Android:Your AI OS Companion 📱
|
| 2 |
+
|
| 3 |
+
Venture into the future of artificial intelligence with **RisingBrain Android**- an essential component of 🧠RisingBrain🧠
|
| 4 |
+
|
| 5 |
+
We bring the revolutionary AI-powered OS right at your fingertips with our Android application.
|
| 6 |
+
This Android counterpart ensures you get all the smart features of RisingBrain OS on your smartphone.
|
| 7 |
+
|
| 8 |
+
Let's dive into the specifics!😆
|
| 9 |
+
|
| 10 |
+
## Getting Started 🏁
|
| 11 |
+
|
| 12 |
+
<p align='center'>
|
| 13 |
+
<img align='center' src='assets/img/desc.png' width='100%'>
|
| 14 |
+
</p>
|
| 15 |
+
<p align="center">
|
| 16 |
+
<img src="assets/img/architecture.png" width="92%">
|
| 17 |
+
</p>
|
| 18 |
+
|
| 19 |
+
This application has built with **MVVM architecture pattern**. (Using Android Architecture Components).
|
| 20 |
+
|
| 21 |
+
Repository Pattern, to abstract the source of data in the application.
|
| 22 |
+
Using of View Model, Live Data and data binding.
|
| 23 |
+
|
| 24 |
+
***The Application utilizes such popular libraries as: [Room](https://developer.android.com/training/data-storage/room), [OkHttp](https://github.com/square/okhttp), [Retrofit](https://github.com/square/retrofit), [Glide](https://github.com/bumptech/glide), etc.
|
| 25 |
+
Written in [Kotlin](https://kotlinlang.org/).***
|
| 26 |
+
|
| 27 |
+
## Features 💫
|
| 28 |
+
|
| 29 |
+
| Title | Description | ScreenShot |
|
| 30 |
+
|:------------------------------:|:--------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------:|
|
| 31 |
+
| Around-the-Clock Conversations | Enjoy casual chats with Rising AI, right from your Android device. | <img src="assets/img/general.png" width="270px" height="530px"/> |
|
| 32 |
+
| Quick Web Tours | Experience swift and accurate browsing based on your interests or queries. | <img src="assets/img/browser.png" width="270px" height="530px"/> |
|
| 33 |
+
| Picture Perfect | Hunt for images using visual cues or descriptions with our smart image search. | <img src="assets/img/image.png" width="270px" height="530px"/> |
|
| 34 |
+
| Stay Connected, Swiftly | Find contacts and initiate calls or text messages without extra effort. | <img src="assets/img/contact.png" width="270px" height="530px"/> |
|
| 35 |
+
| On-Time, Every Time | Set timely reminders and never miss an important event with our alarm feature. | <img src="assets/img/alarm.png" width="270px" height="530px"/> |
|
| 36 |
+
| Swift Emailing | Send emails instantly, without having to switch between apps. | <img src="assets/img/sms.png" width="270px" height="530px"/> |
|
| 37 |
+
| Configured Just for You | Modify backend settings as preferred for an optimized user experience. | <img src="assets/img/setting.png" width="270px" height="530px"/> |
|
| 38 |
+
| Real-Time Data | Stay updated with real-time data reflecting in your responses. | <img src="assets/img/real-time.png" width="270px" height="530px"/> |
|
| 39 |
+
|
| 40 |
+
## Compatibility 🤝
|
| 41 |
+
Our Android app is designed with a broad compatibility range, supporting various Android versions. Regardless of the device you own, RisingBrain Android ensures a seamless, advanced, and user-centric experience.
|
| 42 |
+
|
| 43 |
+
## Contributing 💪
|
| 44 |
+
We appreciate your interest in enhancing our work! Please respect the style and contribution guidelines of every project when submitting patches and additions. Our general Git workflow of choice is "fork-and-pull".
|
| 45 |
+
|
| 46 |
+
1. **Fork** the repository on GitHub
|
| 47 |
+
2. **Clone** your fork to your machine
|
| 48 |
+
3. **Commit** the changes to your personal branch
|
| 49 |
+
4. **Push** these updates back to your fork
|
| 50 |
+
5. Don't forget to submit a **Pull Request** for us to study your contributions.
|
| 51 |
+
|
| 52 |
+
NOTE: Sync with "upstream" to have the latest updates before you make a pull request!
|
Android/app/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/build
|
Android/app/build.gradle
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
plugins {
|
| 2 |
+
id 'com.android.application'
|
| 3 |
+
id 'com.google.gms.google-services'
|
| 4 |
+
id 'kotlin-kapt'
|
| 5 |
+
id 'kotlin-android'
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
android {
|
| 9 |
+
namespace 'com.matthaigh27.chatgptwrapper'
|
| 10 |
+
compileSdk 33
|
| 11 |
+
|
| 12 |
+
defaultConfig {
|
| 13 |
+
applicationId "com.matthaigh27.chatgptwrapper"
|
| 14 |
+
minSdk 28
|
| 15 |
+
targetSdk 33
|
| 16 |
+
versionCode 1
|
| 17 |
+
versionName "1.7"
|
| 18 |
+
|
| 19 |
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
buildTypes {
|
| 23 |
+
debug {
|
| 24 |
+
buildConfigField "String", "BASE_URL", "\"https://ttt246-brain.hf.space/\""
|
| 25 |
+
}
|
| 26 |
+
release {
|
| 27 |
+
buildConfigField "String", "BASE_URL", "\"https://ttt246-brain.hf.space/\""
|
| 28 |
+
|
| 29 |
+
minifyEnabled true
|
| 30 |
+
shrinkResources true
|
| 31 |
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
buildFeatures {
|
| 36 |
+
viewBinding true
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
compileOptions {
|
| 40 |
+
sourceCompatibility JavaVersion.VERSION_11
|
| 41 |
+
targetCompatibility JavaVersion.VERSION_11
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
kotlinOptions {
|
| 45 |
+
jvmTarget = JavaVersion.VERSION_11
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
dataBinding {
|
| 49 |
+
enabled true
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
dependencies {
|
| 54 |
+
//Core
|
| 55 |
+
implementation 'androidx.core:core-ktx:1.9.0'
|
| 56 |
+
implementation 'com.google.code.gson:gson:2.8.5'
|
| 57 |
+
|
| 58 |
+
//UI & UX
|
| 59 |
+
implementation 'androidx.appcompat:appcompat:1.6.0'
|
| 60 |
+
implementation 'com.google.android.material:material:1.8.0'
|
| 61 |
+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
| 62 |
+
implementation 'de.hdodenhof:circleimageview:3.1.0'
|
| 63 |
+
implementation 'com.github.soulqw:CoCo:1.1.2'
|
| 64 |
+
implementation 'com.github.dhaval2404:imagepicker:2.1'
|
| 65 |
+
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
| 66 |
+
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
| 67 |
+
|
| 68 |
+
testImplementation 'org.testng:testng:6.9.6'
|
| 69 |
+
|
| 70 |
+
// Testing-only dependencies
|
| 71 |
+
androidTestImplementation "androidx.test:core:$rootProject.coreVersion"
|
| 72 |
+
androidTestImplementation "androidx.test.ext:junit:$rootProject.extJUnitVersion"
|
| 73 |
+
androidTestImplementation "androidx.test:runner:$rootProject.runnerVersion"
|
| 74 |
+
|
| 75 |
+
testImplementation 'junit:junit:4.13.2'
|
| 76 |
+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
| 77 |
+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
| 78 |
+
|
| 79 |
+
// UiAutomator Testing
|
| 80 |
+
androidTestImplementation "androidx.test.uiautomator:uiautomator:$rootProject.uiAutomatorVersion"
|
| 81 |
+
androidTestImplementation 'org.hamcrest:hamcrest-integration:1.3'
|
| 82 |
+
|
| 83 |
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
|
| 84 |
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
|
| 85 |
+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha05"
|
| 86 |
+
|
| 87 |
+
//Firebase
|
| 88 |
+
implementation platform('com.google.firebase:firebase-bom:31.4.0')
|
| 89 |
+
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
|
| 90 |
+
|
| 91 |
+
implementation 'com.google.firebase:firebase-messaging'
|
| 92 |
+
implementation 'com.google.firebase:firebase-analytics'
|
| 93 |
+
implementation 'com.google.firebase:firebase-firestore-ktx:24.4.5'
|
| 94 |
+
implementation 'com.google.firebase:firebase-database-ktx:19.6.0'
|
| 95 |
+
implementation 'com.google.firebase:firebase-firestore:15.0.0'
|
| 96 |
+
implementation 'com.google.firebase:firebase-storage-ktx:20.1.0'
|
| 97 |
+
implementation 'com.google.firebase:firebase-messaging-ktx'
|
| 98 |
+
implementation 'com.google.firebase:firebase-analytics-ktx'
|
| 99 |
+
implementation 'com.firebaseui:firebase-ui-storage:7.2.0'
|
| 100 |
+
|
| 101 |
+
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
|
| 102 |
+
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
|
| 103 |
+
|
| 104 |
+
// To use room database
|
| 105 |
+
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
|
| 106 |
+
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
|
| 107 |
+
implementation "androidx.room:room-rxjava2:$rootProject.roomVersion"
|
| 108 |
+
implementation "androidx.room:room-rxjava3:$rootProject.roomVersion"
|
| 109 |
+
implementation "androidx.room:room-guava:$rootProject.roomVersion"
|
| 110 |
+
testImplementation "androidx.room:room-testing:$rootProject.roomVersion"
|
| 111 |
+
implementation "androidx.room:room-paging:$rootProject.roomVersion"
|
| 112 |
+
|
| 113 |
+
//To use Retrofit
|
| 114 |
+
|
| 115 |
+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
|
| 116 |
+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
|
| 117 |
+
|
| 118 |
+
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
|
| 119 |
+
implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
|
| 120 |
+
|
| 121 |
+
implementation "com.squareup.okhttp3:okhttp:$rootProject.okHttpVersion"
|
| 122 |
+
implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okHttpVersion"
|
| 123 |
+
implementation "com.squareup.okhttp3:okhttp-urlconnection:$rootProject.okHttpVersion"
|
| 124 |
+
}
|
Android/app/proguard-rules.pro
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Add project specific ProGuard rules here.
|
| 2 |
+
# You can control the set of applied configuration files using the
|
| 3 |
+
# proguardFiles setting in build.gradle.
|
| 4 |
+
#
|
| 5 |
+
# For more details, see
|
| 6 |
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
| 7 |
+
|
| 8 |
+
# If your project uses WebView with JS, uncomment the following
|
| 9 |
+
# and specify the fully qualified class name to the JavaScript interface
|
| 10 |
+
# class:
|
| 11 |
+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
| 12 |
+
# public *;
|
| 13 |
+
#}
|
| 14 |
+
|
| 15 |
+
# Uncomment this to preserve the line number information for
|
| 16 |
+
# debugging stack traces.
|
| 17 |
+
#-keepattributes SourceFile,LineNumberTable
|
| 18 |
+
|
| 19 |
+
# If you keep the line number information, uncomment this to
|
| 20 |
+
# hide the original source file name.
|
| 21 |
+
#-renamesourcefileattribute SourceFile
|
Android/app/src/androidTest/java/com/matthaigh27/chatgptwrapper/ExampleInstrumentedTest.kt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper
|
| 2 |
+
|
| 3 |
+
import androidx.test.platform.app.InstrumentationRegistry
|
| 4 |
+
import androidx.test.ext.junit.runners.AndroidJUnit4
|
| 5 |
+
|
| 6 |
+
import org.junit.Test
|
| 7 |
+
import org.junit.runner.RunWith
|
| 8 |
+
|
| 9 |
+
import org.junit.Assert.*
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Instrumented test, which will execute on an Android device.
|
| 13 |
+
*
|
| 14 |
+
* See [testing documentation](http://d.android.com/tools/testing).
|
| 15 |
+
*/
|
| 16 |
+
@RunWith(AndroidJUnit4::class)
|
| 17 |
+
class
|
| 18 |
+
|
| 19 |
+
ExampleInstrumentedTest {
|
| 20 |
+
@Test
|
| 21 |
+
fun useAppContext() {
|
| 22 |
+
// Context of the app under test.
|
| 23 |
+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
| 24 |
+
assertEquals("com.matthaigh27.chatgptwrapper", appContext.packageName)
|
| 25 |
+
}
|
| 26 |
+
}
|
Android/app/src/main/AndroidManifest.xml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
| 2 |
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
| 3 |
+
package="com.matthaigh27.chatgptwrapper">
|
| 4 |
+
|
| 5 |
+
<uses-permission android:name="android.permission.INTERNET" />
|
| 6 |
+
<uses-permission android:name="android.permission.MICROPHONE" />
|
| 7 |
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
| 8 |
+
<uses-permission android:name="android.permission.LAUNCHER" />
|
| 9 |
+
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
|
| 10 |
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
| 11 |
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
| 12 |
+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
| 13 |
+
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
| 14 |
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
| 15 |
+
<uses-permission
|
| 16 |
+
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
| 17 |
+
android:maxSdkVersion="32" />
|
| 18 |
+
<uses-permission
|
| 19 |
+
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
| 20 |
+
android:maxSdkVersion="32" />
|
| 21 |
+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
| 22 |
+
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
| 23 |
+
<uses-permission android:name="android.permission.SEND_SMS" />
|
| 24 |
+
<uses-permission android:name="android.permission.CALL_PHONE" />
|
| 25 |
+
|
| 26 |
+
<uses-feature android:name="android.hardware.audio.low_latency" />
|
| 27 |
+
<uses-feature android:name="android.hardware.audio.pro" />
|
| 28 |
+
<uses-feature android:name="android.hardware.microphone" />
|
| 29 |
+
<uses-feature
|
| 30 |
+
android:name="android.hardware.telephony"
|
| 31 |
+
android:required="false" />
|
| 32 |
+
|
| 33 |
+
<application
|
| 34 |
+
android:name=".RisingApplication"
|
| 35 |
+
android:hardwareAccelerated="true"
|
| 36 |
+
android:icon="@mipmap/gpt_icon"
|
| 37 |
+
android:label="@string/app_name"
|
| 38 |
+
android:roundIcon="@mipmap/gpt_icon_round"
|
| 39 |
+
android:supportsRtl="true"
|
| 40 |
+
android:theme="@style/AppTheme">
|
| 41 |
+
<activity
|
| 42 |
+
android:name=".ui.splash.SplashActivity"
|
| 43 |
+
android:exported="true">
|
| 44 |
+
<intent-filter>
|
| 45 |
+
<action android:name="android.intent.action.MAIN" />
|
| 46 |
+
|
| 47 |
+
<category android:name="android.intent.category.LAUNCHER" />
|
| 48 |
+
</intent-filter>
|
| 49 |
+
</activity>
|
| 50 |
+
<activity
|
| 51 |
+
android:name=".ui.setting.view.SettingActivity"
|
| 52 |
+
android:exported="false" />
|
| 53 |
+
<activity
|
| 54 |
+
android:name=".ui.chat.view.ChatActivity"
|
| 55 |
+
android:exported="false" />
|
| 56 |
+
|
| 57 |
+
<receiver
|
| 58 |
+
android:name=".utils.helpers.chat.AlarmReceiver"
|
| 59 |
+
android:enabled="true"
|
| 60 |
+
android:exported="true" />
|
| 61 |
+
</application>
|
| 62 |
+
|
| 63 |
+
</manifest>
|
Android/app/src/main/gpt_icon-playstore.png
ADDED
|
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/RisingApplication.kt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper
|
| 2 |
+
|
| 3 |
+
import android.annotation.SuppressLint
|
| 4 |
+
import android.app.Application
|
| 5 |
+
import android.provider.Settings
|
| 6 |
+
import android.util.Log
|
| 7 |
+
import com.google.android.gms.tasks.OnCompleteListener
|
| 8 |
+
import com.google.firebase.messaging.FirebaseMessaging
|
| 9 |
+
|
| 10 |
+
class RisingApplication : Application() {
|
| 11 |
+
|
| 12 |
+
private var fcmToken: String = String()
|
| 13 |
+
private var uuid: String = String()
|
| 14 |
+
@SuppressLint("HardwareIds")
|
| 15 |
+
override fun onCreate() {
|
| 16 |
+
super.onCreate()
|
| 17 |
+
|
| 18 |
+
initToken()
|
| 19 |
+
// on below line we are getting device id.
|
| 20 |
+
uuid = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
| 21 |
+
appContext = applicationContext as RisingApplication
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
private fun initToken() {
|
| 25 |
+
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
|
| 26 |
+
if (!task.isSuccessful) {
|
| 27 |
+
return@OnCompleteListener
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
fcmToken = task.result
|
| 31 |
+
})
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
fun getFCMToken(): String {
|
| 35 |
+
return this.fcmToken
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
fun getUUID(): String {
|
| 39 |
+
return this.uuid
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
companion object {
|
| 43 |
+
lateinit var appContext: RisingApplication
|
| 44 |
+
}
|
| 45 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/AppDatabase.kt
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.local
|
| 2 |
+
|
| 3 |
+
import android.content.Context
|
| 4 |
+
import androidx.room.Database
|
| 5 |
+
import androidx.room.Room
|
| 6 |
+
import androidx.room.RoomDatabase
|
| 7 |
+
import com.matthaigh27.chatgptwrapper.data.local.dao.ContactDao
|
| 8 |
+
import com.matthaigh27.chatgptwrapper.data.local.dao.ImageDao
|
| 9 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ContactEntity
|
| 10 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ImageEntity
|
| 11 |
+
|
| 12 |
+
@Database(entities = [ImageEntity::class, ContactEntity::class], version = 1, exportSchema = false)
|
| 13 |
+
abstract class AppDatabase : RoomDatabase() {
|
| 14 |
+
|
| 15 |
+
abstract fun imageDao(): ImageDao
|
| 16 |
+
abstract fun contactDao(): ContactDao
|
| 17 |
+
|
| 18 |
+
companion object {
|
| 19 |
+
private val DATABASE_NAME = "RisingPhone"
|
| 20 |
+
|
| 21 |
+
@Volatile
|
| 22 |
+
private var INSTANCE: AppDatabase? = null
|
| 23 |
+
|
| 24 |
+
fun getDatabase(context: Context): AppDatabase {
|
| 25 |
+
val tempInstance = INSTANCE
|
| 26 |
+
if (tempInstance != null) {
|
| 27 |
+
return tempInstance
|
| 28 |
+
}
|
| 29 |
+
synchronized(this) {
|
| 30 |
+
val instance = Room.databaseBuilder(
|
| 31 |
+
context = context.applicationContext,
|
| 32 |
+
klass = AppDatabase::class.java,
|
| 33 |
+
name = DATABASE_NAME
|
| 34 |
+
).build()
|
| 35 |
+
INSTANCE = instance
|
| 36 |
+
return instance
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/dao/ContactDao.kt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.local.dao
|
| 2 |
+
|
| 3 |
+
import androidx.room.*
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ContactEntity
|
| 5 |
+
|
| 6 |
+
@Dao
|
| 7 |
+
interface ContactDao {
|
| 8 |
+
@Insert
|
| 9 |
+
suspend fun insert(contact: ContactEntity)
|
| 10 |
+
|
| 11 |
+
@Update
|
| 12 |
+
suspend fun update(contact: ContactEntity)
|
| 13 |
+
|
| 14 |
+
@Delete
|
| 15 |
+
suspend fun delete(contact: ContactEntity)
|
| 16 |
+
|
| 17 |
+
@Query("SELECT * FROM contacts")
|
| 18 |
+
suspend fun getAllData(): List<ContactEntity>
|
| 19 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/dao/ImageDao.kt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.local.dao
|
| 2 |
+
|
| 3 |
+
import androidx.room.*
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ImageEntity
|
| 5 |
+
|
| 6 |
+
@Dao
|
| 7 |
+
interface ImageDao {
|
| 8 |
+
@Insert
|
| 9 |
+
suspend fun insert(image: ImageEntity)
|
| 10 |
+
|
| 11 |
+
@Update
|
| 12 |
+
suspend fun update(image: ImageEntity)
|
| 13 |
+
|
| 14 |
+
@Delete
|
| 15 |
+
suspend fun delete(image: ImageEntity)
|
| 16 |
+
|
| 17 |
+
@Query("SELECT * FROM images")
|
| 18 |
+
suspend fun getAllData(): List<ImageEntity>
|
| 19 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/entity/ContactEntity.kt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.local.entity
|
| 2 |
+
|
| 3 |
+
import androidx.room.Entity
|
| 4 |
+
import androidx.room.PrimaryKey
|
| 5 |
+
|
| 6 |
+
@Entity(tableName = "contacts")
|
| 7 |
+
data class ContactEntity(
|
| 8 |
+
@PrimaryKey(autoGenerate = false) val id: String,
|
| 9 |
+
val name: String,
|
| 10 |
+
val phoneNumber: String,
|
| 11 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/local/entity/ImageEntity.kt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.local.entity
|
| 2 |
+
|
| 3 |
+
import androidx.room.Entity
|
| 4 |
+
import androidx.room.PrimaryKey
|
| 5 |
+
|
| 6 |
+
@Entity(tableName = "images")
|
| 7 |
+
data class ImageEntity(
|
| 8 |
+
@PrimaryKey(autoGenerate = true) val id: Int,
|
| 9 |
+
val path: String,
|
| 10 |
+
val name: String,
|
| 11 |
+
val dataModified: Long
|
| 12 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/AlarmModel.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
data class AlarmModel(
|
| 4 |
+
val id: Int,
|
| 5 |
+
val time: Long,
|
| 6 |
+
val enabled: Boolean,
|
| 7 |
+
val label: String
|
| 8 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/AutoTaskModel.kt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* This class denotes a model to store AutoTask data in Firebase realtime database.
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
data class AutoTaskModel(
|
| 8 |
+
val command: Command? = null,
|
| 9 |
+
val result: String? = null,
|
| 10 |
+
val thoughts: Thoughts? = null
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
data class Command(
|
| 14 |
+
val args: Args? = null,
|
| 15 |
+
val name: String? = null
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
data class Args(
|
| 19 |
+
val tool_input: String? = null,
|
| 20 |
+
val file_path: String? = null,
|
| 21 |
+
val text: String? = null,
|
| 22 |
+
val response: String? = null
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
data class Thoughts(
|
| 26 |
+
val criticism: String? = null,
|
| 27 |
+
val plan: String? = null,
|
| 28 |
+
val reasoning: String? = null,
|
| 29 |
+
val speak: String? = null,
|
| 30 |
+
val text: String? = null
|
| 31 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ChatMessageModel.kt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
import com.google.gson.JsonElement
|
| 4 |
+
|
| 5 |
+
data class ChatMessageModel(
|
| 6 |
+
val type: Int,
|
| 7 |
+
val content: String? = null,
|
| 8 |
+
val data: JsonElement? = null,
|
| 9 |
+
val hasImage: Boolean = false,
|
| 10 |
+
val image: ByteArray? = null,
|
| 11 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ContactModel.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
data class ContactModel(
|
| 4 |
+
var contactId: String = String(),
|
| 5 |
+
var displayName: String = String(),
|
| 6 |
+
var phoneNumbers: ArrayList<String> = ArrayList(),
|
| 7 |
+
var status: String = String()
|
| 8 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/HelpCommandModel.kt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
data class HelpCommandModel(
|
| 4 |
+
var main: String? = null,
|
| 5 |
+
var assist: String? = null
|
| 6 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/HelpPromptModel.kt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
import com.google.gson.Gson
|
| 4 |
+
|
| 5 |
+
data class HelpPromptModel(
|
| 6 |
+
var name: String = "",
|
| 7 |
+
var description: String = "",
|
| 8 |
+
var prompt: String = "",
|
| 9 |
+
var tags: ArrayList<String> = ArrayList()
|
| 10 |
+
) {
|
| 11 |
+
override fun toString(): String {
|
| 12 |
+
val gson = Gson()
|
| 13 |
+
return gson.toJson(this)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
companion object {
|
| 17 |
+
fun init(string: String): HelpPromptModel {
|
| 18 |
+
val gson = Gson()
|
| 19 |
+
return gson.fromJson(string, HelpPromptModel::class.java)
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ImageModel.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
import android.net.Uri
|
| 4 |
+
|
| 5 |
+
data class ImageModel(
|
| 6 |
+
val uri: Uri,
|
| 7 |
+
val modifiedDate: Long
|
| 8 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/ImageRelatenessModel.kt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
data class ImageRelatenessModel(
|
| 4 |
+
val image: ByteArray? = null,
|
| 5 |
+
val description: String? = null
|
| 6 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chat/MailModel.kt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chat
|
| 2 |
+
|
| 3 |
+
data class MailModel(
|
| 4 |
+
val from: String,
|
| 5 |
+
val to: String,
|
| 6 |
+
val date: String,
|
| 7 |
+
val cc: String,
|
| 8 |
+
val subject: String,
|
| 9 |
+
val body: String,
|
| 10 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chatwidgetprops/MailsProps.kt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chatwidgetprops
|
| 2 |
+
|
| 3 |
+
import com.google.gson.Gson
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.MailModel
|
| 5 |
+
|
| 6 |
+
data class MailsProps(
|
| 7 |
+
val mails: ArrayList<MailModel>
|
| 8 |
+
) {
|
| 9 |
+
override fun toString(): String {
|
| 10 |
+
val gson = Gson()
|
| 11 |
+
return gson.toJson(this)
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
companion object {
|
| 15 |
+
fun init(string: String): MailsProps {
|
| 16 |
+
val gson = Gson()
|
| 17 |
+
return gson.fromJson(string, MailsProps::class.java)
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/chatwidgetprops/ScheduleAlarmProps.kt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.chatwidgetprops
|
| 2 |
+
|
| 3 |
+
import com.google.gson.Gson
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.HelpPromptModel
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.models.common.Time
|
| 6 |
+
|
| 7 |
+
data class ScheduleAlarmProps(
|
| 8 |
+
val time: Time? = null,
|
| 9 |
+
val label: String? = null,
|
| 10 |
+
val repeat: BooleanArray? = null
|
| 11 |
+
) {
|
| 12 |
+
override fun toString(): String {
|
| 13 |
+
val gson = Gson()
|
| 14 |
+
return gson.toJson(this)
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
companion object {
|
| 18 |
+
fun init(string: String): ScheduleAlarmProps {
|
| 19 |
+
val gson = Gson()
|
| 20 |
+
return gson.fromJson(string, ScheduleAlarmProps::class.java)
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/common/Time.kt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.common
|
| 2 |
+
|
| 3 |
+
data class Time (
|
| 4 |
+
val hour:Int,
|
| 5 |
+
val minute:Int,
|
| 6 |
+
val second:Int,
|
| 7 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/models/setting/SettingModel.kt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.models.setting
|
| 2 |
+
|
| 3 |
+
import com.google.gson.Gson
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.HelpPromptModel
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.OpenAISetting
|
| 6 |
+
|
| 7 |
+
data class SettingModel(
|
| 8 |
+
val openaiKey: String,
|
| 9 |
+
val pineconeEnv: String,
|
| 10 |
+
val pineconeKey: String,
|
| 11 |
+
val firebaseKey: String,
|
| 12 |
+
val setting: OpenAISetting
|
| 13 |
+
) {
|
| 14 |
+
override fun toString(): String {
|
| 15 |
+
val gson = Gson()
|
| 16 |
+
return gson.toJson(this)
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
companion object {
|
| 20 |
+
fun init(string: String): SettingModel {
|
| 21 |
+
val gson = Gson()
|
| 22 |
+
return gson.fromJson(string, SettingModel::class.java)
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiClient.kt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.utils.constants.CommonConstants.API_BASE_URL
|
| 4 |
+
import okhttp3.OkHttpClient
|
| 5 |
+
import retrofit2.Retrofit
|
| 6 |
+
import retrofit2.converter.gson.GsonConverterFactory
|
| 7 |
+
import java.util.concurrent.TimeUnit
|
| 8 |
+
|
| 9 |
+
object ApiClient {
|
| 10 |
+
val TIME_OUT_CALL = 60L
|
| 11 |
+
val TIME_OUT_CONNECT = 60L
|
| 12 |
+
val TIME_OUT_READ = 60L
|
| 13 |
+
val TIME_OUT_WRITE = 60L
|
| 14 |
+
|
| 15 |
+
private val client = OkHttpClient
|
| 16 |
+
.Builder()
|
| 17 |
+
.callTimeout(TIME_OUT_CALL, TimeUnit.SECONDS)
|
| 18 |
+
.connectTimeout(TIME_OUT_CONNECT, TimeUnit.SECONDS)
|
| 19 |
+
.readTimeout(TIME_OUT_READ, TimeUnit.SECONDS)
|
| 20 |
+
.writeTimeout(TIME_OUT_WRITE, TimeUnit.SECONDS)
|
| 21 |
+
.build()
|
| 22 |
+
|
| 23 |
+
private val retrofit = Retrofit
|
| 24 |
+
.Builder()
|
| 25 |
+
.baseUrl(API_BASE_URL)
|
| 26 |
+
.addConverterFactory(GsonConverterFactory.create())
|
| 27 |
+
.client(client)
|
| 28 |
+
.build()
|
| 29 |
+
|
| 30 |
+
val apiService: ApiService = retrofit.create(ApiService::class.java)
|
| 31 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiResource.kt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote
|
| 2 |
+
|
| 3 |
+
sealed class ApiResource<T>(
|
| 4 |
+
val data: T? = null, val message: String? = null
|
| 5 |
+
) {
|
| 6 |
+
class Success<T>(data: T) : ApiResource<T>(data)
|
| 7 |
+
class Error<T>(message: String, data: T? = null) : ApiResource<T>(data, message)
|
| 8 |
+
class Loading<T>(data: T? = null) : ApiResource<T>(data)
|
| 9 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/ApiService.kt
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.MailModel
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.BaseApiRequest
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ComposeMailApiRequest
|
| 6 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ImageRelatednessApiRequest
|
| 7 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.NotificationApiRequest
|
| 8 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ReadMailApiRequest
|
| 9 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainContactsApiRequest
|
| 10 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
|
| 11 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
|
| 12 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.CommonResult
|
| 13 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.HelpCommandResult
|
| 14 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.ImageRelatenessResult
|
| 15 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.TrainImageResult
|
| 16 |
+
import retrofit2.Call
|
| 17 |
+
import retrofit2.http.Body
|
| 18 |
+
import retrofit2.http.POST
|
| 19 |
+
|
| 20 |
+
interface ApiService {
|
| 21 |
+
@POST("commands")
|
| 22 |
+
fun getAllHelpCommands(@Body request: BaseApiRequest): Call<ApiResponse<HelpCommandResult>>
|
| 23 |
+
|
| 24 |
+
@POST("sendNotification")
|
| 25 |
+
fun sendNotification(@Body request: NotificationApiRequest): Call<ApiResponse<CommonResult>>
|
| 26 |
+
|
| 27 |
+
@POST("train/contacts")
|
| 28 |
+
fun trainContacts(@Body request: TrainContactsApiRequest): Call<ApiResponse<String>>
|
| 29 |
+
|
| 30 |
+
@POST("image_relatedness")
|
| 31 |
+
fun getImageRelatedness(@Body request: ImageRelatednessApiRequest): Call<ApiResponse<ImageRelatenessResult>>
|
| 32 |
+
|
| 33 |
+
@POST("uploadImage")
|
| 34 |
+
fun trainImage(@Body request: TrainImageApiRequest): Call<ApiResponse<TrainImageResult>>
|
| 35 |
+
|
| 36 |
+
@POST("email/read_emails")
|
| 37 |
+
fun readEmails(@Body request: ReadMailApiRequest): Call<ApiResponse<ArrayList<MailModel>>>
|
| 38 |
+
|
| 39 |
+
@POST("email/send_email")
|
| 40 |
+
fun sendEmail(@Body request: ComposeMailApiRequest): Call<ApiResponse<String>>
|
| 41 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/BaseApiRequest.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class BaseApiRequest(
|
| 6 |
+
val confs: Keys
|
| 7 |
+
)
|
| 8 |
+
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ComposeMailApiRequest.kt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class ComposeMailApiRequest(
|
| 6 |
+
val data: ComposeMailData,
|
| 7 |
+
val confs: Keys
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
data class ComposeMailData(
|
| 11 |
+
private val sender: String,
|
| 12 |
+
private val pwd: String,
|
| 13 |
+
private val to: String,
|
| 14 |
+
private val subject: String,
|
| 15 |
+
private val body: String,
|
| 16 |
+
private val to_send: Boolean,
|
| 17 |
+
private val filename: String,
|
| 18 |
+
private val file_content: String
|
| 19 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ImageRelatednessApiRequest.kt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class ImageRelatednessApiRequest(
|
| 6 |
+
val image_name: String,
|
| 7 |
+
val message: String,
|
| 8 |
+
val confs: Keys
|
| 9 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/NotificationApiRequest.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class NotificationApiRequest(
|
| 6 |
+
val message: String,
|
| 7 |
+
val confs: Keys
|
| 8 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/ReadMailApiRequest.kt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class ReadMailApiRequest(
|
| 6 |
+
val data: ReadMailData,
|
| 7 |
+
val confs: Keys
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
data class ReadMailData(
|
| 11 |
+
val sender: String,
|
| 12 |
+
val pwd: String,
|
| 13 |
+
val imap_folder: String,
|
| 14 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/TrainContactsApiRequest.kt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.ContactModel
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 5 |
+
|
| 6 |
+
data class TrainContactsApiRequest(
|
| 7 |
+
val contacts: ArrayList<ContactModel>,
|
| 8 |
+
val confs: Keys
|
| 9 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/TrainImageApiRequest.kt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 4 |
+
|
| 5 |
+
data class TrainImageApiRequest(
|
| 6 |
+
val image_name: String,
|
| 7 |
+
val status: String,
|
| 8 |
+
val confs: Keys
|
| 9 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/common/Keys.kt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests.common
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
data class Keys(
|
| 5 |
+
val uuid: String,
|
| 6 |
+
val token: String,
|
| 7 |
+
val openai_key: String,
|
| 8 |
+
val pinecone_key: String,
|
| 9 |
+
val pinecone_env: String,
|
| 10 |
+
val firebase_key: String,
|
| 11 |
+
val settings: OpenAISetting,
|
| 12 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/requests/common/OpenAISetting.kt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.requests.common
|
| 2 |
+
|
| 3 |
+
data class OpenAISetting(
|
| 4 |
+
val temperature: Float
|
| 5 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/ApiResponse.kt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.responses
|
| 2 |
+
|
| 3 |
+
data class ApiResponse<T>(
|
| 4 |
+
val status_code: Int,
|
| 5 |
+
val message: List<String>,
|
| 6 |
+
val result: T
|
| 7 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/CommonResult.kt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.responses.results
|
| 2 |
+
|
| 3 |
+
import com.google.gson.JsonElement
|
| 4 |
+
|
| 5 |
+
data class CommonResult(
|
| 6 |
+
val program: String,
|
| 7 |
+
val content: JsonElement
|
| 8 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/HelpCommandResult.kt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.responses.results
|
| 2 |
+
|
| 3 |
+
data class HelpCommandResult(
|
| 4 |
+
val program: String,
|
| 5 |
+
val content: ArrayList<HelpCommandResponseItem>
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
data class HelpCommandResponseItem(
|
| 9 |
+
val name: String,
|
| 10 |
+
val description: String,
|
| 11 |
+
val prompt: String,
|
| 12 |
+
val tags: ArrayList<String>,
|
| 13 |
+
val enabled: Boolean
|
| 14 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/ImageRelatenessResult.kt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.responses.results
|
| 2 |
+
|
| 3 |
+
data class ImageRelatenessResult(
|
| 4 |
+
val program: String,
|
| 5 |
+
val content: ImageRelatenessContent
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
data class ImageRelatenessContent(
|
| 9 |
+
val image_name: String,
|
| 10 |
+
val image_desc: String
|
| 11 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/remote/responses/results/TrainImageResult.kt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.remote.responses.results
|
| 2 |
+
|
| 3 |
+
data class TrainImageResult(
|
| 4 |
+
val image_name: String,
|
| 5 |
+
val image_text: String
|
| 6 |
+
)
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/FirebaseRepository.kt
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.repository
|
| 2 |
+
|
| 3 |
+
import com.google.firebase.storage.FirebaseStorage
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.OnFailure
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.OnSuccess
|
| 6 |
+
import java.util.UUID
|
| 7 |
+
import kotlin.coroutines.resume
|
| 8 |
+
import kotlin.coroutines.suspendCoroutine
|
| 9 |
+
|
| 10 |
+
object FirebaseRepository {
|
| 11 |
+
fun downloadImageWithName(
|
| 12 |
+
name: String, onSuccess: OnSuccess<ByteArray>, onFailure: OnFailure<String>
|
| 13 |
+
) {
|
| 14 |
+
val reference = "images/$name"
|
| 15 |
+
|
| 16 |
+
val storageReference = FirebaseStorage.getInstance().getReference(reference)
|
| 17 |
+
storageReference.getBytes(Long.MAX_VALUE).addOnSuccessListener { bytes ->
|
| 18 |
+
onSuccess(bytes)
|
| 19 |
+
}.addOnFailureListener { e ->
|
| 20 |
+
onFailure(e.toString())
|
| 21 |
+
}
|
| 22 |
+
return
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
fun uploadImageAsync(
|
| 26 |
+
imageByteArray: ByteArray, onSuccess: OnSuccess<String>, onFailure: OnFailure<String>
|
| 27 |
+
) {
|
| 28 |
+
val storageRef = FirebaseStorage.getInstance().reference
|
| 29 |
+
val uuid = UUID.randomUUID()
|
| 30 |
+
val imageName = "images/${uuid}"
|
| 31 |
+
val imageRef = storageRef.child(imageName)
|
| 32 |
+
|
| 33 |
+
val uploadTask = imageRef.putBytes(imageByteArray)
|
| 34 |
+
uploadTask.addOnFailureListener {
|
| 35 |
+
onFailure("Fail to upload image to firebase.")
|
| 36 |
+
}.addOnSuccessListener {
|
| 37 |
+
onSuccess("$uuid")
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
suspend fun uploadImage(imageByteArray: ByteArray): String = suspendCoroutine { continuation ->
|
| 42 |
+
val storageRef = FirebaseStorage.getInstance().reference
|
| 43 |
+
val uuid = UUID.randomUUID()
|
| 44 |
+
val imageName = "images/${uuid}"
|
| 45 |
+
val imageRef = storageRef.child(imageName)
|
| 46 |
+
|
| 47 |
+
val uploadTask = imageRef.putBytes(imageByteArray)
|
| 48 |
+
|
| 49 |
+
uploadTask.addOnFailureListener {
|
| 50 |
+
continuation.resume("Error")
|
| 51 |
+
}.addOnSuccessListener {
|
| 52 |
+
continuation.resume("$uuid")
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/RemoteRepository.kt
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.repository
|
| 2 |
+
|
| 3 |
+
import com.matthaigh27.chatgptwrapper.RisingApplication.Companion.appContext
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.data.models.chat.MailModel
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.models.setting.SettingModel
|
| 6 |
+
import com.matthaigh27.chatgptwrapper.data.remote.ApiClient
|
| 7 |
+
import com.matthaigh27.chatgptwrapper.data.remote.ApiResource
|
| 8 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.BaseApiRequest
|
| 9 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ComposeMailApiRequest
|
| 10 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ImageRelatednessApiRequest
|
| 11 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.NotificationApiRequest
|
| 12 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.ReadMailApiRequest
|
| 13 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainContactsApiRequest
|
| 14 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.TrainImageApiRequest
|
| 15 |
+
import com.matthaigh27.chatgptwrapper.data.remote.requests.common.Keys
|
| 16 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.ApiResponse
|
| 17 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.CommonResult
|
| 18 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.HelpCommandResult
|
| 19 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.ImageRelatenessResult
|
| 20 |
+
import com.matthaigh27.chatgptwrapper.data.remote.responses.results.TrainImageResult
|
| 21 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.OnFailure
|
| 22 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.OnSuccess
|
| 23 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.chat.SettingHelper.emptySettingModel
|
| 24 |
+
import kotlinx.coroutines.runBlocking
|
| 25 |
+
import retrofit2.Call
|
| 26 |
+
import retrofit2.Callback
|
| 27 |
+
import retrofit2.Response
|
| 28 |
+
import kotlin.coroutines.resume
|
| 29 |
+
import kotlin.coroutines.suspendCoroutine
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
object RemoteRepository {
|
| 33 |
+
private val apiService = ApiClient.apiService
|
| 34 |
+
|
| 35 |
+
fun getKeys(): Keys{
|
| 36 |
+
RoomRepository
|
| 37 |
+
val settingModel = SharedPreferencesRepository.getConfig()
|
| 38 |
+
val keys = Keys(
|
| 39 |
+
uuid = appContext.getUUID(),
|
| 40 |
+
token = appContext.getFCMToken(),
|
| 41 |
+
openai_key = settingModel.openaiKey,
|
| 42 |
+
pinecone_env = settingModel.pineconeEnv,
|
| 43 |
+
pinecone_key = settingModel.pineconeKey,
|
| 44 |
+
firebase_key = settingModel.firebaseKey,
|
| 45 |
+
settings = settingModel.setting
|
| 46 |
+
)
|
| 47 |
+
return keys
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
fun getAllHelpCommands(
|
| 51 |
+
onSuccess: OnSuccess<ApiResponse<HelpCommandResult>>,
|
| 52 |
+
onFailure: OnFailure<String>
|
| 53 |
+
) {
|
| 54 |
+
val call = apiService.getAllHelpCommands(BaseApiRequest(getKeys()))
|
| 55 |
+
|
| 56 |
+
call.enqueue(object : Callback<ApiResponse<HelpCommandResult>> {
|
| 57 |
+
override fun onResponse(call: Call<ApiResponse<HelpCommandResult>>, response: Response<ApiResponse<HelpCommandResult>>) {
|
| 58 |
+
response.body()?.let { data ->
|
| 59 |
+
onSuccess(data)
|
| 60 |
+
} ?: run {
|
| 61 |
+
onFailure(response.message())
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
override fun onFailure(call: Call<ApiResponse<HelpCommandResult>>, t: Throwable) {
|
| 66 |
+
onFailure(t.message.toString())
|
| 67 |
+
}
|
| 68 |
+
})
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
fun sendNotification(
|
| 72 |
+
request: NotificationApiRequest,
|
| 73 |
+
onSuccess: OnSuccess<ApiResponse<CommonResult>>,
|
| 74 |
+
onFailure: OnFailure<String>
|
| 75 |
+
) {
|
| 76 |
+
val call = apiService.sendNotification(request)
|
| 77 |
+
|
| 78 |
+
call.enqueue(object : Callback<ApiResponse<CommonResult>> {
|
| 79 |
+
override fun onResponse(call: Call<ApiResponse<CommonResult>>, response: Response<ApiResponse<CommonResult>>) {
|
| 80 |
+
response.body()?.let { data ->
|
| 81 |
+
onSuccess(data)
|
| 82 |
+
} ?: run {
|
| 83 |
+
onFailure(response.errorBody().toString())
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
override fun onFailure(call: Call<ApiResponse<CommonResult>>, t: Throwable) {
|
| 88 |
+
onFailure(t.message.toString())
|
| 89 |
+
}
|
| 90 |
+
})
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
fun trainContacts(
|
| 94 |
+
request: TrainContactsApiRequest,
|
| 95 |
+
onSuccess: OnSuccess<ApiResponse<String>>,
|
| 96 |
+
onFailure: OnFailure<String>
|
| 97 |
+
) {
|
| 98 |
+
val call = apiService.trainContacts(request)
|
| 99 |
+
|
| 100 |
+
call.enqueue(object : Callback<ApiResponse<String>> {
|
| 101 |
+
override fun onResponse(
|
| 102 |
+
call: Call<ApiResponse<String>>, response: Response<ApiResponse<String>>
|
| 103 |
+
) {
|
| 104 |
+
response.body()?.let { data ->
|
| 105 |
+
onSuccess(data)
|
| 106 |
+
} ?: run {
|
| 107 |
+
onFailure(response.message())
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
override fun onFailure(call: Call<ApiResponse<String>>, t: Throwable) {
|
| 112 |
+
onFailure(t.message.toString())
|
| 113 |
+
}
|
| 114 |
+
})
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
suspend fun trainImage(request: TrainImageApiRequest) : ApiResource<ApiResponse<TrainImageResult>> = suspendCoroutine { continuation ->
|
| 118 |
+
|
| 119 |
+
val call = apiService.trainImage(request)
|
| 120 |
+
|
| 121 |
+
call.enqueue(object : Callback<ApiResponse<TrainImageResult>> {
|
| 122 |
+
override fun onResponse(
|
| 123 |
+
call: Call<ApiResponse<TrainImageResult>>, response: Response<ApiResponse<TrainImageResult>>
|
| 124 |
+
) {
|
| 125 |
+
response.body()?.let { data ->
|
| 126 |
+
continuation.resume(ApiResource.Success(data))
|
| 127 |
+
} ?: run {
|
| 128 |
+
continuation.resume(ApiResource.Error("Error"))
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
override fun onFailure(call: Call<ApiResponse<TrainImageResult>>, t: Throwable) {
|
| 133 |
+
continuation.resume(ApiResource.Error(t.message.toString()))
|
| 134 |
+
}
|
| 135 |
+
})
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
fun getImageRelatedness(
|
| 139 |
+
request: ImageRelatednessApiRequest,
|
| 140 |
+
onSuccess: OnSuccess<ApiResponse<ImageRelatenessResult>>,
|
| 141 |
+
onFailure: OnFailure<String>
|
| 142 |
+
) {
|
| 143 |
+
val call = apiService.getImageRelatedness(request)
|
| 144 |
+
|
| 145 |
+
call.enqueue(object : Callback<ApiResponse<ImageRelatenessResult>> {
|
| 146 |
+
override fun onResponse(
|
| 147 |
+
call: Call<ApiResponse<ImageRelatenessResult>>, response: Response<ApiResponse<ImageRelatenessResult>>
|
| 148 |
+
) {
|
| 149 |
+
response.body()?.let { data ->
|
| 150 |
+
onSuccess(data)
|
| 151 |
+
} ?: run {
|
| 152 |
+
onFailure(response.message())
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
override fun onFailure(call: Call<ApiResponse<ImageRelatenessResult>>, t: Throwable) {
|
| 157 |
+
onFailure(t.message.toString())
|
| 158 |
+
}
|
| 159 |
+
})
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
fun readEmails(
|
| 163 |
+
request: ReadMailApiRequest,
|
| 164 |
+
onSuccess: OnSuccess<ApiResponse<ArrayList<MailModel>>>,
|
| 165 |
+
onFailure: OnFailure<String>
|
| 166 |
+
) {
|
| 167 |
+
val call = apiService.readEmails(request)
|
| 168 |
+
|
| 169 |
+
call.enqueue(object : Callback<ApiResponse<ArrayList<MailModel>>> {
|
| 170 |
+
override fun onResponse(
|
| 171 |
+
call: Call<ApiResponse<ArrayList<MailModel>>>, response: Response<ApiResponse<ArrayList<MailModel>>>
|
| 172 |
+
) {
|
| 173 |
+
response.body()?.let { data ->
|
| 174 |
+
onSuccess(data)
|
| 175 |
+
} ?: run {
|
| 176 |
+
onFailure(response.message())
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
override fun onFailure(call: Call<ApiResponse<ArrayList<MailModel>>>, t: Throwable) {
|
| 181 |
+
onFailure(t.message.toString())
|
| 182 |
+
}
|
| 183 |
+
})
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
fun sendEmail(
|
| 187 |
+
request: ComposeMailApiRequest,
|
| 188 |
+
onSuccess: OnSuccess<ApiResponse<String>>,
|
| 189 |
+
onFailure: OnFailure<String>
|
| 190 |
+
) {
|
| 191 |
+
val call = apiService.sendEmail(request)
|
| 192 |
+
|
| 193 |
+
call.enqueue(object : Callback<ApiResponse<String>> {
|
| 194 |
+
override fun onResponse(
|
| 195 |
+
call: Call<ApiResponse<String>>, response: Response<ApiResponse<String>>
|
| 196 |
+
) {
|
| 197 |
+
response.body()?.let { data ->
|
| 198 |
+
onSuccess(data)
|
| 199 |
+
} ?: run {
|
| 200 |
+
onFailure(response.message())
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
override fun onFailure(call: Call<ApiResponse<String>>, t: Throwable) {
|
| 205 |
+
onFailure(t.message.toString())
|
| 206 |
+
}
|
| 207 |
+
})
|
| 208 |
+
}
|
| 209 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/RoomRepository.kt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.repository
|
| 2 |
+
|
| 3 |
+
import androidx.lifecycle.MutableLiveData
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.RisingApplication
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.local.AppDatabase
|
| 6 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ContactEntity
|
| 7 |
+
import com.matthaigh27.chatgptwrapper.data.local.entity.ImageEntity
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
object RoomRepository {
|
| 11 |
+
private var databaseHandler: AppDatabase = AppDatabase.getDatabase(RisingApplication.appContext)
|
| 12 |
+
|
| 13 |
+
private var imageDao = databaseHandler.imageDao()
|
| 14 |
+
private var contactDao = databaseHandler.contactDao()
|
| 15 |
+
|
| 16 |
+
suspend fun getAllImages(): MutableLiveData<List<ImageEntity>> {
|
| 17 |
+
return MutableLiveData(imageDao.getAllData())
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
suspend fun insertImage(entity: ImageEntity) {
|
| 21 |
+
imageDao.insert(entity)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
suspend fun updateImage(entity: ImageEntity) {
|
| 25 |
+
imageDao.update(entity)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
suspend fun deleteImage(entity: ImageEntity) {
|
| 29 |
+
imageDao.delete(entity)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
suspend fun getAllContacts(): MutableLiveData<List<ContactEntity>> {
|
| 33 |
+
return MutableLiveData(contactDao.getAllData())
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
suspend fun insertContact(entity: ContactEntity) {
|
| 37 |
+
contactDao.insert(entity)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
suspend fun updateContact(entity: ContactEntity) {
|
| 41 |
+
contactDao.update(entity)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
suspend fun deleteContact(entity: ContactEntity) {
|
| 45 |
+
contactDao.delete(entity)
|
| 46 |
+
}
|
| 47 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/data/repository/SharedPreferencesRepository.kt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.data.repository
|
| 2 |
+
|
| 3 |
+
import android.content.Context
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.RisingApplication.Companion.appContext
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.data.models.setting.SettingModel
|
| 6 |
+
import com.matthaigh27.chatgptwrapper.utils.helpers.chat.SettingHelper.emptySettingModel
|
| 7 |
+
|
| 8 |
+
object SharedPreferencesRepository {
|
| 9 |
+
fun saveConfig(config: SettingModel) {
|
| 10 |
+
val sharedPreferences = appContext.getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
| 11 |
+
val editor = sharedPreferences.edit()
|
| 12 |
+
val jsonString = config.toString()
|
| 13 |
+
editor.putString("config", jsonString)
|
| 14 |
+
editor.apply()
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
fun getConfig(): SettingModel {
|
| 18 |
+
val sharedPreferences = appContext.getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
| 19 |
+
val jsonString = sharedPreferences.getString("config", "")
|
| 20 |
+
if (jsonString == "" || jsonString == null) {
|
| 21 |
+
return emptySettingModel()
|
| 22 |
+
} else {
|
| 23 |
+
return SettingModel.init(jsonString)
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/base/BaseActivity.kt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.ui.base
|
| 2 |
+
|
| 3 |
+
import android.os.Bundle
|
| 4 |
+
import android.view.View
|
| 5 |
+
import android.widget.Toast
|
| 6 |
+
import androidx.appcompat.app.AppCompatActivity
|
| 7 |
+
|
| 8 |
+
@Suppress("DEPRECATION")
|
| 9 |
+
open class BaseActivity : AppCompatActivity() {
|
| 10 |
+
|
| 11 |
+
override fun onCreate(savedInstanceState: Bundle?) {
|
| 12 |
+
super.onCreate(savedInstanceState)
|
| 13 |
+
|
| 14 |
+
// Hide the status bar (system toolbar)
|
| 15 |
+
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
|
| 16 |
+
supportActionBar?.hide()
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
protected fun showToast(message: String) {
|
| 20 |
+
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
| 21 |
+
}
|
| 22 |
+
}
|
Android/app/src/main/java/com/matthaigh27/chatgptwrapper/ui/chat/view/ChatActivity.kt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.matthaigh27.chatgptwrapper.ui.chat.view
|
| 2 |
+
|
| 3 |
+
import android.os.Bundle
|
| 4 |
+
import com.matthaigh27.chatgptwrapper.R
|
| 5 |
+
import com.matthaigh27.chatgptwrapper.ui.base.BaseActivity
|
| 6 |
+
import com.matthaigh27.chatgptwrapper.ui.chat.view.fragments.ChatMainFragment
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ChatActivity : BaseActivity() {
|
| 10 |
+
override fun onCreate(savedInstanceState: Bundle?) {
|
| 11 |
+
super.onCreate(savedInstanceState)
|
| 12 |
+
setContentView(R.layout.activity_chat)
|
| 13 |
+
navigateToChatMainFragment()
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
private fun navigateToChatMainFragment() {
|
| 17 |
+
val fragmentTransaction = supportFragmentManager.beginTransaction()
|
| 18 |
+
fragmentTransaction.replace(R.id.fl_container, ChatMainFragment()).commit()
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|