Skip to content

Commit

Permalink
Added input method switch to keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakota committed Nov 25, 2021
1 parent ffff4ec commit d9286be
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 5 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 29
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -53,7 +53,7 @@ android {
defaultConfig {
applicationId "com.drakota.bttvstickers"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.drakota.bttvstickers

import android.content.ClipDescription
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.inputmethodservice.InputMethodService
import android.net.Uri
import android.os.Build
import android.view.View
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.GridView
import android.widget.ImageButton
import androidx.core.content.FileProvider
import androidx.core.view.inputmethod.InputConnectionCompat
import androidx.core.view.inputmethod.InputContentInfoCompat
Expand Down Expand Up @@ -77,9 +80,17 @@ class StickerInputMethod : InputMethodService() {
}

override fun onCreateInputView(): View? {
val imeManager: InputMethodManager = applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val root: View = layoutInflater.inflate(R.layout.keyboard, null)

val emoteList: GridView = root.findViewById(R.id.EmoteList)
emoteList.numColumns = if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) 4 else 8

val keyboardSwitchBtn: ImageButton = root.findViewById(R.id.KeyboardSwitchBtn)
keyboardSwitchBtn.setOnClickListener {
imeManager.showInputMethodPicker()
}

val dataDir = applicationContext.packageManager.getPackageInfo(applicationContext.packageName, 0).applicationInfo.dataDir;
val packFile = File(String.format(PACK_PATH_PATTERN, dataDir))

Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/res/drawable/ic_baseline_keyboard_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2zM11,8h2v2h-2L11,8zM11,11h2v2h-2v-2zM8,8h2v2L8,10L8,8zM8,11h2v2L8,13v-2zM7,13L5,13v-2h2v2zM7,10L5,10L5,8h2v2zM16,17L8,17v-2h8v2zM16,13h-2v-2h2v2zM16,10h-2L14,8h2v2zM19,13h-2v-2h2v2zM19,10h-2L17,8h2v2z"/>
</vector>
9 changes: 9 additions & 0 deletions android/app/src/main/res/drawable/ripple_rounded_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@android:color/white">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="?android:colorPrimary"/>
</shape>
<color android:color="@android:color/white"/>
</item>
</ripple>
20 changes: 20 additions & 0 deletions android/app/src/main/res/layout/keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,24 @@
android:layout_height="250dp"
android:numColumns="4"
android:stretchMode="columnWidth" />

<HorizontalScrollView
android:id="@+id/Toolbar"
android:layout_below="@id/EmoteList"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/KeyboardSwitchBtn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_baseline_keyboard_24"
android:background="@drawable/ripple_rounded_button" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.4+9
version: 2.1.0+10

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit d9286be

Please sign in to comment.