Options layout improvements

pull/147/head
M66B 7 years ago
parent 693ca7c85f
commit 14a7438fd6

@ -54,23 +54,28 @@ import static android.app.Activity.RESULT_OK;
public class FragmentOptions extends FragmentEx implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptions extends FragmentEx implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swEnabled; private SwitchCompat swEnabled;
private SwitchCompat swMetered; private SwitchCompat swMetered;
private Spinner spDownload;
private SwitchCompat swBrowse;
private SwitchCompat swInsecure;
private SwitchCompat swUnified; private SwitchCompat swUnified;
private SwitchCompat swThreading; private SwitchCompat swThreading;
private SwitchCompat swCompact; private SwitchCompat swCompact;
private SwitchCompat swAvatars; private SwitchCompat swAvatars;
private SwitchCompat swIdenticons; private SwitchCompat swIdenticons;
private SwitchCompat swPreview; private SwitchCompat swPreview;
private SwitchCompat swLight; private SwitchCompat swLight;
private Button btnSound; private Button btnSound;
private SwitchCompat swBrowse;
private SwitchCompat swSwipe; private SwitchCompat swSwipe;
private SwitchCompat swActionbar; private SwitchCompat swActionbar;
private SwitchCompat swAutoclose; private SwitchCompat swAutoclose;
private SwitchCompat swConfirm; private SwitchCompat swConfirm;
private SwitchCompat swSender; private SwitchCompat swSender;
private SwitchCompat swInsecure;
private Spinner spDownload;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
private SwitchCompat swDebug; private SwitchCompat swDebug;
@ -84,23 +89,28 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
// Get controls // Get controls
swEnabled = view.findViewById(R.id.swEnabled); swEnabled = view.findViewById(R.id.swEnabled);
swMetered = view.findViewById(R.id.swMetered); swMetered = view.findViewById(R.id.swMetered);
spDownload = view.findViewById(R.id.spDownload);
swBrowse = view.findViewById(R.id.swBrowse);
swInsecure = view.findViewById(R.id.swInsecure);
swUnified = view.findViewById(R.id.swUnified); swUnified = view.findViewById(R.id.swUnified);
swThreading = view.findViewById(R.id.swThreading); swThreading = view.findViewById(R.id.swThreading);
swCompact = view.findViewById(R.id.swCompact); swCompact = view.findViewById(R.id.swCompact);
swAvatars = view.findViewById(R.id.swAvatars); swAvatars = view.findViewById(R.id.swAvatars);
swIdenticons = view.findViewById(R.id.swIdenticons); swIdenticons = view.findViewById(R.id.swIdenticons);
swPreview = view.findViewById(R.id.swPreview); swPreview = view.findViewById(R.id.swPreview);
swLight = view.findViewById(R.id.swLight); swLight = view.findViewById(R.id.swLight);
btnSound = view.findViewById(R.id.btnSound); btnSound = view.findViewById(R.id.btnSound);
swBrowse = view.findViewById(R.id.swBrowse);
swSwipe = view.findViewById(R.id.swSwipe); swSwipe = view.findViewById(R.id.swSwipe);
swActionbar = view.findViewById(R.id.swActionbar); swActionbar = view.findViewById(R.id.swActionbar);
swAutoclose = view.findViewById(R.id.swAutoclose); swAutoclose = view.findViewById(R.id.swAutoclose);
swConfirm = view.findViewById(R.id.swConfirm); swConfirm = view.findViewById(R.id.swConfirm);
swSender = view.findViewById(R.id.swSender); swSender = view.findViewById(R.id.swSender);
swInsecure = view.findViewById(R.id.swInsecure);
spDownload = view.findViewById(R.id.spDownload);
swUpdates = view.findViewById(R.id.swUpdates); swUpdates = view.findViewById(R.id.swUpdates);
swDebug = view.findViewById(R.id.swDebug); swDebug = view.findViewById(R.id.swDebug);
@ -126,6 +136,41 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
} }
}); });
int download = prefs.getInt("download", 32768);
final int[] values = getResources().getIntArray(R.array.downloadValues);
for (int i = 0; i < values.length; i++)
if (values[i] == download) {
spDownload.setSelection(i);
break;
}
spDownload.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
prefs.edit().putInt("download", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("download").apply();
}
});
swBrowse.setChecked(prefs.getBoolean("browse", true));
swBrowse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("browse", checked).apply();
}
});
swInsecure.setChecked(prefs.getBoolean("insecure", false));
swInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("insecure", checked).apply();
}
});
swUnified.setChecked(prefs.getBoolean("unified", true)); swUnified.setChecked(prefs.getBoolean("unified", true));
swUnified.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swUnified.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -229,14 +274,6 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
} }
}); });
swBrowse.setChecked(prefs.getBoolean("browse", true));
swBrowse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("browse", checked).apply();
}
});
swSwipe.setChecked(prefs.getBoolean("swipe", true)); swSwipe.setChecked(prefs.getBoolean("swipe", true));
swSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -277,33 +314,6 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
} }
}); });
swInsecure.setChecked(prefs.getBoolean("insecure", false));
swInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("insecure", checked).apply();
}
});
int download = prefs.getInt("download", 32768);
final int[] values = getResources().getIntArray(R.array.downloadValues);
for (int i = 0; i < values.length; i++)
if (values[i] == download) {
spDownload.setSelection(i);
break;
}
spDownload.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
prefs.edit().putInt("download", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("download").apply();
}
});
swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override

