-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lent item click actions & filtering
Signed-off-by: Aron Heinecke <aron.heinecke@t-online.de>
- Loading branch information
Showing
11 changed files
with
265 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
/config.toml | ||
/out.txt | ||
/testlabel.pdf | ||
/lars.svg |
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
90 changes: 90 additions & 0 deletions
90
app/src/main/java/de/tu_darmstadt/seemoo/LARS/ui/lent/LentClickActionBTFragment.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,90 @@ | ||
package de.tu_darmstadt.seemoo.LARS.ui.lent | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.navigation.fragment.findNavController | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import de.tu_darmstadt.seemoo.LARS.R | ||
import de.tu_darmstadt.seemoo.LARS.data.model.Asset | ||
import de.tu_darmstadt.seemoo.LARS.ui.info.AssetInfoBTFragment | ||
import de.tu_darmstadt.seemoo.LARS.ui.user.AssetListFragment | ||
|
||
/** | ||
* Asset click action BSD fragment for LentFragment | ||
*/ | ||
class LentClickActionBTFragment: BottomSheetDialogFragment() { | ||
private lateinit var asset: Asset | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
if(savedInstanceState == null) { | ||
requireArguments().run { | ||
asset = this.getParcelable(PARAM_ASSET) | ||
} | ||
} else { | ||
asset = savedInstanceState.getParcelable(PARAM_ASSET) | ||
} | ||
} | ||
|
||
override fun onSaveInstanceState(outState: Bundle) { | ||
super.onSaveInstanceState(outState) | ||
outState.putParcelable(PARAM_ASSET,asset) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { // Inflate the layout for this fragment | ||
val viewModel: LentViewModel = ViewModelProvider(requireActivity())[LentViewModel::class.java] | ||
|
||
val view = inflater.inflate(R.layout.fragment_lent_asset_action, container, false) | ||
val btnFilter: Button = view.findViewById(R.id.frag_lent_asset_action_filter_button) | ||
val btnInfo: Button = view.findViewById(R.id.frag_lent_asset_action_info_button) | ||
val btnUserDetails: Button = view.findViewById(R.id.frag_lent_asset_action_userdetails_button) | ||
|
||
val userName = asset?.assigned_to?.username ?: "<missing>" | ||
btnFilter.text = getString(R.string.filter_by_user_x,userName) | ||
btnUserDetails.text = getString(R.string.show_assets_of_x,userName) | ||
|
||
btnFilter.setOnClickListener { | ||
asset?.assigned_to?.run { | ||
viewModel.filteredUser.value = this.asSelector() | ||
} | ||
dismiss() | ||
} | ||
|
||
btnInfo.setOnClickListener { | ||
asset?.run { | ||
AssetInfoBTFragment.newInstance(this).show( | ||
parentFragmentManager, | ||
"LentAssetInfoBTFragment" | ||
) | ||
} | ||
dismiss() | ||
} | ||
|
||
btnUserDetails.setOnClickListener { | ||
asset?.assigned_to?.run { | ||
val (id,args) = AssetListFragment.newInstancePair(this.asSelector()) | ||
findNavController().navigate(id, args) | ||
} | ||
dismiss() | ||
} | ||
return view | ||
} | ||
|
||
companion object { | ||
fun newInstance(asset: Asset): LentClickActionBTFragment { | ||
val bundle = Bundle() | ||
val fragment = LentClickActionBTFragment() | ||
bundle.putParcelable(PARAM_ASSET,asset) | ||
fragment.arguments = bundle | ||
return fragment | ||
} | ||
|
||
private const val PARAM_ASSET = "asset" | ||
} | ||
} |
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,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout 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" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:text="@string/lent_asset_bt_action" | ||
android:textAlignment="viewStart" | ||
android:textAllCaps="true" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" | ||
android:textSize="16sp" /> | ||
|
||
<Button | ||
android:id="@+id/frag_lent_asset_action_info_button" | ||
style="@style/Widget.MaterialComponents.Button.TextButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingStart="8dp" | ||
android:text="Show asset info" | ||
android:textAlignment="textStart" | ||
android:textAllCaps="false" | ||
app:icon="@android:drawable/ic_menu_info_details" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/frag_lent_asset_action_filter_button" | ||
style="@style/Widget.MaterialComponents.Button.TextButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingStart="10dp" | ||
android:textAlignment="textStart" | ||
android:textAllCaps="false" | ||
app:icon="@drawable/ic_filter_list_white_24dp" | ||
app:iconPadding="4dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/frag_lent_asset_action_userdetails_button" | ||
style="@style/Widget.MaterialComponents.Button.TextButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingStart="10dp" | ||
android:textAlignment="textStart" | ||
android:textAllCaps="false" | ||
app:icon="@drawable/ic_filter_list_white_24dp" | ||
app:iconPadding="4dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</LinearLayout> |
Oops, something went wrong.