Skip to content

Commit

Permalink
feat:Made changes to the privacy policy file in accordance with chang…
Browse files Browse the repository at this point in the history
…e in navigation implementation
  • Loading branch information
angrezichatterbox committed Aug 30, 2024
1 parent a60b1bc commit 26a6032
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 84 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
android:label="@string/app.about.wikimedia"
android:parentActivityName=".fragments.MainFragment" />
<activity
android:name=".activities.PrivacyPolicyActivity"
android:name=".fragments.PrivacyPolicyFragment"
android:label="@string/app.about.privacyPolicy"
android:parentActivityName=".activities.MainActivity" />
<activity
Expand Down
50 changes: 0 additions & 50 deletions app/src/main/java/be/scri/activities/PrivacyPolicyActivity.kt

This file was deleted.

15 changes: 14 additions & 1 deletion app/src/main/java/be/scri/fragments/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.GestureDetector
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.addCallback
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import be.scri.R
Expand All @@ -32,6 +33,10 @@ class AboutFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
binding = FragmentAboutBinding.inflate(inflater, container, false)
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
getParentFragmentManager().popBackStack()
}
callback.isEnabled = true
return binding.root
}

Expand Down Expand Up @@ -77,7 +82,7 @@ class AboutFragment : Fragment() {

private fun getThirdRecyclerViewData(): List<ItemsViewModel> {
return listOf(
ItemsViewModel(image = R.drawable.shield_lock, R.string.app_about_privacyPolicy, image2 = R.drawable.right_arrow, url = null, activity = null, action = null),
ItemsViewModel(image = R.drawable.shield_lock, R.string.app_about_privacyPolicy, image2 = R.drawable.right_arrow, url = null, activity = null, action = ::loadPrivacyPolicyFragment),
ItemsViewModel(image = R.drawable.license_icon, R.string.app_about_thirdParty, image2 = R.drawable.right_arrow, url = null, activity = null, action = null)
)
}
Expand Down Expand Up @@ -111,5 +116,13 @@ class AboutFragment : Fragment() {
fragmentTransaction.commit()
}

private fun loadPrivacyPolicyFragment() {
val fragment = PrivacyPolicyFragment()
val fragmentTransaction = requireActivity().supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, fragment)
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
}


}
5 changes: 5 additions & 0 deletions app/src/main/java/be/scri/fragments/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.Fragment
import be.scri.R
Expand Down Expand Up @@ -43,6 +44,10 @@ class MainFragment : Fragment() {
}
}
}
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
getParentFragmentManager().popBackStack()
}
callback.isEnabled = true
return binding.root
}

Expand Down
66 changes: 66 additions & 0 deletions app/src/main/java/be/scri/fragments/PrivacyPolicyFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package be.scri.fragments


import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.activity.addCallback
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import be.scri.R
import be.scri.activities.MainActivity
import be.scri.databinding.ActivityPrivacyPolicyBinding


class PrivacyPolicyFragment : Fragment(){


private lateinit var binding: ActivityPrivacyPolicyBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val viewpager = requireActivity().findViewById<ViewPager2>(R.id.view_pager)
val frameLayout = requireActivity().findViewById<ViewGroup>(R.id.fragment_container)
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
viewpager.setCurrentItem(2, true);
}
callback.isEnabled = true


}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = ActivityPrivacyPolicyBinding.inflate(inflater, container, false)
(requireActivity() as MainActivity).supportActionBar?.title = getString(R.string.app_about_privacyPolicy)
(requireActivity() as MainActivity).showFragmentContainer()
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
val viewpager = requireActivity().findViewById<ViewPager2>(R.id.view_pager)
val frameLayout = requireActivity().findViewById<ViewGroup>(R.id.fragment_container)
if (viewpager.currentItem == 2) {
viewpager.setCurrentItem(2, true)
frameLayout.visibility = View.GONE
} else {
if (parentFragmentManager.backStackEntryCount > 0) {
parentFragmentManager.popBackStack()
} else {
isEnabled = false
requireActivity().onBackPressed()
}
}

(requireActivity() as MainActivity).supportActionBar?.title = getString(R.string.app_about_title)
}
})
return binding.root

}

}



5 changes: 5 additions & 0 deletions app/src/main/java/be/scri/fragments/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.provider.Settings.ACTION_APP_LOCALE_SETTINGS
import android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS
import android.view.*
import android.view.inputmethod.InputMethodManager
import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.Fragment
Expand All @@ -28,6 +29,10 @@ class SettingsFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentSettingsBinding.inflate(inflater, container, false)
val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
getParentFragmentManager().popBackStack()
}
callback.isEnabled = true
return binding.root
}

Expand Down
33 changes: 1 addition & 32 deletions app/src/main/res/layout/activity_privacy_policy.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView 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/clBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color">

<ScrollView
android:id="@+id/scrollView2"
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<View
android:layout_width="match_parent"
android:layout_height="40dp" />

<TextView
android:id="@+id/textView"
android:layout_width="303dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="56dp"
android:text="@string/app.about.privacyPolicy.caption"
android:layout_marginEnd="16dp"
android:textColor="@color/app_text_color"
Expand Down Expand Up @@ -93,15 +74,3 @@
</LinearLayout>
</ScrollView>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/nav_bar_color"
app:itemIconTint="@drawable/nav_bar_selector"
app:itemTextColor="@drawable/nav_bar_selector"
app:menu="@menu/menu_navigation_bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 26a6032

Please sign in to comment.