Skip to content

Commit

Permalink
Refactor styles
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Jan 23, 2025
1 parent ef103c9 commit 3f9c9c0
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 60 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ android {
implementation(libs.okhttp.brotli)
implementation(libs.okhttp.mockwebserver)
implementation(libs.koin)
//implementation(libs.jts)
implementation(libs.mpandroidchart)
implementation(libs.coil.core)
implementation(libs.coil.svg)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:icon="${appIcon}"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.BtcMap">
android:theme="@style/Theme.Material3.DayNight.NoActionBar">

<activity
android:name="activity.Activity"
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/kotlin/activity/Activity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package activity

import android.os.Build
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import org.btcmap.databinding.ActivityBinding
import org.maplibre.android.MapLibre

Expand All @@ -15,11 +14,8 @@ class Activity : AppCompatActivity() {
super.onCreate(savedInstanceState)
MapLibre.getInstance(this)
binding = ActivityBinding.inflate(layoutInflater)
enableEdgeToEdge()
setContentView(binding.root)

// TODO remove once we switch to 35+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
WindowCompat.setDecorFitsSystemWindows(window, false)
}
window.isNavigationBarContrastEnforced = false
}
}
4 changes: 4 additions & 0 deletions app/src/main/kotlin/app/ContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import android.content.pm.ApplicationInfo

fun Context.isDebuggable(): Boolean {
return applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
}

fun Context.dpToPx(dp: Int): Int {
return (dp * resources.displayMetrics.density).toInt()
}
10 changes: 8 additions & 2 deletions app/src/main/kotlin/donation/DonationFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import org.btcmap.databinding.FragmentDonationBinding

class DonationFragment : Fragment() {

companion object {
const val ONCHAIN = "bc1qy3c4tq8tdv2rj0g74r84sjjg2rqdeljn3u498e"
const val LIGHTNING =
"LNURL1DP68GURN8GHJ7CM0WFJJUCN5VDKKZUPWDAEXWTMVDE6HYMRS9AR4V3J3F4ZS4MX2FN"
}

private var _binding: FragmentDonationBinding? = null
private val binding get() = _binding!!

Expand Down Expand Up @@ -54,7 +60,7 @@ class DonationFragment : Fragment() {
}

private fun initOnchain() {
val paymentAddress = getString(R.string.donation_address_onchain)
val paymentAddress = ONCHAIN
val paymentUrl = "bitcoin:$paymentAddress"

val qrEncoder = QRGEncoder(paymentUrl, null, QRGContents.Type.TEXT, 1000)
Expand All @@ -76,7 +82,7 @@ class DonationFragment : Fragment() {
}

private fun initLightning() {
val paymentAddress = getString(R.string.donation_address_lightning)
val paymentAddress = LIGHTNING
val paymentUrl = "lightning:$paymentAddress"

val qrEncoder = QRGEncoder(paymentUrl, null, QRGContents.Type.TEXT, 1000)
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/kotlin/element/ElementFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,16 @@ class ElementFragment : Fragment() {

if (imageUrl != null) {
binding.image.isVisible = true
binding.image.load(imageUrl) {
this.fallback(R.drawable.merchant)
this.error(R.drawable.merchant)
}
binding.image.load(imageUrl)
} else {
binding.image.isVisible = false
}

val comments = runBlocking { elementCommentRepo.selectByElementId(element.id) }
binding.commentsTitle.text = getString(R.string.comments_d, comments.size)
binding.commentsTitle.isVisible = comments.isNotEmpty()
binding.comments.text = resources.getQuantityString(R.plurals.d_comments, comments.size, comments.size)
binding.comments.text =
resources.getQuantityString(R.plurals.d_comments, comments.size, comments.size)
commentsAdapter.submitList(comments)
}

Expand Down
16 changes: 16 additions & 0 deletions app/src/main/kotlin/element_comment/ElementCommentsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import androidx.fragment.app.replace
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager
import app.dpToPx
import element.CommentsAdapter
import kotlinx.coroutines.launch
import org.btcmap.R
Expand Down Expand Up @@ -49,6 +53,18 @@ class ElementCommentsFragment : Fragment() {

viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
ViewCompat.setOnApplyWindowInsetsListener(binding.fab) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())

v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = insets.top
rightMargin = insets.right + v.context.dpToPx(24)
bottomMargin = insets.bottom + v.context.dpToPx(24)
leftMargin = insets.left
}

WindowInsetsCompat.CONSUMED
}
binding.topAppBar.setNavigationOnClickListener { parentFragmentManager.popBackStack() }
binding.topAppBar.setOnMenuItemClickListener {
when (it.itemId) {
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/kotlin/map/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.core.os.bundleOf
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
Expand All @@ -37,6 +38,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager
import app.dpToPx
import area.AreaResultModel
import area.AreasFragment
import area.bounds
Expand Down Expand Up @@ -152,9 +154,16 @@ class MapFragment : Fragment() {
): View {
_binding = FragmentMapBinding.inflate(inflater, container, false)

ViewCompat.setOnApplyWindowInsetsListener(binding.searchBar) { view, windowInsets ->
val navBarsInsets = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars())
binding.fab.translationY = -navBarsInsets.bottom.toFloat()
ViewCompat.setOnApplyWindowInsetsListener(binding.fab) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())

v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = insets.top
rightMargin = insets.right + v.context.dpToPx(24)
bottomMargin = insets.bottom + v.context.dpToPx(24)
leftMargin = insets.left
}

WindowInsetsCompat.CONSUMED
}

Expand Down
Binary file removed app/src/main/res/drawable-nodpi/merchant.png
Binary file not shown.
7 changes: 2 additions & 5 deletions app/src/main/res/layout/fragment_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<com.google.android.material.search.SearchBar
android:id="@+id/search_bar"
android:layout_width="match_parent"
app:menu="@menu/map"
android:layout_height="wrap_content"
android:hint="@string/search_here" />
android:hint="@string/search_here"
app:menu="@menu/map" />

</com.google.android.material.appbar.AppBarLayout>

Expand Down Expand Up @@ -68,9 +68,6 @@
android:layout_margin="24dp"
android:contentDescription="@string/show_my_location"
app:elevation="0dp"
app:layout_anchor="@id/elementDetails"
app:layout_anchorGravity="end"
app:layout_dodgeInsetEdges="bottom"
app:srcCompat="@drawable/my_location" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
7 changes: 0 additions & 7 deletions app/src/main/res/values-night/styles.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/values-v35/styles.xml

This file was deleted.

14 changes: 0 additions & 14 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@

<resources>

<style name="Theme.BtcMap" parent="Theme.Material3.DynamicColors.DayNight">
<item name="android:windowLightStatusBar">@bool/window_light_status_bar</item>
<!-- TODO remove once we switch to 35+ -->
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- TODO remove once we switch to 35+ -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<!-- TODO remove once we switch to 35+ -->
<item name="windowActionBar">false</item>
<!-- TODO remove once we switch to 35+ -->
<item name="windowNoTitle">true</item>
</style>

<bool name="window_light_status_bar">true</bool>

<style name="RoundedImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">20dp</item>
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/values/untranslatable-strings.xml

This file was deleted.

0 comments on commit 3f9c9c0

Please sign in to comment.