Skip to content

Commit

Permalink
Merge pull request #63 from angrezichatterbox/Language-Based-Settings
Browse files Browse the repository at this point in the history
Implemented Language Based Settings
  • Loading branch information
andrewtavis authored Aug 23, 2024
2 parents 81234e0 + 4888dce commit 1ccc094
Show file tree
Hide file tree
Showing 126 changed files with 988 additions and 472 deletions.
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ if (keystorePropertiesFile.exists()) {

android {
compileSdk 34



buildFeatures {
viewBinding = true
}
defaultConfig {
applicationId "be.scri"
minSdk 23
targetSdk 31
minSdk 26
targetSdk 34
versionCode 7
versionName "1.0.0"
multiDexEnabled true
Expand Down Expand Up @@ -67,6 +67,8 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.activity:activity-ktx:1.9.1'
kapt 'androidx.room:room-compiler:2.6.1'
implementation 'androidx.room:room-runtime:2.6.1'
annotationProcessor 'androidx.room:room-compiler:2.6.1'
Expand Down
73 changes: 40 additions & 33 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<uses-permission
android:name="android.permission.USE_FINGERPRINT"
tools:node="remove" />

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
Expand All @@ -17,114 +15,133 @@
android:appCategory="productivity"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_launcher_name"
android:localeConfig="@xml/locales_config"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:localeConfig="@xml/locales_config">

android:theme="@style/AppTheme">
<activity
android:name=".activities.SplashActivity"
android:exported="false"
android:theme="@style/SplashTheme" />

<activity-alias
android:name=".activities.SplashActivity.Orange"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:targetActivity=".activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>

<activity
android:name=".activities.MainActivity"
android:exported="false" />

<service
android:exported="true"
android:name=".services.EnglishKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_english" />
</service>

<service
android:exported="true"
android:name=".services.GermanKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_german" />
</service>

<service
android:exported="true"
android:name=".services.FrenchKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_french" />
</service>
<service
android:exported="true"
android:name=".services.ItalianKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_italian" />
</service>
<service
android:exported="true"
android:name=".services.PortugueseKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_portuguese" />
</service>
<service
android:exported="true"
android:name=".services.RussianKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_russian" />
</service>
<service
android:exported="true"
android:name=".services.SpanishKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_spanish" />
</service>
<service
android:exported="true"
android:name=".services.SwedishKeyboardIME"
android:exported="true"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method_swedish" />
Expand All @@ -135,37 +152,27 @@
android:exported="true"
android:label="@string/app.settings.title"
android:parentActivityName=".activities.MainActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name="be.scri.activities.AboutActivity"
android:name=".activities.AboutActivity"
android:label="@string/app.about.title"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name="be.scri.activities.WikimediaScribeActivity"
android:name=".activities.WikimediaScribeActivity"
android:label="@string/app.about.wikimedia"
android:parentActivityName=".activities.MainActivity" />

<activity-alias
android:name=".activities.SplashActivity.Orange"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:targetActivity=".activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity
android:name=".activities.LanguageSettings"
android:label="Language Settings"
android:parentActivityName=".activities.MainActivity" />
</application>

</manifest>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be.scri.activities


import android.content.Intent
import android.os.Bundle
import android.view.GestureDetector
Expand Down Expand Up @@ -88,7 +89,7 @@ class AboutActivity : BaseSimpleActivity(), GestureDetector.OnGestureListener{
recyclerView3.suppressLayout(true)
}

private fun getFirstRecyclerViewData(): List<ItemsViewModel> = listOf(
private fun getFirstRecyclerViewData(): List<Any> = listOf(
ItemsViewModel(image = R.drawable.github_logo, textResId = R.string.app_about_github, image2 = R.drawable.external_link, url = "https://github.com/scribe-org/Scribe-Android", activity = null, action = null),
ItemsViewModel(image = R.drawable.matrix_icon, textResId = R.string.app_about_matrix, image2 = R.drawable.external_link, url = "https://matrix.to/%23/%23scribe_community:matrix.org", activity = null, action = null),
ItemsViewModel(image = R.drawable.mastodon_svg_icon, textResId = R.string.app_about_mastodon, image2 = R.drawable.external_link, url = "https://wikis.world/@scribe", activity = null, action = null),
Expand All @@ -97,7 +98,7 @@ class AboutActivity : BaseSimpleActivity(), GestureDetector.OnGestureListener{
ItemsViewModel(image = R.drawable.wikimedia_logo_black, textResId = R.string.app_about_wikimedia, image2 = R.drawable.right_arrow, url = null, activity = WikimediaScribeActivity::class.java, action = null)
)

private fun getSecondRecyclerViewData(): List<ItemsViewModel> = listOf(
private fun getSecondRecyclerViewData(): List<Any> = listOf(
ItemsViewModel(image = R.drawable.star, textResId = R.string.app_about_rate, image2 = R.drawable.external_link, url = null, activity = null, action = null),
ItemsViewModel(image = R.drawable.bug_report_icon, textResId = R.string.app_about_bugReport, image2 = R.drawable.external_link, url = "https://github.com/scribe-org/Scribe-Android/issues", activity = null, action = null),
ItemsViewModel(image = R.drawable.mail_icon, textResId = R.string.app_about_email, image2 = R.drawable.external_link, url = null, activity = null, action = ::sendEmail),
Expand Down
81 changes: 81 additions & 0 deletions app/src/main/java/be/scri/activities/LanguageSettings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package be.scri.activities

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.recyclerview.widget.LinearLayoutManager
import be.scri.R
import be.scri.databinding.ActivityLanguageSettingsBinding
import be.scri.extensions.config
import be.scri.helpers.CustomAdapter
import be.scri.models.SwitchItem
import com.google.android.material.bottomnavigation.BottomNavigationView

class LanguageSettings : SimpleActivity() {
private lateinit var binding: ActivityLanguageSettingsBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
binding = ActivityLanguageSettingsBinding.inflate(layoutInflater)
val view = binding.root
val language = intent.getStringExtra("LANGUAGE_EXTRA")
setContentView(view)
if (language != null) {
setupRecyclerView(language=language)
}
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottom_navigation)
bottomNavigationView.setOnNavigationItemSelectedListener(BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.info -> {
startActivity(Intent(applicationContext, AboutActivity::class.java))
overridePendingTransition(0, 0)
return@OnNavigationItemSelectedListener true
}

R.id.settings -> {
return@OnNavigationItemSelectedListener true }
R.id.installation -> {
startActivity(Intent(applicationContext, MainActivity::class.java))
overridePendingTransition(0, 0)
return@OnNavigationItemSelectedListener true
}
}
false
})
bottomNavigationView.selectedItemId = R.id.settings

}
private fun setupRecyclerView(language: String) {
val recyclerView1 = binding.recyclerView
recyclerView1.layoutManager = LinearLayoutManager(this)
recyclerView1.adapter = CustomAdapter(getRecyclerViewData(language), this)
recyclerView1.suppressLayout(true)
}

private fun getRecyclerViewData(language: String): List<Any> {
val sharedPref = getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
return listOf(
SwitchItem(
isChecked = sharedPref.getBoolean("period_on_double_tap_$language", false),
title = "Double space Periods",
action = { enablePeriodOnSpaceBarDoubleTap(language = language) },
action2 = { disablePeriodOnSpaceBarDoubleTap(language = language) }))
}
private fun enablePeriodOnSpaceBarDoubleTap(language: String) {
val sharedPref = getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val editor = sharedPref.edit()
editor.putBoolean("period_on_double_tap_$language", true)
editor.apply()
}

private fun disablePeriodOnSpaceBarDoubleTap(language: String) {
val sharedPref = getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val editor = sharedPref.edit()
editor.putBoolean("period_on_double_tap_$language", false)
editor.apply()
}

}


Loading

0 comments on commit 1ccc094

Please sign in to comment.