Skip to content

Commit

Permalink
UX adjustments
Browse files Browse the repository at this point in the history
 - fixed placeholder player picture
 - added keyboard hiding on submit of the player ID in settings
  • Loading branch information
fobo66 committed Aug 14, 2018
1 parent aa202db commit 09a956e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ android {
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

package io.github.fobo66.wearmmr.ui

import android.content.Context
import android.os.Bundle
import android.support.wearable.activity.WearableActivity
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.TextView.BufferType.EDITABLE
import butterknife.BindView
Expand All @@ -31,6 +33,10 @@ class SettingsActivity : WearableActivity() {
@BindView(R.id.player_id_input)
lateinit var playerIdInput: EditText

private val inputMethodManager: InputMethodManager by lazy {
getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
Expand All @@ -41,13 +47,14 @@ class SettingsActivity : WearableActivity() {

playerIdInput.setText(defaultSharedPreferences.getInt("playerId", 0).toString(), EDITABLE)

playerIdInput.setOnEditorActionListener({ _, actionId, _ ->
playerIdInput.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
inputMethodManager.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
val playerId: Int = Integer.parseInt(playerIdInput.text.toString())
this.defaultSharedPreferences.edit().putInt("playerId", playerId).apply()
return@setOnEditorActionListener true
}
false
})
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
<android.support.v7.widget.AppCompatImageView
android:id="@+id/player_pic"
android:layout_width="50dp"
android:layout_height="50dp"
Expand Down

0 comments on commit 09a956e

Please sign in to comment.