generated from armorycodes/android-research-tech-deprecated
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from amirisback/develop/multi-language-support
DEVELOP :: MULTI LANGUAGE SUPPORT
- Loading branch information
Showing
30 changed files
with
2,909 additions
and
4 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
app/schemas/com.frogobox.keyboard.data.local.db.AppDatabase/1.json
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,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')" | ||
] | ||
} | ||
} |
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
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
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/frogobox/keyboard/ui/language/KeyboardLanguage.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,17 @@ | ||
package com.frogobox.keyboard.ui.language | ||
|
||
/** | ||
* 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 | ||
*/ | ||
|
||
|
||
data class KeyboardLanguage( | ||
val name: String, | ||
val xml: Int, | ||
) |
109 changes: 109 additions & 0 deletions
109
app/src/main/java/com/frogobox/keyboard/ui/language/KeyboardLanguageActivity.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,109 @@ | ||
package com.frogobox.keyboard.ui.language | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.activity.viewModels | ||
import com.frogobox.keyboard.common.base.BaseActivity | ||
import com.frogobox.keyboard.databinding.ActivityKeyboardLanguageBinding | ||
import com.frogobox.keyboard.databinding.ItemLanguageKeyboardBinding | ||
import com.frogobox.recycler.core.FrogoRecyclerNotifyListener | ||
import com.frogobox.recycler.core.IFrogoBindingAdapter | ||
import com.frogobox.recycler.ext.injectorBinding | ||
import com.frogobox.sdk.ext.gone | ||
import com.frogobox.sdk.ext.showToast | ||
import com.frogobox.sdk.ext.visible | ||
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>(), | ||
IFrogoBindingAdapter<KeyboardLanguage, ItemLanguageKeyboardBinding> { | ||
|
||
private val viewModel: KeyboardLanguageViewModel by viewModels() | ||
|
||
override fun setupViewBinding(): ActivityKeyboardLanguageBinding { | ||
return ActivityKeyboardLanguageBinding.inflate(layoutInflater) | ||
} | ||
|
||
override fun setupViewModel() { | ||
super.setupViewModel() | ||
viewModel.apply { | ||
keyboardLanguage.observe(this@KeyboardLanguageActivity) { | ||
setupRV(it) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateExt(savedInstanceState: Bundle?) { | ||
super.onCreateExt(savedInstanceState) | ||
if (savedInstanceState == null) { | ||
viewModel.getKeyboardLanguage(this) | ||
} | ||
} | ||
|
||
override fun initView() { | ||
super.initView() | ||
setupDetailActivity("Keyboard Language") | ||
binding.apply { | ||
|
||
} | ||
} | ||
|
||
override fun setViewBinding(parent: ViewGroup): ItemLanguageKeyboardBinding { | ||
return ItemLanguageKeyboardBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
} | ||
|
||
override fun onItemClicked( | ||
binding: ItemLanguageKeyboardBinding, | ||
data: KeyboardLanguage, | ||
position: Int, | ||
notifyListener: FrogoRecyclerNotifyListener<KeyboardLanguage> | ||
) { | ||
viewModel.setKeyboard(data.xml) { | ||
viewModel.getKeyboardLanguage(this@KeyboardLanguageActivity) | ||
} | ||
} | ||
|
||
override fun onItemLongClicked( | ||
binding: ItemLanguageKeyboardBinding, | ||
data: KeyboardLanguage, | ||
position: Int, | ||
notifyListener: FrogoRecyclerNotifyListener<KeyboardLanguage> | ||
) {} | ||
|
||
override fun setupInitComponent( | ||
binding: ItemLanguageKeyboardBinding, | ||
data: KeyboardLanguage, | ||
position: Int, | ||
notifyListener: FrogoRecyclerNotifyListener<KeyboardLanguage> | ||
) { | ||
binding.apply { | ||
tvItemKeyboardMain.text = data.name | ||
if (viewModel.checkKeyboardType(data.xml)) { | ||
this.ivIcon.visible() | ||
} else { | ||
this.ivIcon.gone() | ||
} | ||
} | ||
} | ||
|
||
private fun setupRV(data: List<KeyboardLanguage>) { | ||
binding.rvKeyboardLanguage | ||
.injectorBinding<KeyboardLanguage, ItemLanguageKeyboardBinding>() | ||
.addData(data) | ||
.addCallback(this) | ||
.createLayoutLinearVertical(false) | ||
.build() | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
app/src/main/java/com/frogobox/keyboard/ui/language/KeyboardLanguageViewModel.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,76 @@ | ||
package com.frogobox.keyboard.ui.language | ||
|
||
import android.content.Context | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import com.frogobox.coresdk.response.FrogoStateResponse | ||
import com.frogobox.keyboard.R | ||
import com.frogobox.keyboard.common.base.BaseViewModel | ||
import com.frogobox.keyboard.util.Constant | ||
import com.frogobox.sdk.delegate.preference.PreferenceDelegates | ||
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( | ||
private val pref : PreferenceDelegates | ||
) : BaseViewModel() { | ||
|
||
private var _keyboardLanguage = MutableLiveData<List<KeyboardLanguage>>() | ||
var keyboardLanguage: LiveData<List<KeyboardLanguage>> = _keyboardLanguage | ||
|
||
private var _showloading = MutableLiveData<Boolean>() | ||
var showloading: LiveData<Boolean> = _showloading | ||
|
||
fun getKeyboardLanguage(context: Context) { | ||
val list = mutableListOf<KeyboardLanguage>() | ||
list.add(KeyboardLanguage("${context.getString(R.string.translation_english)} (QWERTY)", R.xml.keys_letters_qwerty)) | ||
list.add(KeyboardLanguage("${context.getString(R.string.translation_english)} (QWERTZ)", R.xml.keys_letters_english_qwertz)) | ||
list.add(KeyboardLanguage("${context.getString(R.string.translation_english)} (DVORAK)", R.xml.keys_letters_english_dvorak)) | ||
|
||
list.add(KeyboardLanguage(context.getString(R.string.translation_bengali), R.xml.keys_letters_bengali)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_bulgarian), R.xml.keys_letters_bulgarian)) | ||
|
||
list.add(KeyboardLanguage(context.getString(R.string.translation_french), R.xml.keys_letters_french)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_german), R.xml.keys_letters_german)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_greek), R.xml.keys_letters_greek)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_lithuanian), R.xml.keys_letters_lithuanian)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_romanian), R.xml.keys_letters_romanian)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_slovenian), R.xml.keys_letters_slovenian)) | ||
list.add(KeyboardLanguage(context.getString(R.string.translation_spanish), R.xml.keys_letters_spanish_qwerty)) | ||
list.add(KeyboardLanguage("${context.getString(R.string.translation_turkish)} (Q)", R.xml.keys_letters_turkish_q)) | ||
_keyboardLanguage.postValue(list) | ||
} | ||
|
||
fun setKeyboard(xml: Int, onSuccess: () -> Unit) { | ||
pref.savePrefInt(Constant.PREF_KEYBOARD_TYPE, xml, object : FrogoStateResponse { | ||
override fun onFailed(statusCode: Int, errorMessage: String) {} | ||
override fun onFinish() {} | ||
override fun onHideProgress() { | ||
_showloading.postValue(false) | ||
} | ||
override fun onShowProgress() { | ||
_showloading.postValue(true) | ||
} | ||
override fun onSuccess() { | ||
onSuccess() | ||
} | ||
}) | ||
} | ||
|
||
fun checkKeyboardType(xml: Int) : Boolean { | ||
return pref.loadPrefInt(Constant.PREF_KEYBOARD_TYPE, R.xml.keys_letters_qwerty) == xml | ||
} | ||
|
||
} |
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
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
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="@color/tv_text_color" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z" /> | ||
</vector> |
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,12 @@ | ||
<?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:id="@+id/rv_keyboard_language" | ||
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> |
Oops, something went wrong.