Archived
Implemented navigation component; deleting an entry now shows a snack bar that allows for undo; edited several layouts
This commit is contained in:
+3
-1
@@ -42,11 +42,13 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.10.0'
|
||||
implementation 'androidx.core:core-ktx:1.10.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.9.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.denizd.textbasic.activity
|
||||
|
||||
import android.app.backup.BackupManager
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.denizd.textbasic.R
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.denizd.textbasic.databinding.ActivityMainBinding
|
||||
import com.denizd.textbasic.fragment.GuideFragment
|
||||
import com.denizd.textbasic.fragment.QuoteFragment
|
||||
import com.denizd.textbasic.fragment.SettingsFragment
|
||||
import com.denizd.textbasic.widget.TextCanvasWidget
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
@@ -24,57 +20,9 @@ class MainActivity : AppCompatActivity() {
|
||||
binding = ActivityMainBinding.inflate(this.layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.buttonBackupUpload.setOnClickListener {
|
||||
BackupManager(this).dataChanged()
|
||||
Snackbar.make(binding.rootLayout, R.string.snack_backup_upload, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
binding.bottomNav.setOnItemSelectedListener { item ->
|
||||
loadFragment(item.itemId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
if (supportFragmentManager.fragments.size == 0) {
|
||||
binding.bottomNav.selectedItemId = R.id.quotes
|
||||
loadFragment(R.id.quotes)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadFragment(type: Int): Boolean {
|
||||
val fragment = when (type) {
|
||||
R.id.quotes -> QuoteFragment()
|
||||
R.id.guide -> GuideFragment()
|
||||
R.id.settings -> SettingsFragment()
|
||||
else -> QuoteFragment()
|
||||
}//supportFragmentManager.findFragmentByTag(type) ?: viewModel.getFragment(type)
|
||||
|
||||
if (supportFragmentManager.fragments.isNotEmpty() &&
|
||||
supportFragmentManager.fragments[supportFragmentManager.fragments.size-1]
|
||||
.tag?.equals(type.toString()) == true
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (fragment.lifecycle.currentState != Lifecycle.State.INITIALIZED) {
|
||||
return false
|
||||
}
|
||||
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment, type.toString())
|
||||
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||
.commit()
|
||||
|
||||
// with (supportFragmentManager) {
|
||||
// beginTransaction()
|
||||
// .hide(fragments[fragments.size - 1]) // should this be 0?
|
||||
// .show(findFragmentByTag(type) ?: TODO())
|
||||
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
// .commit()
|
||||
// }
|
||||
return true
|
||||
binding.navView.setupWithNavController(
|
||||
binding.navHostFragmentContentMain.getFragment<NavHostFragment>().findNavController()
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -5,14 +5,15 @@ import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.denizd.textbasic.R
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import java.util.Collections
|
||||
|
||||
class QuoteAdapter(
|
||||
quotes: List<String>,
|
||||
private val onDeleteListener: OnDeleteListener,
|
||||
) : RecyclerView.Adapter<QuoteAdapter.QuoteViewHolder>(),
|
||||
RecyclerRowMoveCallback.RecyclerViewTouchHelperContract {
|
||||
|
||||
@@ -20,8 +21,8 @@ class QuoteAdapter(
|
||||
|
||||
class QuoteViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
val quote: TextView = view.findViewById(R.id.quote)
|
||||
val delete: ImageButton = view.findViewById(R.id.delete_button)
|
||||
val quote: TextView = view.findViewById(R.id.edit_text_quote)
|
||||
val delete: MaterialButton = view.findViewById(R.id.delete_button)
|
||||
}
|
||||
|
||||
// override fun getItemViewType(position: Int): Int {
|
||||
@@ -47,6 +48,7 @@ class QuoteAdapter(
|
||||
})
|
||||
|
||||
holder.delete.setOnClickListener {
|
||||
onDeleteListener.onDelete(mutableQuotes[holder.layoutPosition], holder.layoutPosition)
|
||||
mutableQuotes.removeAt(holder.layoutPosition)
|
||||
notifyItemRemoved(holder.layoutPosition)
|
||||
}
|
||||
@@ -59,6 +61,11 @@ class QuoteAdapter(
|
||||
notifyItemInserted(mutableQuotes.size + 1)
|
||||
}
|
||||
|
||||
fun addEntryAt(index: Int, entry: String) {
|
||||
mutableQuotes.add(index, entry)
|
||||
notifyItemInserted(index)
|
||||
}
|
||||
|
||||
fun getAllQuotes(): Array<String> {
|
||||
return mutableQuotes.filter { s -> s.isNotBlank() }.toTypedArray()
|
||||
}
|
||||
@@ -80,4 +87,8 @@ class QuoteAdapter(
|
||||
override fun onRowClear(viewHolder: QuoteViewHolder) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
interface OnDeleteListener {
|
||||
fun onDelete(entry: String, index: Int)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.denizd.textbasic.fragment
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
@@ -11,40 +10,40 @@ import com.denizd.textbasic.util.viewBinding
|
||||
import com.denizd.textbasic.R
|
||||
import com.denizd.textbasic.adapter.RecyclerRowMoveCallback
|
||||
import com.denizd.textbasic.databinding.FragmentQuoteBinding
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import com.denizd.textbasic.util.showSnackBar
|
||||
|
||||
class QuoteFragment : BaseFragment(R.layout.fragment_quote) {
|
||||
class QuoteFragment : BaseFragment(R.layout.fragment_quote), QuoteAdapter.OnDeleteListener {
|
||||
|
||||
private lateinit var storage: QuoteStorage
|
||||
private lateinit var quoteAdapter: QuoteAdapter
|
||||
|
||||
private val binding: FragmentQuoteBinding by viewBinding(FragmentQuoteBinding::bind)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.quoteConstraintLayout.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
|
||||
storage = QuoteStorage(context)
|
||||
quoteAdapter = QuoteAdapter(storage.getAllQuotes())
|
||||
quoteAdapter = QuoteAdapter(storage.getAllQuotes(), this)
|
||||
|
||||
binding.quoteScroller.let { s ->
|
||||
s.layoutManager = LinearLayoutManager(context)
|
||||
ItemTouchHelper(RecyclerRowMoveCallback(quoteAdapter)).attachToRecyclerView(s)
|
||||
s.adapter = quoteAdapter
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
ItemTouchHelper(RecyclerRowMoveCallback(quoteAdapter))
|
||||
.attachToRecyclerView(binding.recyclerView)
|
||||
binding.recyclerView.adapter = quoteAdapter
|
||||
|
||||
// Set up scroll change listener to shrink and extend FAB accordingly
|
||||
binding.recyclerView.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
|
||||
// Calculate the vertical scroll difference
|
||||
val dy = scrollY - oldScrollY
|
||||
if (dy > 0) {
|
||||
// If scrolling down, shrink the FAB
|
||||
binding.fabAddQuote.shrink()
|
||||
} else if (dy < 0) {
|
||||
// If scrolling up, extend the FAB
|
||||
binding.fabAddQuote.extend()
|
||||
}
|
||||
}
|
||||
|
||||
binding.addFab.setOnClickListener {
|
||||
binding.fabAddQuote.setOnClickListener {
|
||||
quoteAdapter.addNewQuote()
|
||||
}
|
||||
}
|
||||
@@ -57,4 +56,15 @@ class QuoteFragment : BaseFragment(R.layout.fragment_quote) {
|
||||
save()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onDelete(entry: String, index: Int) {
|
||||
context.theme.showSnackBar(
|
||||
binding.coordinatorLayout,
|
||||
getString(R.string.quote_fragment_snack_text),
|
||||
null,
|
||||
getString(R.string.quote_fragment_snack_undo),
|
||||
) {
|
||||
quoteAdapter.addEntryAt(index, entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.denizd.textbasic.util
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
/**
|
||||
* Retrieves a specified colour customised to the currently applied theme.
|
||||
*
|
||||
* @param id attribute ID of the colour reference
|
||||
* @return resolved colour
|
||||
*/
|
||||
fun Resources.Theme.getThemedColor(@AttrRes id: Int): Int = TypedValue().also { value ->
|
||||
resolveAttribute(id, value, true)
|
||||
}.data
|
||||
|
||||
/**
|
||||
* Show a snack bar. Colours will be applied according to the theme given.
|
||||
*
|
||||
* @receiver theme to apply colours of
|
||||
* @param view view where the snack bar will be shown in
|
||||
* @param text text to present in the snack bar
|
||||
* @param anchor view to anchor the snack bar to
|
||||
* @param actionText text to show on the action button; button will only be shown if a value is
|
||||
* passed here
|
||||
* @param action action to execute if the action button is pressed
|
||||
*/
|
||||
fun Resources.Theme.showSnackBar(
|
||||
view: CoordinatorLayout,
|
||||
text: String,
|
||||
anchor: View? = null,
|
||||
actionText: String = "",
|
||||
action: () -> Unit = {},
|
||||
) {
|
||||
val s = Snackbar.make(view, text, Snackbar.LENGTH_SHORT)
|
||||
// Set colours
|
||||
.setTextColor(getThemedColor(com.google.android.material.R.attr.colorOnSurfaceInverse))
|
||||
.setBackgroundTint(getThemedColor(com.google.android.material.R.attr.colorSurfaceInverse))
|
||||
|
||||
if (actionText.isNotBlank()) {
|
||||
// Set action, if a value for the text has been passed
|
||||
s.setAction(actionText) {
|
||||
action()
|
||||
}
|
||||
|
||||
// Show this snack bar for a longer time for the user to have a chance to react
|
||||
s.duration = Snackbar.LENGTH_LONG
|
||||
}
|
||||
|
||||
// Set anchor view, if one has been passed
|
||||
anchor?.let { a -> s.setAnchorView(a) }
|
||||
s.show()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime">
|
||||
|
||||
<translate
|
||||
android:fromYDelta="20%"
|
||||
android:toYDelta="0"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<alpha
|
||||
android:fromAlpha="0"
|
||||
android:toAlpha="1"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
<scale
|
||||
android:fromXScale="100%"
|
||||
android:fromYScale="100%"
|
||||
android:toXScale="100%"
|
||||
android:toYScale="100%"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
/>
|
||||
|
||||
</set>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layoutAnimation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:animation="@anim/item_animation_fall_down"
|
||||
android:delay="15%"
|
||||
android:animationOrder="normal"/>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M11,18c0,1.1 -0.9,2 -2,2s-2,-0.9 -2,-2 0.9,-2 2,-2 2,0.9 2,2zM9,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM9,4c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM15,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM15,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM15,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
||||
@@ -1,89 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
tools:context=".activity.MainActivity"
|
||||
android:orientation="vertical"
|
||||
android:backgroundTint="?attr/colorTintBackground">
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment_content_main"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/main_nav_graph"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nav_view"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="26sp"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:fontFamily="@font/mono_bold_italic"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:menu="@menu/nav_items"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:itemTextColor="?attr/colorOnSurfaceVariant"
|
||||
android:layout_gravity="bottom"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_backup_upload"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/cloud_upload"
|
||||
android:padding="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintTop_toTopOf="@id/app_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/app_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_backup_download"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/cloud_download"
|
||||
android:padding="4dp"
|
||||
android:layout_marginStart="16dp"
|
||||
app:layout_constraintTop_toTopOf="@id/app_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/app_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraint_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:menu="@menu/nav_items"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:labelVisibilityMode="selected"/>
|
||||
|
||||
<!-- android:background="?attr/colorPrimary"-->
|
||||
<!-- app:itemIconTint="@color/bottom_nav_color"-->
|
||||
<!-- app:itemTextColor="@color/bottom_nav_color"-->
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,34 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/quote_constraint_layout"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
tools:context=".fragment.QuoteFragment">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_title_bar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quote_fragment_title"
|
||||
android:textSize="28sp"
|
||||
android:fontFamily="@font/mono_bold_italic"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/quote_scroller"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:paddingBottom="84dp"
|
||||
android:clipToPadding="false"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add_fab"
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/fab_add_quote"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:backgroundTint="?attr/colorOnPrimary"
|
||||
android:src="@drawable/add"
|
||||
app:tint="?attr/colorPrimary"/>
|
||||
android:text="@string/quote_fragment_fab_add"
|
||||
app:icon="@drawable/add"/>
|
||||
<!-- app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlayExtended"-->
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -3,39 +3,64 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp">
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:layout_marginVertical="4dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/Widget.Material3.CardView.Outlined"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp">
|
||||
<!-- android:backgroundTint="?attr/colorSecondary"-->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/quote"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/text_layout_quote"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:textCursorDrawable="@null"
|
||||
android:hint="@string/enter_text"/>
|
||||
<!-- android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"-->
|
||||
android:hint="@string/quote_entry_text_input_hint"
|
||||
app:boxStrokeColor="@color/selector_text_input"
|
||||
app:hintTextColor="@color/selector_text_input">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edit_text_quote"
|
||||
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorOnSurfaceVariant" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/delete_button"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/delete"
|
||||
android:background="@null"
|
||||
app:icon="@drawable/delete"
|
||||
android:minWidth="0dp"
|
||||
app:iconPadding="0dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="4dp"/>
|
||||
<!-- android:tint="?attr/colorOnPrimary"-->
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
app:icon="@drawable/drag_indicator"
|
||||
android:minWidth="0dp"
|
||||
app:iconPadding="0dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="2dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<item
|
||||
android:id="@+id/quotes"
|
||||
android:icon="@drawable/pen_outlined"
|
||||
android:title="@string/edit"
|
||||
android:title="@string/nav_items_entries"
|
||||
android:enabled="true"/>
|
||||
<item
|
||||
android:id="@+id/guide"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_nav_graph"
|
||||
app:startDestination="@id/quotes">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/quotes"
|
||||
android:name="com.denizd.textbasic.fragment.QuoteFragment"
|
||||
android:label="QuoteFragment"
|
||||
tools:layout="@layout/fragment_quote"/>
|
||||
<fragment
|
||||
android:id="@+id/guide"
|
||||
android:name="com.denizd.textbasic.fragment.GuideFragment"
|
||||
tools:layout="@layout/fragment_guide"
|
||||
android:label="GuideFragment"/>
|
||||
<fragment
|
||||
android:id="@+id/settings"
|
||||
android:name="com.denizd.textbasic.fragment.SettingsFragment"
|
||||
android:label="SettingsFragment"
|
||||
tools:layout="@layout/fragment_settings"/>
|
||||
</navigation>
|
||||
@@ -2,7 +2,8 @@
|
||||
<resources>
|
||||
<string name="app_name">Text Basic</string>
|
||||
<string name="enter_text">Gib etwas ein…</string>
|
||||
<string name="example_text">Dies ist ein Beispieltext</string>
|
||||
<string name="quote_entry_text_input_hint">Eintrag</string>
|
||||
<string name="example_text">Beispieltext</string>
|
||||
<string name="text_size">Textgröße</string>
|
||||
<string name="text_opacity">Textopazität</string>
|
||||
<string name="bg_opacity">Hintergrundopazität</string>
|
||||
@@ -15,7 +16,13 @@
|
||||
<string name="snack_backup_download">Daten werden wiederhergestellt…</string>
|
||||
<string name="snack_backup_upload">Deine Daten werden innerhalb der nächsten Stunde gesichert</string>
|
||||
|
||||
<string name="quote_fragment_title">Deine Einträge</string>
|
||||
<string name="quote_fragment_fab_add">Eintrag hinzufügen</string>
|
||||
<string name="quote_fragment_snack_text">Eintrag wurde gelöscht</string>
|
||||
<string name="quote_fragment_snack_undo">Rückgängig</string>
|
||||
|
||||
<string name="edit">Text bearbeiten</string>
|
||||
<string name="nav_items_entries">Einträge</string>
|
||||
<string name="guide">Anleitung</string>
|
||||
<string name="settings">Einstellungen</string>
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<resources>
|
||||
<string name="app_name">Text Basic</string>
|
||||
<string name="enter_text">Enter something…</string>
|
||||
<string name="example_text">This is an example text</string>
|
||||
<string name="quote_entry_text_input_hint">Entry</string>
|
||||
<string name="example_text">Sample text</string>
|
||||
<string name="text_size">text size</string>
|
||||
<string name="text_opacity">text opacity</string>
|
||||
<string name="bg_opacity">bg opacity</string>
|
||||
@@ -14,7 +15,13 @@
|
||||
<string name="snack_backup_download">Restoring your data…</string>
|
||||
<string name="snack_backup_upload">Your data will be backed up within the next hour</string>
|
||||
|
||||
<string name="quote_fragment_title">Your Entries</string>
|
||||
<string name="quote_fragment_fab_add">Add entry</string>
|
||||
<string name="quote_fragment_snack_text">Entry has been deleted</string>
|
||||
<string name="quote_fragment_snack_undo">Undo</string>
|
||||
|
||||
<string name="edit">Edit Text</string>
|
||||
<string name="nav_items_entries">Entries</string>
|
||||
<string name="guide">Guide</string>
|
||||
<string name="settings">Settings</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user