From aa9986fc0bf1af983fd488ada17f146e07c784a4 Mon Sep 17 00:00:00 2001 From: sds100 Date: Mon, 12 Aug 2024 20:41:11 -0600 Subject: [PATCH] #1274 use build flavor source directory rather than gradle module --- .gitmodules | 4 +- app/build.gradle | 10 ++++- .../assistant/AssistantTriggerFragment.kt | 41 +++++++++++++++++++ .../sds100/keymapper/home/HomePagerAdapter.kt | 6 +-- .../main/res/layout/fragment_compose_view.xml | 16 ++++++++ settings.gradle | 1 - 6 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 app/src/free/java/io/github/sds100/keymapper/mappings/assistant/AssistantTriggerFragment.kt create mode 100644 app/src/main/res/layout/fragment_compose_view.xml diff --git a/.gitmodules b/.gitmodules index 29a9742694..69e73f5a6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "pro"] - path = pro +[submodule "app/src/pro"] + path = app/src/pro url = https://github.com/keymapperorg/KeyMapperPro diff --git a/app/build.gradle b/app/build.gradle index 57cb78ae1b..a0039312b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,6 +90,7 @@ android { viewBinding true aidl true buildConfig true + compose true } compileOptions { @@ -105,6 +106,10 @@ android { kapt { correctErrorTypes = true } + + composeOptions { + kotlinCompilerExtensionVersion "1.5.10" + } } android.sourceSets { @@ -129,7 +134,6 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') compileOnly project(':systemstubs') - proImplementation project(":pro") def room_version = "2.6.1" def coroutinesVersion = "1.5.0" @@ -195,6 +199,10 @@ dependencies { implementation "androidx.core:core-splashscreen:1.0.1" kapt "androidx.room:room-compiler:$room_version" + // Compose + implementation 'androidx.compose.ui:ui-android:1.6.8' + implementation 'androidx.compose.material3:material3-android:1.2.1' + // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6' def junitVersion = "4.13.2" diff --git a/app/src/free/java/io/github/sds100/keymapper/mappings/assistant/AssistantTriggerFragment.kt b/app/src/free/java/io/github/sds100/keymapper/mappings/assistant/AssistantTriggerFragment.kt new file mode 100644 index 0000000000..2cb72e8554 --- /dev/null +++ b/app/src/free/java/io/github/sds100/keymapper/mappings/assistant/AssistantTriggerFragment.kt @@ -0,0 +1,41 @@ +package io.github.sds100.keymapper.mappings.assistant + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.fragment.app.Fragment +import io.github.sds100.keymapper.databinding.FragmentComposeViewBinding + +class AssistantTriggerFragment : Fragment() { + private var _binding: FragmentComposeViewBinding? = null + + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentComposeViewBinding.inflate(inflater, container, false) + val view = binding.root + binding.composeView.apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme { + Text("I am free build variant.") + } + } + } + + return view + } + + override fun onDestroyView() { + _binding = null + super.onDestroyView() + } +} \ No newline at end of file diff --git a/app/src/main/java/io/github/sds100/keymapper/home/HomePagerAdapter.kt b/app/src/main/java/io/github/sds100/keymapper/home/HomePagerAdapter.kt index 81344e94be..ae1e948393 100644 --- a/app/src/main/java/io/github/sds100/keymapper/home/HomePagerAdapter.kt +++ b/app/src/main/java/io/github/sds100/keymapper/home/HomePagerAdapter.kt @@ -3,9 +3,9 @@ package io.github.sds100.keymapper.home import androidx.fragment.app.Fragment import androidx.viewpager2.adapter.FragmentStateAdapter import io.github.sds100.keymapper.R +import io.github.sds100.keymapper.mappings.assistant.AssistantTriggerFragment import io.github.sds100.keymapper.mappings.fingerprintmaps.FingerprintMapListFragment import io.github.sds100.keymapper.mappings.keymaps.KeyMapListFragment -import io.github.sds100.keymapperpro.AssistantTriggerFragment /** * Created by sds100 on 26/01/2020. @@ -45,9 +45,7 @@ class HomePagerAdapter( HomeTab.ASSISTANT_TRIGGER -> { { - AssistantTriggerFragment().apply { - isAppBarVisible = false - } + AssistantTriggerFragment() } } } diff --git a/app/src/main/res/layout/fragment_compose_view.xml b/app/src/main/res/layout/fragment_compose_view.xml new file mode 100644 index 0000000000..cf6151272e --- /dev/null +++ b/app/src/main/res/layout/fragment_compose_view.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 41ccca99a4..a2a582b50a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,2 @@ include ':app' include ':systemstubs' -include ':pro'