-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 53349a1
Showing
44 changed files
with
3,380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store | ||
/build | ||
/*/build/ | ||
/captures | ||
/Gemfile* | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
app/release | ||
.project | ||
.settings | ||
.classpath |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Resources | ||
|
||
- https://github.com/THEAccess/compose-keyboard-ime | ||
- https://stackoverflow.com/questions/65570024/build-software-keyboard-with-jetpack-compose-ime-input-method-with-jetpack-com | ||
- https://developer.android.com/develop/ui/views/touch-and-input/creating-input-method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.dessalines.thumbkey" | ||
minSdk 21 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
shrinkResources true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.4.3" | ||
} | ||
namespace 'com.dessalines.thumbkey' | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.10" | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation "androidx.compose.ui:ui:1.3.3" | ||
implementation "androidx.compose.material3:material3:1.0.1" | ||
implementation "androidx.compose.material:material-icons-extended:1.3.1" | ||
implementation "androidx.compose.material3:material3-window-size-class:1.0.1" | ||
implementation "androidx.compose.ui:ui-tooling:1.3.3" | ||
implementation "androidx.activity:activity-compose:1.6.1" | ||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' | ||
implementation "com.louiscad.splitties:splitties-systemservices:3.0.0" | ||
implementation "com.louiscad.splitties:splitties-views:3.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:windowSoftInputMode="adjustResize" | ||
android:theme="@style/Theme.AppCompat.NoActionBar"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.AppCompat.NoActionBar" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<service | ||
android:name=".IMEService" | ||
android:label="Thumb-Key" | ||
|
||
android:permission="android.permission.BIND_INPUT_METHOD" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="android.view.InputMethod" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.view.im" | ||
android:resource="@xml/method" /> | ||
</service> | ||
</application> | ||
|
||
</manifest> |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/dessalines/thumbkey/ComposeKeyboardView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.dessalines.thumbkey | ||
|
||
import android.content.Context | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.AbstractComposeView | ||
import com.dessalines.thumbkey.ui.components.KeyboardScreen | ||
import com.dessalines.thumbkey.ui.theme.MainTheme | ||
|
||
class ComposeKeyboardView(context: Context) : AbstractComposeView(context) { | ||
|
||
@Composable | ||
override fun Content() { | ||
MainTheme { | ||
KeyboardScreen() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.dessalines.thumbkey | ||
|
||
import android.inputmethodservice.InputMethodService | ||
import android.view.View | ||
import androidx.lifecycle.* | ||
import androidx.savedstate.SavedStateRegistry | ||
import androidx.savedstate.SavedStateRegistryController | ||
import androidx.savedstate.SavedStateRegistryOwner | ||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner | ||
|
||
class IMEService : | ||
InputMethodService(), | ||
LifecycleOwner, | ||
ViewModelStoreOwner, | ||
SavedStateRegistryOwner { | ||
|
||
override fun onCreateInputView(): View { | ||
val view = ComposeKeyboardView(this) | ||
|
||
window?.window?.decorView?.let { decorView -> | ||
ViewTreeLifecycleOwner.set(decorView, this) | ||
ViewTreeViewModelStoreOwner.set(decorView, this) | ||
decorView.setViewTreeSavedStateRegistryOwner(this) | ||
} | ||
view.let { | ||
ViewTreeLifecycleOwner.set(it, this) | ||
ViewTreeViewModelStoreOwner.set(it, this) | ||
view.setViewTreeSavedStateRegistryOwner(this) | ||
} | ||
return view | ||
} | ||
|
||
// Lifecylce Methods | ||
|
||
private var lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this) | ||
|
||
private fun handleLifecycleEvent(event: Lifecycle.Event) = | ||
lifecycleRegistry.handleLifecycleEvent(event) | ||
|
||
override fun getLifecycle(): Lifecycle { | ||
return lifecycleRegistry | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
savedStateRegistryController.performRestore(null) | ||
handleLifecycleEvent(Lifecycle.Event.ON_RESUME) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) | ||
} | ||
|
||
// ViewModelStore Methods | ||
private val store = ViewModelStore() | ||
|
||
override fun getViewModelStore(): ViewModelStore = store | ||
|
||
// SaveStateRegestry Methods | ||
|
||
private val savedStateRegistryController = SavedStateRegistryController.create(this) | ||
override val savedStateRegistry: SavedStateRegistry = savedStateRegistryController.savedStateRegistry | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.dessalines.thumbkey | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import androidx.activity.compose.setContent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.* | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import androidx.compose.ui.unit.dp | ||
import com.dessalines.thumbkey.ui.theme.MainTheme | ||
import splitties.systemservices.inputMethodManager | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContent { | ||
MainTheme { | ||
Surface(modifier = Modifier.fillMaxSize()) { | ||
Column { | ||
Options() | ||
Spacer(modifier = Modifier.weight(1f)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun Options() { | ||
Column( | ||
Modifier | ||
.padding(16.dp) | ||
.fillMaxWidth() | ||
) { | ||
val ctx = LocalContext.current | ||
Text(text = "Compose Keyboard") | ||
val (text, setValue) = remember { mutableStateOf(TextFieldValue("Try here")) } | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
Button(modifier = Modifier.fillMaxWidth(), onClick = { | ||
ctx.startActivity(Intent(Settings.ACTION_INPUT_METHOD_SETTINGS)) | ||
}) { | ||
Text(text = "Enable IME") | ||
} | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
Button(modifier = Modifier.fillMaxWidth(), onClick = { | ||
inputMethodManager.showInputMethodPicker() | ||
}) { | ||
Text(text = "Select IME") | ||
} | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
TextField(value = text, onValueChange = setValue, modifier = Modifier.fillMaxWidth()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.dessalines.thumbkey | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.LinearProgressIndicator | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun MockKeyboard() { | ||
Column( | ||
Modifier | ||
.fillMaxWidth() | ||
.height(200.dp) | ||
.background(Color.Gray), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text(color = Color.Black, text = "This should resemble a keyboard") | ||
Button(modifier = Modifier.width(250.dp), onClick = { }) { | ||
Text(text = "A Button") | ||
} | ||
Text(color = Color.Black, text = "Example for Linear Progress Indicator") | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
LinearProgressIndicator() | ||
} | ||
} |
Oops, something went wrong.