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

Update popup style #136

Merged
merged 1 commit into from
Feb 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class MainFragment : BrowseSupportFragment() {

// set fastLane (or headers) background color
brandColor = ContextCompat.getColor(requireActivity(), R.color.fastlane_background)
// set search icon color
searchAffordanceColor = ContextCompat.getColor(requireActivity(), R.color.search_opaque)
}

private fun setupEventListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package com.github.damontecres.stashapp.presenters

import android.view.View
import android.view.View.OnLongClickListener
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.appcompat.widget.ListPopupWindow
import com.github.damontecres.stashapp.StashOnFocusChangeListener
import com.github.damontecres.stashapp.R

/**
* An OnLongClickListener which shows a popup of predefined options
Expand All @@ -24,30 +23,15 @@ class PopupOnLongClickListener(
)
listPopUp.inputMethodMode = ListPopupWindow.INPUT_METHOD_NEEDED
listPopUp.anchorView = view
// listPopUp.width = ViewGroup.LayoutParams.MATCH_PARENT
// TODO: Better width calculation
listPopUp.width = 200
listPopUp.width = ListPopupWindow.WRAP_CONTENT
listPopUp.isModal = true

val focusChangeListener = StashOnFocusChangeListener(view.context)

val adapter =
object : ArrayAdapter<String>(
ArrayAdapter(
view.context,
android.R.layout.simple_list_item_1,
R.layout.popup_item,
popupOptions,
) {
override fun getView(
position: Int,
convertView: View?,
parent: ViewGroup,
): View {
val itemView = super.getView(position, convertView, parent)
// TODO: this doesn't seem to work?
itemView.onFocusChangeListener = focusChangeListener
return itemView
}
}
)
listPopUp.setAdapter(adapter)

listPopUp.setOnItemClickListener { parent: AdapterView<*>, v: View, position: Int, id: Long ->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/color/popup_background_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/popup_selected_background" />
<item android:color="@color/popup_background" />
</selector>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/popup_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_item_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:background="@color/popup_background_selector"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
3 changes: 2 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<color name="background_gradient_start">#000000</color>
<color name="background_gradient_end">#DDDDDD</color>
<color name="fastlane_background">#0096a6</color>
<color name="search_opaque">#477ab5</color>
<color name="selected_background">#4785b5</color>
<color name="default_background">#202b33</color>
<color name="default_card_background">#30404d</color>
<color name="gold">#FFD700</color>
<color name="popup_selected_background">#3c719a</color>
<color name="popup_background">#111a20</color>
</resources>
Loading