-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from yahoo/piano-tones
Piano keys, clean up, updated settings
- Loading branch information
Showing
75 changed files
with
503 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 0 additions & 111 deletions
111
...n/java/com/yahoo/mobile/android/audiocharts/sample/settings/AudioChartSettingsActivity.kt
This file was deleted.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
app/src/main/java/com/yahoo/mobile/android/audiocharts/sample/settings/SettingsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.yahoo.mobile.android.audiocharts.sample.settings | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.widget.* | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.yahoo.mobile.android.songbird.util.SettingsHelper | ||
import com.yahoo.mobile.android.audiocharts.R | ||
import com.yahoo.mobile.android.audiocharts.base.ApplicationBase | ||
import com.yahoo.mobile.android.songbird.player.AudioPlayer | ||
|
||
class SettingsActivity : AppCompatActivity() { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun intent(context: Context) = Intent(context, SettingsActivity::class.java) | ||
} | ||
|
||
private val settingsHelper: SettingsHelper = SettingsHelper( | ||
ApplicationBase.instance | ||
) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContentView(R.layout.activity_settings) | ||
|
||
setSupportActionBar(findViewById(R.id.toolbar)) | ||
|
||
supportActionBar?.apply { | ||
setDisplayHomeAsUpEnabled(true) | ||
title = getString(R.string.settings) | ||
} | ||
val orderButtons: RadioGroup = findViewById(R.id.order_buttons) | ||
orderButtons.setOnCheckedChangeListener { _, checkedId -> | ||
settingsHelper.setOrderPosition(orderButtons.indexOfChild(orderButtons.findViewById(checkedId))) | ||
} | ||
|
||
val dateButtons: RadioGroup = findViewById(R.id.date_buttons) | ||
dateButtons.setOnCheckedChangeListener { _, checkedId -> | ||
settingsHelper.setDatePosition(dateButtons.indexOfChild(dateButtons.findViewById(checkedId))) | ||
} | ||
|
||
val highToneInput = findViewById<Spinner>(R.id.high_tone_input) | ||
ArrayAdapter.createFromResource( | ||
this, | ||
R.array.high_tones, | ||
android.R.layout.simple_spinner_item | ||
).also { adapter -> | ||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) | ||
highToneInput.adapter = adapter | ||
highToneInput.setSelection(AudioPlayer.tones.size-1-settingsHelper.getMaximumTone()) | ||
} | ||
highToneInput.onItemSelectedListener = | ||
object: AdapterView.OnItemSelectedListener { | ||
override fun onItemSelected( | ||
parent: AdapterView<*>?, | ||
view: View?, | ||
position: Int, | ||
id: Long | ||
) { | ||
settingsHelper.setMaximumTone(AudioPlayer.tones.size-1-position) | ||
} | ||
|
||
override fun onNothingSelected(parent: AdapterView<*>?) { | ||
settingsHelper.setMaximumTone(AudioPlayer.tones.size-1) | ||
} | ||
} | ||
|
||
val lowToneInput = findViewById<Spinner>(R.id.low_tone_input) | ||
ArrayAdapter.createFromResource( | ||
this, | ||
R.array.low_tones, | ||
android.R.layout.simple_spinner_item | ||
).also { adapter -> | ||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) | ||
lowToneInput.adapter = adapter | ||
lowToneInput.setSelection(settingsHelper.getMinimumTone()) | ||
} | ||
lowToneInput.onItemSelectedListener = | ||
object: AdapterView.OnItemSelectedListener { | ||
override fun onItemSelected( | ||
parent: AdapterView<*>?, | ||
view: View?, | ||
position: Int, | ||
id: Long | ||
) { | ||
settingsHelper.setMinimumTone(position) | ||
} | ||
|
||
override fun onNothingSelected(parent: AdapterView<*>?) { | ||
settingsHelper.setMinimumTone(0) | ||
} | ||
} | ||
|
||
val echoButton = findViewById<ToggleButton>(R.id.echo_button) | ||
echoButton.setOnClickListener { | ||
settingsHelper.switchEchoToggle() | ||
} | ||
|
||
val feedbackButton = findViewById<Button>(R.id.feedback) | ||
feedbackButton.setOnClickListener { | ||
Toast.makeText(this, getString(R.string.visit_us_at_repo), Toast.LENGTH_LONG).show() | ||
} | ||
|
||
(orderButtons.getChildAt(settingsHelper.getSavedOrderPosition()) as RadioButton).isChecked = true | ||
(dateButtons.getChildAt(settingsHelper.getSavedDateOrderPosition()) as RadioButton).isChecked = true | ||
echoButton.isChecked = settingsHelper.getEchoChecked() | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return when (item.itemId) { | ||
android.R.id.home -> { | ||
finish() | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.