mirror of https://github.com/M66B/FairEmail.git
parent
b4ca7c6df6
commit
ec35b51ef5
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,113 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of FairEmail.
|
||||||
|
|
||||||
|
FairEmail is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FairEmail is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.constraintlayout.widget.Group;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ActivityAnswer extends ActivityBase {
|
||||||
|
@Override
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
getSupportActionBar().setSubtitle(getString(R.string.app_answer));
|
||||||
|
|
||||||
|
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
|
||||||
|
setContentView(view);
|
||||||
|
|
||||||
|
ListView lvAnswer = view.findViewById(R.id.lvAnswer);
|
||||||
|
Group grpReady = view.findViewById(R.id.grpReady);
|
||||||
|
ContentLoadingProgressBar pbWait = view.findViewById(R.id.pbWait);
|
||||||
|
|
||||||
|
lvAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
|
||||||
|
EntityAnswer answer = (EntityAnswer) adapterView.getAdapter().getItem(pos);
|
||||||
|
|
||||||
|
String html = answer.getText(null);
|
||||||
|
String text = HtmlHelper.getText(ActivityAnswer.this, 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();
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if (intent != null) {
|
||||||
|
boolean readonly = intent.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);
|
||||||
|
if (!readonly) {
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra(Intent.EXTRA_PROCESS_TEXT, text);
|
||||||
|
setResult(RESULT_OK, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
new SimpleTask<List<EntityAnswer>>() {
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute(Bundle args) {
|
||||||
|
grpReady.setVisibility(View.GONE);
|
||||||
|
pbWait.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Bundle args) {
|
||||||
|
grpReady.setVisibility(View.VISIBLE);
|
||||||
|
pbWait.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<EntityAnswer> onExecute(Context context, Bundle args) throws Throwable {
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
return db.answer().getAnswersExternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
|
||||||
|
ArrayAdapter<EntityAnswer> adapter = new ArrayAdapter<EntityAnswer>(ActivityAnswer.this,
|
||||||
|
android.R.layout.simple_list_item_1, answers);
|
||||||
|
lvAnswer.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Log.unexpectedError(getSupportFragmentManager(), ex);
|
||||||
|
}
|
||||||
|
}.execute(this, new Bundle(), "answers");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="eu.faircode.email.ActivityAnswer">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/lvAnswer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Group
|
||||||
|
android:id="@+id/grpReady"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:constraint_referenced_ids="lvAnswer" />
|
||||||
|
|
||||||
|
<eu.faircode.email.ContentLoadingProgressBar
|
||||||
|
android:id="@+id/pbWait"
|
||||||
|
style="@style/Base.Widget.AppCompat.ProgressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in new issue