From ac15bdbe9d603b6a32dfa7063ebb269a3fa8786d Mon Sep 17 00:00:00 2001 From: "Hanjoong.Cho" Date: Tue, 18 Jun 2024 23:21:55 +0900 Subject: [PATCH] refactor: Compose card settings --- .../easydiary/activities/BaseDevActivity.kt | 9 ++--- .../easydiary/activities/EasyDiaryActivity.kt | 8 ++--- app/src/main/res/layout/activity_base_dev.xml | 36 +++++-------------- .../main/res/layout/partial_appbar_layout.xml | 19 ++++++++++ 4 files changed, 34 insertions(+), 38 deletions(-) create mode 100644 app/src/main/res/layout/partial_appbar_layout.xml diff --git a/app/src/main/java/me/blog/korn123/easydiary/activities/BaseDevActivity.kt b/app/src/main/java/me/blog/korn123/easydiary/activities/BaseDevActivity.kt index faf2c2391..c9f88fa21 100644 --- a/app/src/main/java/me/blog/korn123/easydiary/activities/BaseDevActivity.kt +++ b/app/src/main/java/me/blog/korn123/easydiary/activities/BaseDevActivity.kt @@ -34,7 +34,6 @@ import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -50,7 +49,6 @@ import androidx.compose.ui.unit.dp import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat -import androidx.databinding.DataBindingUtil import androidx.lifecycle.viewmodel.compose.viewModel import com.bumptech.glide.Glide import com.bumptech.glide.load.resource.bitmap.CenterCrop @@ -110,7 +108,6 @@ import me.blog.korn123.easydiary.models.ActionLog import me.blog.korn123.easydiary.models.Diary import me.blog.korn123.easydiary.services.BaseNotificationService import me.blog.korn123.easydiary.services.NotificationService -import me.blog.korn123.easydiary.ui.components.CardContainer import me.blog.korn123.easydiary.ui.components.CategoryTitleCard import me.blog.korn123.easydiary.ui.components.ScrollableCard import me.blog.korn123.easydiary.ui.components.SimpleCard @@ -181,7 +178,7 @@ open class BaseDevActivity : EasyDiaryActivity() { super.onCreate(savedInstanceState) mBinding = ActivityBaseDevBinding.inflate(layoutInflater) setContentView(mBinding.root) - setSupportActionBar(mBinding.toolbar) + setSupportActionBar(mBinding.partialAppbarLayout.toolbar) supportActionBar?.run { title = "Easy-Diary Dev Mode" setDisplayHomeAsUpEnabled(true) @@ -609,7 +606,7 @@ open class BaseDevActivity : EasyDiaryActivity() { CategoryTitleCard(title = "Custom Launcher") FlowRow( maxItemsInEachRow = maxItemsInEachRow, - modifier = Modifier.padding(6.dp, 3.dp) + modifier = Modifier ) { SimpleCard( "EasyDiary Launcher", @@ -790,7 +787,7 @@ open class BaseDevActivity : EasyDiaryActivity() { AppTheme { val configuration = LocalConfiguration.current val maxItemsInEachRow = if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) 2 else 3 - CardContainer { + Column { val settingCardModifier = Modifier .fillMaxWidth() .weight(1f) diff --git a/app/src/main/java/me/blog/korn123/easydiary/activities/EasyDiaryActivity.kt b/app/src/main/java/me/blog/korn123/easydiary/activities/EasyDiaryActivity.kt index a9c6abea4..0bccc04d7 100644 --- a/app/src/main/java/me/blog/korn123/easydiary/activities/EasyDiaryActivity.kt +++ b/app/src/main/java/me/blog/korn123/easydiary/activities/EasyDiaryActivity.kt @@ -3,6 +3,7 @@ package me.blog.korn123.easydiary.activities import android.content.Intent import android.hardware.SensorManager import android.os.Bundle +import android.view.View import android.view.ViewGroup import com.simplemobiletools.commons.models.Release import com.squareup.seismic.ShakeDetector @@ -21,9 +22,6 @@ import java.util.Calendar open class EasyDiaryActivity : BaseSimpleActivity(), ShakeDetector.Listener { var mCustomLineSpacing = true - private val mRootView: ViewGroup? by lazy { - findViewById(R.id.main_holder) - } /*************************************************************************************************** @@ -48,7 +46,7 @@ open class EasyDiaryActivity : BaseSimpleActivity(), ShakeDetector.Listener { startMainActivityWithClearTask() } else { resumeLock() - mRootView?.let { + getMainViewGroup()?.let { initTextSize(it) updateTextColors(it) updateAppViews(it) @@ -78,7 +76,7 @@ open class EasyDiaryActivity : BaseSimpleActivity(), ShakeDetector.Listener { overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) } - override fun getMainViewGroup(): ViewGroup? = mRootView + override fun getMainViewGroup(): ViewGroup? = if (findViewById(R.id.main_holder) != null) findViewById(R.id.main_holder) else findViewById(R.id.compose_view) override fun hearShake() { TransitionHelper.startActivityWithTransition( diff --git a/app/src/main/res/layout/activity_base_dev.xml b/app/src/main/res/layout/activity_base_dev.xml index 9524822ed..5a782c185 100644 --- a/app/src/main/res/layout/activity_base_dev.xml +++ b/app/src/main/res/layout/activity_base_dev.xml @@ -5,35 +5,17 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - - + - - - - + android:layout_weight="1" /> + app:layout_constraintTop_toBottomOf="@+id/partial_appbar_layout" /> diff --git a/app/src/main/res/layout/partial_appbar_layout.xml b/app/src/main/res/layout/partial_appbar_layout.xml new file mode 100644 index 000000000..18d9b4a5a --- /dev/null +++ b/app/src/main/res/layout/partial_appbar_layout.xml @@ -0,0 +1,19 @@ + + + + + + +