mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-28 10:47:28 +00:00
Improved external answers
This commit is contained in:
parent
bb67c03e21
commit
689638bb3a
3 changed files with 33 additions and 4 deletions
|
@ -35,9 +35,13 @@ import android.widget.Toast;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.constraintlayout.widget.Group;
|
import androidx.constraintlayout.widget.Group;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
public class ActivityAnswer extends ActivityBase {
|
public class ActivityAnswer extends ActivityBase {
|
||||||
|
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "answer");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -55,14 +59,27 @@ public class ActivityAnswer extends ActivityBase {
|
||||||
lvAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
lvAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
|
||||||
|
final Context context = adapterView.getContext();
|
||||||
EntityAnswer answer = (EntityAnswer) adapterView.getAdapter().getItem(pos);
|
EntityAnswer answer = (EntityAnswer) adapterView.getAdapter().getItem(pos);
|
||||||
|
|
||||||
|
executor.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
db.answer().applyAnswer(answer.id, new Date().getTime());
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
String html = answer.getHtml(null);
|
String html = answer.getHtml(null);
|
||||||
String text = HtmlHelper.getText(ActivityAnswer.this, html);
|
String text = HtmlHelper.getText(context, html);
|
||||||
|
|
||||||
ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
cbm.setPrimaryClip(ClipData.newHtmlText(getString(R.string.app_name), text, html));
|
cbm.setPrimaryClip(ClipData.newHtmlText(getString(R.string.app_name), text, html));
|
||||||
ToastEx.makeText(ActivityAnswer.this, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||||
private View view;
|
private View view;
|
||||||
private TextView tvName;
|
private TextView tvName;
|
||||||
private TextView tvGroup;
|
private TextView tvGroup;
|
||||||
|
private ImageView ivExternal;
|
||||||
private ImageView ivStandard;
|
private ImageView ivStandard;
|
||||||
private ImageView ivFavorite;
|
private ImageView ivFavorite;
|
||||||
private ImageView ivReceipt;
|
private ImageView ivReceipt;
|
||||||
|
@ -86,6 +87,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||||
view = itemView.findViewById(R.id.clItem);
|
view = itemView.findViewById(R.id.clItem);
|
||||||
tvName = itemView.findViewById(R.id.tvName);
|
tvName = itemView.findViewById(R.id.tvName);
|
||||||
tvGroup = itemView.findViewById(R.id.tvGroup);
|
tvGroup = itemView.findViewById(R.id.tvGroup);
|
||||||
|
ivExternal = itemView.findViewById(R.id.ivExternal);
|
||||||
ivStandard = itemView.findViewById(R.id.ivStandard);
|
ivStandard = itemView.findViewById(R.id.ivStandard);
|
||||||
ivFavorite = itemView.findViewById(R.id.ivFavorite);
|
ivFavorite = itemView.findViewById(R.id.ivFavorite);
|
||||||
ivReceipt = itemView.findViewById(R.id.ivReceipt);
|
ivReceipt = itemView.findViewById(R.id.ivReceipt);
|
||||||
|
@ -108,6 +110,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
||||||
tvName.setText(answer.name);
|
tvName.setText(answer.name);
|
||||||
tvGroup.setText(answer.group);
|
tvGroup.setText(answer.group);
|
||||||
tvGroup.setVisibility(TextUtils.isEmpty(answer.group) ? View.GONE : View.VISIBLE);
|
tvGroup.setVisibility(TextUtils.isEmpty(answer.group) ? View.GONE : View.VISIBLE);
|
||||||
|
ivExternal.setVisibility(answer.external ? View.VISIBLE : View.GONE);
|
||||||
ivStandard.setVisibility(answer.standard ? View.VISIBLE : View.GONE);
|
ivStandard.setVisibility(answer.standard ? View.VISIBLE : View.GONE);
|
||||||
ivFavorite.setVisibility(answer.favorite ? View.VISIBLE : View.GONE);
|
ivFavorite.setVisibility(answer.favorite ? View.VISIBLE : View.GONE);
|
||||||
ivReceipt.setVisibility(answer.receipt ? View.VISIBLE : View.GONE);
|
ivReceipt.setVisibility(answer.receipt ? View.VISIBLE : View.GONE);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
android:minHeight="24dp"
|
android:minHeight="24dp"
|
||||||
android:text="Name"
|
android:text="Name"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/ivStandard"
|
app:layout_constraintEnd_toStartOf="@+id/ivExternal"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="Group"
|
android:text="Group"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/ivReceipt"
|
app:layout_constraintEnd_toStartOf="@+id/ivExternal"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tvName" />
|
app:layout_constraintTop_toBottomOf="@+id/tvName" />
|
||||||
|
|
||||||
|
@ -61,6 +61,15 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvGroup" />
|
app:layout_constraintTop_toBottomOf="@id/tvGroup" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivExternal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/ivReceipt"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/twotone_open_in_new_24" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivReceipt"
|
android:id="@+id/ivReceipt"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Loading…
Reference in a new issue