Skip to content

Commit

Permalink
Merge pull request #170 from OSLL/Alex0
Browse files Browse the repository at this point in the history
Major Gradle and Kotlin update, migration to ViewBinding
  • Loading branch information
bialger authored Aug 21, 2023
2 parents 0c5b2eb + 2742796 commit 1791a47
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 185 deletions.
37 changes: 26 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 31
compileSdkVersion 33

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

buildFeatures {
viewBinding true
dataBinding true
}

defaultConfig {
applicationId "com.bigri239.easymusic"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 31
versionCode 1
versionName "1.0"
Expand All @@ -21,19 +34,21 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
namespace 'com.bigri239.easymusic'
buildToolsVersion '33.0.1'

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.material:material:1.5.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.9.0'
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.3.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bigri239.easymusic">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

Expand Down
18 changes: 11 additions & 7 deletions app/src/main/java/com/bigri239/easymusic/AddingfilesActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bigri239.easymusic.adapter.CustomAdapter
import com.bigri239.easymusic.adapter.CustomConnector
import kotlinx.android.synthetic.main.activity_addfiles.*
import com.bigri239.easymusic.databinding.ActivityAddfilesBinding
import java.io.*
import kotlin.math.abs

Expand Down Expand Up @@ -44,6 +44,7 @@ class AddingfilesActivity : AppCompatActivity() {
private val customList = arrayListOf<String>()
private lateinit var defaultAdapter: CustomAdapter
private lateinit var customAdapter: CustomAdapter
private lateinit var binding: ActivityAddfilesBinding

private val connectorSound = object : CustomConnector {
override fun function(string: String) {
Expand All @@ -53,7 +54,10 @@ class AddingfilesActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_addfiles)
binding = ActivityAddfilesBinding.inflate(layoutInflater)
val view = binding.root.also {
setContentView(it)
}
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
val path = filesDir
val file = File(path, "sounds.conf")
Expand All @@ -64,13 +68,13 @@ class AddingfilesActivity : AppCompatActivity() {
}
else FileOutputStream(file).write("".toByteArray())

val recyclerView: RecyclerView = recyclerView111
val recyclerView: RecyclerView = binding.recyclerView111
defaultAdapter = CustomAdapter(defaultList, connectorSound)
recyclerView.layoutManager = LinearLayoutManager(applicationContext)
recyclerView.adapter = defaultAdapter
recyclerView.layoutParams = getLayoutParametersRelativeWidth()

val recyclerView1: RecyclerView = recyclerView222
val recyclerView1: RecyclerView = binding.recyclerView222
customAdapter = CustomAdapter(customList, connectorSound)
recyclerView1.layoutManager = LinearLayoutManager(applicationContext)
recyclerView1.adapter = customAdapter
Expand All @@ -81,7 +85,7 @@ class AddingfilesActivity : AppCompatActivity() {
super.onStart()
val intent = Intent(this, MainActivity::class.java)
findViewById<TextView>(R.id.back_A).setOnClickListener {
back_A.isClickable = false
binding.backA.isClickable = false
startActivity(intent)
}
}
Expand Down Expand Up @@ -163,8 +167,8 @@ class AddingfilesActivity : AppCompatActivity() {
private fun playSound (soundName : String) {
len = getSoundLength(soundName)
if (len != 0.toLong()) {
name.text = "Sound name: $soundName"
length.text = "Sound length: $len"
binding.name.text = "Sound name: $soundName"
binding.length.text = "Sound length: $len"
track.release()
track = SoundPool(1, AudioManager.STREAM_MUSIC, 0)
id = if (defaultList.contains(soundName)) track.load(
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/bigri239/easymusic/AuthorsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ package com.bigri239.easymusic
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_authors.*
import com.bigri239.easymusic.databinding.ActivityAuthorsBinding

@Suppress("DEPRECATION")
class AuthorsActivity : AppCompatActivity() {
private lateinit var binding: ActivityAuthorsBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_authors)
binding = ActivityAuthorsBinding.inflate(layoutInflater)
val view = binding.root.also {
setContentView(it)
}
}

override fun onStart() {
super.onStart()
val intent = Intent(this, HelpActivity::class.java)
backauth.setOnClickListener {
backauth.isClickable = false
binding.backauth.setOnClickListener {
binding.backauth.isClickable = false
startActivity(intent)
}
}
Expand Down
18 changes: 11 additions & 7 deletions app/src/main/java/com/bigri239/easymusic/FaqActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import android.content.Intent
import android.os.Bundle
import android.os.StrictMode
import androidx.appcompat.app.AppCompatActivity
import com.bigri239.easymusic.databinding.ActivityFaqBinding
import com.bigri239.easymusic.net.WebRequester
import kotlinx.android.synthetic.main.activity_faq.*

@Suppress("DEPRECATION")
class FaqActivity : AppCompatActivity() {
private lateinit var binding: ActivityFaqBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_faq)
binding = ActivityFaqBinding.inflate(layoutInflater)
val view = binding.root.also {
setContentView(it)
}
}

override fun onStart() {
Expand All @@ -21,13 +25,13 @@ class FaqActivity : AppCompatActivity() {
val webRequester = WebRequester(this@FaqActivity)

val intent = Intent(this, HelpActivity::class.java)
backfaq.setOnClickListener {
backfaq.isClickable = false
binding.backfaq.setOnClickListener {
binding.backfaq.isClickable = false
startActivity(intent)
}

val faqText = webRequester.getTextResource("faq")
text_view.text = if (faqText != "0") faqText
binding.textView0.text = if (faqText != "0") faqText
else {
"1. Q: Is it possible to save the sound to the device in mp3 or other audio format? \n" +
"A: Unfortunately, no, the application was created for educational purposes and aims to explain in simple terms the principle of creating music from sounds and understand if you want to do it. However, you can share music with your friends inside the app by uploading projects to your account. Or, if desired, record music using the built-in screen recording application on your phone, and then extract the audio track from the video in the online service. \n\n" +
Expand All @@ -42,7 +46,7 @@ class FaqActivity : AppCompatActivity() {
val pixelsWidth = (displayMetrics.widthPixels * 0.95F).toInt()
val pixelsHeight = (displayMetrics.heightPixels * 0.95F - 100 * scale + 0.5f).toInt()

scroll.layoutParams.height = pixelsHeight
scroll.layoutParams.width = pixelsWidth
binding.scroll.layoutParams.height = pixelsHeight
binding.scroll.layoutParams.width = pixelsWidth
}
}
27 changes: 16 additions & 11 deletions app/src/main/java/com/bigri239/easymusic/FriendActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.recyclerview.widget.LinearLayoutManager
import com.bigri239.easymusic.adapter.*
import com.bigri239.easymusic.databinding.ActivityFriendBinding
import com.bigri239.easymusic.net.WebRequester
import kotlinx.android.synthetic.main.activity_friend.*

@Suppress("DEPRECATION")
class FriendActivity : AppCompatActivity() {
Expand All @@ -21,6 +21,7 @@ class FriendActivity : AppCompatActivity() {
private lateinit var webRequester : WebRequester
private lateinit var soundsAdapter: CustomAdapter
private lateinit var projectsAdapter: CustomAdapter
private lateinit var binding: ActivityFriendBinding
private val connectorProject = object : CustomConnector {
override fun function(string: String) {
loadProject(string)
Expand All @@ -33,6 +34,10 @@ class FriendActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityFriendBinding.inflate(layoutInflater)
val view = binding.root.also {
setContentView(it)
}
setContentView(R.layout.activity_friend)
email = intent.getStringExtra("owner").toString()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
Expand All @@ -45,8 +50,8 @@ class FriendActivity : AppCompatActivity() {
super.onStart()
val info = email.let { webRequester.getFriendInfo(it) }
if (!info.contentEquals(Array (5) {arrayOf("")})) {
username.text = "Username: " + info[0][0]
aboutme.text = "About me: " + info[1][0]
binding.username.text = "Username: " + info[0][0]
binding.aboutme.text = "About me: " + info[1][0]
soundsList = info[3]
projectsList = info[4]
if (soundsList == arrayListOf("")) soundsList = arrayListOf()
Expand All @@ -58,20 +63,20 @@ class FriendActivity : AppCompatActivity() {
}

val intent = Intent(this, RecoveryActivity::class.java)
backrec.setOnClickListener {
backrec.isClickable = false
binding.backrec.setOnClickListener {
binding.backrec.isClickable = false
startActivity(intent)
}

soundsAdapter = CustomAdapter(soundsList, connectorSound)
recyclerView2.layoutManager = LinearLayoutManager(applicationContext)
recyclerView2.adapter = soundsAdapter
recyclerView2.layoutParams = getLayoutParametersRelativeWidth()
binding.recyclerView2.layoutManager = LinearLayoutManager(applicationContext)
binding.recyclerView2.adapter = soundsAdapter
binding.recyclerView2.layoutParams = getLayoutParametersRelativeWidth()

projectsAdapter = CustomAdapter(projectsList, connectorProject)
recyclerView3.layoutManager = LinearLayoutManager(applicationContext)
recyclerView3.adapter = projectsAdapter
recyclerView3.layoutParams = getLayoutParametersRelativeWidth()
binding.recyclerView3.layoutManager = LinearLayoutManager(applicationContext)
binding.recyclerView3.adapter = projectsAdapter
binding.recyclerView3.layoutParams = getLayoutParametersRelativeWidth()
}

private fun getLayoutParametersRelativeWidth (): LinearLayout.LayoutParams {
Expand Down
24 changes: 14 additions & 10 deletions app/src/main/java/com/bigri239/easymusic/HelpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,43 @@ package com.bigri239.easymusic
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_help.*
import com.bigri239.easymusic.databinding.ActivityHelpBinding

@Suppress("DEPRECATION")
class HelpActivity : AppCompatActivity() {
private lateinit var binding: ActivityHelpBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_help)
binding = ActivityHelpBinding.inflate(layoutInflater)
val view = binding.root.also {
setContentView(it)
}
}

override fun onStart() {
super.onStart()

val intent = Intent(this, MainActivity::class.java)
back_H.setOnClickListener {
back_H.isClickable = false
binding.backH.setOnClickListener {
binding.backH.isClickable = false
startActivity(intent)
}

val intent11 = Intent(this, AuthorsActivity::class.java)
authors.setOnClickListener {
authors.isClickable = false
binding.authors.setOnClickListener {
binding.authors.isClickable = false
startActivity(intent11)
}

val intent12 = Intent(this, FaqActivity::class.java)
frequently.setOnClickListener {
terms.isClickable = false
binding.frequently.setOnClickListener {
binding.frequently.isClickable = false
startActivity(intent12)
}

val intent13 = Intent(this, TermsActivity::class.java)
terms.setOnClickListener {
terms.isClickable = false
binding.terms.setOnClickListener {
binding.terms.isClickable = false
intent13.putExtra("isStart", "false")
startActivity(intent13)
}
Expand Down
Loading

0 comments on commit 1791a47

Please sign in to comment.