-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4 WindowInset Keyboard Sample Screen
- Loading branch information
1 parent
c494948
commit 75453c9
Showing
14 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id("playground.android.library") | ||
id("playground.android.hilt") | ||
} | ||
|
||
android { | ||
namespace = "com.sample.feature.window" | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.compose.activity) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.material) | ||
} |
24 changes: 24 additions & 0 deletions
24
...nset-animation/src/androidTest/java/com/sample/inset_animation/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sample.inset_animation | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.sample.inset_animation.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
26 changes: 26 additions & 0 deletions
26
...nimation/src/main/java/com/sample/feature/inset_animation/InsetAnimationSampleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.sample.feature.inset_animation | ||
|
||
import android.os.Bundle | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.sample.feature.window.databinding.ActivityInsetAnimationSampleBinding | ||
|
||
|
||
class InsetAnimationSampleActivity : AppCompatActivity() { | ||
|
||
private val binding by lazy { ActivityInsetAnimationSampleBinding.inflate(layoutInflater) } | ||
|
||
private val adapter = ItemAdapter() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(binding.root) | ||
enableEdgeToEdge() | ||
|
||
binding.recyclerView.adapter = adapter | ||
val items = List(1000) { index -> | ||
Item(index, "Item $index") | ||
} | ||
adapter.submitList(items) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
feature/inset-animation/src/main/java/com/sample/feature/inset_animation/ItemAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.sample.feature.inset_animation | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sample.feature.window.R | ||
|
||
data class Item(val id: Int, val text: String) | ||
|
||
class ItemAdapter : ListAdapter<Item, ItemAdapter.ItemViewHolder>(ItemDiffCallback()) { | ||
|
||
class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
private val textView: TextView = itemView.findViewById(R.id.text_view) | ||
|
||
fun bind(item: Item) { | ||
textView.text = item.text | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_view, parent, false) | ||
return ItemViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
|
||
companion object { | ||
class ItemDiffCallback : DiffUtil.ItemCallback<Item>() { | ||
override fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean { | ||
return oldItem.id == newItem.id | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean { | ||
return oldItem == newItem | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
feature/inset-animation/src/main/res/layout/activity_inset_animation_sample.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/recycler_view" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toTopOf="@+id/edit_text" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layoutManager="LinearLayoutManager" /> | ||
|
||
<EditText | ||
android:id="@+id/edit_text" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:hint="Type here" | ||
android:background="@android:color/white" | ||
android:padding="16dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout 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" | ||
android:padding="16dp"> | ||
|
||
<TextView | ||
android:id="@+id/text_view" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:textSize="16sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
17 changes: 17 additions & 0 deletions
17
feature/inset-animation/src/test/java/com/sample/inset_animation/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.sample.inset_animation | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters