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

Add bottom padding to last item so that all items can be visible even if UI scroll is enabled #66

Merged
merged 1 commit into from
Mar 5, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class LockableScrollView : ScrollView {
if (!over) scrollTo(0, 0)
lockView.layoutParams.height = if (over) height else height - lockView.top
lockView.requestLayout()
adapter.onSizeChanged(if (over) lockView.top else 0)
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
Expand All @@ -70,6 +71,7 @@ class LockableScrollView : ScrollView {
lockView?.let {
it.layoutParams.height = if (over) h else h - it.top
it.requestLayout()
adapter.onSizeChanged(if (over) it.top else 0)
it.post { scrollTo(0, pos) }
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/jp/ddo/hotmist/unicodepad/PageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ class PageAdapter(private val activity: UnicodeActivity, private val pref: Share
for (i in 0 until MAX_VIEWS) views[i]?.invalidateViews()
}

fun onSizeChanged(top: Int) {
adapters.forEach {
it.lastPadding = top
}
}

companion object {
var column = 8
private const val MAX_VIEWS: Int = 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class UnicodeActivity : AppCompatActivity() {
pager.adapter = it
scroll.setAdapter(it)
}
scroll.setLockView(pager, Integer.valueOf(pref.getString("scroll", null)?.toIntOrNull() ?: 1) + (if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) 1 else 0) > 1)
scroll.setLockView(pager, (pref.getString("scroll", null)?.toIntOrNull() ?: 1) + (if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) 1 else 0) > 1)
cm = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
disableime = pref.getBoolean("ime", true)
pager.setCurrentItem(min(pref.getInt("page", 1), adpPage.count - 1), false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.mobeta.android.dslv.DragSortListView.RemoveListener
abstract class UnicodeAdapter(protected val activity: Activity, private val db: NameDatabase, var single: Boolean) : BaseAdapter() {
private var typeface: Typeface? = null
protected var view: AbsListView? = null
internal var lastPadding: Int = 0
open fun name(): Int {
return 0
}
Expand Down Expand Up @@ -94,10 +95,11 @@ abstract class UnicodeAdapter(protected val activity: Activity, private val db:
(linearLayout.getChildAt(1) as TextView).text = db[getItemString(i), "name"]
}
}
it.setPadding(0, 0, 0, if (i == this.count - 1) lastPadding else 0)
}
} else {
(view as CharacterView? ?: CharacterView(activity, null, android.R.attr.textAppearanceLarge)).also {
it.setPadding(padding, padding, padding, padding)
it.setPadding(padding, padding, padding, padding + if (i == this.count - 1) lastPadding else 0)
it.setTextSize(fontsize)
it.shrinkWidth(shrink)
it.setTypeface(typeface)
Expand Down