Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small UI/UX tweaks to setup, filter creation, & non-TV devices #423

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
android:required="false" />
<uses-feature
android:name="android.hardware.microphone"
android:required="false" />
Expand All @@ -37,7 +37,6 @@
android:icon="@mipmap/stash_logo"
android:logo="@mipmap/stash_logo"
android:noHistory="true"
android:screenOrientation="landscape"
android:theme="@style/NoTitleTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class StashGridFragment() : Fragment() {
playAllButton = root.findViewById(R.id.play_all_button)
val gridDock = root.findViewById<View>(androidx.leanback.R.id.browse_grid_dock) as ViewGroup
mGridViewHolder = mGridPresenter.onCreateViewHolder(gridDock)
mGridViewHolder.view.isFocusableInTouchMode = false
gridDock.addView(mGridViewHolder.view)
mGridViewHolder.gridView.setOnChildLaidOutListener(mChildLaidOutListener)
if (name == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CreateFilterStep : CreateFilterGuidedStepFragment() {
.hasNext(true)
.enabled(false)
.title("Save and submit")
.description("Experimental!")
.description(getString(R.string.save_and_submit_no_name_desc))
.build(),
)
}
Expand Down Expand Up @@ -171,6 +171,12 @@ class CreateFilterStep : CreateFilterGuidedStepFragment() {
if (action.id == FILTER_NAME) {
val submitAction = findActionById(SAVE_SUBMIT)
submitAction.isEnabled = action.description.isNotNullOrBlank()
submitAction.description =
if (submitAction.isEnabled) {
getString(R.string.save_and_submit_desc)
} else {
getString(R.string.save_and_submit_no_name_desc)
}
notifyActionChanged(findActionPositionById(SAVE_SUBMIT))
}
return GuidedAction.ACTION_ID_NEXT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.damontecres.stashapp.presenters

import android.content.Context
import android.graphics.drawable.Drawable
import android.graphics.drawable.PictureDrawable
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -29,23 +28,13 @@ import com.github.damontecres.stashapp.data.OCounter
import com.github.damontecres.stashapp.suppliers.FilterArgs
import com.github.damontecres.stashapp.util.StashGlide
import com.github.damontecres.stashapp.util.svg.SvgSoftwareLayerSetter
import kotlin.properties.Delegates

abstract class StashPresenter<T>(private val callback: LongClickCallBack<T>? = null) :
Presenter() {
protected var vParent: ViewGroup by Delegates.notNull()
protected var mDefaultCardImage: Drawable? = null

abstract class StashPresenter<T>(private val callback: LongClickCallBack<T>? = null) : Presenter() {
final override fun onCreateViewHolder(parent: ViewGroup): ViewHolder {
vParent = parent
mDefaultCardImage =
ContextCompat.getDrawable(parent.context, R.drawable.baseline_camera_indoor_48)

val cardView = StashImageCardView(parent.context)
cardView.isFocusable = true
cardView.isFocusableInTouchMode = true
cardView.isFocusableInTouchMode = false
cardView.updateCardBackgroundColor(cardView, false)

return ViewHolder(cardView)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.damontecres.stashapp.setup

import android.os.Bundle
import android.text.InputType
import androidx.core.content.ContextCompat
import androidx.leanback.widget.GuidanceStylist
import androidx.leanback.widget.GuidedAction
Expand Down Expand Up @@ -29,6 +30,7 @@ class SetupStep1ServerUrl : SetupActivity.SimpleGuidedStepSupportFragment() {
GuidedAction.Builder(requireContext())
.id(SetupActivity.ACTION_SERVER_URL)
.title("Server URL")
.descriptionInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
.descriptionEditable(true)
.hasNext(true)
.build(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.damontecres.stashapp.setup

import android.os.Bundle
import android.text.InputType
import androidx.core.content.ContextCompat
import androidx.leanback.widget.GuidanceStylist
import androidx.leanback.widget.GuidedAction
Expand Down Expand Up @@ -33,6 +34,7 @@ class SetupStep3ApiKey(private val setupState: SetupState) :
.description("API key not set")
.editDescription("")
.descriptionEditable(true)
.descriptionEditInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD)
.hasNext(true)
.build(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import com.github.damontecres.stashapp.util.isNotNullOrBlank

class SetupStep4Pin(private val setupState: SetupState) :
SetupActivity.SimpleGuidedStepSupportFragment() {
private var pinCode: Int? = null

override fun onCreateGuidance(savedInstanceState: Bundle?): GuidanceStylist.Guidance {
return GuidanceStylist.Guidance(
"Set a PIN code?",
Expand All @@ -33,7 +31,7 @@ class SetupStep4Pin(private val setupState: SetupState) :
.description("")
.editDescription("")
.descriptionEditable(true)
.descriptionEditInputType(InputType.TYPE_CLASS_NUMBER)
.descriptionEditInputType(InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD)
.build(),
)
actions.add(
Expand All @@ -43,7 +41,7 @@ class SetupStep4Pin(private val setupState: SetupState) :
.description("")
.editDescription("")
.descriptionEditable(true)
.descriptionEditInputType(InputType.TYPE_CLASS_NUMBER)
.descriptionEditInputType(InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD)
.focusable(false)
.enabled(false)
.build(),
Expand All @@ -62,7 +60,6 @@ class SetupStep4Pin(private val setupState: SetupState) :
val okAction = findActionById(GuidedAction.ACTION_ID_OK)
if (action.id == ACTION_PIN) {
if (action.editDescription.isNotNullOrBlank()) {
pinCode = action.editDescription.toString().toInt()
val confirmAction = findActionById(ACTION_CONFIRM_PIN)
confirmAction.isEnabled = true
confirmAction.isFocusable = true
Expand All @@ -82,9 +79,14 @@ class SetupStep4Pin(private val setupState: SetupState) :
}
} else if (action.id == ACTION_CONFIRM_PIN) {
if (action.editDescription.isNotNullOrBlank()) {
val confirmPin = action.editDescription.toString().toInt()
val pinCode = findActionById(ACTION_PIN).editDescription.toString().toIntOrNull()
val confirmPin = action.editDescription.toString().toIntOrNull()

if (pinCode != confirmPin) {
Toast.makeText(requireContext(), "PINs do not match!", Toast.LENGTH_LONG).show()
Toast.makeText(requireContext(), "PINs do not match!", Toast.LENGTH_SHORT)
.show()
okAction.isEnabled = false
notifyActionChanged(findActionPositionById(GuidedAction.ACTION_ID_OK))
return GuidedAction.ACTION_ID_CURRENT
} else {
okAction.title = "Save PIN"
Expand All @@ -100,8 +102,15 @@ class SetupStep4Pin(private val setupState: SetupState) :

override fun onGuidedActionClicked(action: GuidedAction) {
if (action.id == GuidedAction.ACTION_ID_OK) {
val newState = setupState.copy(pinCode = pinCode)
finishSetup(newState)
val pin = findActionById(ACTION_PIN).editDescription.toString().toIntOrNull()
val confirmPin =
findActionById(ACTION_CONFIRM_PIN).editDescription.toString().toIntOrNull()
if (pin == confirmPin) {
val newState = setupState.copy(pinCode = pin)
finishSetup(newState)
} else {
Toast.makeText(requireContext(), "PINs do not match!", Toast.LENGTH_SHORT).show()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/stash_grid_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<androidx.leanback.widget.BrowseFrameLayout
android:id="@+id/grid_frame"
android:focusable="true"
android:focusableInTouchMode="true"
android:focusableInTouchMode="false"
android:descendantFocusability="afterDescendants"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/create_filter_strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="save_and_submit_no_name_desc">Experimental! Enter a name to save.</string>
<string name="save_and_submit_desc">Experimental!</string>
</resources>