Avoid code duplication and let the Activity manage the Fragments

This commit is contained in:
Benoit Marty 2020-09-23 12:50:49 +02:00 committed by Benoit Marty
parent fb74628aa8
commit b8c350488b
3 changed files with 12 additions and 12 deletions

View File

@ -31,6 +31,7 @@ import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.ensureProtocol
import im.vector.app.features.discovery.change.SetIdentityServerFragment
import im.vector.app.features.settings.VectorSettingsActivity
import im.vector.app.features.terms.ReviewTermsActivity
import org.matrix.android.sdk.api.session.identity.SharedState
import org.matrix.android.sdk.api.session.identity.ThreePid
@ -178,10 +179,6 @@ class DiscoverySettingsFragment @Inject constructor(
}
private fun navigateToChangeIdentityServerFragment() {
parentFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom, R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom)
.replace(R.id.vector_settings_page, SetIdentityServerFragment::class.java, null)
.addToBackStack(null)
.commit()
(vectorBaseActivity as? VectorSettingsActivity)?.navigateTo(SetIdentityServerFragment::class.java)
}
}

View File

@ -17,6 +17,7 @@ package im.vector.app.features.settings
import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
@ -134,6 +135,14 @@ class VectorSettingsActivity : VectorBaseActivity(),
}
}
fun <T: Fragment> navigateTo(fragmentClass: Class<T>) {
supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom, R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom)
.replace(R.id.vector_settings_page, fragmentClass, null)
.addToBackStack(null)
.commit()
}
companion object {
fun getIntent(context: Context, directAccess: Int) = Intent(context, VectorSettingsActivity::class.java)
.apply { putExtra(EXTRA_DIRECT_ACCESS, directAccess) }

View File

@ -56,7 +56,6 @@ import im.vector.app.features.crypto.recover.BootstrapBottomSheet
import im.vector.app.features.navigation.Navigator
import im.vector.app.features.pin.PinActivity
import im.vector.app.features.pin.PinCodeStore
import im.vector.app.features.pin.PinLocker
import im.vector.app.features.pin.PinMode
import im.vector.app.features.raw.wellknown.ElementWellKnownMapper
import im.vector.app.features.raw.wellknown.isE2EByDefault
@ -374,12 +373,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
}
private fun doOpenPinCodePreferenceScreen() {
// TODO Avoid duplication of this code. Move it to Activity
parentFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom, R.anim.anim_slide_in_bottom, R.anim.anim_slide_out_bottom)
.replace(R.id.vector_settings_page, VectorSettingsPinFragment::class.java, null)
.addToBackStack(null)
.commit()
(vectorActivity as? VectorSettingsActivity)?.navigateTo(VectorSettingsPinFragment::class.java)
}
private fun refreshKeysManagementSection() {