Skip to content

Commit

Permalink
changed rec screen layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidius20 committed Jul 18, 2024
1 parent 8ff38af commit fa32540
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,32 +207,54 @@ class RecordingsListFragment : Fragment() {
// if success
// todo: first stop actionmode, then show rename dialog, so that the need for payloads is evident






actionMode!!.finish()

showRenameDialog(position) // probably not very sustainable when we will implement
// restoring the dialog after screen rotation. Maybe it is better to restore selected
// items and then take position from there


}

/**
* shows rename dialog for the first time or after activity recreation
*/
fun showRenameDialog(position: Int) {
// todo: dialog being shown is a part of UI state. It should be stored in viewmodel
// and there should be a "render" function that simply renders out the state that is
// saved in viewmodel

// todo: it is lost when screen rotates
val dialogView = RenameDialogBinding.inflate(layoutInflater)


// todo: this right here is a "feature envy" code smell. Need to refactor
// and reachitect the ui state logic

//todo: dialog fragment with callback?
viewModel.renameFileNewName.value = viewModel.recordings.value!![position].name

val dialogView = RenameDialogBinding.inflate(layoutInflater)
AlertDialog.Builder(requireContext())
.setTitle(R.string.recordings_list_choose_new_name)
.setView(dialogView.root)
.setPositiveButton(android.R.string.ok) { d, i ->

onRenameDialogSubmitted(position)
}
.show()
}

actionMode!!.finish()
private fun onRenameDialogSubmitted(position: Int) {
val newData = viewModel.recordings.value!![position].copy(
name = "new name"
name = viewModel.renameFileNewName.value!!
)
// todo: actually rename in Repository
adapter.replaceItemAt(position, newData)
}

/**
* shows rename dialog for the first time or after activity recreation
*/
fun showRenameDialog() {}

fun onRenameDialogSubmitted() {

}


}
8 changes: 7 additions & 1 deletion app/src/main/res/drawable/ic_stop.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M6,6h12v12H6z"/>

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
Expand Down
80 changes: 64 additions & 16 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,84 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment">

<Chronometer
android:id="@+id/rec_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/recordButton"
android:layout_marginBottom="@dimen/margin_normal"
android:textAppearance="?textAppearanceLabelLarge"
/>

<Button
<com.google.android.material.button.MaterialButton
style="?attr/materialIconButtonFilledStyle"

app:backgroundTint="?colorSecondaryContainer"



app:iconTint="?colorOnSecondaryContainer"

app:iconGravity="textStart"

tools:icon="@drawable/ic_record"

android:layout_width="72dp"
android:layout_height="72dp"
app:shapeAppearance="?attr/shapeAppearanceCornerMedium"

android:elevation="1dp"
android:id="@+id/recordButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:contentDescription="@string/rec_pause_btn_desc"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/margin_normal"

app:layout_constraintBottom_toBottomOf="parent"

android:layout_marginBottom="@dimen/margin_large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:icon="@{viewModel.uiState.recPauseBtnIcon == RecPauseBtnIcon.RECORD ? @drawable/ic_record : @drawable/ic_pause}"
android:visibility="@{viewModel.uiState.recPauseBtnVisible ? View.VISIBLE : View.GONE}"
android:onClick="@{() -> fragment.onRecButtonClick()}"
/>

<Button
style="?attr/materialIconButtonFilledStyle"
<com.google.android.material.button.MaterialButton
style="?attr/materialIconButtonOutlinedStyle"
app:shapeAppearance="?attr/shapeAppearanceCornerMedium"
android:id="@+id/stopButton"
android:layout_marginTop="@dimen/margin_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/recordButton"
app:icon="@drawable/ic_stop"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="@{viewModel.uiState.stopButtonVisible ? View.VISIBLE : View.GONE}"
android:layout_width="72dp"
android:layout_height="72dp"
app:iconGravity="textStart"



app:strokeColor="?colorError"
app:iconTint="?colorError"


android:layout_marginStart="@dimen/margin_normal"
android:layout_marginBottom="@dimen/margin_large"
android:onClick="@{() -> fragment.onStopBtnClick()}"
/>
android:visibility="@{viewModel.uiState.stopButtonVisible ? View.VISIBLE : View.GONE}"

app:icon="@drawable/ic_stop"






app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/recordButton" />

<!--
android:scaleType="fitXY"
android:padding="20dp"
-->


</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/rename_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewmodel.renameFileNewName}" />
android:text="@={viewmodel.renameFileNewName}" />

</com.google.android.material.textfield.TextInputLayout>
</layout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@


<dimen name="margin_normal">16dp</dimen>

<dimen name="margin_large">48dp</dimen>
</resources>

0 comments on commit fa32540

Please sign in to comment.