mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 13:39:24 +00:00
Remove wrapped fragments from settings.
This commit is contained in:
committed by
Cody Henthorne
parent
570a475229
commit
3aa4e75ef3
@@ -1,52 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
||||
/**
|
||||
* Wraps a fragment to give it a Settings style toolbar. This class should be used sparingly, and
|
||||
* is really only here as stop-gap as we migrate more settings screens to the new UI
|
||||
*/
|
||||
abstract class SettingsWrapperFragment : Fragment(R.layout.settings_wrapper_fragment) {
|
||||
|
||||
protected lateinit var toolbar: Toolbar
|
||||
private set
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
toolbar = view.findViewById(R.id.toolbar)
|
||||
|
||||
toolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, OnBackPressed())
|
||||
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.wrapped_fragment, getFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
abstract fun getFragment(): Fragment
|
||||
|
||||
fun setTitle(@StringRes titleId: Int) {
|
||||
toolbar.setTitle(titleId)
|
||||
}
|
||||
|
||||
private fun onBackPressed() {
|
||||
if (!childFragmentManager.popBackStackImmediate()) {
|
||||
requireActivity().onNavigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnBackPressed : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.preferences.AdvancedPinPreferenceFragment
|
||||
|
||||
class WrappedAdvancedPinPreferenceFragment : SettingsWrapperFragment() {
|
||||
override fun getFragment(): Fragment {
|
||||
toolbar.setTitle(R.string.preferences__advanced_pin_settings_title)
|
||||
return AdvancedPinPreferenceFragment()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.preferences.BackupsPreferenceFragment
|
||||
|
||||
class WrappedBackupsPreferenceFragment : SettingsWrapperFragment() {
|
||||
override fun getFragment(): Fragment {
|
||||
toolbar.setTitle(R.string.BackupsPreferenceFragment__chat_backups)
|
||||
return BackupsPreferenceFragment()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.delete.DeleteAccountFragment
|
||||
|
||||
class WrappedDeleteAccountFragment : SettingsWrapperFragment() {
|
||||
override fun getFragment(): Fragment {
|
||||
toolbar.setTitle(R.string.preferences__delete_account)
|
||||
return DeleteAccountFragment()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.preferences.EditProxyFragment
|
||||
|
||||
class WrappedEditProxyFragment : SettingsWrapperFragment() {
|
||||
override fun getFragment(): Fragment {
|
||||
toolbar.setTitle(R.string.preferences_use_proxy)
|
||||
return EditProxyFragment()
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.wrapped
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.help.HelpFragment
|
||||
|
||||
class WrappedHelpFragment : SettingsWrapperFragment() {
|
||||
override fun getFragment(): Fragment {
|
||||
toolbar.title = getString(R.string.preferences__help)
|
||||
|
||||
val fragment = HelpFragment()
|
||||
fragment.arguments = arguments
|
||||
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,10 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -60,6 +62,7 @@ public class DeleteAccountFragment extends Fragment {
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
Spinner countrySpinner = view.findViewById(R.id.delete_account_fragment_country_spinner);
|
||||
View confirm = view.findViewById(R.id.delete_account_fragment_delete);
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
bullets = view.findViewById(R.id.delete_account_fragment_bullets);
|
||||
countryCode = view.findViewById(R.id.delete_account_fragment_country_code);
|
||||
@@ -76,6 +79,7 @@ public class DeleteAccountFragment extends Fragment {
|
||||
countryCode.getInput().addTextChangedListener(new AfterTextChanged(this::afterCountryCodeChanged));
|
||||
countryCode.getInput().setImeOptions(EditorInfo.IME_ACTION_NEXT);
|
||||
confirm.setOnClickListener(unused -> viewModel.submit());
|
||||
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
initializeSpinner(countrySpinner);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
@@ -61,6 +63,7 @@ public class HelpFragment extends LoggingFragment {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
initializeViewModels();
|
||||
initializeToolbar(view);
|
||||
initializeViews(view);
|
||||
initializeListeners();
|
||||
initializeObservers();
|
||||
@@ -138,6 +141,11 @@ public class HelpFragment extends LoggingFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeToolbar(@NonNull View view) {
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).navigateUp());
|
||||
}
|
||||
|
||||
private void handleEmojiClicked(@NonNull View clicked) {
|
||||
if (clicked.isSelected()) {
|
||||
clicked.setSelected(false);
|
||||
|
||||
@@ -17,8 +17,10 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.google.android.material.timepicker.MaterialTimePicker;
|
||||
import com.google.android.material.timepicker.TimeFormat;
|
||||
@@ -74,6 +76,9 @@ public class BackupsPreferenceFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
create = view.findViewById(R.id.fragment_backup_create);
|
||||
folder = view.findViewById(R.id.fragment_backup_folder);
|
||||
verify = view.findViewById(R.id.fragment_backup_verify);
|
||||
|
||||
@@ -11,9 +11,11 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ShareCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
@@ -54,6 +56,9 @@ public class EditProxyFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
this.proxySwitch = view.findViewById(R.id.edit_proxy_switch);
|
||||
this.proxyTitle = view.findViewById(R.id.edit_proxy_address_title);
|
||||
this.proxyText = view.findViewById(R.id.edit_proxy_host);
|
||||
|
||||
Reference in New Issue
Block a user