Skip to content

Commit

Permalink
Add MetronomeActivity.
Browse files Browse the repository at this point in the history
Complete notes.
Update string no_change_made
  • Loading branch information
Ali Avci committed Oct 18, 2018
1 parent c8b1852 commit eadca43
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</activity>
<activity android:name=".ui.ScaleActivity"
android:label="Scales and Arpeggios" />
<activity android:name=".ui.MetronomeActivity"
android:label="Metronome" />
<activity android:name=".ui.NotesActivity"
android:label="Notes" />
<activity android:name=".ui.NoteEditorActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MainAdapter(val context: Context): BaseAdapter() {
private val menuItemsInfos = mutableListOf<Triple<Int, String, Activity>>(
Triple(R.drawable.music_scale, "Scales and Arpeggios", ScaleActivity()),
Triple(R.drawable.music_note, "Tuner", ScaleActivity()),
Triple(R.drawable.music_symbol, "Metronome", ScaleActivity()),
Triple(R.drawable.music_symbol, "Metronome", MetronomeActivity()),
Triple(R.drawable.note_book, "Notes", NotesActivity())
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package info.aiavci.violincompanion.ui

import android.os.Bundle
import info.aiavci.violincompanion.R

/**
* Created by ${$FULLNAME}
* Version
*/
class MetronomeActivity: BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_metronome)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package info.aiavci.violincompanion.ui
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import info.aiavci.violincompanion.R
Expand Down Expand Up @@ -35,20 +34,17 @@ class NoteEditorActivity : BaseActivity() {

edit_title.setText(existingNoteTitle ?: "")
edit_content.setText(existingNoteContent ?: "")

// saveMenuItem?.apply {
// isEnabled = false
// }
}

// private val isChangeMade: Boolean
// get() = edit_title.text.toString() != existingNoteTitle ||
// edit_content.text.toString() != existingNoteContent
private val isChangeMade: Boolean
get() = edit_title.text.toString() != existingNoteTitle ||
edit_content.text.toString() != existingNoteContent

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.note_menu, menu)

saveMenuItem = menu?.findItem(R.id.action_save)
saveMenuItem?.isEnabled = true

return super.onCreateOptionsMenu(menu)
}
Expand All @@ -70,7 +66,7 @@ class NoteEditorActivity : BaseActivity() {
private fun performSave() {
val noteIntent = Intent()

if (TextUtils.isEmpty(edit_content.text)) {
if (!isChangeMade) {
setResult(Activity.RESULT_CANCELED, noteIntent)
} else {
val noteTitle = edit_title.text.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NotesActivity: BaseActivity() {
} else {
Toast.makeText(
applicationContext,
R.string.empty_not_saved,
R.string.no_change_made,
Toast.LENGTH_LONG).show()
}

Expand Down
54 changes: 54 additions & 0 deletions app/src/main/res/layout/activity_metronome.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<SeekBar
android:id="@+id/seekBar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/bpmTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="123"
app:layout_constraintBottom_toBottomOf="@id/seekBar"
app:layout_constraintStart_toStartOf="@id/seekBar"
app:layout_constraintTop_toTopOf="parent"/>

<Button
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Play"
app:layout_constraintBottom_toBottomOf="@id/seekBar"
app:layout_constraintEnd_toEndOf="@id/seekBar"
app:layout_constraintTop_toTopOf="parent"/>

</android.support.constraint.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<string name="hint_note">Note</string>
<string name="hint_title">Title</string>
<string name="save">Save</string>
<string name="empty_not_saved">Note not saved because it is empty.</string>
<string name="no_change_made">Note not saved because no changes were made.</string>
</resources>

0 comments on commit eadca43

Please sign in to comment.