Skip to content

Commit

Permalink
Update 1.2_r1.
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 8, 2022
1 parent 4cd4fda commit 0e308c5
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 149 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: D4rK7355608
patreon: patreon.com/D4rK7355608
custom: ['https://www.paypal.me/d4rkmichaeltutorials']
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 1.2_r1:
- Fixed theme settings;
- Reduced app size;
- Removed seek bar unseen text.

# Version 1.1_r1:
- Added Check for updates button;
- Added Changelog;
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ __English with Lidia Plus is 100% free, open source, ad free, and have a clean d

## 💿 Features!
- ⭐️ No internet required.
- ⭐️ Material-You.
- ⭐️ Free.
- ⭐️ Adaptive themes + Material-You.
- ⭐️ Simple and easy to use.
- ⭐️ Fast and lightweight.
- ⭐️ Play audio instead of reading.
- ⭐️ Open source & secure.
- ⭐️ Free Open source & secure.

__❗️Note❗️__ Some features are still in progress or needs more improvements and investigations.

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ plugins {
}
android {
compileSdk 32
def tagName = '1.1_r1'
def tagName = '1.2_r1'
defaultConfig {
applicationId "com.d4rk.englishwithlidia.plus"
minSdk 23
targetSdk 32
versionCode 13
versionCode 15
versionName tagName
archivesBaseName = "com.d4rk.englishwithlidia.plus-v${tagName}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.d4rk.englishwithlidia.plus

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/Theme.App.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Binary file modified app/src/main/assets/lesson1.ogg
Binary file not shown.
Binary file modified app/src/main/assets/lesson2.ogg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class MainActivity : AppCompatActivity() {
@Suppress("UNUSED_VARIABLE")
val splashScreen = installSplashScreen()
binding = ActivityMainBinding.inflate(layoutInflater)
val darkModeValues = resources.getStringArray(R.array.dark_mode_values)
when (PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.dark_mode), getString(R.string.dark_mode_def_value))) {
darkModeValues[0] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
darkModeValues[1] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
darkModeValues[2] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
darkModeValues[3] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY)
}
setContentView(binding.root)
setSupportActionBar(binding.appBarMain.toolbar)
val drawerLayout: DrawerLayout = binding.drawerLayout
Expand All @@ -38,17 +45,10 @@ class MainActivity : AppCompatActivity() {
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment_content_main) as NavHostFragment
navHostFragment.navController
}
appBarConfiguration = AppBarConfiguration(setOf(R.id.nav_home, R.id.nav_about, R.id.nav_lessons), drawerLayout)
appBarConfiguration = AppBarConfiguration(setOf(R.id.nav_home, R.id.nav_settings, R.id.nav_about, R.id.nav_lessons, R.id.nav_lesson1, R.id.nav_lesson2), drawerLayout)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
navController.setGraph(R.navigation.mobile_navigation)
val darkModeValues = resources.getStringArray(R.array.dark_mode_values)
when (PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.dark_mode), getString(R.string.dark_mode_def_value))) {
darkModeValues[0] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
darkModeValues[1] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
darkModeValues[2] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
darkModeValues[3] -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY)
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.more_menu, menu)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,65 @@
package com.d4rk.englishwithlidia.plus.ui.lessons
import android.media.MediaPlayer
import android.os.Bundle
import android.view.View
import android.widget.SeekBar
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.d4rk.englishwithlidia.plus.R
import com.d4rk.englishwithlidia.plus.databinding.ActivityLesson1Binding
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.kieronquinn.monetcompat.app.MonetCompatActivity
import kotlin.math.ceil
import kotlin.math.roundToInt
class Lesson1Activity: MonetCompatActivity(), Runnable {
private var mediaPlayer: MediaPlayer = MediaPlayer()
private lateinit var seekBar: SeekBar
private var wasPlaying = false
private lateinit var fab: FloatingActionButton
private var startPoint = 0
private lateinit var binding: ActivityLesson1Binding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLesson1Binding.inflate(layoutInflater)
setContentView(R.layout.activity_lesson1)
fab = findViewById(R.id.lesson1PlayButton)
fab.setOnClickListener { playSong() }
val seekBarHint = findViewById<TextView>(R.id.lesson1LengthText)
seekBar = findViewById(R.id.lesson1Seekbar)
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
setContentView(binding.root)
binding.lesson1PlayButton.setOnClickListener {
playSong()
}
binding.lesson1Seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onStartTrackingTouch(seekBar: SeekBar) {
seekBarHint.visibility = View.INVISIBLE
startPoint = seekBar.progress
}
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromTouch: Boolean) {
seekBarHint.visibility = View.INVISIBLE
val x = ceil((progress / 1000f).toDouble()).toInt()
val i = "0:$x"
if (x < 10) seekBarHint.text = i else seekBarHint.text = i
ceil((progress / 1000f).toDouble()).toInt()
val percent = progress / seekBar.max.toDouble()
val offset = seekBar.thumbOffset
val seekWidth = seekBar.width
val `val` = (percent * (seekWidth - 2 * offset)).roundToInt()
val labelWidth = seekBarHint.width
seekBarHint.x = (offset + seekBar.x + `val` - (percent * offset).roundToInt() - (percent * labelWidth / 2).roundToInt())
(percent * (seekWidth - 2 * offset)).roundToInt()
if (progress > 0 && !mediaPlayer.isPlaying) {
clearMediaPlayer()
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_media_play))
this@Lesson1Activity.seekBar.progress = 0
onDestroy()
binding.lesson1PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_media_play))
this@Lesson1Activity.binding.lesson1Seekbar.progress = 0
}
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
if (mediaPlayer.isPlaying) {
mediaPlayer.seekTo(seekBar.progress)
mediaPlayer.seekTo(binding.lesson1Seekbar.progress)
}
}
})
}
private fun playSong() {
try {
if (mediaPlayer.isPlaying) {
clearMediaPlayer()
seekBar.progress = 0
onDestroy()
binding.lesson1Seekbar.progress = 0
wasPlaying = true
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_play))
binding.lesson1PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_play))
}
if (! wasPlaying) {
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_pause))
if (!wasPlaying) {
binding.lesson1PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson1Activity, R.drawable.ic_pause))
val descriptor = assets.openFd("lesson1.ogg")
mediaPlayer.setDataSource(descriptor.fileDescriptor, descriptor.startOffset, descriptor.length)
descriptor.close()
mediaPlayer.prepare()
mediaPlayer.setVolume(0.5f, 0.5f)
mediaPlayer.isLooping = false
seekBar.max = mediaPlayer.duration
binding.lesson1Seekbar.max = mediaPlayer.duration
mediaPlayer.start()
Thread(this).start()
}
Expand All @@ -88,18 +78,11 @@ class Lesson1Activity: MonetCompatActivity(), Runnable {
} catch (e: Exception) {
return
}
seekBar.progress = currentPosition
binding.lesson1Seekbar.progress = currentPosition
}
}
override fun onDestroy() {
if (!mediaPlayer.isPlaying) {
mediaPlayer.stop()
clearMediaPlayer()
}
super.onDestroy()
}
private fun clearMediaPlayer() {
mediaPlayer.stop()
mediaPlayer.release()
super.onDestroy()
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
package com.d4rk.englishwithlidia.plus.ui.lessons
import android.media.MediaPlayer
import android.os.Bundle
import android.view.View
import android.widget.SeekBar
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.d4rk.englishwithlidia.plus.R
import com.d4rk.englishwithlidia.plus.databinding.ActivityLesson2Binding
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.kieronquinn.monetcompat.app.MonetCompatActivity
import kotlin.math.ceil
import kotlin.math.roundToInt
class Lesson2Activity: MonetCompatActivity(), Runnable {
private var mediaPlayer: MediaPlayer = MediaPlayer()
private lateinit var seekBar: SeekBar
private var wasPlaying = false
private lateinit var fab: FloatingActionButton
private var startPoint = 0
private lateinit var binding: ActivityLesson2Binding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLesson2Binding.inflate(layoutInflater)
setContentView(R.layout.activity_lesson2)
fab = findViewById(R.id.lesson2PlayButton)
fab.setOnClickListener { playSong() }
val seekBarHint = findViewById<TextView>(R.id.lesson2LengthText)
seekBar = findViewById(R.id.lesson2Seekbar)
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
setContentView(binding.root)
binding.lesson2PlayButton.setOnClickListener { playSong() }
binding.lesson2Seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onStartTrackingTouch(seekBar: SeekBar) {
seekBarHint.visibility = View.INVISIBLE
startPoint = seekBar.progress
}
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromTouch: Boolean) {
seekBarHint.visibility = View.INVISIBLE
val x = ceil((progress / 1000f).toDouble()).toInt()
val i = "0:$x"
if (x < 10) seekBarHint.text = i else seekBarHint.text = i
ceil((progress / 1000f).toDouble()).toInt()
val percent = progress / seekBar.max.toDouble()
val offset = seekBar.thumbOffset
val seekWidth = seekBar.width
val `val` = (percent * (seekWidth - 2 * offset)).roundToInt()
val labelWidth = seekBarHint.width
seekBarHint.x = (offset + seekBar.x + `val` - (percent * offset).roundToInt() - (percent * labelWidth / 2).roundToInt())
(percent * (seekWidth - 2 * offset)).roundToInt()
if (progress > 0 && !mediaPlayer.isPlaying) {
clearMediaPlayer()
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_media_play))
this@Lesson2Activity.seekBar.progress = 0
binding.lesson2PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_media_play))
this@Lesson2Activity.binding.lesson2Seekbar.progress = 0
}
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
Expand All @@ -57,19 +45,19 @@ class Lesson2Activity: MonetCompatActivity(), Runnable {
try {
if (mediaPlayer.isPlaying) {
clearMediaPlayer()
seekBar.progress = 0
binding.lesson2Seekbar.progress = 0
wasPlaying = true
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_play))
binding.lesson2PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_play))
}
if (! wasPlaying) {
fab.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_pause))
binding.lesson2PlayButton.setImageDrawable(ContextCompat.getDrawable(this@Lesson2Activity, R.drawable.ic_pause))
val descriptor = assets.openFd("lesson2.ogg")
mediaPlayer.setDataSource(descriptor.fileDescriptor, descriptor.startOffset, descriptor.length)
descriptor.close()
mediaPlayer.prepare()
mediaPlayer.setVolume(0.5f, 0.5f)
mediaPlayer.isLooping = false
seekBar.max = mediaPlayer.duration
binding.lesson2Seekbar.max = mediaPlayer.duration
mediaPlayer.start()
Thread(this).start()
}
Expand All @@ -88,15 +76,15 @@ class Lesson2Activity: MonetCompatActivity(), Runnable {
} catch (e: Exception) {
return
}
seekBar.progress = currentPosition
binding.lesson2Seekbar.progress = currentPosition
}
}
override fun onDestroy() {
super.onDestroy()
if (!mediaPlayer.isPlaying) {
mediaPlayer.stop()
clearMediaPlayer()
}
super.onDestroy()
}
private fun clearMediaPlayer() {
mediaPlayer.stop()
Expand Down
Loading

0 comments on commit 0e308c5

Please sign in to comment.