Skip to content

Commit

Permalink
Updated to 0.0.18b
Browse files Browse the repository at this point in the history
- WebBrowser ForTests added
- README.md
  • Loading branch information
Sav22999 committed Jan 12, 2020
1 parent 9a9d605 commit 182d304
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This is not the official app of the project Common Voice by Mozilla. This app is developed by Saverio Morelli, via Android Studio, because of there isn’t an official app for Android.

[![Crowdin](https://badges.crowdin.net/common-voice-android/localized.svg)](https://crowdin.com/project/common-voice-android) [![Generic badge](https://img.shields.io/badge/supported%20languages-4-green.svg)](https://saveriomorelli.com) [![GitHub release](https://img.shields.io/github/release/Sav22999/common-voice-android.svg)](https://github.com/Sav22999/common-voice-android/releases/) [![GitHub license](https://img.shields.io/github/license/Sav22999/common-voice-android.svg)](https://github.com/Sav22999/common-voice-android/blob/master/LICENSE) [![Github all releases](https://img.shields.io/github/downloads/Sav22999/common-voice-android/total.svg)](https://GitHub.com/Sav22999/common-voice-android/releases/) ![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)
[![Crowdin](https://badges.crowdin.net/common-voice-android/localized.svg)](https://crowdin.com/project/common-voice-android) [![Generic badge](https://img.shields.io/badge/supported%20languages-4-green.svg)](https://crowdin.com/project/common-voice-android) [![GitHub release](https://img.shields.io/github/release/Sav22999/common-voice-android.svg)](https://github.com/Sav22999/common-voice-android/releases/) [![GitHub license](https://img.shields.io/github/license/Sav22999/common-voice-android.svg)](https://github.com/Sav22999/common-voice-android/blob/master/LICENSE) [![Github all releases](https://img.shields.io/github/downloads/Sav22999/common-voice-android/total.svg)](https://GitHub.com/Sav22999/common-voice-android/releases/) ![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)

[<img src="images/googlePlayBadge.png" width="200px"></img>](https://play.google.com/store/apps/details?id=org.commonvoice.saverio) [<img src="images/aptoideBadge.png" height="50px"></img>](https://common-voice-android.en.aptoide.com/?store_name=sav22999&app_id=49778274)

Expand Down
4 changes: 2 additions & 2 deletions 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 = 35
versionName '0.0.17b'
versionCode = 36
versionName '0.0.18a'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
android:theme="@style/AppTheme"
android:label="@string/app_name" >
</activity>
<!-- WebBrowser - For Testings only -->
<activity
android:screenOrientation="portrait"
android:name=".WebBrowser"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
</activity>
</application>

</manifest>
4 changes: 1 addition & 3 deletions app/src/main/java/org/commonvoice/saverio/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class LoginActivity : AppCompatActivity() {
//val email = findViewById<EditText>(R.id.txt_email_login).text

if (type == "login") {
//if (android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() || true) {
setContentView(R.layout.fragment_webbrowser)
setContentView(R.layout.activity_webbrowser)

var txtLoading: TextView = findViewById(R.id.txtLoadingWebBrowser)
var bgLoading: ImageView = findViewById(R.id.imgBackgroundWebBrowser)
Expand Down Expand Up @@ -145,7 +144,6 @@ class LoginActivity : AppCompatActivity() {

//webView.loadUrl("https://accounts.firefox.com/signup?email=" + email)
webView.loadUrl("https://voice.mozilla.org/login")
//}
} else if (type == "logout") {
val sharedPref: SharedPreferences =
getSharedPreferences(LOGGED_IN_NAME, PRIVATE_MODE)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/org/commonvoice/saverio/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,10 @@ class MainActivity : AppCompatActivity() {
fun stopAnimation(img: Button) {
img.clearAnimation()
}

fun openWebBrowserForTest() {
val intent = Intent(this, WebBrowser::class.java).also {
startActivity(it)
}
}
}
104 changes: 104 additions & 0 deletions app/src/main/java/org/commonvoice/saverio/WebBrowser.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.commonvoice.saverio

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.graphics.Bitmap
import android.net.ConnectivityManager
import android.os.Bundle
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.webkit.CookieManager
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone

class WebBrowser : AppCompatActivity() {

private lateinit var webView: WebView

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

if (checkConnection()) {
navigateWebBrowser()
} else {
finish()
}
}

fun checkConnection(): Boolean {
if (LoginActivity.checkInternet(this))
{
return true
} else {
openNoConnection()
return false
}
}

companion object {
fun checkInternet(context: Context):Boolean {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = cm.activeNetworkInfo
if (networkInfo != null && networkInfo.isConnected) {
//Connection OK
return true
}
else {
//No connection
return false
}

}
}

fun openNoConnection() {
val intent = Intent(this, NoConnectionActivity::class.java).also {
startActivity(it)
}
}

fun startAnimation(img: ImageView) {
var animation: Animation =
AnimationUtils.loadAnimation(applicationContext, R.anim.login)
img.startAnimation(animation)
}

fun stopAnimation(img: ImageView) {
img.clearAnimation()
}

fun navigateWebBrowser() {
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)

webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
webView.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
// Loading started
txtLoading.isGone = false
bgLoading.isGone = false
imgLoading.isGone = false
startAnimation(imgLoading)
}

override fun onPageFinished(view: WebView?, url: String?) {
// Loading finished
txtLoading.isGone = true
bgLoading.isGone = true
imgLoading.isGone = true
stopAnimation(imgLoading)
}
}
webView.loadUrl("https://voice.allizom.org/it")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.widget.AdapterView
import android.widget.Button
import android.widget.Spinner
import android.widget.TextView
import androidx.core.view.isGone
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import org.commonvoice.saverio.BuildConfig
Expand All @@ -21,9 +22,9 @@ import org.commonvoice.saverio.R
class SettingsFragment : Fragment() {

private lateinit var settingsViewModel: SettingsViewModel
var languages_list_short =
var languagesListShort =
arrayOf("en") // don't change it manually -> it will import automatically
var languages_list =
var languagesList =
arrayOf("English") // don't change it manually -> it will import automatically

override fun onCreateView(
Expand All @@ -46,15 +47,15 @@ class SettingsFragment : Fragment() {
releaseNumber.text = BuildConfig.VERSION_NAME

// import the languages list (short and "standard" from mainactivity)
this.languages_list_short = main.languagesListShortArray
this.languages_list = main.languagesListArray
this.languagesListShort = main.languagesListShortArray
this.languagesList = main.languagesListArray

var language: Spinner = root.findViewById(R.id.languageList)
language.adapter = main.getLanguageList()

var selected_language: String = main.getSelectedLanguage()
var selectedLanguage: String = main.getSelectedLanguage()

language.setSelection(languages_list_short.indexOf(selected_language))
language.setSelection(languagesListShort.indexOf(selectedLanguage))

language.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
Expand All @@ -67,39 +68,48 @@ class SettingsFragment : Fragment() {
position: Int,
id: Long
) {
main.setLanguageSettings(languages_list_short.get(position))
main.setLanguageSettings(languagesListShort.get(position))
}
}

var text_project_github: TextView = root.findViewById(R.id.textProjectGitHub)
text_project_github.setOnClickListener {
var textProjectGithub: TextView = root.findViewById(R.id.textProjectGitHub)
textProjectGithub.setOnClickListener {
val browserIntent =
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/Sav22999/common-voice-android")
)
startActivity(browserIntent)
}
text_project_github.paintFlags = Paint.UNDERLINE_TEXT_FLAG
textProjectGithub.paintFlags = Paint.UNDERLINE_TEXT_FLAG

var text_donate_paypal: TextView = root.findViewById(R.id.textDonatePayPal)
text_donate_paypal.setOnClickListener {
var textDonatePaypal: TextView = root.findViewById(R.id.textDonatePayPal)
textDonatePaypal.setOnClickListener {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.me/saveriomorelli"))
startActivity(browserIntent)
}
text_donate_paypal.paintFlags = Paint.UNDERLINE_TEXT_FLAG
textDonatePaypal.paintFlags = Paint.UNDERLINE_TEXT_FLAG

var btn_open_tutorial: Button = root.findViewById(R.id.buttonOpenTutorial)
btn_open_tutorial.setOnClickListener {
var btnOpenTutorial: Button = root.findViewById(R.id.buttonOpenTutorial)
btnOpenTutorial.setOnClickListener {
main.openTutorial()
}

var txt_contributors: TextView = root.findViewById(R.id.textContributors)
txt_contributors.text = getString(R.string.txt_contributors)
var btnWebBrowserForTest: Button = root.findViewById(R.id.buttonOpenWBTests)
btnWebBrowserForTest.setOnClickListener {
main.openWebBrowserForTest()
}

if (main.logged && (main.userName == "Sav22999" || main.userName == "Common Voice Android")) {
btnWebBrowserForTest.isGone = false
}

var txtContributors: TextView = root.findViewById(R.id.textContributors)
txtContributors.text = getString(R.string.txt_contributors)

var txt_developed_by: TextView = root.findViewById(R.id.textDevelopedBy)
txt_developed_by.text = getString(R.string.txt_developed_by)
var txtDevelopedBy: TextView = root.findViewById(R.id.textDevelopedBy)
txtDevelopedBy.text = getString(R.string.txt_developed_by)

main.checkConnection()

Expand Down
17 changes: 15 additions & 2 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
android:isScrollContainer="true"
android:paddingBottom="10dp">

<Button
android:id="@+id/buttonOpenWBTests"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/btn_rounded"
android:text="Show Web Browser (FOR TESTS)"
android:textColor="@color/colorWhite"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonOpenTutorial"
tools:visibility="visible" />

<TextView
android:id="@+id/textDonatePayPal"
android:layout_width="0dp"
Expand Down Expand Up @@ -132,7 +146,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="30dp"
android:fontFamily="@font/zillaslab"
Expand All @@ -146,7 +159,7 @@
app:layout_constraintBottom_toTopOf="@+id/textContributors"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonOpenTutorial" />
app:layout_constraintTop_toBottomOf="@+id/buttonOpenWBTests" />

<TextView
android:id="@+id/textContributors"
Expand Down

0 comments on commit 182d304

Please sign in to comment.