Skip to content

Commit

Permalink
Updated to 0.0.16a
Browse files Browse the repository at this point in the history
- Fixed a bug in Dashboard
- Changing language UI manually -> Re-implemented. If the selected language exists in the language of the device (when you installed the app), it will display everything in that language, otherwise it will display in English.
- Updated Loading page in WebBrowser
  • Loading branch information
Sav22999 committed Jan 9, 2020
1 parent 946b0a5 commit b2aed77
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 181 deletions.
4 changes: 2 additions & 2 deletions Common Voice Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.commonvoice.saverio"
minSdkVersion 23
targetSdkVersion 28
versionCode = 24
versionName '0.0.15a'
versionCode = 28
versionName '0.0.16a'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified Common Voice Android/app/release/app-release.aab
Binary file not shown.
1 change: 1 addition & 0 deletions Common Voice Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_commonvoice_round"
android:supportsRtl="true"
android:configChanges="locale"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<!-- First start (TutorialActivity) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class LoginActivity : AppCompatActivity() {
//if (android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() || true) {
setContentView(R.layout.fragment_webbrowser)

var txtLoading: TextView = findViewById(R.id.textLoadingPage)
var txtLoading: TextView = findViewById(R.id.txtLoadingWebBrowser)
var bgLoading: ImageView = findViewById(R.id.imgBackgroundWebBrowser)
var imgLoading: ImageView = findViewById(R.id.imgRobotWebBrowser)

webView = findViewById(R.id.webViewBrowser)

Expand All @@ -87,15 +89,15 @@ class LoginActivity : AppCompatActivity() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
// Loading started
txtLoading.isGone = false
txtLoading.isVisible = true
txtLoading.text = getString(R.string.txt_loading_page)
bgLoading.isGone = false
imgLoading.isGone = false
}

