Skip to content

Commit

Permalink
Improve design of about section
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Sep 24, 2022
1 parent 07b7f07 commit db9b3fa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AboutFragment : Fragment() {
val instagramIcon = mehdi.sakout.aboutpage.R.drawable.about_icon_instagram
val instagramColor = mehdi.sakout.aboutpage.R.color.about_instagram_color

return AboutPage(context)
return AboutPage(context, R.style.Theme_AboutPage)
.setImage(R.mipmap.ic_launcher_foreground)
.setDescription(getString(R.string.about_description))
.addItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import com.cyb3rko.logviewerforopenhab.R
import com.cyb3rko.logviewerforopenhab.openUrl
import com.google.android.material.card.MaterialCardView

class AnimationCreditsFragment : Fragment() {

Expand All @@ -22,6 +23,7 @@ class AnimationCreditsFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val myContext = requireContext()
val information = listOf(
Triple("error lottie", "koh", "https://lottiefiles.com/17373-error-lottie"),
Triple("Face scanning", "Aneesh Ravi", "https://lottiefiles.com/4432-face-scanning"),
Expand All @@ -31,26 +33,45 @@ class AnimationCreditsFragment : Fragment() {
Triple("Secure lock", "LottieFiles", "https://lottiefiles.com/11476-secure-lock"),
Triple("Timer Progress Animation", "Vishalpari Goswami", "https://lottiefiles.com/35812-timer-progress-animation")
)
val view = ScrollView(requireContext())
val linearLayout = LinearLayout(requireContext())
val view = ScrollView(myContext)
val linearLayout = LinearLayout(myContext)
linearLayout.orientation = LinearLayout.VERTICAL
linearLayout.setPaddingRelative(50, 50, 50, 0)
information.forEach {
val textView = TextView(requireContext())
val textView = TextView(myContext)
textView.textSize = 18f
textView.setPaddingRelative(40, 50, 40, 0)
textView.setPaddingRelative(50, 50, 50, 50)
val text = getString(R.string.about_animations, it.first, it.second)
val spannableString = SpannableString(text)
val clickableSpan = object: ClickableSpan() {
override fun onClick(widget: View) {
openUrl(it.third)
}
}
spannableString.setSpan(clickableSpan, 1, 1 + it.first.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
spannableString.setSpan(
clickableSpan,
1,
it.first.length + 1,
Spanned.SPAN_INCLUSIVE_INCLUSIVE
)
textView.text = spannableString
textView.movementMethod = LinkMovementMethod.getInstance()
linearLayout.addView(textView)
val card = MaterialCardView(myContext)
card.setMargins(0, 0, 0, 20)
card.addView(textView)
linearLayout.addView(card)
}
view.addView(linearLayout)
return view
}

private fun View.setMargins(start: Int, top: Int, end: Int, bottom: Int) {
val layoutParams = ViewGroup.MarginLayoutParams(
ViewGroup.MarginLayoutParams.MATCH_PARENT,
ViewGroup.MarginLayoutParams.WRAP_CONTENT
)
layoutParams.setMargins(start, top, end, bottom)
this.layoutParams = layoutParams
this.requestLayout()
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<color name="toolBarTextColor">@color/colorOnPrimary</color>
<color name="textColor">#aeaeae</color>
<color name="cardColor">@color/colorSurface</color>
<color name="aboutPageColor">#1c1b1f</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
<color name="textColor">@color/colorSecondary</color>
<color name="cardColor">@color/colorSurface</color>
<color name="introElementColor">#934933</color>
<color name="aboutPageColor">#ffffff</color>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@
<item name="buttonTint">@color/introElementColor</item>
</style>

<style name="Theme.AboutPage" parent="about_About">
<item name="aboutBackground">@color/aboutPageColor</item>
</style>

</resources>

0 comments on commit db9b3fa

Please sign in to comment.