@ -20,6 +20,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparator1"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swEnabled" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swMetered" android:id="@+id/swMetered"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -27,7 +37,65 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_metered" android:text="@string/title_advanced_metered"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swEnabled" /> app:layout_constraintTop_toBottomOf="@id/vSeparator1" />
<TextView
android:id="@+id/tvDownload"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_download"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toStartOf="@+id/spDownload"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMetered" />
<Spinner
android:id="@+id/spDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:entries="@array/downloadNames"
app:layout_constraintBottom_toBottomOf="@id/tvDownload"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tvDownload"
app:layout_constraintTop_toTopOf="@id/tvDownload" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="tvDownload,spDownload" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBrowse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_browse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier1" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swInsecure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_allow_insecure"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBrowse" />
<View
android:id="@+id/vSeparator2"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swInsecure" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUnified" android:id="@+id/swUnified"
@ -36,7 +104,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_unified" android:text="@string/title_advanced_unified"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMetered" /> app:layout_constraintTop_toBottomOf="@id/vSeparator2" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swThreading" android:id="@+id/swThreading"
@ -83,6 +151,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swIdenticons" /> app:layout_constraintTop_toBottomOf="@id/swIdenticons" />
<View
android:id="@+id/vSeparator3"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPreview" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLight" android:id="@+id/swLight"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -90,7 +168,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_light" android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPreview" /> app:layout_constraintTop_toBottomOf="@id/vSeparator3" />
<Button <Button
android:id="@+id/btnSound" android:id="@+id/btnSound"
@ -104,12 +182,13 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLight" /> app:layout_constraintTop_toBottomOf="@id/swLight" />
<androidx.appcompat.widget.SwitchCompat <View
android:id="@+id/swBrowse" android:id="@+id/vSeparator4"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_browse" android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnSound" /> app:layout_constraintTop_toBottomOf="@id/btnSound" />
@ -120,7 +199,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_swipe" android:text="@string/title_advanced_swipe"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBrowse" /> app:layout_constraintTop_toBottomOf="@id/vSeparator4" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swActionbar" android:id="@+id/swActionbar"
@ -164,40 +243,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/title_advanced_sender_hint" android:text="@string/title_advanced_sender_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSender" /> app:layout_constraintTop_toBottomOf="@id/swSender" />
<androidx.appcompat.widget.SwitchCompat <View
android:id="@+id/swInsecure" android:id="@+id/vSeparator5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_allow_insecure"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSender" />
<TextView
android:id="@+id/tvDownload"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_download" android:background="?attr/colorSeparator"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toStartOf="@+id/spDownload"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swInsecure" />
<Spinner
android:id="@+id/spDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:entries="@array/downloadNames"
app:layout_constraintBottom_toBottomOf="@id/tvDownload"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tvDownload" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tvDownload" /> app:layout_constraintTop_toBottomOf="@id/tvSender" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUpdates" android:id="@+id/swUpdates"
@ -206,7 +264,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_updates" android:text="@string/title_advanced_updates"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDownload" /> app:layout_constraintTop_toBottomOf="@id/vSeparator5" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDebug" android:id="@+id/swDebug"
@ -217,4 +275,4 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUpdates" /> app:layout_constraintTop_toBottomOf="@id/swUpdates" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

Loading…
Cancel
Save