override fun onPageFinished(view: WebView?, url: String?) {
// Loading finished
var txtLoading: TextView = findViewById(R.id.textLoadingPage)
txtLoading.isGone = true
txtLoading.isVisible = false
bgLoading.isGone = true
imgLoading.isGone = true

var cookies: String? = CookieManager.getInstance().getCookie(url)
//println(" ---->> "+url+" >> "+CookieManager.getInstance().getCookie(url)+" <<---- ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import java.util.*
class MainActivity : AppCompatActivity() {

private val translations_languages: Array<String> =
arrayOf("en", "it", "sv", "fr") //change manually
arrayOf("en", "sv", "it", "fr") //change manually

private var firstRun = true
private val RECORD_REQUEST_CODE = 101
Expand All @@ -53,7 +53,9 @@ class MainActivity : AppCompatActivity() {
private val LAST_VOICES_ONLINE_BEFORE = "LAST_VOICES_ONLINE_BEFORE"
private val LAST_VOICES_ONLINE_NOW_VALUE = "LAST_VOICES_ONLINE_NOW_VALUE"
private val LAST_VOICES_ONLINE_BEFORE_VALUE = "LAST_VOICES_ONLINE_BEFORE_VALUE"
private val UI_LANGUAGE_CHANGED = "UI_LANGUAGE_CHANGED"

var dashboard_selected = false

var languagesListShortArray =
arrayOf("en") // don't change manually -> it's imported from strings.xml
Expand All @@ -66,9 +68,9 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_main)
val navView: BottomNavigationView = findViewById(R.id.nav_view)

val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
Expand All @@ -85,14 +87,20 @@ class MainActivity : AppCompatActivity() {
val sharedPref: SharedPreferences = getSharedPreferences(PREF_NAME, PRIVATE_MODE)
this.firstRun = sharedPref.getBoolean(PREF_NAME, true)

// import languages from array
this.languagesListArray = resources.getStringArray(R.array.languages)
this.languagesListShortArray = resources.getStringArray(R.array.languages_short)

val sharedPref2: SharedPreferences = getSharedPreferences(LANGUAGE_NAME, PRIVATE_MODE)
this.selectedLanguageVar = sharedPref2.getString(LANGUAGE_NAME, "en")

setLanguageUI()
if (this.firstRun) {
// close main and open tutorial -- first run
openTutorial()
} else {
setLanguageUI("start")
checkPermissions()
}

// import languages from array
this.languagesListArray = resources.getStringArray(R.array.languages)
this.languagesListShortArray = resources.getStringArray(R.array.languages_short)

val sharedPref3: SharedPreferences = getSharedPreferences(LOGGED_IN_NAME, PRIVATE_MODE)
this.logged = sharedPref3.getBoolean(LOGGED_IN_NAME, false)
Expand All @@ -104,13 +112,6 @@ class MainActivity : AppCompatActivity() {
val sharedPref5: SharedPreferences = getSharedPreferences(USER_NAME, PRIVATE_MODE)
this.userName = sharedPref5.getString(USER_NAME, "")
}

if (this.firstRun) {
// close main and open tutorial -- first run
openTutorial()
} else {
checkPermissions()
}
}

fun getHiUsernameLoggedIn(): String {
Expand Down Expand Up @@ -350,7 +351,12 @@ class MainActivity : AppCompatActivity() {
this.selectedLanguageVar = lang

if (languageChanged) {
setLanguageUI()
val sharedPref2: SharedPreferences = getSharedPreferences(UI_LANGUAGE_CHANGED, PRIVATE_MODE)
val editor2 = sharedPref2.edit()
editor2.putBoolean(UI_LANGUAGE_CHANGED, true)
editor2.apply()

setLanguageUI("restart")
setSavedStatistics("you", "?")
setSavedStatistics("everyone", "?")
setSavedVoicesOnline("voicesNow", "?")
Expand Down Expand Up @@ -477,16 +483,12 @@ class MainActivity : AppCompatActivity() {
}
}

fun setLanguageUI() {
/*var lang = selectedLanguageVar.split("-")[0]
var restart = false
if (getString(R.string.language) != selectedLanguageVar && translations_languages.indexOf(
lang
) != -1
) {
restart = true
} else if (translations_languages.indexOf(lang) == -1 && getString(R.string.language) != "en") {
restart = true
fun setLanguageUI(type: String) {
val sharedPref: SharedPreferences = getSharedPreferences(UI_LANGUAGE_CHANGED, PRIVATE_MODE)
var restart: Boolean = sharedPref.getBoolean(UI_LANGUAGE_CHANGED, true)

var lang = selectedLanguageVar.split("-")[0]
if (translations_languages.indexOf(lang) == -1) {
lang = "en"
}
//println("-->sel: " + selectedLanguageVar + " -->lang: " + getString(R.string.language))
Expand All @@ -499,13 +501,19 @@ class MainActivity : AppCompatActivity() {
res.updateConfiguration(config, res.displayMetrics)
//createConfigurationContext(config)

if (restart) {
if (restart || type=="restart") {
val intent = Intent(this, RestartActivity::class.java).also {
startActivity(it)

finish()
}
}*/
} else {
if (type == "start") {
val intent = Intent(this, RestartActivity::class.java).also {
startActivity(it)
}
}
}
}

fun checkConnection(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
package org.commonvoice.saverio

import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import java.util.*
import kotlin.concurrent.schedule

class RestartActivity : AppCompatActivity() {

private var PRIVATE_MODE = 0
private val UI_LANGUAGE_CHANGED = "UI_LANGUAGE_CHANGED"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_restart)

val sharedPref: SharedPreferences = getSharedPreferences(UI_LANGUAGE_CHANGED, PRIVATE_MODE)
var restart: Boolean = sharedPref.getBoolean(UI_LANGUAGE_CHANGED, true)
if (restart) {
Timer("StartOrRestart", false).schedule(2000) {
restart()
}
} else {
Timer("StartOrRestart", false).schedule(1000) {
start()
}
}
}

override fun onBackPressed() {
//
}

fun restart() {
val sharedPref: SharedPreferences = getSharedPreferences(UI_LANGUAGE_CHANGED, PRIVATE_MODE)
val editor = sharedPref.edit()
editor.putBoolean(UI_LANGUAGE_CHANGED, false)
editor.apply()

val intent = Intent(this, MainActivity::class.java).also {
startActivity(it)
finish()
}
}

fun start() {
finish()
}
}
Loading

0 comments on commit b2aed77

Please sign in to comment.