mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 18:27:43 +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.constraintlayout.widget.Group;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class ActivityAnswer extends ActivityBase {
|
||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "answer");
|
||||
|
||||
@Override
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -55,14 +59,27 @@ public class ActivityAnswer extends ActivityBase {
|
|||
lvAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
|
||||
final Context context = adapterView.getContext();
|
||||
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 text = HtmlHelper.getText(ActivityAnswer.this, html);
|
||||
String text = HtmlHelper.getText(context, html);
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
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();
|
||||
if (intent != null) {
|
||||
|
|
|
@ -72,6 +72,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
private View view;
|
||||
private TextView tvName;
|
||||
private TextView tvGroup;
|
||||
private ImageView ivExternal;
|
||||
private ImageView ivStandard;
|
||||
private ImageView ivFavorite;
|
||||
private ImageView ivReceipt;
|
||||
|
@ -86,6 +87,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
view = itemView.findViewById(R.id.clItem);
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
tvGroup = itemView.findViewById(R.id.tvGroup);
|
||||
ivExternal = itemView.findViewById(R.id.ivExternal);
|
||||
ivStandard = itemView.findViewById(R.id.ivStandard);
|
||||
ivFavorite = itemView.findViewById(R.id.ivFavorite);
|
||||
ivReceipt = itemView.findViewById(R.id.ivReceipt);
|
||||
|
@ -108,6 +110,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
tvName.setText(answer.name);
|
||||
tvGroup.setText(answer.group);
|
||||
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);
|
||||
ivFavorite.setVisibility(answer.favorite ? View.VISIBLE : View.GONE);
|
||||
ivReceipt.setVisibility(answer.receipt ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
android:minHeight="24dp"
|
||||
android:text="Name"
|
||||
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_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
|||
android:maxLines="1"
|
||||
android:text="Group"
|
||||
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_constraintTop_toBottomOf="@+id/tvName" />
|
||||
|
||||
|
@ -61,6 +61,15 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
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
|
||||
android:id="@+id/ivReceipt"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue