mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 23:56:07 +02:00
Add send via dialog
This commit is contained in:
@@ -811,6 +811,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
args.putString("action", a.getString("action"));
|
||||
args.putLong("id", a.getLong("id", -1));
|
||||
args.putLong("account", a.getLong("account", -1));
|
||||
args.putLong("identity", a.getLong("identity", -1));
|
||||
args.putLong("reference", a.getLong("reference", -1));
|
||||
args.putSerializable("ics", a.getSerializable("ics"));
|
||||
args.putString("status", a.getString("status"));
|
||||
@@ -827,9 +828,6 @@ public class FragmentCompose extends FragmentBase {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("action", "edit");
|
||||
args.putLong("id", working);
|
||||
args.putLong("account", -1);
|
||||
args.putLong("reference", -1);
|
||||
args.putLong("answer", -1);
|
||||
draftLoader.execute(this, args, "compose:edit");
|
||||
}
|
||||
} else {
|
||||
@@ -840,9 +838,6 @@ public class FragmentCompose extends FragmentBase {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("action", working < 0 ? "new" : "edit");
|
||||
args.putLong("id", working);
|
||||
args.putLong("account", -1);
|
||||
args.putLong("reference", -1);
|
||||
args.putLong("answer", -1);
|
||||
draftLoader.execute(this, args, "compose:instance");
|
||||
}
|
||||
}
|
||||
@@ -2297,16 +2292,25 @@ public class FragmentCompose extends FragmentBase {
|
||||
Address from = null;
|
||||
EntityIdentity selected = null;
|
||||
long aid = args.getLong("account", -1);
|
||||
long iid = args.getLong("identity", -1);
|
||||
|
||||
if (iid >= 0)
|
||||
for (EntityIdentity identity : data.identities)
|
||||
if (identity.id.equals(iid)) {
|
||||
selected = identity;
|
||||
break;
|
||||
}
|
||||
|
||||
if (data.draft.from != null && data.draft.from.length > 0) {
|
||||
for (Address sender : data.draft.from)
|
||||
for (EntityIdentity identity : data.identities)
|
||||
if (identity.account.equals(aid) &&
|
||||
identity.sameAddress(sender)) {
|
||||
from = sender;
|
||||
selected = identity;
|
||||
break;
|
||||
}
|
||||
if (selected == null)
|
||||
for (Address sender : data.draft.from)
|
||||
for (EntityIdentity identity : data.identities)
|
||||
if (identity.account.equals(aid) &&
|
||||
identity.sameAddress(sender)) {
|
||||
from = sender;
|
||||
selected = identity;
|
||||
break;
|
||||
}
|
||||
|
||||
if (selected == null)
|
||||
for (Address sender : data.draft.from)
|
||||
|
||||
@@ -66,11 +66,13 @@ import android.view.animation.TranslateAnimation;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -751,10 +753,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
fabCompose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", account)
|
||||
);
|
||||
boolean identities_asked = prefs.getBoolean("identities_asked", false);
|
||||
if (identities_asked)
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", account)
|
||||
);
|
||||
else {
|
||||
FragmentDialogIdentity fragment = new FragmentDialogIdentity();
|
||||
fragment.show(getFragmentManager(), "messages:identities");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4580,8 +4588,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("crash_reports", true).apply();
|
||||
Log.setCrashReporting(true);
|
||||
}
|
||||
})
|
||||
@@ -4629,6 +4635,93 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogIdentity extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_identity, null);
|
||||
ListView lvIdentity = dview.findViewById(R.id.lvIdentity);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
Button btnFix = dview.findViewById(R.id.btnFix);
|
||||
Group grpIdentities = dview.findViewById(R.id.grpIdentities);
|
||||
Group grpNoIdentities = dview.findViewById(R.id.grpNoIdentities);
|
||||
ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
||||
|
||||
lvIdentity.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TupleIdentityEx identity = (TupleIdentityEx) lvIdentity.getAdapter().getItem(position);
|
||||
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", identity.account)
|
||||
.putExtra("identity", identity.id)
|
||||
);
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("identities_asked", isChecked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
btnFix.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), ActivitySetup.class));
|
||||
getActivity().finish();
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
grpIdentities.setVisibility(View.GONE);
|
||||
grpNoIdentities.setVisibility(View.GONE);
|
||||
|
||||
new SimpleTask<List<TupleIdentityEx>>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bundle args) {
|
||||
pbWait.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
||||
DB db = DB.getInstance(getContext());
|
||||
return db.identity().getComposableIdentities(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, List<TupleIdentityEx> identities) {
|
||||
AdapterIdentitySelect iadapter = new AdapterIdentitySelect(getContext(), identities);
|
||||
lvIdentity.setAdapter(iadapter);
|
||||
|
||||
grpIdentities.setVisibility(identities.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
grpNoIdentities.setVisibility(identities.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getFragmentManager(), ex);
|
||||
}
|
||||
}.execute(this, new Bundle(), "identity:select");
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogError extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
"welcome", "show_html_confirmed", "print_html_confirmed", "delete_ref_confirmed", "edit_ref_confirmed", "crash_reports_asked"
|
||||
"welcome", "crash_reports_asked",
|
||||
"show_html_confirmed", "print_html_confirmed",
|
||||
"identities_asked", "edit_ref_confirmed", "delete_ref_confirmed"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
76
app/src/main/res/layout/dialog_identity.xml
Normal file
76
app/src/main/res/layout/dialog_identity.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvIdentity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_send_via"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbWait"
|
||||
style="@style/Base.Widget.AppCompat.ProgressBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
android:padding="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvIdentity" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lvIdentity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/pbWait" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNotAgain"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_no_ask_again"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/lvIdentity" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNoIdenties"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/title_no_identities"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFix"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_fix"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNoIdenties" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpIdentities"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="lvIdentity,cbNotAgain" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpNoIdentities"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvNoIdenties,btnFix" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -572,6 +572,7 @@
|
||||
<string name="title_discard">Discard</string>
|
||||
<string name="title_save">Save</string>
|
||||
<string name="title_send">Send</string>
|
||||
<string name="title_send_via">Send via</string>
|
||||
<string name="title_send_with_options">Send …</string>
|
||||
<string name="title_send_at">Send at …</string>
|
||||
<string name="title_no_server">No server found at \'%1$s\'</string>
|
||||
|
||||
Reference in New Issue
Block a user