| @@ -16,7 +16,7 @@ class EditActivity : AppCompatActivity() { | |||||
| private fun displayFile() { | private fun displayFile() { | ||||
| val fileTextView = findViewById<TextView>(R.id.fileTextView) | val fileTextView = findViewById<TextView>(R.id.fileTextView) | ||||
| currentUri?.let { uri -> | currentUri?.let { uri -> | ||||
| fileTextView.setText(getFileName(uri)) | |||||
| fileTextView.text = getFileName(uri) | |||||
| if (captionEditText.text.isBlank()) { | if (captionEditText.text.isBlank()) { | ||||
| captionEditText.setText(fileTextView.text) | captionEditText.setText(fileTextView.text) | ||||
| } | } | ||||
| @@ -30,7 +30,7 @@ class EditActivity : AppCompatActivity() { | |||||
| val captionEditText = findViewById<EditText>(R.id.captionEditText) | val captionEditText = findViewById<EditText>(R.id.captionEditText) | ||||
| captionEditText.setText(intent.getStringExtra("caption")) | captionEditText.setText(intent.getStringExtra("caption")) | ||||
| fileTextView.setText(intent.getStringExtra("fileName")) | |||||
| fileTextView.text = intent.getStringExtra("fileName") | |||||
| val okButton = findViewById<Button>(R.id.okButton) | val okButton = findViewById<Button>(R.id.okButton) | ||||
| okButton.setOnClickListener { | okButton.setOnClickListener { | ||||
| @@ -64,7 +64,7 @@ class EditActivity : AppCompatActivity() { | |||||
| } | } | ||||
| } | } | ||||
| var currentUri: Uri? = null | |||||
| private var currentUri: Uri? = null | |||||
| override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||||
| super.onActivityResult(requestCode, resultCode, data) | super.onActivityResult(requestCode, resultCode, data) | ||||
| @@ -75,7 +75,7 @@ class EditActivity : AppCompatActivity() { | |||||
| } | } | ||||
| } | } | ||||
| fun getFileName(uri: Uri): String { | |||||
| private fun getFileName(uri: Uri): String { | |||||
| var result: String? = null | var result: String? = null | ||||
| if (uri.scheme == "content") { | if (uri.scheme == "content") { | ||||
| val cursor = contentResolver.query(uri, null, null, null, null) | val cursor = contentResolver.query(uri, null, null, null, null) | ||||
| @@ -132,7 +132,7 @@ class MainActivity : AppCompatActivity() { | |||||
| val preferences = getPreferences(Context.MODE_PRIVATE) | val preferences = getPreferences(Context.MODE_PRIVATE) | ||||
| val numButtons = preferences.getInt("numButtons", 0) | val numButtons = preferences.getInt("numButtons", 0) | ||||
| for (index in 0..numButtons - 1) { | |||||
| for (index in 0 until numButtons) { | |||||
| val soundButton = SoundButton(this) | val soundButton = SoundButton(this) | ||||
| addButton(soundButton) | addButton(soundButton) | ||||
| val caption = preferences.getString("caption" + index, "") | val caption = preferences.getString("caption" + index, "") | ||||
| @@ -162,7 +162,7 @@ class MainActivity : AppCompatActivity() { | |||||
| } else { | } else { | ||||
| val caption = data.getStringExtra("caption") | val caption = data.getStringExtra("caption") | ||||
| if (caption != null) { | if (caption != null) { | ||||
| textView.setText(caption) | |||||
| textView.text = caption | |||||
| } | } | ||||
| val uri = data.getParcelableExtra<Uri>("uri") | val uri = data.getParcelableExtra<Uri>("uri") | ||||
| val fileName = data.getStringExtra("fileName") | val fileName = data.getStringExtra("fileName") | ||||
| @@ -190,9 +190,9 @@ class MainActivity : AppCompatActivity() { | |||||
| buttons[index].soundId = newSoundId | buttons[index].soundId = newSoundId | ||||
| editor.putLong("soundId" + index, newSoundId) | editor.putLong("soundId" + index, newSoundId) | ||||
| editor.commit() | editor.commit() | ||||
| grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) | |||||
| grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) | |||||
| val output = BufferedOutputStream(openFileOutput("audio" + newSoundId, Context.MODE_PRIVATE)) | val output = BufferedOutputStream(openFileOutput("audio" + newSoundId, Context.MODE_PRIVATE)) | ||||
| val input = BufferedInputStream(getContentResolver().openInputStream(uri)) | |||||
| val input = BufferedInputStream(contentResolver.openInputStream(uri)) | |||||
| try { | try { | ||||
| val buf = ByteArray(1024) | val buf = ByteArray(1024) | ||||
| input.read(buf) | input.read(buf) | ||||
| @@ -206,6 +206,5 @@ class MainActivity : AppCompatActivity() { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -22,7 +22,7 @@ class SoundButton : FrameLayout { | |||||
| progressBar = findViewById<ProgressBar>(R.id.progress_bar) | progressBar = findViewById<ProgressBar>(R.id.progress_bar) | ||||
| textView = findViewById<TextView>(R.id.text_view_button) | textView = findViewById<TextView>(R.id.text_view_button) | ||||
| objectAnimator = ObjectAnimator.ofInt(progressBar, "progress", progressBar.getProgress(), 1000) | |||||
| objectAnimator = ObjectAnimator.ofInt(progressBar, "progress", progressBar.progress, 1000) | |||||
| objectAnimator.interpolator = LinearInterpolator() | objectAnimator.interpolator = LinearInterpolator() | ||||
| progressBar.max = 1000 | progressBar.max = 1000 | ||||
| objectAnimator.addUpdateListener({ valueAnimator -> | objectAnimator.addUpdateListener({ valueAnimator -> | ||||