Initial commit
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
74
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# Built application files
|
||||
*.apk
|
||||
*.aab
|
||||
*.ap_
|
||||
*.aapk
|
||||
*.aar
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
.idea/caches/
|
||||
.idea/libraries/
|
||||
.idea/misc.xml
|
||||
.idea/modules.xml
|
||||
.idea/runConfigurations/
|
||||
.idea/shelf/
|
||||
.idea/vcs.xml
|
||||
.idea/workspace.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# External native build folder created in Android Studio 2.2 and later
|
||||
.externalNativeBuild/
|
||||
|
||||
# Google Services (e.g. Google Maps)
|
||||
google-services.json
|
||||
|
||||
# Signed APKs
|
||||
release/
|
||||
|
||||
# Crashlytics plugin
|
||||
com_crashlytics_export_strings.xml
|
||||
|
||||
# Other
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
profile-results/
|
||||
lint-results-*.xml
|
||||
lint-results-debug.xml
|
||||
lint-results-release.xml
|
||||
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 Sourav Anand
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
168
README.md
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
# AI Assistant Android App
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Demo & Screenshots
|
||||
|
||||
<p align="center">
|
||||
<b>App Overview:</b> <br/>
|
||||
<img src="screenshots/gif1.gif" alt="App Overview GIF">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<b>Screenshots:</b> <br/>
|
||||
</p>
|
||||
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<img src="screenshots/image1.png" alt="Screenshot 1" width="250">
|
||||
</td>
|
||||
<td>
|
||||
<img src="screenshots/image2.png" alt="Screenshot 2" width="250">
|
||||
</td>
|
||||
<td>
|
||||
<img src="screenshots/image3.png" alt="Screenshot 3" width="250">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Overview
|
||||
|
||||
Assistant is an Android application designed to act as a personal voice assistant. It can understand spoken commands, process them, and perform various actions like making calls, playing music, setting alarms, providing weather information, and more. The app integrates with several external services and uses on-device machine learning for intent recognition.
|
||||
|
||||
## Features
|
||||
|
||||
* **Voice Commands:** Interact with the assistant using natural language.
|
||||
* **Text-to-Speech & Speech-to-Text:** Converts spoken language to text and vice-versa for interaction.
|
||||
* **Intent Classification:** Understands user intent and categorizes requests (e.g., Call, Music, Weather, Navigation, Alarm, Reminder).
|
||||
* **Phone Calls:** Can initiate phone calls to contacts.
|
||||
* **Music Playback:** Plays music via YouTube.
|
||||
* **Alarms & Reminders:** Set alarms and reminders.
|
||||
* **Navigation:** Provides navigation directions using Google Maps.
|
||||
* **Weather Information:** Fetches and displays weather forecasts for specified locations or current location.
|
||||
* **Large Language Model (LLM) Integration:** Uses Groq API for advanced query understanding and responses (can be changed as per requirement).
|
||||
* **Translation:** Supports language translation for input queries and responses.
|
||||
* **Conversation History:** Stores and displays past interactions.
|
||||
* **Customizable UI:** Offers options for UI presentation.
|
||||
|
||||
## Default Assistant App
|
||||
|
||||
This application can be set as the default assistant app on your Android device. This allows you to launch the app by long-pressing the home button or using other system-level gestures for invoking the assistant.
|
||||
|
||||
## Process Flow
|
||||
|
||||
```
|
||||
Start (User Input on ChatScreen: Voice/Text)
|
||||
│
|
||||
V
|
||||
MainViewModel (Input Processing, Permissions, Translation, Cleaning)
|
||||
│
|
||||
├─+------------------------------------─> Lock Active? (e.g., Call/Song specific flow)
|
||||
│ │ (Yes)
|
||||
V (No / General Flow) │
|
||||
Text Classification (Determine User Intent) Process Input based on Active Lock
|
||||
│ │
|
||||
V │
|
||||
Action Execution <──────────────────────────+
|
||||
(Based on Intent or Lock:
|
||||
- Make Call
|
||||
- Play Song
|
||||
- Navigate
|
||||
- Get Weather
|
||||
- Set Alarm/Reminder
|
||||
- Query General AI (Groq)
|
||||
- etc.)
|
||||
│
|
||||
V
|
||||
Process Action Result (e.g., Format AI response, Translate back)
|
||||
│
|
||||
V
|
||||
Update UI (ChatScreen displays conversation)
|
||||
│
|
||||
V
|
||||
Speak Response (TextToSpeech, if enabled)
|
||||
│
|
||||
V
|
||||
End
|
||||
```
|
||||
|
||||
1. **User Input:** The user provides input via voice or text in the `ChatScreen`.
|
||||
2. **Input Handling (`MainViewModel`):**
|
||||
* The input is sent to the `MainViewModel`.
|
||||
* Permissions (like microphone for voice input) are checked.
|
||||
* If the input is not in English, it's translated to English. * The text is cleaned and punctuated.
|
||||
3. **Lock State Management (`MainViewModel`):**
|
||||
* The current lock state is checked.
|
||||
* If a specific lock is active (e.g., "call lock," "song lock"), the input is processed according to that lock.
|
||||
* If no lock is active or the input is negative (e.g., "cancel"), the input proceeds to general classification.
|
||||
4. **Text Classification (`TextClassifierHelper` via `MainViewModel`):**
|
||||
* The input text is classified to determine the user's intent (e.g., make a call, play a song, navigate, get weather, set alarm/reminder, or general query).
|
||||
5. **Action Execution (`CallCommand` & `MainViewModel`):**
|
||||
* Based on the classified category, the `MainViewModel` (often via a `CallCommand` utility) triggers the appropriate action:
|
||||
* **Call:** Initiates a phone call.
|
||||
* **Songs:** Plays a song.
|
||||
* **Navigation:** Starts navigation.
|
||||
* **Weather:** Fetches weather information.
|
||||
* **Alarm:** Sets an alarm.
|
||||
* **Reminder:** Sets a reminder.
|
||||
* **Other/Settings/General AI:** For other queries, or if the intent is unclear or relates to settings, the input is sent to a general AI (Groq API).
|
||||
6. **AI Response Processing (if applicable via `MainViewModel`):**
|
||||
* The response from the Groq API is received.
|
||||
* The response is processed and formatted.
|
||||
* If the original input was not in English, the AI's English response is translated back to the original language.
|
||||
7. **Updating UI (`ChatScreen`):**
|
||||
* The result of the action (e.g., confirmation of a call, song playing, navigation started, weather info, alarm/reminder set, or AI response) is added to the chat list in the `MainViewModel`.
|
||||
* The `ChatScreen` observes changes in the chat list and updates to display the conversation.
|
||||
8. **Speech Output (if enabled via `MainViewModel`):**
|
||||
* The response or confirmation is converted to speech using TextToSpeech.
|
||||
* The synthesized speech is played back to the user.
|
||||
|
||||
## Technologies Used
|
||||
|
||||
* **Kotlin:** Primary programming language.
|
||||
* **Jetpack Compose:** For building the user interface.
|
||||
* **Android Jetpack:**
|
||||
* ViewModel: For managing UI-related data in a lifecycle-conscious way.
|
||||
* **Speech Recognition & Synthesis:** Android's built-in `SpeechRecognizer` and `TextToSpeech` engines.
|
||||
* **Text Classification:** MediaPipe, utilizing a custom-trained TensorFlow Lite (TFLite) model for on-device text classification.
|
||||
* **Offline Translation:** Google ML Kit for on-device language identification and translation, enabling completely offline functionality.
|
||||
* **Networking:** OkHttp for making API calls.
|
||||
* **APIs:**
|
||||
* Groq API (for LLM, can be changed as per requirement)
|
||||
* YouTube Data API v3 (for music search)
|
||||
* **Coroutines:** For asynchronous programming.
|
||||
|
||||
## Setup
|
||||
|
||||
1. **Clone the repository:**
|
||||
2. **API Keys:**
|
||||
This project requires API keys for YouTube and Groq services. You need to create a `local.properties` file in the root directory of your project (if it doesn't already exist) and add your keys there:
|
||||
```properties
|
||||
YOUTUBE_API_KEY=YOUR_YOUTUBE_API_KEY
|
||||
GROQ_API_KEY=YOUR_GROQ_API_KEY
|
||||
```
|
||||
These keys are then accessed via `BuildConfig` fields in the app.
|
||||
|
||||
3. **Ensure `local.properties` is in `.gitignore`:** The `.gitignore` file should include `local.properties` to prevent your API keys from being checked into version control.
|
||||
|
||||
## How to Build and Run
|
||||
|
||||
1. Open the project in Android Studio.
|
||||
2. Let Android Studio sync the project and download necessary dependencies.
|
||||
3. Ensure you have an Android device or emulator connected/running.
|
||||
4. Click the "Run" button (green play icon) in Android Studio.
|
||||
|
||||
## Notes
|
||||
|
||||
* The app requests various permissions at runtime (e.g., Record Audio, Read Contacts, Call Phone, Location) as needed for its features.
|
||||
* Bluetooth SCO is managed for better compatibility with Bluetooth headsets during speech recognition.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
Copyright (c) 2025 Sourav Anand
|
||||
115
app/build.gradle.kts
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
kotlin("plugin.serialization") version "2.0.0"
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.app.assistant"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.app.assistant"
|
||||
minSdk = 24
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
}
|
||||
|
||||
// Read local.properties
|
||||
val localProperties = Properties()
|
||||
val localPropertiesFile = rootProject.file("local.properties")
|
||||
if (localPropertiesFile.exists()) {
|
||||
localProperties.load(FileInputStream(localPropertiesFile))
|
||||
}
|
||||
|
||||
// Define BuildConfig fields for API keys
|
||||
// Make sure YOUTUBE_API_KEY and GROQ_API_KEY exist in your local.properties
|
||||
buildConfigField("String", "YOUTUBE_API_KEY",
|
||||
"\"${localProperties.getProperty("YOUTUBE_API_KEY") ?: ""}\"" // Add quotes
|
||||
)
|
||||
|
||||
buildConfigField("String", "GROQ_API_KEY",
|
||||
"\"${localProperties.getProperty("GROQ_API_KEY") ?: ""}\"" // Add quotes
|
||||
)
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
// You might want to also define buildConfigFields for release
|
||||
// if you have different keys for release builds, or if local.properties is not available in CI
|
||||
}
|
||||
debug {
|
||||
// BuildConfigFields from defaultConfig are inherited.
|
||||
// Add specific debug configurations here if needed, for example:
|
||||
// isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true // Ensure buildConfig is enabled
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.1"
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.ui)
|
||||
implementation(libs.androidx.ui.graphics)
|
||||
implementation(libs.androidx.ui.tooling.preview)
|
||||
implementation(libs.androidx.material3)
|
||||
implementation("androidx.compose.material3:material3:1.2.1")
|
||||
implementation("androidx.compose.material3:material3-window-size-class:1.2.1")
|
||||
implementation("androidx.compose.material3:material3-adaptive-navigation-suite:1.3.0-beta02")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
|
||||
implementation ("com.google.mlkit:translate:17.0.2")
|
||||
implementation ("org.commonmark:commonmark:0.24.0")
|
||||
//implementation ("com.github.jeziellago:compose-markdown:0.5.4")
|
||||
implementation("io.coil-kt.coil3:coil-compose:3.0.0-rc02")
|
||||
implementation("io.coil-kt.coil3:coil-network-okhttp:3.0.0-rc02")
|
||||
implementation ("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation(libs.play.services.location)
|
||||
implementation(libs.androidx.ui.test.android)
|
||||
testImplementation(libs.junit)
|
||||
// androidTestImplementation(libs.androidx.junit)
|
||||
// androidTestImplementation(libs.androidx.espresso.core)
|
||||
// androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
// androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
|
||||
//MediaPipe library
|
||||
implementation ("com.google.mediapipe:tasks-text:0.10.14")
|
||||
}
|
||||
|
||||
21
app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
68
app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR"/>
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
|
||||
|
||||
<queries>
|
||||
<!-- YouTube Music -->
|
||||
<package android:name="com.google.android.apps.youtube.music" />
|
||||
<!-- YouTube -->
|
||||
<package android:name="com.google.android.youtube" />
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Assistant">
|
||||
|
||||
<!-- Single Entry Point: AssistActivity -->
|
||||
<activity
|
||||
android:name=".AssistActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.TransparentActivity">
|
||||
|
||||
<!-- Handles assistant trigger (home button long press) -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.ASSIST" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.ACTION_VOICE_COMMAND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- Handles normal app launch -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- MainActivity (now launched from AssistActivity) -->
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.TransparentActivity"
|
||||
android:showOnLockScreen="true" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/assets/model.tflite
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
54
app/src/main/java/com/app/assistant/AssistActivity.kt
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
package com.app.assistant
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.ComponentActivity
|
||||
|
||||
class AssistActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
allowOnLockScreen()
|
||||
|
||||
// Check if the app was launched as an assistant
|
||||
if (Intent.ACTION_ASSIST == intent.action || Intent.ACTION_VOICE_COMMAND == intent.action) {
|
||||
// Launched via home button long press
|
||||
moveToMainActivity()
|
||||
} else {
|
||||
startDefaultFlow()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startDefaultFlow() {
|
||||
// Directly launch MainActivity when launched as assistant
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun moveToMainActivity(){
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NO_USER_ACTION
|
||||
intent.putExtra("speak", true)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun allowOnLockScreen() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
keyguardManager.requestDismissKeyguard(this, null)
|
||||
} else {
|
||||
this.window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.app.assistant.Classifier
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
import com.google.mediapipe.tasks.core.BaseOptions
|
||||
import com.google.mediapipe.tasks.text.textclassifier.TextClassifier
|
||||
import com.google.mediapipe.tasks.text.textclassifier.TextClassifierResult
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor
|
||||
|
||||
class TextClassifierHelper(
|
||||
var currentModel: String = MOBILEBERT,
|
||||
val context: Context,
|
||||
val listener: TextResultsListener
|
||||
) {
|
||||
private lateinit var textClassifier: TextClassifier
|
||||
private lateinit var executor: ScheduledThreadPoolExecutor
|
||||
|
||||
init {
|
||||
initClassifier()
|
||||
}
|
||||
|
||||
fun initClassifier() {
|
||||
val baseOptionsBuilder = BaseOptions.builder()
|
||||
.setModelAssetPath(currentModel)
|
||||
|
||||
try {
|
||||
val baseOptions = baseOptionsBuilder.build()
|
||||
val optionsBuilder = TextClassifier.TextClassifierOptions.builder()
|
||||
.setBaseOptions(baseOptions)
|
||||
val options = optionsBuilder.build()
|
||||
textClassifier = TextClassifier.createFromOptions(context, options)
|
||||
} catch (e: IllegalStateException) {
|
||||
listener.onError(
|
||||
"Text classifier failed to initialize. See error logs for " +
|
||||
"details"
|
||||
)
|
||||
Log.e(
|
||||
TAG, "Text classifier failed to load the task with error: " + e
|
||||
.message
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Run text classification using MediaPipe Text Classifier API
|
||||
fun classify(text: String, itemId: Long, loadingItemId: Long, speak: Boolean) {
|
||||
executor = ScheduledThreadPoolExecutor(1)
|
||||
|
||||
executor.execute {
|
||||
// inferenceTime is the amount of time, in milliseconds, that it takes to
|
||||
// classify the input text.
|
||||
var inferenceTime = SystemClock.uptimeMillis()
|
||||
|
||||
val results = textClassifier.classify(text)
|
||||
|
||||
inferenceTime = SystemClock.uptimeMillis() - inferenceTime
|
||||
|
||||
listener.onResult(results, inferenceTime, text, itemId, loadingItemId, speak)
|
||||
}
|
||||
}
|
||||
|
||||
interface TextResultsListener {
|
||||
fun onError(error: String)
|
||||
fun onResult(results: TextClassifierResult, inferenceTime: Long, inputText: String, itemId: Long, loadingItemId: Long, speak: Boolean)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "TextClassifierHelper"
|
||||
const val MOBILEBERT = "model.tflite"
|
||||
}
|
||||
}
|
||||
58
app/src/main/java/com/app/assistant/MainActivity.kt
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package com.app.assistant
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import com.app.assistant.ui.screen.SetupUI
|
||||
import com.app.assistant.viewmodel.MainViewModel
|
||||
import com.app.assistant.viewmodel.MainViewModelFactory
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
private val viewModel: MainViewModel by viewModels{
|
||||
MainViewModelFactory(application, intent.getBooleanExtra("speak", false))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
allowOnLockScreen()
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
SetupUI(viewModel)
|
||||
}
|
||||
}
|
||||
|
||||
private fun allowOnLockScreen() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { // Android 8.1+
|
||||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
} else {
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
if (keyguardManager.isKeyguardLocked) {
|
||||
keyguardManager.requestDismissKeyguard(this, null)
|
||||
}
|
||||
}
|
||||
}catch (ex: Exception){
|
||||
ex.message?.let { Log.d("Exception Occurred", it) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
viewModel.shutdownResources()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.app.assistant.db
|
||||
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import com.app.assistant.model.Conversation
|
||||
import kotlin.reflect.full.memberProperties
|
||||
|
||||
|
||||
class DynamicConversationDbHelper(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
|
||||
|
||||
companion object {
|
||||
private const val DATABASE_NAME = "conversation.db"
|
||||
private const val DATABASE_VERSION = 1
|
||||
|
||||
private const val COLUMN_IV = "iv"
|
||||
|
||||
// Groups Table
|
||||
private const val TABLE_GROUPS = "groups"
|
||||
private const val COLUMN_GROUP_ID = "group_id"
|
||||
private const val COLUMN_TITLE = "title"
|
||||
private const val COLUMN_CREATED_AT = "created_at"
|
||||
|
||||
// Messages Table
|
||||
private const val TABLE_MESSAGES = "messages"
|
||||
}
|
||||
|
||||
override fun onCreate(db: SQLiteDatabase?) {
|
||||
val createGroupsTableQuery = """
|
||||
CREATE TABLE $TABLE_GROUPS (
|
||||
$COLUMN_GROUP_ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
$COLUMN_TITLE TEXT,
|
||||
$COLUMN_CREATED_AT INTEGER
|
||||
)
|
||||
""".trimIndent()
|
||||
db?.execSQL(createGroupsTableQuery)
|
||||
|
||||
val createMessageTableQuery = buildCreateTableQuery()
|
||||
db?.execSQL(createMessageTableQuery)
|
||||
}
|
||||
|
||||
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
|
||||
db?.execSQL("DROP TABLE IF EXISTS $TABLE_MESSAGES")
|
||||
db?.execSQL("DROP TABLE IF EXISTS $TABLE_GROUPS")
|
||||
onCreate(db)
|
||||
}
|
||||
|
||||
private fun buildCreateTableQuery(): String {
|
||||
val fields = Conversation::class.memberProperties
|
||||
val columns = fields.filterNot { it.name == "isLoading" }.joinToString(", ") { field ->
|
||||
val fieldType = mapFieldTypeToSQLiteType(field.returnType.toString())
|
||||
if (field.name == "id") {
|
||||
"${field.name} INTEGER PRIMARY KEY"
|
||||
} else {
|
||||
"${field.name} $fieldType"
|
||||
}
|
||||
}
|
||||
|
||||
return """
|
||||
CREATE TABLE $TABLE_MESSAGES (
|
||||
$columns,
|
||||
iv TEXT,
|
||||
$COLUMN_GROUP_ID INTEGER,
|
||||
FOREIGN KEY ($COLUMN_GROUP_ID) REFERENCES $TABLE_GROUPS($COLUMN_GROUP_ID)
|
||||
)
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
private fun mapFieldTypeToSQLiteType(kotlinType: String): String {
|
||||
return when (kotlinType) {
|
||||
"kotlin.String" -> "TEXT"
|
||||
"kotlin.Int", "kotlin.Long", "kotlin.Boolean" -> "INTEGER"
|
||||
"java.net.URI" -> "TEXT"
|
||||
else -> "TEXT"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
package com.app.assistant.db
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.text.format.DateFormat
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import com.app.assistant.model.Conversation
|
||||
import com.app.assistant.model.Group
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.net.URI
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlin.reflect.full.memberProperties
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
class DynamicConversationRepository(private val context: Context) {
|
||||
|
||||
companion object {
|
||||
private const val TABLE_GROUPS = "groups"
|
||||
private const val COLUMN_GROUP_ID = "group_id"
|
||||
private const val COLUMN_TITLE = "title"
|
||||
private const val COLUMN_CREATED_AT = "created_at"
|
||||
private const val TABLE_MESSAGES = "messages"
|
||||
private const val COLUMN_MESSAGE_ID = "id"
|
||||
}
|
||||
|
||||
private val dbHelper = DynamicConversationDbHelper(context)
|
||||
var currentGroupId: Long = -1L
|
||||
|
||||
private suspend fun startNewChat(msg: String): Long {
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.writableDatabase
|
||||
val contentValues = ContentValues().apply {
|
||||
put(COLUMN_TITLE, generateChatTitle(msg))
|
||||
put(COLUMN_CREATED_AT, System.nanoTime())
|
||||
}
|
||||
currentGroupId = db.insert(TABLE_GROUPS, null, contentValues)
|
||||
}
|
||||
return currentGroupId
|
||||
}
|
||||
|
||||
private fun generateChatTitle(msg: String): String {
|
||||
val date = Date()
|
||||
val words = msg.split(" ").take(2).joinToString(" ")
|
||||
val time = SimpleDateFormat("h:mm aa - EEE, MMM d", Locale.getDefault()).format(date)
|
||||
return "$words $time"
|
||||
}
|
||||
|
||||
suspend fun addMessage(conversation: Conversation) {
|
||||
withContext(Dispatchers.IO) {
|
||||
if (currentGroupId == -1L) {
|
||||
currentGroupId = startNewChat(conversation.englishText.takeIf { it.isNotEmpty() } ?: conversation.translatedText)
|
||||
}
|
||||
|
||||
val db = dbHelper.writableDatabase
|
||||
val (encryptedMap, iv) = encryptConversation(conversation)
|
||||
val values = ContentValues().apply {
|
||||
encryptedMap.forEach { (key, value) -> put(key, value) }
|
||||
put("iv", iv)
|
||||
put(COLUMN_GROUP_ID, currentGroupId)
|
||||
}
|
||||
try{
|
||||
db.insert(TABLE_MESSAGES, null, values)
|
||||
}catch (e: Exception){
|
||||
e.message?.let { Log.d("Test", it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteMessage(id: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.writableDatabase
|
||||
db.delete(
|
||||
TABLE_MESSAGES,
|
||||
"id = ?",
|
||||
arrayOf(id.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateMessage(oldConversation: Conversation, newConversation: Conversation) {
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.writableDatabase
|
||||
val (encryptedMap, iv) = encryptConversation(newConversation)
|
||||
val values = ContentValues().apply {
|
||||
encryptedMap.forEach { (key, value) -> put(key, value) }
|
||||
put("iv", iv)
|
||||
}
|
||||
db.update(
|
||||
TABLE_MESSAGES,
|
||||
values,
|
||||
"id = ?",
|
||||
arrayOf(oldConversation.id.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun clearMessages(conversations: List<Conversation>) {
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.writableDatabase
|
||||
val ids = conversations.joinToString(",") { it.id.toString() }
|
||||
db.execSQL("DELETE FROM $TABLE_MESSAGES WHERE id IN ($ids)")
|
||||
db.execSQL("DELETE FROM $TABLE_GROUPS WHERE $COLUMN_GROUP_ID == $currentGroupId")
|
||||
currentGroupId = -1L
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun loadAllGroups(): MutableList<Group> {
|
||||
val groupList = mutableListOf<Group>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.readableDatabase
|
||||
val cursor: Cursor = db.query(
|
||||
TABLE_GROUPS,
|
||||
arrayOf(COLUMN_GROUP_ID, COLUMN_TITLE),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"$COLUMN_GROUP_ID DESC" // Sort by latest created
|
||||
)
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val groupId = cursor.getLong(cursor.getColumnIndexOrThrow(COLUMN_GROUP_ID))
|
||||
val title = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_TITLE))
|
||||
groupList.add(Group(groupId, title))
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
return groupList
|
||||
}
|
||||
|
||||
|
||||
suspend fun loadMessagesForGroup(groupId: Long): MutableList<Conversation> {
|
||||
val tempList = mutableListOf<Conversation>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val db = dbHelper.readableDatabase
|
||||
val cursor: Cursor = db.query(
|
||||
TABLE_MESSAGES,
|
||||
null,
|
||||
"$COLUMN_GROUP_ID = ?",
|
||||
arrayOf(groupId.toString()),
|
||||
null,
|
||||
null,
|
||||
COLUMN_MESSAGE_ID // Sort by latest created
|
||||
)
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val conversation = cursorToConversation(cursor)
|
||||
tempList.add(conversation)
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
return tempList
|
||||
}
|
||||
|
||||
private fun cursorToConversation(cursor: Cursor): Conversation {
|
||||
val properties = Conversation::class.memberProperties
|
||||
val fieldMap = mutableMapOf<String, Any?>()
|
||||
val iv = cursor.getString(cursor.getColumnIndexOrThrow("iv"))
|
||||
|
||||
properties.filter { it.name != "isLoading" }.forEach { property ->
|
||||
val columnName = property.name
|
||||
val columnIndex = cursor.getColumnIndexOrThrow(columnName)
|
||||
val value = when (property.returnType.toString()) {
|
||||
"kotlin.String" -> cursor.getString(columnIndex)//?.let { EncryptionUtil.decrypt(it, iv) }
|
||||
"kotlin.Int" -> cursor.getInt(columnIndex)
|
||||
"kotlin.Long" -> cursor.getLong(columnIndex)
|
||||
"kotlin.Boolean" -> cursor.getString(columnIndex).toBooleanStrictOrNull() ?: false
|
||||
"java.net.URI" -> URI(cursor.getString(columnIndex))
|
||||
else -> null
|
||||
}
|
||||
fieldMap[columnName] = value
|
||||
}
|
||||
|
||||
return Conversation::class.constructors.first().callBy(
|
||||
Conversation::class.primaryConstructor!!.parameters
|
||||
.filter { it.name != "isLoading" } // Ignore "isLoading"
|
||||
.associateWith { parameter -> fieldMap[parameter.name] }
|
||||
)
|
||||
}
|
||||
|
||||
private fun encryptConversation(conversation: Conversation): Pair<Map<String, String>, String> {
|
||||
val properties = Conversation::class.memberProperties
|
||||
val encryptedMap = mutableMapOf<String, String>()
|
||||
val iv = EncryptionUtil.generateIV()
|
||||
|
||||
properties.forEach { property ->
|
||||
val key = property.name
|
||||
val value = property.getter.call(conversation)?.toString()
|
||||
if (value != null && key!="isLoading") {
|
||||
//encryptedMap[key] = EncryptionUtil.encrypt(value, iv).first
|
||||
encryptedMap[key] = value
|
||||
}
|
||||
}
|
||||
return Pair(encryptedMap, iv)
|
||||
}
|
||||
}
|
||||
69
app/src/main/java/com/app/assistant/db/EncryptionUtil.kt
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package com.app.assistant.db
|
||||
|
||||
import android.util.Base64
|
||||
import java.security.SecureRandom
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.KeyGenerator
|
||||
import javax.crypto.SecretKey
|
||||
import javax.crypto.spec.GCMParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
object EncryptionUtil {
|
||||
private const val KEY_SIZE = 256
|
||||
private const val IV_SIZE = 12 // Recommended size for GCM is 12 bytes
|
||||
private const val ALGORITHM = "AES"
|
||||
private const val TRANSFORMATION = "AES/GCM/NoPadding"
|
||||
private const val TAG_LENGTH_BIT = 128
|
||||
|
||||
// Generate a random encryption key
|
||||
private val secretKey: SecretKey = generateSecretKey()
|
||||
|
||||
// Generates a new random initialization vector (IV)
|
||||
fun generateIV(): String {
|
||||
val secureRandom = SecureRandom()
|
||||
val iv = ByteArray(IV_SIZE)
|
||||
secureRandom.nextBytes(iv)
|
||||
return Base64.encodeToString(iv, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
// Encrypt a string and return encrypted text and IV
|
||||
fun encrypt(input: String, ivString: String): Pair<String, String> {
|
||||
val iv = Base64.decode(ivString, Base64.DEFAULT)
|
||||
val cipher = Cipher.getInstance(TRANSFORMATION)
|
||||
val spec = GCMParameterSpec(TAG_LENGTH_BIT, iv)
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, spec)
|
||||
|
||||
val encryptedBytes = cipher.doFinal(input.toByteArray())
|
||||
val encryptedText = Base64.encodeToString(encryptedBytes, Base64.DEFAULT)
|
||||
return Pair(encryptedText, ivString)
|
||||
}
|
||||
|
||||
// Decrypt an encrypted string using IV
|
||||
fun decrypt(encryptedInput: String, ivString: String): String {
|
||||
val iv = Base64.decode(ivString, Base64.DEFAULT)
|
||||
val cipher = Cipher.getInstance(TRANSFORMATION)
|
||||
val spec = GCMParameterSpec(TAG_LENGTH_BIT, iv)
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, spec)
|
||||
|
||||
val encryptedBytes = Base64.decode(encryptedInput, Base64.DEFAULT)
|
||||
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
||||
return String(decryptedBytes)
|
||||
}
|
||||
|
||||
// Generate a new secret key
|
||||
private fun generateSecretKey(): SecretKey {
|
||||
val keyGenerator = KeyGenerator.getInstance(ALGORITHM)
|
||||
keyGenerator.init(KEY_SIZE, SecureRandom())
|
||||
return keyGenerator.generateKey()
|
||||
}
|
||||
|
||||
// Save and restore secret key as Base64 (for persistence)
|
||||
fun getSecretKeyAsString(): String {
|
||||
return Base64.encodeToString(secretKey.encoded, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
fun restoreSecretKeyFromString(keyString: String): SecretKey {
|
||||
val decodedKey = Base64.decode(keyString, Base64.DEFAULT)
|
||||
return SecretKeySpec(decodedKey, 0, decodedKey.size, ALGORITHM)
|
||||
}
|
||||
}
|
||||
50
app/src/main/java/com/app/assistant/db/SyncStateList.kt
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package com.app.assistant.db
|
||||
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import com.app.assistant.model.Conversation
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class SyncStateList(
|
||||
private val repository: DynamicConversationRepository, // Repository to handle DB operations
|
||||
private val stateList: SnapshotStateList<Conversation> = mutableStateListOf()
|
||||
) : MutableList<Conversation> by stateList {
|
||||
|
||||
override fun add(element: Conversation): Boolean {
|
||||
val result = stateList.add(element)
|
||||
if (result && !element.isLoading) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.addMessage(element)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun removeAt(index: Int): Conversation {
|
||||
val result = stateList.removeAt(index)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.deleteMessage(result.id)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun set(index: Int, element: Conversation): Conversation {
|
||||
val oldElement = stateList[index]
|
||||
stateList[index] = element
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.updateMessage(oldElement, element)
|
||||
}
|
||||
return oldElement
|
||||
}
|
||||
|
||||
fun clearAll(): Job {
|
||||
val oldList = stateList.toList()
|
||||
stateList.clear()
|
||||
return CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.clearMessages(oldList) // Suspends until DB operations finish
|
||||
}
|
||||
}
|
||||
}
|
||||
3
app/src/main/java/com/app/assistant/model/Contact.kt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package com.app.assistant.model
|
||||
|
||||
data class Contact(val id: String ,val name: String, val phoneNumber: String)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.app.assistant.model
|
||||
import com.app.assistant.util.Category
|
||||
import java.net.URI
|
||||
|
||||
data class Conversation(var id: Long = System.currentTimeMillis() * 1_000_000 + (System.nanoTime() % 1_000_000), var englishText: String, var translatedText: String, val isMe: Boolean, val isLoading: Boolean = false, var category: String = Category.OTHER.name, val contentURL: String ="", val navigationURI: URI=URI("") )
|
||||
3
app/src/main/java/com/app/assistant/model/Group.kt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package com.app.assistant.model
|
||||
|
||||
data class Group(val groupId: Long, val title: String)
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.app.assistant.translation
|
||||
|
||||
import android.util.Log
|
||||
import com.google.mlkit.common.model.DownloadConditions
|
||||
import com.google.mlkit.common.model.RemoteModelManager
|
||||
import com.google.mlkit.nl.translate.TranslateLanguage
|
||||
import com.google.mlkit.nl.translate.TranslateRemoteModel
|
||||
import com.google.mlkit.nl.translate.Translation
|
||||
import com.google.mlkit.nl.translate.Translator
|
||||
import com.google.mlkit.nl.translate.TranslatorOptions
|
||||
|
||||
class TranslatorManager {
|
||||
|
||||
private var toEnglishTranslator: Translator? = null
|
||||
private var fromEnglishTranslator: Translator? = null
|
||||
private val modelManager = RemoteModelManager.getInstance()
|
||||
|
||||
fun setupTranslators(selectedLanguageCode: String, onResult: (Boolean) -> Unit) {
|
||||
modelManager.getDownloadedModels(TranslateRemoteModel::class.java)
|
||||
.addOnSuccessListener { downloadedModels ->
|
||||
val downloadedLanguages = downloadedModels.map { it.language }.toSet()
|
||||
|
||||
val isSelectedModelDownloaded = selectedLanguageCode in downloadedLanguages
|
||||
val isEnglishModelDownloaded = TranslateLanguage.ENGLISH in downloadedLanguages
|
||||
|
||||
// Download selected language model if not already downloaded
|
||||
if (!isSelectedModelDownloaded) {
|
||||
downloadLanguageModel(selectedLanguageCode) { success ->
|
||||
if (!success) {
|
||||
onResult(false)
|
||||
return@downloadLanguageModel
|
||||
}else{
|
||||
// Download English model if not already downloaded
|
||||
if (!isEnglishModelDownloaded) {
|
||||
downloadLanguageModel(TranslateLanguage.ENGLISH) { successEnglish ->
|
||||
if (!successEnglish) {
|
||||
onResult(false)
|
||||
return@downloadLanguageModel
|
||||
}else{
|
||||
onResult(true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("Translator", "English language model already exists. Not downloading.")
|
||||
onResult(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("Translator", "Selected language model ($selectedLanguageCode) already exists. Not downloading.")
|
||||
onResult(true)
|
||||
}
|
||||
|
||||
// Set up the translators for the selected language and English
|
||||
initializeTranslators(selectedLanguageCode)
|
||||
}
|
||||
.addOnFailureListener { e ->
|
||||
Log.e("Translator", "Failed to get downloaded models: ${e.message}")
|
||||
onResult(false)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to initialize translators for the selected language
|
||||
private fun initializeTranslators(selectedLanguageCode: String) {
|
||||
// Set up translator for selected language -> English
|
||||
val toEnglishOptions = TranslatorOptions.Builder()
|
||||
.setSourceLanguage(selectedLanguageCode)
|
||||
.setTargetLanguage(TranslateLanguage.ENGLISH)
|
||||
.build()
|
||||
|
||||
toEnglishTranslator = Translation.getClient(toEnglishOptions)
|
||||
|
||||
// Set up translator for English -> selected language
|
||||
val fromEnglishOptions = TranslatorOptions.Builder()
|
||||
.setSourceLanguage(TranslateLanguage.ENGLISH)
|
||||
.setTargetLanguage(selectedLanguageCode)
|
||||
.build()
|
||||
|
||||
fromEnglishTranslator = Translation.getClient(fromEnglishOptions)
|
||||
}
|
||||
|
||||
|
||||
// Use this method to translate from selected language to English
|
||||
fun translateToEnglish(text: String, callback: (translatedText: String?) -> Unit) {
|
||||
toEnglishTranslator?.translate(text)
|
||||
?.addOnSuccessListener { translatedText ->
|
||||
callback(translatedText)
|
||||
}
|
||||
?.addOnFailureListener { e ->
|
||||
Log.e("Translator", "Translation to English failed: ${e.message}")
|
||||
callback(null)
|
||||
}
|
||||
}
|
||||
|
||||
// Use this method to translate from English to the selected language
|
||||
fun translateFromEnglish(text: String, callback: (translatedText: String?) -> Unit) {
|
||||
fromEnglishTranslator?.translate(text)
|
||||
?.addOnSuccessListener { translatedText ->
|
||||
callback(translatedText)
|
||||
}
|
||||
?.addOnFailureListener { e ->
|
||||
Log.e("Translator", "Translation from English failed: ${e.message}")
|
||||
callback(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun downloadLanguageModel(languageCode: String, onDownloadComplete: (Boolean) -> Unit) {
|
||||
val languageModel = TranslateRemoteModel.Builder(languageCode).build()
|
||||
val conditions = DownloadConditions.Builder().build()
|
||||
|
||||
modelManager.download(languageModel, conditions)
|
||||
.addOnSuccessListener {
|
||||
Log.d("Translator", "Language model for $languageCode downloaded successfully.")
|
||||
onDownloadComplete(true)
|
||||
}
|
||||
.addOnFailureListener { e ->
|
||||
Log.e("Translator", "Failed to download language model for $languageCode: ${e.message}")
|
||||
onDownloadComplete(false)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the previously downloaded language model
|
||||
private fun deletePreviousLanguageModel(languageCode: String) {
|
||||
val languageModel = TranslateRemoteModel.Builder(languageCode).build()
|
||||
modelManager.deleteDownloadedModel(languageModel)
|
||||
.addOnSuccessListener {
|
||||
Log.d("Translator", "Language model for $languageCode deleted successfully.")
|
||||
}
|
||||
.addOnFailureListener { e ->
|
||||
Log.e("Translator", "Failed to delete language model for $languageCode: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
fun closeTranslator(){
|
||||
toEnglishTranslator?.close()
|
||||
fromEnglishTranslator?.close()
|
||||
}
|
||||
}
|
||||
1272
app/src/main/java/com/app/assistant/ui/screen/ChatScreen.kt
Normal file
11
app/src/main/java/com/app/assistant/ui/theme/Color.kt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package com.app.assistant.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Purple80 = Color(0xFFD0BCFF)
|
||||
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
val Pink80 = Color(0xFFEFB8C8)
|
||||
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
57
app/src/main/java/com/app/assistant/ui/theme/Theme.kt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
package com.app.assistant.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = Purple40,
|
||||
secondary = PurpleGrey40,
|
||||
tertiary = Pink40
|
||||
|
||||
/* Other default colors to override
|
||||
background = Color(0xFFFFFBFE),
|
||||
surface = Color(0xFFFFFBFE),
|
||||
onPrimary = Color.White,
|
||||
onSecondary = Color.White,
|
||||
onTertiary = Color.White,
|
||||
onBackground = Color(0xFF1C1B1F),
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
*/
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun AssistantTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
34
app/src/main/java/com/app/assistant/ui/theme/Type.kt
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package com.app.assistant.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 22.sp,
|
||||
lineHeight = 28.sp,
|
||||
letterSpacing = 0.sp
|
||||
),
|
||||
labelSmall = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 11.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
*/
|
||||
)
|
||||
5
app/src/main/java/com/app/assistant/util/Category.kt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package com.app.assistant.util
|
||||
|
||||
enum class Category {
|
||||
SONGS, CALL, ALARM, REMINDER, OTHER, NAVIGATION, SETTINGS, WEATHER
|
||||
}
|
||||
6
app/src/main/java/com/app/assistant/util/Constants.kt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package com.app.assistant.util
|
||||
|
||||
object Constants {
|
||||
const val MAIN_CONTEXT = "You are my smart assistant who answers just like normal human response, not too long. Don't refer yourself as an AI."
|
||||
val CATEGORY_CONTEXT = "You are a assistant who can classify commands based on previous conversation, from these categories. "+ enumValues<Category>().joinToString(",") { it.name } +". Just say the category name."
|
||||
}
|
||||
20
app/src/main/java/com/app/assistant/util/LockState.kt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package com.app.assistant.util
|
||||
|
||||
sealed class LockState {
|
||||
object None : LockState() // Default state when no task is locked
|
||||
|
||||
data class LockAlarm(
|
||||
var day: String? = null, // Already processed day (e.g., "tomorrow")
|
||||
var time: String? = null // Time to be provided
|
||||
) : LockState()
|
||||
|
||||
data class LockReminder(
|
||||
var day: String? = null, // Already processed day (e.g., "tomorrow")
|
||||
var time: String? = null, // Time to be provided
|
||||
var context: String? = null // Message for reminder
|
||||
) : LockState()
|
||||
|
||||
object LockNavigation : LockState() // No additional data needed
|
||||
|
||||
// Add more categories here as needed
|
||||
}
|
||||
2028
app/src/main/java/com/app/assistant/viewmodel/MainViewModel.kt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package com.app.assistant.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class MainViewModelFactory(
|
||||
private val application: Application,
|
||||
private val speak: Boolean
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
if (modelClass.isAssignableFrom(MainViewModel::class.java)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return MainViewModel(application, speak) as T
|
||||
}
|
||||
throw IllegalArgumentException("Unknown ViewModel class")
|
||||
}
|
||||
}
|
||||
5
app/src/main/res/drawable/ic_add_new_chat.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M22,4c0,-1.1 -0.9,-2 -2,-2L4,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4L22,4zM20,17.17L18.83,16L4,16L4,4h16v13.17zM13,5h-2v4L7,9v2h4v4h2v-4h4L17,9h-4z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_content_copy.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_delete.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
|
||||
|
||||
</vector>
|
||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
15
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#A5A33E">
|
||||
<group android:scaleX="0.58"
|
||||
android:scaleY="0.58"
|
||||
android:translateX="5.04"
|
||||
android:translateY="5.04">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,21h-1l1,-7H7.5c-0.58,0 -0.57,-0.32 -0.38,-0.66 0.19,-0.34 0.05,-0.08 0.07,-0.12C8.48,10.94 10.42,7.54 13,3h1l-1,7h3.5c0.49,0 0.56,0.33 0.47,0.51l-0.07,0.15C12.96,17.55 11,21 11,21z"/>
|
||||
</group>
|
||||
</vector>
|
||||
15
app/src/main/res/drawable/ic_menu.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF">
|
||||
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,8h18v2H3z" />
|
||||
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,14h10v2H3z" />
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_mic.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_restart.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,5V1L7,6l5,5V7c3.31,0 6,2.69 6,6s-2.69,6 -6,6 -6,-2.69 -6,-6H4c0,4.42 3.58,8 8,8s8,-3.58 8,-8 -3.58,-8 -8,-8z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_stop.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM16,16H8V8h8V16z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_translate.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_up_arrow.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z"/>
|
||||
|
||||
</vector>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 922 B |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 696 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
10
app/src/main/res/values/colors.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
||||
3
app/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">Assistant</string>
|
||||
</resources>
|
||||
9
app/src/main/res/values/themes.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Assistant" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
<style name="Theme.TransparentActivity" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
5
build.gradle.kts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.jetbrains.kotlin.android) apply false
|
||||
}
|
||||
23
gradle.properties
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
39
gradle/libs.versions.toml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
[versions]
|
||||
agp = "8.12.3"
|
||||
kotlin = "1.9.0"
|
||||
coreKtx = "1.13.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
lifecycleRuntimeKtx = "2.8.0"
|
||||
activityCompose = "1.9.0"
|
||||
composeBom = "2023.08.00"
|
||||
datastoreCoreAndroid = "1.1.1"
|
||||
runtimeLivedata = "1.7.4"
|
||||
playServicesLocation = "21.3.0"
|
||||
uiTestAndroid = "1.7.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
androidx-datastore-core-android = { group = "androidx.datastore", name = "datastore-core-android", version.ref = "datastoreCoreAndroid" }
|
||||
androidx-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata", version.ref = "runtimeLivedata" }
|
||||
play-services-location = { group = "com.google.android.gms", name = "play-services-location", version.ref = "playServicesLocation" }
|
||||
androidx-ui-test-android = { group = "androidx.compose.ui", name = "ui-test-android", version.ref = "uiTestAndroid" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#Wed Jun 05 13:23:07 IST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
185
gradlew
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
BIN
screenshots/gif1.gif
Normal file
|
After Width: | Height: | Size: 5.9 MiB |
BIN
screenshots/image1.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
screenshots/image2.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
screenshots/image3.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
24
settings.gradle.kts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Assistant"
|
||||
include(":app")
|
||||