Browse Source

improve account color dialog

main
Distopico Vegan 4 years ago
parent
commit
a15f6106ae
No known key found for this signature in database GPG Key ID: 98093A8072546BF3
7 changed files with 35 additions and 42 deletions
  1. +6
    -2
      app/src/main/java/org/dystopia/email/ColorDialogFragment.java
  2. +4
    -16
      app/src/main/java/org/dystopia/email/FragmentAccount.java
  3. +1
    -0
      app/src/main/java/org/dystopia/email/ViewButtonColor.java
  4. +19
    -24
      app/src/main/res/layout/fragment_account.xml
  5. +1
    -0
      app/src/main/res/values-en/strings.xml
  6. +3
    -0
      app/src/main/res/values-es-rES/strings.xml
  7. +1
    -0
      app/src/main/res/values/strings.xml

+ 6
- 2
app/src/main/java/org/dystopia/email/ColorDialogFragment.java View File

@ -64,6 +64,7 @@ public class ColorDialogFragment extends DialogFragment {
color = savedInstanceState == null ? args.getInt("color") : savedInstanceState.getInt("dialog:color"); color = savedInstanceState == null ? args.getInt("color") : savedInstanceState.getInt("dialog:color");
String title = args.getString("title"); String title = args.getString("title");
boolean reset = args.getBoolean("reset", false); boolean reset = args.getBoolean("reset", false);
boolean hasColor = color != Color.TRANSPARENT;
Context context = getContext(); Context context = getContext();
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor); int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
@ -90,12 +91,15 @@ public class ColorDialogFragment extends DialogFragment {
} }
}); });
if (color != Color.TRANSPARENT) {
if (!hasColor) {
builder.initialColor(Helper.resolveColor(getContext(), android.R.attr.colorPrimary));
} else {
builder.initialColor(color); builder.initialColor(color);
} }
if (reset) { if (reset) {
builder.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
int negativeText = !hasColor ? R.string.title_cancel : R.string.title_reset;
builder.setNegativeButton(negativeText, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
getArguments().putInt("color", Color.TRANSPARENT); getArguments().putInt("color", Color.TRANSPARENT);


+ 4
- 16
app/src/main/java/org/dystopia/email/FragmentAccount.java View File

@ -34,7 +34,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -54,14 +53,13 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentResultListener; import androidx.fragment.app.FragmentResultListener;
@ -109,7 +107,7 @@ public class FragmentAccount extends FragmentEx {
private EditText etName; private EditText etName;
private ViewButtonColor btnColor; private ViewButtonColor btnColor;
private ImageView ibColorReset;
private LinearLayout llContainerColor;
private EditText etSignature; private EditText etSignature;
private CheckBox cbSynchronize; private CheckBox cbSynchronize;
@ -178,6 +176,7 @@ public class FragmentAccount extends FragmentEx {
btnAutoConfig = view.findViewById(R.id.btnAutoConfig); btnAutoConfig = view.findViewById(R.id.btnAutoConfig);
etHost = view.findViewById(R.id.etHost); etHost = view.findViewById(R.id.etHost);
llContainerColor = view.findViewById(R.id.llContainerColor);
etPort = view.findViewById(R.id.etPort); etPort = view.findViewById(R.id.etPort);
cbStartTls = view.findViewById(R.id.cbStartTls); cbStartTls = view.findViewById(R.id.cbStartTls);
cbInsecure = view.findViewById(R.id.cbInsecure); cbInsecure = view.findViewById(R.id.cbInsecure);
@ -190,7 +189,6 @@ public class FragmentAccount extends FragmentEx {
etName = view.findViewById(R.id.etName); etName = view.findViewById(R.id.etName);
btnColor = view.findViewById(R.id.btnColor); btnColor = view.findViewById(R.id.btnColor);
tvName = view.findViewById(R.id.tvName); tvName = view.findViewById(R.id.tvName);
ibColorReset = view.findViewById(R.id.ibColorReset);
etSignature = view.findViewById(R.id.etSignature); etSignature = view.findViewById(R.id.etSignature);
cbSynchronize = view.findViewById(R.id.cbSynchronize); cbSynchronize = view.findViewById(R.id.cbSynchronize);
@ -377,7 +375,7 @@ public class FragmentAccount extends FragmentEx {
}); });
btnColor.setColor(color); btnColor.setColor(color);
btnColor.setOnClickListener(
llContainerColor.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -392,15 +390,6 @@ public class FragmentAccount extends FragmentEx {
} }
}); });
ibColorReset.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
btnColor.setColor(Color.TRANSPARENT);
ibColorReset.setVisibility(View.GONE);
}
});
cbSynchronize.setOnCheckedChangeListener( cbSynchronize.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() { new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -1101,7 +1090,6 @@ public class FragmentAccount extends FragmentEx {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
color = result.getInt("color"); color = result.getInt("color");
btnColor.setColor(color); btnColor.setColor(color);
ibColorReset.setVisibility(View.VISIBLE);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, "Set account color error: " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, "Set account color error: " + ex + "\n" + Log.getStackTraceString(ex));


+ 1
- 0
app/src/main/java/org/dystopia/email/ViewButtonColor.java View File

@ -68,6 +68,7 @@ public class ViewButtonColor extends AppCompatButton {
background.setStroke( background.setStroke(
ViewHelper.dp2px(getContext(), 1), ViewHelper.dp2px(getContext(), 1),
Helper.resolveColor(getContext(), R.attr.colorSeparator)); Helper.resolveColor(getContext(), R.attr.colorSeparator));
background.setCornerRadius(50);
setBackground(background); setBackground(background);
if (color == Color.TRANSPARENT) if (color == Color.TRANSPARENT)


+ 19
- 24
app/src/main/res/layout/fragment_account.xml View File

@ -221,39 +221,34 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<LinearLayout <LinearLayout
android:id="@+id/colorContainer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword">
<org.dystopia.email.ViewButtonColor
android:id="@+id/btnColor"
style="?android:attr/buttonStyleSmall"
android:layout_width="@dimen/color_pick"
android:layout_height="@dimen/color_pick"
android:layout_marginStart="@dimen/margin_sm"
android:background="@color/colorAccent"
android:tag="disable" />
android:id="@+id/llContainerColor"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tilPassword">
<TextView <TextView
android:id="@+id/tvColor" android:id="@+id/tvColor"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/padding_sm"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/title_account_color" android:text="@string/title_account_color"
android:textAppearance="@style/TextAppearance.AppCompat.Small" /> android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<ImageView
android:id="@+id/ibColorReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<org.dystopia.email.ViewButtonColor
android:id="@+id/btnColor"
android:clickable="false"
android:focusable="false"
android:layout_width="@dimen/color_pick"
android:layout_height="@dimen/color_pick"
android:layout_marginEnd="@dimen/margin_sm"
android:layout_gravity="right" android:layout_gravity="right"
android:src="@drawable/baseline_close_24"
android:visibility="invisible" />
android:background="@color/colorAccent"
android:tag="disable" />
</LinearLayout> </LinearLayout>
<Button <Button
@ -266,7 +261,7 @@
android:minHeight="0dp" android:minHeight="0dp"
android:text="@string/title_setup_advanced" android:text="@string/title_setup_advanced"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/colorContainer" />
app:layout_constraintTop_toBottomOf="@id/llContainerColor" />
<!-- advanced --> <!-- advanced -->


+ 1
- 0
app/src/main/res/values-en/strings.xml View File

@ -262,4 +262,5 @@
<string name="title_no_identities_yet">You don\'t have identities configured yet</string> <string name="title_no_identities_yet">You don\'t have identities configured yet</string>
<string name="title_reset">Reset</string> <string name="title_reset">Reset</string>
<string name="title_color">Color</string> <string name="title_color">Color</string>
<string name="title_cancel">Cancel</string>
</resources> </resources>

+ 3
- 0
app/src/main/res/values-es-rES/strings.xml View File

@ -262,4 +262,7 @@
<string name="title_show_details">Ver detalles</string> <string name="title_show_details">Ver detalles</string>
<string name="title_no_accounts_yet">Aún no tienes cuentas configuradas</string> <string name="title_no_accounts_yet">Aún no tienes cuentas configuradas</string>
<string name="title_no_identities_yet">Aún no tienes identidades configuradas</string> <string name="title_no_identities_yet">Aún no tienes identidades configuradas</string>
<string name="title_reset">Reiniciar</string>
<string name="title_color">Color</string>
<string name="title_cancel">Cancelar</string>
</resources> </resources>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -329,4 +329,5 @@
<string name="title_no_identities_yet">You don\'t have identities configured yet</string> <string name="title_no_identities_yet">You don\'t have identities configured yet</string>
<string name="title_reset">Reset</string> <string name="title_reset">Reset</string>
<string name="title_color">Color</string> <string name="title_color">Color</string>
<string name="title_cancel">Cancel</string>
</resources> </resources>

Loading…
Cancel
Save