Skip to content

Commit

Permalink
Update layout
Browse files Browse the repository at this point in the history
  • Loading branch information
0xf4b1 committed Dec 10, 2023
1 parent 69e4cca commit 8dd46f5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 29 deletions.
29 changes: 25 additions & 4 deletions app/src/main/java/com/tiefensuche/motionmate/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.ItemTouchHelper
import android.view.View
import android.view.ViewGroup
import android.widget.CalendarView
import android.widget.TextView
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.preference.PreferenceManager
import com.google.android.material.color.DynamicColors
import com.tiefensuche.motionmate.R
import com.tiefensuche.motionmate.service.MotionService
import com.tiefensuche.motionmate.ui.cards.MotionActivityTextItem
Expand All @@ -48,6 +55,10 @@ internal class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Util.applyTheme(PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "system")!!)
DynamicColors.applyToActivitiesIfAvailable(application)

WindowCompat.setDecorFitsSystemWindows(window, false)
setContentView(R.layout.activity_main)

mTextViewSteps = findViewById(R.id.textViewSteps)
Expand Down Expand Up @@ -101,10 +112,20 @@ internal class MainActivity : AppCompatActivity() {
}).attachToRecyclerView(mRecyclerView)

// Floating action button to start new activity
findViewById<View>(R.id.fab).setOnClickListener {
val i = Intent(this@MainActivity, MotionService::class.java)
i.action = MotionService.ACTION_START_ACTIVITY
startService(i)
findViewById<View>(R.id.fab).let {
it.setOnClickListener {
val i = Intent(this@MainActivity, MotionService::class.java)
i.action = MotionService.ACTION_START_ACTIVITY
startService(i)
}

ViewCompat.setOnApplyWindowInsetsListener(it) { view, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = insets.bottom + 50
}
WindowInsetsCompat.CONSUMED
}
}

// initial update of the diagram
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/res/layout/cardview_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
~ SPDX-License-Identifier: GPL-3.0-only
-->

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:contentPadding="10dp"
android:layout_marginBottom="4dp">
android:layout_margin="2dp">

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -46,4 +45,4 @@

</LinearLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
30 changes: 12 additions & 18 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
android:fitsSystemWindows="true">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:contentPadding="10dp"
android:layout_marginBottom="4dp">
android:layout_margin="2dp">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -45,19 +43,17 @@

</LinearLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="360dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
android:layout_height="wrap_content"
app:contentPadding="10dp"
android:layout_marginBottom="4dp">
android:layout_margin="2dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
Expand All @@ -78,15 +74,13 @@

</LinearLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="300dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:contentPadding="10dp"
android:layout_marginBottom="4dp">
android:layout_margin="2dp">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -106,7 +100,7 @@

</LinearLayout>

</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>


<androidx.recyclerview.widget.RecyclerView
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<item name="colorAccent">@color/colorAccent</item>
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
</style>

</resources>

0 comments on commit 8dd46f5

Please sign in to comment.