Skip to content

Commit

Permalink
Merge pull request kiwix#2531 from kiwix/feature/macgills/2530-remove…
Browse files Browse the repository at this point in the history
…-activity-finishing

kiwix#2530 Remove activity finishing from IntroFragment and rely on default behaviour
  • Loading branch information
macgills authored Dec 1, 2020
2 parents 9f08ca7 + 6d008e4 commit 2a54e16
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 2 additions & 8 deletions app/src/main/java/org/kiwix/kiwixmobile/intro/IntroFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.navigation.fragment.findNavController
import androidx.viewpager.widget.ViewPager
import kotlinx.android.synthetic.main.fragment_intro.get_started
import kotlinx.android.synthetic.main.fragment_intro.tab_indicator
Expand All @@ -35,7 +35,6 @@ import org.kiwix.kiwixmobile.cachedComponent
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.zim_manager.SimplePageChangeListener
import java.util.Timer
import java.util.TimerTask
Expand Down Expand Up @@ -103,15 +102,10 @@ class IntroFragment : BaseFragment(), IntroContract.View, FragmentActivityExtens
views = emptyArray()
}

override fun onBackPressed(activity: AppCompatActivity): FragmentActivityExtensions.Super {
activity.finish()
return super.onBackPressed(activity)
}

private fun navigateToLibrary() {
dismissAutoRotate()
presenter.setIntroShown()
(requireActivity() as KiwixMainActivity).navController.popBackStack()
findNavController().navigate(IntroFragmentDirections.actionIntrofragmentToLibraryFragment())
}

private fun updateView(position: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragmentDirections

const val NAVIGATE_TO_ZIM_HOST_FRAGMENT = "navigate_to_zim_host_fragment"

Expand Down Expand Up @@ -94,7 +95,7 @@ class KiwixMainActivity : CoreMainActivity() {
}
}
if (sharedPreferenceUtil.showIntro()) {
navigate(R.id.introFragment)
navigate(LocalLibraryFragmentDirections.actionLibraryFragmentToIntrofragment())
}
}

Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/navigation/kiwix_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
<action
android:id="@+id/action_libraryFragment_to_localFileTransferFragment"
app:destination="@id/localFileTransferFragment" />
<action
android:id="@+id/action_libraryFragment_to_introfragment"
app:destination="@id/introFragment"
app:popUpTo="@id/libraryFragment"
app:popUpToInclusive="true" />
</fragment>

<fragment
Expand All @@ -85,7 +90,13 @@
android:id="@+id/introFragment"
android:name="org.kiwix.kiwixmobile.intro.IntroFragment"
android:label="IntroFragment"
tools:layout="@layout/fragment_intro" />
tools:layout="@layout/fragment_intro">
<action
android:id="@+id/action_introfragment_to_libraryFragment"
app:destination="@id/libraryFragment"
app:popUpTo="@id/introFragment"
app:popUpToInclusive="true" />
</fragment>
<fragment
android:id="@+id/historyFragment"
android:name="org.kiwix.kiwixmobile.core.page.history.HistoryFragment"
Expand Down

0 comments on commit 2a54e16

Please sign in to comment.