1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-24 16:53:37 +00:00

Layout improvements

This commit is contained in:
M66B 2018-09-07 12:34:54 +00:00
parent b948eb45a9
commit 8c2efa2486
7 changed files with 130 additions and 43 deletions

View file

@ -29,10 +29,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Paint;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -50,7 +50,6 @@ import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.snackbar.Snackbar;
@ -90,8 +89,8 @@ public class FragmentAccount extends FragmentEx {
private TextInputLayout tilPassword;
private Button btnAdvanced;
private EditText etName;
private TextView tvSignaturePro;
private EditText etSignature;
private ImageButton ibPro;
private CheckBox cbSynchronize;
private CheckBox cbPrimary;
private Button btnCheck;
@ -140,8 +139,9 @@ public class FragmentAccount extends FragmentEx {
btnAdvanced = view.findViewById(R.id.btnAdvanced);
etName = view.findViewById(R.id.etName);
tvSignaturePro = view.findViewById(R.id.tvSignaturePro);
etSignature = view.findViewById(R.id.etSignature);
ibPro = view.findViewById(R.id.ibPro);
cbSynchronize = view.findViewById(R.id.cbSynchronize);
cbPrimary = view.findViewById(R.id.cbPrimary);
@ -248,8 +248,7 @@ public class FragmentAccount extends FragmentEx {
}
});
tvSignaturePro.setPaintFlags(tvSignaturePro.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvSignaturePro.setOnClickListener(new View.OnClickListener() {
ibPro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
@ -803,6 +802,16 @@ public class FragmentAccount extends FragmentEx {
Helper.setViewsEnabled(view, true);
boolean pro = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pro", false);
etSignature.setHint(pro ? R.string.title_optional : R.string.title_pro_feature);
etSignature.setEnabled(pro);
if (pro) {
ViewGroup.LayoutParams lp = ibPro.getLayoutParams();
lp.height = 0;
lp.width = 0;
ibPro.setLayoutParams(lp);
}
cbPrimary.setEnabled(cbSynchronize.isChecked());
// Consider previous check/save/delete as cancelled

View file

@ -26,6 +26,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
@ -38,10 +39,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.util.List;
@ -67,10 +68,12 @@ public class FragmentSetup extends FragmentEx {
private Button btnData;
private CheckBox cbDarkTheme;
private ToggleButton tbDarkTheme;
private Button btnOptions;
private Drawable check;
private static final String[] permissions = new String[]{
Manifest.permission.READ_CONTACTS
};
@ -80,6 +83,8 @@ public class FragmentSetup extends FragmentEx {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(R.string.title_setup);
check = getResources().getDrawable(R.drawable.baseline_check_24, getContext().getTheme());
View view = inflater.inflate(R.layout.fragment_setup, container, false);
// Get controls
@ -97,7 +102,7 @@ public class FragmentSetup extends FragmentEx {
btnData = view.findViewById(R.id.btnData);
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
tbDarkTheme = view.findViewById(R.id.tbDarkTheme);
btnOptions = view.findViewById(R.id.btnOptions);
// Wire controls
@ -165,14 +170,14 @@ public class FragmentSetup extends FragmentEx {
String theme = prefs.getString("theme", "light");
boolean dark = "dark".equals(theme);
cbDarkTheme.setTag(dark);
cbDarkTheme.setChecked(dark);
cbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
tbDarkTheme.setTag(dark);
tbDarkTheme.setChecked(dark);
tbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton button, boolean checked) {
if (checked != (Boolean) button.getTag()) {
button.setTag(checked);
cbDarkTheme.setChecked(checked);
tbDarkTheme.setChecked(checked);
prefs.edit().putString("theme", checked ? "dark" : "light").apply();
}
}
@ -190,11 +195,19 @@ public class FragmentSetup extends FragmentEx {
// Initialize
tvAccountDone.setText(null);
tvAccountDone.setCompoundDrawables(null, null, null, null);
btnIdentity.setEnabled(false);
tvIdentityDone.setText(null);
tvIdentityDone.setCompoundDrawables(null, null, null, null);
tvPermissionsDone.setText(null);
tvPermissionsDone.setCompoundDrawables(null, null, null, null);
btnDoze.setEnabled(false);
tvDozeDone.setText(null);
tvDozeDone.setCompoundDrawables(null, null, null, null);
btnData.setVisibility(View.GONE);
int[] grantResults = new int[permissions.length];
@ -247,15 +260,19 @@ public class FragmentSetup extends FragmentEx {
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
@Override
public void onChanged(@Nullable List<EntityAccount> accounts) {
btnIdentity.setEnabled(accounts != null && accounts.size() > 0);
tvAccountDone.setText(accounts != null && accounts.size() > 0 ? R.string.title_setup_done : R.string.title_setup_to_do);
boolean done = (accounts != null && accounts.size() > 0);
btnIdentity.setEnabled(done);
tvAccountDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do);
tvAccountDone.setCompoundDrawablesWithIntrinsicBounds(done ? check : null, null, null, null);
}
});
db.identity().liveIdentities(true).observe(getViewLifecycleOwner(), new Observer<List<EntityIdentity>>() {
@Override
public void onChanged(@Nullable List<EntityIdentity> identities) {
tvIdentityDone.setText(identities != null && identities.size() > 0 ? R.string.title_setup_done : R.string.title_setup_to_do);
boolean done = (identities != null && identities.size() > 0);
tvIdentityDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do);
tvIdentityDone.setCompoundDrawablesWithIntrinsicBounds(done ? check : null, null, null, null);
}
});
}
@ -268,6 +285,7 @@ public class FragmentSetup extends FragmentEx {
boolean ignoring = pm.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID);
btnDoze.setEnabled(!ignoring);
tvDozeDone.setText(ignoring ? R.string.title_setup_done : R.string.title_setup_to_do);
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds(ignoring ? check : null, null, null, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
ConnectivityManager cm = getContext().getSystemService(ConnectivityManager.class);
@ -287,5 +305,6 @@ public class FragmentSetup extends FragmentEx {
btnPermissions.setEnabled(!has);
tvPermissionsDone.setText(has ? R.string.title_setup_done : R.string.title_setup_to_do);
tvPermissionsDone.setCompoundDrawablesWithIntrinsicBounds(has ? check : null, null, null, null);
}
}

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>

View file

@ -209,25 +209,26 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
<TextView
android:id="@+id/tvSignaturePro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSignature" />
<EditText
android:id="@+id/etSignature"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/title_optional"
android:inputType="textCapSentences|textMultiLine"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/ibPro"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSignaturePro" />
app:layout_constraintTop_toBottomOf="@id/tvSignature" />
<ImageButton
android:id="@+id/ibPro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:src="@drawable/baseline_info_24"
app:layout_constraintBottom_toBottomOf="@id/etSignature"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/etSignature" />
<CheckBox
android:id="@+id/cbSynchronize"
@ -427,7 +428,7 @@
android:id="@+id/grpAdvanced"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvName,etName,tvSignature,tvSignaturePro,etSignature,cbSynchronize,cbPrimary" />
app:constraint_referenced_ids="tvName,etName,tvSignature,etSignature,ibPro,cbSynchronize,cbPrimary" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpFolders"

View file

@ -37,6 +37,7 @@
android:id="@+id/tvAccountDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/baseline_check_24"
android:text="@string/title_setup_done"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
@ -44,17 +45,26 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
<View
android:id="@+id/vSeparatorAccount"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="9dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccountDone" />
<!-- identity -->
<Button
android:id="@+id/btnIdentity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginTop="9dp"
android:text="@string/title_setup_identity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccountDone" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorAccount" />
<TextView
android:id="@+id/tvIdentity"
@ -70,6 +80,7 @@
android:id="@+id/tvIdentityDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/baseline_check_24"
android:text="@string/title_setup_done"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
@ -77,17 +88,26 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvIdentity" />
<View
android:id="@+id/vSeparatorIdentity"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="9dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvIdentityDone" />
<!-- permissions -->
<Button
android:id="@+id/btnPermissions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginTop="9dp"
android:text="@string/title_setup_permissions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvIdentityDone" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorIdentity" />
<TextView
android:id="@+id/tvPermissions"
@ -103,24 +123,34 @@
android:id="@+id/tvPermissionsDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_setup_to_do"
android:drawableStart="@drawable/baseline_check_24"
android:text="@string/title_setup_done"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPermissions" />
<View
android:id="@+id/vSeparatorPermissions"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="9dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPermissionsDone" />
<!-- doze -->
<Button
android:id="@+id/btnDoze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginTop="9dp"
android:text="@string/title_setup_doze"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPermissionsDone" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorPermissions" />
<TextView
android:id="@+id/tvDoze"
@ -136,13 +166,23 @@
android:id="@+id/tvDozeDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_setup_to_do"
android:drawableStart="@drawable/baseline_check_24"
android:text="@string/title_setup_done"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDoze" />
<View
android:id="@+id/vSeparatorDoze"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="9dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDozeDone" />
<!-- data saver -->
<Button
@ -150,20 +190,21 @@
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginTop="9dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:text="@string/title_setup_data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDozeDone" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorDoze" />
<CheckBox
android:id="@+id/cbDarkTheme"
<ToggleButton
android:id="@+id/tbDarkTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:text="@string/title_setup_dark_theme"
android:textOff="@string/title_setup_dark_theme"
android:textOn="@string/title_setup_light_theme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnData" />
@ -179,6 +220,6 @@
android:text="@string/title_advanced"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbDarkTheme" />
app:layout_constraintTop_toBottomOf="@id/tbDarkTheme" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View file

@ -68,6 +68,7 @@
<string name="title_setup_permissions_remark">To autocomplete addresses (optional)</string>
<string name="title_setup_to_do">To do</string>
<string name="title_setup_done">Done</string>
<string name="title_setup_light_theme">Light theme</string>
<string name="title_setup_dark_theme">Dark theme</string>
<string name="title_advanced">Advanced options</string>

View file

@ -26,6 +26,7 @@
<item name="android:checkboxStyle">@style/checkboxStyle</item>
<item name="android:buttonStyle">@style/buttonStyle</item>
<item name="android:buttonStyleSmall">@style/buttonStyleSmall</item>
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
</style>
<style name="AppThemeDark" parent="Base.Theme.AppCompat">
@ -47,6 +48,7 @@
<item name="android:checkboxStyle">@style/checkboxStyle</item>
<item name="android:buttonStyle">@style/buttonStyle</item>
<item name="android:buttonStyleSmall">@style/buttonStyleSmall</item>
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
</style>
<style name="Theme.Transparent" parent="Base.Theme.AppCompat">
@ -70,4 +72,8 @@
<style name="buttonStyleSmall" parent="Base.Widget.AppCompat.Button.Small">
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Small</item>
</style>
<style name="buttonStyleToggle" parent="Base.Widget.AppCompat.Button">
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Medium</item>
</style>
</resources>