mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 21:48:17 +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);
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/symbol_arrow_start_24"
|
||||
app:title="@string/preferences__delete_account" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/delete_account_fragment_warning"
|
||||
android:layout_width="40dp"
|
||||
@@ -18,7 +29,7 @@
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
app:srcCompat="@drawable/ic_warning_40"
|
||||
app:tint="@color/signal_alert_primary" />
|
||||
|
||||
|
||||
@@ -5,8 +5,17 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/symbol_arrow_start_24"
|
||||
app:title="@string/preferences_use_proxy" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/edit_proxy_switch_title"
|
||||
@@ -14,7 +23,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/preferences_use_proxy"
|
||||
style="@style/Signal.Text.Body"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/edit_proxy_switch"/>
|
||||
|
||||
@@ -25,6 +35,7 @@
|
||||
android:text="@string/preferences_only_use_a_proxy_if"
|
||||
style="@style/Signal.Text.Preview"
|
||||
android:textColor="@color/signal_text_secondary"
|
||||
android:layout_marginStart="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_proxy_switch_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/edit_proxy_switch"/>
|
||||
@@ -34,6 +45,7 @@
|
||||
android:id="@+id/edit_proxy_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/edit_proxy_switch_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/edit_proxy_switch_title_description"/>
|
||||
@@ -43,6 +55,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
style="@style/Signal.Text.Preview"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/signal_accent_primary"
|
||||
@@ -53,8 +66,8 @@
|
||||
android:id="@+id/edit_proxy_host"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="-2dp"
|
||||
android:hint="@string/preferences_enter_proxy_address"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_proxy_address_title"
|
||||
tools:hint="https://proxy.parker.org"/>
|
||||
|
||||
@@ -63,6 +76,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
style="@style/Signal.Text.Caption"
|
||||
app:layout_constraintTop_toBottomOf="@id/edit_proxy_host"
|
||||
tools:text="@string/preferences_connected_to_proxy"/>
|
||||
@@ -72,6 +86,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="19dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:text="@string/preferences_share"
|
||||
app:drawableStartCompat="@drawable/symbol_share_android_24"
|
||||
@@ -90,8 +105,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/preferences_save"
|
||||
app:cornerRadius="80dp"
|
||||
|
||||
@@ -11,6 +11,16 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/symbol_arrow_start_24"
|
||||
app:title="@string/BackupsPreferenceFragment__chat_backups" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -25,6 +25,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/symbol_arrow_start_24"
|
||||
app:title="@string/preferences__help" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_fragment_contact"
|
||||
android:layout_width="match_parent"
|
||||
@@ -37,7 +47,7 @@
|
||||
android:textColor="@color/signal_text_secondary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/help_fragment_problem"
|
||||
|
||||
@@ -208,12 +208,12 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/advancedPinSettingsFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.wrapped.WrappedAdvancedPinPreferenceFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.privacy.advanced.AdvancedPrivacySettingsFragment"
|
||||
android:label="advanced_pin_settings_fragment" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/deleteAccountFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.wrapped.WrappedDeleteAccountFragment"
|
||||
android:name="org.thoughtcrime.securesms.delete.DeleteAccountFragment"
|
||||
android:label="delete_account_fragment"
|
||||
tools:layout="@layout/delete_account_fragment" />
|
||||
|
||||
@@ -387,7 +387,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/backupsPreferenceFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.wrapped.WrappedBackupsPreferenceFragment"
|
||||
android:name="org.thoughtcrime.securesms.preferences.BackupsPreferenceFragment"
|
||||
android:label="backups_preference_fragment"
|
||||
tools:layout="@layout/fragment_backups" />
|
||||
|
||||
@@ -504,7 +504,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/editProxyFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.wrapped.WrappedEditProxyFragment"
|
||||
android:name="org.thoughtcrime.securesms.preferences.EditProxyFragment"
|
||||
android:label="edit_proxy_fragment" />
|
||||
|
||||
<!-- endregion -->
|
||||
@@ -539,7 +539,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/helpFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.wrapped.WrappedHelpFragment"
|
||||
android:name="org.thoughtcrime.securesms.help.HelpFragment"
|
||||
android:label="help_fragment">
|
||||
|
||||
<argument
|
||||
|
||||
Reference in New Issue
Block a user