Browse Source

feat: change to switch on advance options

main
Distopico Vegan 5 years ago
parent
commit
236d39b168
2 changed files with 68 additions and 67 deletions
  1. +34
    -34
      app/src/main/java/org/dystopia/email/FragmentOptions.java
  2. +34
    -33
      app/src/main/res/layout/fragment_options.xml

+ 34
- 34
app/src/main/java/org/dystopia/email/FragmentOptions.java View File

@ -25,21 +25,21 @@ import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.Switch;
import android.widget.CompoundButton;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class FragmentOptions extends FragmentEx {
private CheckBox cbEnabled;
private CheckBox cbAvatars;
private CheckBox cbLight;
private CheckBox cbBrowse;
private CheckBox cbSwipe;
private CheckBox cbCompact;
private CheckBox cbInsecure;
private CheckBox cbDebug;
private Switch optEnabled;
private Switch optAvatars;
private Switch optLight;
private Switch optBrowse;
private Switch optSwipe;
private Switch optCompact;
private Switch optInsecure;
private Switch optDebug;
@Override
@Nullable
@ -49,21 +49,21 @@ public class FragmentOptions extends FragmentEx {
View view = inflater.inflate(R.layout.fragment_options, container, false);
// Get controls
cbEnabled = view.findViewById(R.id.cbEnabled);
cbAvatars = view.findViewById(R.id.cbAvatars);
cbLight = view.findViewById(R.id.cbLight);
cbBrowse = view.findViewById(R.id.cbBrowse);
cbSwipe = view.findViewById(R.id.cbSwipe);
cbCompact = view.findViewById(R.id.cbCompact);
cbInsecure = view.findViewById(R.id.cbInsecure);
cbDebug = view.findViewById(R.id.cbDebug);
optEnabled = view.findViewById(R.id.optEnabled);
optAvatars = view.findViewById(R.id.optAvatars);
optLight = view.findViewById(R.id.optLight);
optBrowse = view.findViewById(R.id.optBrowse);
optSwipe = view.findViewById(R.id.optSwipe);
optCompact = view.findViewById(R.id.optCompact);
optInsecure = view.findViewById(R.id.optInsecure);
optDebug = view.findViewById(R.id.optDebug);
// Wire controls
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
cbEnabled.setChecked(prefs.getBoolean("enabled", true));
cbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optEnabled.setChecked(prefs.getBoolean("enabled", true));
optEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("enabled", checked).apply();
@ -74,56 +74,56 @@ public class FragmentOptions extends FragmentEx {
}
});
cbAvatars.setChecked(prefs.getBoolean("avatars", true));
cbAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optAvatars.setChecked(prefs.getBoolean("avatars", true));
optAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("avatars", checked).apply();
}
});
cbLight.setChecked(prefs.getBoolean("light", false));
cbLight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optLight.setChecked(prefs.getBoolean("light", false));
optLight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("light", checked).apply();
}
});
cbBrowse.setChecked(prefs.getBoolean("browse", true));
cbBrowse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optBrowse.setChecked(prefs.getBoolean("browse", true));
optBrowse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("browse", checked).apply();
}
});
cbSwipe.setChecked(prefs.getBoolean("swipe", true));
cbSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optSwipe.setChecked(prefs.getBoolean("swipe", true));
optSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("swipe", checked).apply();
}
});
cbCompact.setChecked(prefs.getBoolean("compact", false));
cbCompact.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optCompact.setChecked(prefs.getBoolean("compact", false));
optCompact.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("compact", checked).apply();
}
});
cbInsecure.setChecked(prefs.getBoolean("insecure", false));
cbInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optInsecure.setChecked(prefs.getBoolean("insecure", false));
optInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("insecure", checked).apply();
}
});
cbDebug.setChecked(prefs.getBoolean("debug", false));
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
optDebug.setChecked(prefs.getBoolean("debug", false));
optDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("debug", checked).apply();
@ -131,7 +131,7 @@ public class FragmentOptions extends FragmentEx {
}
});
cbLight.setVisibility(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
optLight.setVisibility(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
return view;
}


+ 34
- 33
app/src/main/res/layout/fragment_options.xml View File

@ -9,11 +9,12 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_margin="12dp">
<CheckBox
android:id="@+id/cbEnabled"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optEnabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
@ -21,74 +22,74 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/cbAvatars"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optAvatars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_avatars"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbEnabled" />
app:layout_constraintTop_toBottomOf="@id/optEnabled" />
<CheckBox
android:id="@+id/cbLight"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optLight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
app:layout_constraintTop_toBottomOf="@id/optAvatars" />
<CheckBox
android:id="@+id/cbBrowse"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optBrowse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_browse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLight" />
app:layout_constraintTop_toBottomOf="@id/optLight" />
<CheckBox
android:id="@+id/cbSwipe"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optSwipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_swipe"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbBrowse" />
app:layout_constraintTop_toBottomOf="@id/optBrowse" />
<CheckBox
android:id="@+id/cbCompact"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optCompact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_compact"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSwipe" />
app:layout_constraintTop_toBottomOf="@id/optSwipe" />
<CheckBox
android:id="@+id/cbInsecure"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optInsecure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_allow_insecure"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbCompact" />
app:layout_constraintTop_toBottomOf="@id/optCompact" />
<CheckBox
android:id="@+id/cbDebug"
android:layout_width="wrap_content"
<Switch
android:id="@+id/optDebug"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_debug"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbInsecure" />
app:layout_constraintTop_toBottomOf="@id/optInsecure" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</ScrollView>

Loading…
Cancel
Save