Skip to content

Commit

Permalink
Suggest the user to share evalution
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanklee committed Dec 8, 2024
1 parent e98c752 commit 1ce2b2d
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/klee/sapio/ui/view/EvaluateFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/java/com/klee/sapio/ui/view/SuccessFragment.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 16 additions & 4 deletions app/src/main/res/layout/fragment_success.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,26 @@
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/evaludateAnotherAppButton"
android:id="@+id/shareEvaluation"
style="@style/Theme.Sapio.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/evaluate_another_app"
android:layout_margin="20dp"
style="@style/Theme.Sapio.Button"
android:text="@string/share"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"/>

<TextView
android:id="@+id/shareText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/share_text"
android:layout_margin="20dp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/shareEvaluation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appEvaluatedText" />

</androidx.constraintlayout.widget.ConstraintLayout>
9 changes: 6 additions & 3 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
android:id="@+id/successFragment"
android:name="com.klee.sapio.ui.view.SuccessFragment"
android:label="SuccessFragment" >
<action
android:id="@+id/action_successFragment_to_warningFragment"
app:destination="@id/warningFragment" />
<argument
android:name="package"
app:argType="string" />
<argument
android:name="name"
app:argType="string" />
</fragment>
</navigation>
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<string name="upload_error">Erreur lors de l\'évaluation</string>
<string name="about_text">Sapio est l\'anagramme d\'Open Source API.\n\nSapio fournit la matrice de compatibilité d\'une application Android avec les téléphones fonctionnant sur un Android Open Source Project (AOSP) déGooglisé, associés ou non à microG.\n\nSapio peut être utilisé comme un outil de lobbying en partageant les matrices de compatibilité sur les réseaux sociaux pour sensibiliser les développeurs d\'applications aux données personnelles des utilisateurs.\n\nLes évaluations de Sapio sont fournies à la communauté par la communauté.</string>
<string name="credits">Icone cerveau créé par Freepik - Flaticon</string>
<string name="evaluate_another_app">Evaluer une autre application</string>
<string name="configuration_detected">Configuration détéctée</string>
<string name="look_for_an_application">Rechercher une application</string>
<string name="updated_on">Mis à jour le %1$s</string>
Expand All @@ -39,4 +38,5 @@
<string name="share">Partager</string>
<string name="rating_rules"><![CDATA[<a href="%1$s">Règles d\'évaluation</a>]]></string>
<string name="i_have_read_and_i_understand_the_rating_rules">J\'ai lu et je comprends les règles d\'évaluation</string>
<string name="share_text">N\'hésitez pas à partager votre évaluation sur les réseaux sociaux pour sensibiliser les développeurs au respect des données personnelles.</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<string name="upload_error">Error evaluating app</string>
<string name="about_text">Sapio is the anagram of Open Source API.\n\nSapio provides the compatibility matrix of an Android application with deGoogled bare Android Open Source Project (AOSP) devices, coupled or not with microG.\n\nSapio can serve as a lobbying tool by sharing compatibility matrices on social media to raise awareness among app developers about respecting users\' personal data.\n\nEvaluations in Sapio are given to the community by the community.</string>
<string name="credits">Brain icons created by Freepik - Flaticon</string>
<string name="evaluate_another_app">Evaluate another app</string>
<string name="configuration_detected">Configuration detected</string>
<string name="look_for_an_application">Look for an application</string>
<string name="updated_on">Updated on %1$s</string>
Expand All @@ -41,6 +40,7 @@
<string name="bad">Does not work at all</string>
<string name="unknown">Unknown</string>
<string name="share">Share</string>
<string name="share_text">Feel free to share your evaluation on social media to raise awareness among app developers about respecting users\' personal data.</string>
<string name="donate">Donate</string>
<string name="rating_rules"><![CDATA[<a href="%1$s">Rating rules</a>]]></string>
<string name="i_have_read_and_i_understand_the_rating_rules">I have read and I understand the rating rules</string>
Expand Down

0 comments on commit 1ce2b2d

Please sign in to comment.