Skip to content

Commit 8c764e9

Browse files
committed
Initial commit
0 parents  commit 8c764e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+980
-0
lines changed

.gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
*.aab
5+
6+
# Files for the Dalvik VM
7+
*.dex
8+
9+
# Java class files
10+
*.class
11+
12+
# Generated files
13+
bin/
14+
gen/
15+
out/
16+
17+
# Gradle files
18+
.gradle/
19+
build/
20+
21+
# Local configuration file (sdk path, etc)
22+
local.properties
23+
24+
# Proguard folder generated by Eclipse
25+
proguard/
26+
27+
# Log Files
28+
*.log
29+
30+
# Android Studio Navigation editor temp files
31+
.navigation/
32+
33+
# Android Studio captures folder
34+
captures/
35+
36+
# IntelliJ
37+
*.iml
38+
.idea/
39+
.idea_modules/
40+
41+
# Keystore files
42+
*.jks
43+
*.keystore
44+
45+
# External native build folder generated in Android Studio 2.2 and later
46+
.externalNativeBuild/
47+
48+
# Google Services (e.g. APIs or Firebase)
49+
google-services.json
50+
51+
# Freeline
52+
freeline.py
53+
freeline/
54+
freeline_project_description.json
55+
56+
# Fabric properties
57+
fabric.properties
58+
59+
# Crashlytics configuations
60+
com_crashlytics_export_strings.xml
61+
crashlytics-build.properties
62+
crashlytics.properties

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Hello World Keyboard
2+
3+
Welcome to the Hello World Keyboard project!
4+
This custom Android keyboard is a perfect starting point for first-time Android developers interested in exploring custom keyboard development.
5+
The keyboard features three simple buttons that input "hello", "world", and "keyboard".
6+
7+
![Keyboard Gif](./images/use.gif)
8+
9+
## Getting Started
10+
11+
These instructions will guide you through forking the project, making it your own, and setting up a development environment for testing and further development.
12+
13+
### Prerequisites
14+
15+
Before you start, ensure you have Android Studio installed, the official IDE for Android app development:
16+
17+
- [Install Android Studio](https://developer.android.com/studio/install)
18+
19+
### Forking and Cloning the Project
20+
21+
1. **Fork the Repository**:
22+
- Visit the original repository at `https://github.com/modularizer/helloworldkeyboard`.
23+
- Click on the `Fork` button at the top right corner of the page to create a copy of the repository in your GitHub account.
24+
25+
2. **Clone Your Fork**:
26+
- After forking, go to your GitHub account where the new repository exists.
27+
- Open the forked repository and click on `Code` to get the clone URL.
28+
- Copy the URL.
29+
30+
3. **Import the Project in Android Studio**:
31+
- Open Android Studio.
32+
- Go to `File` > `New` > `Project from Version Control`.
33+
- In the URL field, paste the URL of your forked repository.
34+
- Choose your preferred directory and click `Clone`.
35+
36+
### Running and Testing the Project
37+
38+
1. **Set Up an Emulator**:
39+
- Go to Tools > Device Manager > Create Device to create a new Virtual Device.
40+
- Choose a device definition and a system image.
41+
42+
2. **Run the App**:
43+
- With the emulator open, run the app from Android Studio.
44+
45+
3. **Enable and Test the Keyboard**:
46+
- In the emulator, navigate to `Settings` (hint: double-tap the top bar, swipe down, find the gear icon)
47+
- In Settings, search `Manage on-screen Keyboards` or navigate to `Settings` > `System` > `Languages & input` > `On-screen keyboard` > `Manage on-screen keyboards`.
48+
- Enable `Hello World Keyboard`.
49+
- Open any text field, and in the bottom right corner of the screen, tap the keyboard icon to switch to your new keyboard.
50+
51+
![Setup Gif](./images/setup.gif)
52+
53+
## Customizing Your Keyboard
54+
### Key Files for Customization
55+
- `app/src/main/java/com.example.helloworldkeyboard/KeyboardService.kt`: Main service for keyboard logic.
56+
- `app/src/main/res/keyboard_layout.xml`: Layout file for the keyboard UI.
57+
- `app/src/main/res/values/strings.xml`: Strings file for keyboard UI text.
58+
- `app/src/main/AndroidManifest.xml`: App declarations and configurations.
59+
60+
### Tips for Designing Your Keyboard
61+
- **Layout**: Modify `keyboard_layout.xml` for UI changes.
62+
- **Functionality**: Adapt `KeyboardService.kt` for different key actions.
63+
- **Testing**: Always test changes on an emulator or device.
64+
65+
## Contributing
66+
67+
This project is open to contributions with the goal of making an absolute bare-bones keyboard for first-time Android developers,
68+
encouraging best practices and good coding habits while also providing a starting point for further development.
69+
Feel free to fork this repository, make your changes, and submit pull requests to contribute to this project.
70+
71+
## License
72+
73+
This project is 100% open source and free to use for any purpose.
74+
This project is licensed under the [Unlicense](https://unlicense.org) - see the [LICENSE](LICENSE) file for details.
75+

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
}
5+
6+
android {
7+
namespace = "com.example.helloworldkeyboard"
8+
compileSdk = 34
9+
10+
defaultConfig {
11+
applicationId = "com.example.helloworldkeyboard"
12+
minSdk = 24
13+
targetSdk = 34
14+
versionCode = 1
15+
versionName = "1.0"
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
isMinifyEnabled = false
23+
proguardFiles(
24+
getDefaultProguardFile("proguard-android-optimize.txt"),
25+
"proguard-rules.pro"
26+
)
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_1_8
31+
targetCompatibility = JavaVersion.VERSION_1_8
32+
}
33+
kotlinOptions {
34+
jvmTarget = "1.8"
35+
}
36+
}
37+
38+
dependencies {
39+
40+
implementation("androidx.core:core-ktx:1.9.0")
41+
implementation("androidx.appcompat:appcompat:1.6.1")
42+
implementation("com.google.android.material:material:1.8.0")
43+
testImplementation("junit:junit:4.13.2")
44+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
45+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
46+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.helloworldkeyboard
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.helloworldkeyboard", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.HelloWorldKeyboard"
14+
tools:targetApi="31">
15+
<service
16+
android:name=".KeyboardService"
17+
android:label="@string/service_label"
18+
android:enabled="true"
19+
android:exported="true"
20+
android:permission="android.permission.BIND_INPUT_METHOD">
21+
<intent-filter>
22+
<action android:name="android.view.InputMethod" />
23+
</intent-filter>
24+
<meta-data
25+
android:name="android.view.im"
26+
android:resource="@xml/method" />
27+
</service>
28+
29+
</application>
30+
31+
</manifest>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.helloworldkeyboard
2+
3+
import android.inputmethodservice.InputMethodService
4+
import android.view.View
5+
import android.widget.Button
6+
7+
class KeyboardService : InputMethodService() {
8+
override fun onCreateInputView(): View {
9+
// Inflate your keyboard layout from the XML file
10+
val inflater = layoutInflater
11+
val inputView = inflater.inflate(R.layout.keyboard_layout, null)
12+
13+
// Get references to your buttons
14+
val buttonHello = inputView.findViewById<Button>(R.id.button_hello)
15+
val buttonWorld = inputView.findViewById<Button>(R.id.button_world)
16+
val buttonKeyboard = inputView.findViewById<Button>(R.id.button_keyboard)
17+
18+
// Set click listeners for your buttons
19+
buttonHello.setOnClickListener { inputText("hello") }
20+
buttonWorld.setOnClickListener { inputText("world") }
21+
buttonKeyboard.setOnClickListener { inputText("keyboard") }
22+
23+
24+
return inputView
25+
}
26+
27+
private fun inputText(text: String) {
28+
val inputConnection = currentInputConnection
29+
inputConnection?.commitText(text, 1)
30+
}
31+
}

0 commit comments

Comments
 (0)