diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-08 03:03:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-08 03:03:55 -0400 |
commit | b10a745c7f0f46f4f014e1ba7fa71172d7442b83 (patch) | |
tree | ef2516b69fb04ec0f565c5bb569fd5d80b7bd262 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt | |
parent | 6adfc496374eb88919f70a240eb15a726d2c18e0 (diff) | |
download | frost-1.2.tar.gz frost-1.2.tar.bz2 frost-1.2.zip |
Dev-1.1.7 (#39) - feature overload + context menuv1.2
* Address some crashlytics issues
* Add text scaling
* Kau fixes and cleanup
* WIP formatter
* Create in house url formatter
* Update context menu
* Update themes
* Test proguard without R
* Implement sharing and clean up context menu
* Disable viewpager swipe on long press
* Test keeping lib strings
* Update changelog and proguard
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt deleted file mode 100644 index e0aa5ebd..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebContextMenu.kt +++ /dev/null @@ -1,100 +0,0 @@ -package com.pitchedapps.frost.web - -import android.content.Context -import android.support.constraint.ConstraintLayout -import android.support.constraint.ConstraintSet -import android.text.method.ScrollingMovementMethod -import android.util.AttributeSet -import android.widget.TextView -import ca.allanwang.kau.logging.KL -import ca.allanwang.kau.utils.* -import com.pitchedapps.frost.R -import com.pitchedapps.frost.utils.Prefs - -/** - * Created by Allan Wang on 2017-07-06. - */ -class FrostWebContextMenu @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr) { - - var url = "" - - val urlHolder = TextView(context, attrs, defStyleAttr) - - init { - layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) - elevation = 20f - setBackgroundColor(0x80000000.toInt()) - gone() - - val tc = Prefs.textColor - val bg = Prefs.bgColor.colorToForeground(0.1f).withAlpha(255) - - urlHolder.apply { - isVerticalScrollBarEnabled = true - movementMethod = ScrollingMovementMethod() - maxHeight = 60.dpToPx - } - addView(urlHolder) - - //collection of items in our menu and their click event - val data = arrayOf( - R.string.copy_link to { context.copyToClipboard(url) } - ) - - //add views and extract ids - val views = data.map { - (textId, onClick) -> - val tv = TextView(context).apply { - text = context.string(textId) - setOnClickListener({ onClick(); close() }) - } - addView(tv) - tv - }.toMutableList() - - views.add(0, urlHolder) - - val ids = views.mapIndexed { index, textView -> - textView.apply { - id = 74329 + index //totally arbitrary - setTextColor(tc) - setBackgroundColor(bg) - } - KL.d("ID ${textView.text}") - textView.id - } - - //clone to set only after ids are set - val set = ConstraintSet() - set.clone(this) - - ids.forEach { - set.connect(it, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, 16) - set.connect(it, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END, 16) - } - - - set.createVerticalChain(ConstraintSet.PARENT_ID, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, - ids.toIntArray(), null, ConstraintSet.CHAIN_PACKED) - - set.applyTo(this) - setOnClickListener { - close() - } - } - - fun close() { - transitionAuto() - gone() - } - - fun show(url: String) { - this.url = url - urlHolder.text = this.url - transitionAuto() - visible() - } - -}
\ No newline at end of file |