Skip to content

Commit

Permalink
feat:Converted the thirdparty activity to fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
angrezichatterbox committed Aug 30, 2024
1 parent 26a6032 commit a6d90b5
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 96 deletions.
Empty file removed app/CustomAdapter.kt
Empty file.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
android:label="@string/app.about.privacyPolicy"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name=".activities.ThirdPartyActivity"
android:name=".fragments.ThirdPartyFragment"
android:label="@string/app.about.thirdParty"
android:parentActivityName=".activities.MainActivity" />
<activity
Expand Down
47 changes: 0 additions & 47 deletions app/src/main/java/be/scri/activities/ThirdPartyActivity.kt

This file was deleted.

10 changes: 9 additions & 1 deletion app/src/main/java/be/scri/fragments/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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 = ::loadPrivacyPolicyFragment),
ItemsViewModel(image = R.drawable.license_icon, R.string.app_about_thirdParty, image2 = R.drawable.right_arrow, url = null, activity = null, action = null)
ItemsViewModel(image = R.drawable.license_icon, R.string.app_about_thirdParty, image2 = R.drawable.right_arrow, url = null, activity = null, action = ::loadThirdPartyLicensesFragment)
)
}

Expand Down Expand Up @@ -124,5 +124,13 @@ class AboutFragment : Fragment() {
fragmentTransaction.commit()
}

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


}
14 changes: 12 additions & 2 deletions app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ class LanguageSettingsFragment : Fragment() {
private var _binding: FragmentLanguageSettingsBinding? = null
private val binding get() = _binding!!

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(3, true);
(requireActivity() as MainActivity).supportActionBar?.setDisplayHomeAsUpEnabled(false);
}
callback.isEnabled = true

}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?,
Expand Down Expand Up @@ -98,6 +110,4 @@ class LanguageSettingsFragment : Fragment() {
_binding = null
}



}
8 changes: 5 additions & 3 deletions app/src/main/java/be/scri/fragments/PrivacyPolicyFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import be.scri.R
import be.scri.activities.MainActivity
import be.scri.databinding.ActivityPrivacyPolicyBinding
import be.scri.databinding.FragmentPrivacyPolicyBinding


class PrivacyPolicyFragment : Fragment(){


private lateinit var binding: ActivityPrivacyPolicyBinding
private lateinit var binding: FragmentPrivacyPolicyBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -34,7 +34,7 @@ class PrivacyPolicyFragment : Fragment(){
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = ActivityPrivacyPolicyBinding.inflate(inflater, container, false)
binding = FragmentPrivacyPolicyBinding.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) {
Expand All @@ -60,6 +60,8 @@ class PrivacyPolicyFragment : Fragment(){

}



}


Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/be/scri/fragments/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class SettingsFragment : Fragment() {
setupRecycleView()
setupRecyclerView2()
(requireActivity() as MainActivity).supportActionBar?.title = getString(R.string.app_settings_title)

val imm = requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val enabledInputMethods = imm.enabledInputMethodList
for (inputMethod in enabledInputMethods) {
Expand Down
62 changes: 62 additions & 0 deletions app/src/main/java/be/scri/fragments/ThirdPartyFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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.FragmentThirdPartyBinding


class ThirdPartyFragment : Fragment() {

private lateinit var binding: FragmentThirdPartyBinding



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 = FragmentThirdPartyBinding.inflate(inflater, container, false)
(requireActivity() as MainActivity).supportActionBar?.title = getString(R.string.app_about_thirdParty)
(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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import be.scri.R
import be.scri.activities.MainActivity
import be.scri.databinding.ActivityWikimediaScribeBinding
import be.scri.databinding.FragmentWikimediaScribeBinding


class WikimediaScribeFragment : Fragment(){

private lateinit var binding: ActivityWikimediaScribeBinding
private lateinit var binding: FragmentWikimediaScribeBinding



Expand All @@ -35,7 +35,7 @@ class WikimediaScribeFragment : Fragment(){
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = ActivityWikimediaScribeBinding.inflate(inflater, container, false)
binding = FragmentWikimediaScribeBinding.inflate(inflater, container, false)
(requireActivity() as MainActivity).supportActionBar?.title = getString(R.string.app_about_wikimedia)
(requireActivity() as MainActivity).showFragmentContainer()
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
android:id="@+id/recycleView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:paddingBottom="50dp"
android:layout_marginTop="10dp"/>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,27 @@
<?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.thirdParty.caption"
android:layout_marginEnd="16dp"
android:textColor="@color/app_text_color"
android:textSize="20sp"
android:textStyle="bold" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand All @@ -56,13 +37,11 @@
android:background="@color/card_view_color"
app:cardBackgroundColor="@color/card_view_color"
app:cardCornerRadius="20dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:layout_width="304dp"
android:layout_height="wrap_content"
Expand All @@ -71,15 +50,13 @@
android:textSize="16sp" />

</LinearLayout>

<ImageView
android:layout_width="75dp"
android:layout_height="76dp"
android:layout_gravity="top|end"
android:alpha="0.9"
android:contentDescription="@string/app.about.thirdParty"
android:src="@drawable/corner_polygon" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -92,16 +69,3 @@
</FrameLayout>
</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 a6d90b5

Please sign in to comment.