From f2e4a5250a10fbcd235dbdb521b95cb73d78599b Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Tue, 14 Nov 2023 13:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8F=AF=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/compiler.xml | 6 ++ .idea/gradle.xml | 20 ++++ .idea/kotlinc.xml | 6 ++ .idea/misc.xml | 7 ++ app/build.gradle.kts | 2 + .../coldmint/scalableLayout/FirstFragment.kt | 44 --------- .../coldmint/scalableLayout/MainActivity.kt | 30 ------ .../coldmint/scalableLayout/SecondFragment.kt | 44 --------- app/src/main/res/layout/activity_main.xml | 51 ++++++++-- app/src/main/res/layout/content_main.xml | 19 ---- app/src/main/res/layout/fragment_first.xml | 35 ------- app/src/main/res/layout/fragment_second.xml | 35 ------- app/src/main/res/menu/menu_main.xml | 10 -- app/src/main/res/navigation/nav_graph.xml | 28 ------ build.gradle.kts | 1 + scalableLayout/.gitignore | 1 + scalableLayout/build.gradle.kts | 43 +++++++++ scalableLayout/consumer-rules.pro | 0 scalableLayout/proguard-rules.pro | 21 +++++ .../scalablelayout/ExampleInstrumentedTest.kt | 24 +++++ scalableLayout/src/main/AndroidManifest.xml | 4 + .../scalablelayout/OnWidthChangeListener.kt | 12 +++ .../coldmint/scalablelayout/ScalableLayout.kt | 92 +++++++++++++++++++ scalableLayout/src/main/res/values/attrs.xml | 8 ++ .../scalablelayout/ExampleUnitTest.kt | 17 ++++ settings.gradle.kts | 2 +- 26 files changed, 307 insertions(+), 255 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/misc.xml delete mode 100644 app/src/main/java/com/coldmint/scalableLayout/FirstFragment.kt delete mode 100644 app/src/main/java/com/coldmint/scalableLayout/SecondFragment.kt delete mode 100644 app/src/main/res/layout/content_main.xml delete mode 100644 app/src/main/res/layout/fragment_first.xml delete mode 100644 app/src/main/res/layout/fragment_second.xml delete mode 100644 app/src/main/res/menu/menu_main.xml delete mode 100644 app/src/main/res/navigation/nav_graph.xml create mode 100644 scalableLayout/.gitignore create mode 100644 scalableLayout/build.gradle.kts create mode 100644 scalableLayout/consumer-rules.pro create mode 100644 scalableLayout/proguard-rules.pro create mode 100644 scalableLayout/src/androidTest/java/com/coldmint/scalablelayout/ExampleInstrumentedTest.kt create mode 100644 scalableLayout/src/main/AndroidManifest.xml create mode 100644 scalableLayout/src/main/java/com/coldmint/scalablelayout/OnWidthChangeListener.kt create mode 100644 scalableLayout/src/main/java/com/coldmint/scalablelayout/ScalableLayout.kt create mode 100644 scalableLayout/src/main/res/values/attrs.xml create mode 100644 scalableLayout/src/test/java/com/coldmint/scalablelayout/ExampleUnitTest.kt diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..0039db1 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..fdf8d99 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e837843 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1f939cc..358d444 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,12 +40,14 @@ android { dependencies { + implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.8.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") implementation("androidx.navigation:navigation-ui-ktx:2.5.3") + implementation(project(mapOf("path" to ":scalableLayout"))) testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/app/src/main/java/com/coldmint/scalableLayout/FirstFragment.kt b/app/src/main/java/com/coldmint/scalableLayout/FirstFragment.kt deleted file mode 100644 index 476e4d4..0000000 --- a/app/src/main/java/com/coldmint/scalableLayout/FirstFragment.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.coldmint.scalableLayout - -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.navigation.fragment.findNavController -import com.coldmint.scalableLayout.databinding.FragmentFirstBinding - -/** - * A simple [Fragment] subclass as the default destination in the navigation. - */ -class FirstFragment : Fragment() { - - private var _binding: FragmentFirstBinding? = null - - // This property is only valid between onCreateView and - // onDestroyView. - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - - _binding = FragmentFirstBinding.inflate(inflater, container, false) - return binding.root - - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - binding.buttonFirst.setOnClickListener { - findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment) - } - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/scalableLayout/MainActivity.kt b/app/src/main/java/com/coldmint/scalableLayout/MainActivity.kt index 538e6a7..c078894 100644 --- a/app/src/main/java/com/coldmint/scalableLayout/MainActivity.kt +++ b/app/src/main/java/com/coldmint/scalableLayout/MainActivity.kt @@ -13,7 +13,6 @@ import com.coldmint.scalableLayout.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { - private lateinit var appBarConfiguration: AppBarConfiguration private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { @@ -24,35 +23,6 @@ class MainActivity : AppCompatActivity() { setSupportActionBar(binding.toolbar) - val navController = findNavController(R.id.nav_host_fragment_content_main) - appBarConfiguration = AppBarConfiguration(navController.graph) - setupActionBarWithNavController(navController, appBarConfiguration) - - binding.fab.setOnClickListener { view -> - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - } } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.menu_main, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - return when (item.itemId) { - R.id.action_settings -> true - else -> super.onOptionsItemSelected(item) - } - } - - override fun onSupportNavigateUp(): Boolean { - val navController = findNavController(R.id.nav_host_fragment_content_main) - return navController.navigateUp(appBarConfiguration) - || super.onSupportNavigateUp() - } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/scalableLayout/SecondFragment.kt b/app/src/main/java/com/coldmint/scalableLayout/SecondFragment.kt deleted file mode 100644 index f99dc95..0000000 --- a/app/src/main/java/com/coldmint/scalableLayout/SecondFragment.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.coldmint.scalableLayout - -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.navigation.fragment.findNavController -import com.coldmint.scalableLayout.databinding.FragmentSecondBinding - -/** - * A simple [Fragment] subclass as the second destination in the navigation. - */ -class SecondFragment : Fragment() { - - private var _binding: FragmentSecondBinding? = null - - // This property is only valid between onCreateView and - // onDestroyView. - private val binding get() = _binding!! - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - - _binding = FragmentSecondBinding.inflate(inflater, container, false) - return binding.root - - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - binding.buttonSecond.setOnClickListener { - findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment) - } - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 16313e0..1aaa61c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -19,15 +19,48 @@ - + - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml deleted file mode 100644 index e416e1c..0000000 --- a/app/src/main/res/layout/content_main.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_first.xml b/app/src/main/res/layout/fragment_first.xml deleted file mode 100644 index 44baecd..0000000 --- a/app/src/main/res/layout/fragment_first.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - -