Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVELOP :: MULTI LANGUAGE SUPPORT #37

Merged
merged 4 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions app/schemas/com.frogobox.keyboard.data.local.db.AppDatabase/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "f76c2f5058229a55fe3cb182b8e11113",
"entities": [
{
"tableName": "auto_text",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `label` TEXT NOT NULL, `date` TEXT NOT NULL, `updatedDate` TEXT NOT NULL, `updatedTime` TEXT NOT NULL, `body` TEXT NOT NULL, `isActive` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "date",
"columnName": "date",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "updatedDate",
"columnName": "updatedDate",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "updatedTime",
"columnName": "updatedTime",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "body",
"columnName": "body",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isActive",
"columnName": "isActive",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f76c2f5058229a55fe3cb182b8e11113')"
]
}
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
android:name=".ui.toggle.ToggleActivity"
android:exported="false" />

<activity android:name=".ui.language.KeyboardLanguageActivity"
android:exported="false" />

<activity
android:name=".ui.main.MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.core.content.ContextCompat
import com.frogobox.keyboard.R
import com.frogobox.keyboard.util.Constant.PREF_KEYBOARD_TYPE
import com.frogobox.keyboard.util.Constant.PREF_ROOT_NAME
import com.frogobox.sdk.delegate.preference.PreferenceDelegatesImpl

/**
* Created by Faisal Amir on 24/10/22
Expand Down Expand Up @@ -45,4 +48,9 @@ fun Context.getStrokeColor() = ContextCompat.getColor(this, R.color.keyboard_bg_

fun Drawable.applyColorFilter(color: Int) = mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN)

fun ImageView.applyColorFilter(color: Int) = setColorFilter(color, PorterDuff.Mode.SRC_IN)
fun ImageView.applyColorFilter(color: Int) = setColorFilter(color, PorterDuff.Mode.SRC_IN)

fun Context.getKeyboardType(): Int {
val pref = PreferenceDelegatesImpl(this, PREF_ROOT_NAME)
return pref.loadPrefInt(PREF_KEYBOARD_TYPE, R.xml.keys_letters_qwerty)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.widget.EditText
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import com.frogobox.keyboard.R
import com.frogobox.keyboard.common.ext.getKeyboardType
import com.frogobox.keyboard.common.ext.getProperBackgroundColor
import com.frogobox.keyboard.common.ext.getProperTextColor
import com.frogobox.keyboard.databinding.ItemKeyboardHeaderBinding
Expand Down Expand Up @@ -622,7 +623,7 @@ class KeyboardIME : InputMethodService(), OnKeyboardActionListener {
}

private fun getKeyboardLayoutXML(): Int {
return R.xml.keys_letters_qwerty
return baseContext.getKeyboardType()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.frogobox.keyboard.ui.language
Fixed Show fixed Hide fixed

import android.os.Bundle
import androidx.activity.viewModels
import com.frogobox.keyboard.common.base.BaseActivity
import com.frogobox.keyboard.databinding.ActivityKeyboardLanguageBinding
import dagger.hilt.android.AndroidEntryPoint

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : faisalamircs@gmail.com
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

@AndroidEntryPoint
class KeyboardLanguageActivity : BaseActivity<ActivityKeyboardLanguageBinding>() {

private val viewModel: KeyboardLanguageViewModel by viewModels()

override fun setupViewBinding(): ActivityKeyboardLanguageBinding {
return ActivityKeyboardLanguageBinding.inflate(layoutInflater)
}

override fun setupViewModel() {
super.setupViewModel()
viewModel.apply {

}
}

override fun onCreateExt(savedInstanceState: Bundle?) {
super.onCreateExt(savedInstanceState)
setupUI()
}

private fun setupUI() {
binding.apply {

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.frogobox.keyboard.ui.language
Fixed Show fixed Hide fixed

import com.frogobox.keyboard.common.base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : faisalamircs@gmail.com
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/


@HiltViewModel
class KeyboardLanguageViewModel @Inject constructor(

): BaseViewModel() {
Fixed Show fixed Hide fixed


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.frogobox.keyboard.common.ext.isDarkThemeOn
import com.frogobox.keyboard.databinding.ActivityMainBinding
import com.frogobox.keyboard.ui.autotext.AutoTextActivity
import com.frogobox.keyboard.ui.detail.DetailActivity
import com.frogobox.keyboard.ui.language.KeyboardLanguageActivity
import com.frogobox.keyboard.ui.toggle.ToggleActivity
import com.frogobox.sdk.ext.showLogDebug
import com.frogobox.sdk.ext.startActivityExt
Expand Down Expand Up @@ -98,6 +99,10 @@ class MainActivity : BaseMainActivity<ActivityMainBinding>() {
startActivityExt<ToggleActivity>()
}

btnMultiLanguage.setOnClickListener {
startActivityExt<KeyboardLanguageActivity>()
}

}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/frogobox/keyboard/util/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ object Constant {

const val PREF_ROOT_NAME = "PREF_ROOT_NAME"

const val PREF_KEYBOARD_TYPE = "PREF_KEYBOARD_TYPE"

object Extra {
const val EXTRA_DATA = "EXTRA_DATA"
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_keyboard_language.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/frogo_dimen_16dp"
tools:itemCount="20"
tools:listitem="@layout/item_language_keyboard">

</androidx.recyclerview.widget.RecyclerView>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
android:layout_height="wrap_content"
android:text="Toggle Function" />

<Button
android:id="@+id/btn_multi_language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Setup Keyboard Language" />

</LinearLayout>

<Button
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/layout/item_language_keyboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/bg_card_8dp"
android:elevation="@dimen/frogo_dimen_4dp">

<TextView
android:id="@+id/tv_item_keyboard_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/frogo_dimen_16dp"
android:textColor="@color/tv_text_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Frogo Keyboard" />

</LinearLayout>
14 changes: 14 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@
<string name="animals">Animals</string>
<string name="network_problem">Network error occurred while downloading.</string>
<string name="download_problem">IO error occurred while downloading</string>

<string name="translation_bengali">Bengali</string>
<string name="translation_bulgarian">Bulgarian</string>
<string name="translation_english">English</string>
<string name="translation_french">French</string>
<string name="translation_german">German</string>
<string name="translation_greek">Greek</string>
<string name="translation_lithuanian">Lithuanian</string>
<string name="translation_romanian">Romanian</string>
<string name="translation_russian">Russian</string>
<string name="translation_slovenian">Slovenian</string>
<string name="translation_spanish">Spanish</string>
<string name="translation_turkish">Turkish</string>

</resources>
Loading
Loading