Skip to content

Commit

Permalink
Updated to 0.0.4a
Browse files Browse the repository at this point in the history
- Improvements to UI
- Added ListenActivity and SpeakActivity
- Added Listen and Speak sections (pressing the relative icon)
- Added 0.0.3a screenshots
- Added 0.0.4a screenshots
- Updated README.md
- Fixed some problems with the icon
  • Loading branch information
Sav22999 committed Dec 4, 2019
1 parent 2b14040 commit 8ba46d4
Show file tree
Hide file tree
Showing 33 changed files with 391 additions and 112 deletions.
16 changes: 14 additions & 2 deletions Common Voice Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<!-- First start -->
<!-- First start (TutorialActivity) -->
<activity
android:name=".TutorialActivity"
android:theme="@style/AppTheme.FullScreen"
android:label="@string/app_name" >
</activity>
<!-- The actual app -->
<!-- The actual app (MainActivity) -->
<activity
android:name=".MainActivity"
android:label="@string/app_name">
Expand All @@ -30,6 +30,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- SpeakActivity -->
<activity
android:name=".SpeakActivity"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
</activity>
<!-- ListenActivity -->
<activity
android:name=".ListenActivity"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.commonvoice.saverio

import android.Manifest
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat


class ListenActivity : AppCompatActivity() {

private val RECORD_REQUEST_CODE = 101

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

checkRecordVoicePermission()
}

fun checkRecordVoicePermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.INTERNET), RECORD_REQUEST_CODE)
}
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
RECORD_REQUEST_CODE -> {
if (grantResults.isEmpty() || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
checkRecordVoicePermission()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.android.synthetic.main.fragment_settings.*
import kotlinx.android.synthetic.main.fragment_home.*
import java.net.URL


class MainActivity : AppCompatActivity() {
Expand Down Expand Up @@ -49,12 +50,25 @@ class MainActivity : AppCompatActivity() {
startActivity(it)
}
finish()
}
else {
} else {
checkRecordVoicePermission()
}
}

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

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

fun checkRecordVoicePermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.commonvoice.saverio

import android.Manifest
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.activity_speak.*
import java.net.HttpURLConnection
import java.net.URL


class SpeakActivity : AppCompatActivity() {

private val RECORD_REQUEST_CODE = 101

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

//checkRecordVoicePermission()

this.btn_start_speak.setOnClickListener {
//
}
}

fun checkRecordVoicePermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO), RECORD_REQUEST_CODE)
}
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
RECORD_REQUEST_CODE -> {
if (grantResults.isEmpty() || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
checkRecordVoicePermission()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.os.Bundle
import android.webkit.WebView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
Expand All @@ -33,14 +32,6 @@ class TutorialActivity : AppCompatActivity() {
this.btn_next.setOnClickListener{
tutorialStart()
}

/*webView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
view?.loadUrl(url)
return true
}
}
webView.loadUrl("https://voice.mozilla.org/it/")*/
}

fun tutorialStart() {
Expand All @@ -66,8 +57,8 @@ class TutorialActivity : AppCompatActivity() {
}

fun tutorialStart1() {
this.textViewMessage.isVisible = false
this.textViewMessage.text = ""
this.textTutorialMessage.isVisible = false
this.textTutorialMessage.text = ""
this.seekBar.progress = 1
this.textView_tutorial.text = getString(R.string.tutorial_text2)
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
Expand All @@ -94,30 +85,31 @@ class TutorialActivity : AppCompatActivity() {
fun tutorialStartPermissionDenied()
{
// Permission is not granted
this.textViewMessage.isVisible = true
this.textViewMessage.text = "Error: permission fail"
this.textTutorialMessage.isVisible = true
this.textTutorialMessage.text = "Error: permission fail"
//Toast.makeText(this, "Error: permission fail", Toast.LENGTH_LONG).show()
this.btn_next.text = getString(R.string.btn_tutorial4) // try again
}

fun tutorialStartPermissionSuccessful()
{
// Permission is granted
this.textViewMessage.isVisible = true
this.textViewMessage.text = "Permission successful"
this.textTutorialMessage.isVisible = true
this.textTutorialMessage.text = "Permission successful"
//Toast.makeText(this,"Permission successful",Toast.LENGTH_SHORT).show()
this.btn_next.text = getString(R.string.btn_tutorial3) // next
this.status = 2
}

fun tutorialStart3() {
// finish
this.textViewMessage.isVisible = false
this.textViewMessage.text = ""
this.textTutorialMessage.isVisible = false
this.textTutorialMessage.text = ""
this.seekBar.progress = 2
this.textView_tutorial.text = getString(R.string.tutorial_text3)
this.btn_next.text = getString(R.string.btn_tutorial5)
this.status = 3
this.languageListTutorial.isVisible = true
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package org.commonvoice.saverio.ui.dashboard

import android.content.SharedPreferences
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import kotlinx.android.synthetic.main.fragment_webbrowser.*
import org.commonvoice.saverio.R

class DashboardFragment : Fragment() {

private lateinit var dashboardViewModel: DashboardViewModel
private lateinit var webView: WebView
private var language = "it"

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -22,10 +28,10 @@ class DashboardFragment : Fragment() {
dashboardViewModel =
ViewModelProviders.of(this).get(DashboardViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_dashboard, container, false)
val textView: TextView = root.findViewById(R.id.text_dashboard)
dashboardViewModel.text.observe(this, Observer {
textView.text = it
})
val textStatistics: TextView = root.findViewById(R.id.text_dashboardStatistics)
textStatistics.text = getText(R.string.dashboardStatistics)


return root
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.fragment_settings.*
import org.commonvoice.saverio.MainActivity
import org.commonvoice.saverio.R

class HomeFragment : Fragment() {
Expand All @@ -24,15 +26,18 @@ class HomeFragment : Fragment() {
homeViewModel =
ViewModelProviders.of(this).get(HomeViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_home, container, false)
/*val textView: TextView = root.findViewById(R.id.text_home)
homeViewModel.text.observe(this, Observer {
textView.text = it
})*/

val btnSpeak: Button = root.findViewById(R.id.btn_speak)
val btnListen: Button = root.findViewById(R.id.btn_listen)

return root
}
btnSpeak.setOnClickListener{
(activity as MainActivity).open_speak_section()
}

btnListen.setOnClickListener{
(activity as MainActivity).open_listen_section()
}

return root
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.MultiAutoCompleteTextView
import android.widget.MultiAutoCompleteTextView.CommaTokenizer
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import kotlinx.android.synthetic.main.fragment_settings.*
import org.commonvoice.saverio.R


class SettingsFragment : Fragment() {

private lateinit var settingsViewModel: SettingsViewModel
Expand All @@ -22,10 +26,10 @@ class SettingsFragment : Fragment() {
settingsViewModel =
ViewModelProviders.of(this).get(SettingsViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_settings, container, false)
/*val textView: TextView = root.findViewById(R.id.text_settings)
settingsViewModel.text.observe(this, Observer {
textView.text = it
})*/
val textLanguage: TextView = root.findViewById(R.id.text_settingsLanguage)
textLanguage.text = getText(R.string.settingsLanguage)



return root
}
Expand Down
Loading

0 comments on commit 8ba46d4

Please sign in to comment.