From 1ce2b2d4dcdafb362b8dfb326adf71159d6a5ac6 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Sun, 8 Dec 2024 13:24:14 +0100 Subject: [PATCH] Suggest the user to share evalution --- .../klee/sapio/ui/view/ChooseAppFragment.kt | 6 +++++- .../klee/sapio/ui/view/EvaluateFragment.kt | 12 +++++++++-- .../com/klee/sapio/ui/view/SuccessFragment.kt | 20 ++++++++++++++----- app/src/main/res/layout/fragment_success.xml | 20 +++++++++++++++---- app/src/main/res/navigation/nav_graph.xml | 9 ++++++--- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 7 files changed, 54 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/klee/sapio/ui/view/ChooseAppFragment.kt b/app/src/main/java/com/klee/sapio/ui/view/ChooseAppFragment.kt index e4591ea..0ee7fea 100644 --- a/app/src/main/java/com/klee/sapio/ui/view/ChooseAppFragment.kt +++ b/app/src/main/java/com/klee/sapio/ui/view/ChooseAppFragment.kt @@ -66,7 +66,11 @@ class ChooseAppFragment : Fragment() { } private fun onNextButtonClicked() { - val bundle = bundleOf("package" to mApp?.packageName) + val bundle = bundleOf( + "package" to mApp?.packageName, + "name" to mApp?.name + ) + findNavController().navigate(R.id.action_chooseAppFragment_to_evaluateFragment, bundle) } diff --git a/app/src/main/java/com/klee/sapio/ui/view/EvaluateFragment.kt b/app/src/main/java/com/klee/sapio/ui/view/EvaluateFragment.kt index 5f15273..7fd46dc 100644 --- a/app/src/main/java/com/klee/sapio/ui/view/EvaluateFragment.kt +++ b/app/src/main/java/com/klee/sapio/ui/view/EvaluateFragment.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.widget.RadioButton import android.widget.Toast import androidx.annotation.RequiresApi +import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import com.klee.sapio.R @@ -35,6 +36,7 @@ class EvaluateFragment : Fragment() { @Inject lateinit var mDeviceConfiguration: DeviceConfiguration private lateinit var mBinding: FragmentEvaluateBinding private lateinit var mPackageName: String + private lateinit var mAppName: String @RequiresApi(Build.VERSION_CODES.M) override fun onCreateView( @@ -52,7 +54,8 @@ class EvaluateFragment : Fragment() { mBinding.rootConfiguration.text = isRootedLabel.text mBinding.rootConfiguration.setBackgroundColor(isRootedLabel.color) - mPackageName = arguments?.getString("package")!! + mPackageName = arguments?.getString("package").orEmpty() + mAppName = arguments?.getString("name").orEmpty() mBinding.validateButton.isEnabled = false mBinding.note.setOnCheckedChangeListener { _, value -> mBinding.validateButton.isEnabled = value != -1 @@ -85,7 +88,12 @@ class EvaluateFragment : Fragment() { } private fun onUploadSuccess() { - findNavController().navigate(R.id.action_evaluateFragment_to_successFragment) + val bundle = bundleOf( + "package" to mPackageName, + "name" to mAppName + ) + + findNavController().navigate(R.id.action_evaluateFragment_to_successFragment, bundle) } private fun onUploadError() { diff --git a/app/src/main/java/com/klee/sapio/ui/view/SuccessFragment.kt b/app/src/main/java/com/klee/sapio/ui/view/SuccessFragment.kt index fbd79bd..b775287 100644 --- a/app/src/main/java/com/klee/sapio/ui/view/SuccessFragment.kt +++ b/app/src/main/java/com/klee/sapio/ui/view/SuccessFragment.kt @@ -1,27 +1,37 @@ package com.klee.sapio.ui.view +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController -import com.klee.sapio.R import com.klee.sapio.databinding.FragmentSuccessBinding class SuccessFragment : Fragment() { private lateinit var mBinding: FragmentSuccessBinding + companion object { + const val EXTRA_PACKAGE_NAME = "packageName" + const val EXTRA_APP_NAME = "appName" + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { + ): View { + val packageName = arguments?.getString("package").orEmpty() + val appName = arguments?.getString("name").orEmpty() + mBinding = FragmentSuccessBinding.inflate(inflater, container, false) mBinding.emoji.text = "\uD83C\uDF89 \uD83E\uDD73" - mBinding.evaludateAnotherAppButton.setOnClickListener { - findNavController().navigate(R.id.action_successFragment_to_warningFragment) + mBinding.shareEvaluation.setOnClickListener { + val intent = Intent(requireContext(), EvaluationsActivity::class.java) + intent.putExtra(EXTRA_PACKAGE_NAME, packageName) + intent.putExtra(EXTRA_APP_NAME, appName) + requireContext().startActivity(intent) } return mBinding.root diff --git a/app/src/main/res/layout/fragment_success.xml b/app/src/main/res/layout/fragment_success.xml index d1d8442..63c14f9 100644 --- a/app/src/main/res/layout/fragment_success.xml +++ b/app/src/main/res/layout/fragment_success.xml @@ -33,14 +33,26 @@ app:layout_constraintTop_toTopOf="parent" />