mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-26 16:03:18 +00:00
Handle new DSN intent
This commit is contained in:
parent
43af1a68f7
commit
e79a003063
1 changed files with 29 additions and 10 deletions
|
@ -22,6 +22,7 @@ package eu.faircode.email;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -34,10 +35,15 @@ import androidx.constraintlayout.widget.Group;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class ActivityDSN extends ActivityBase {
|
public class ActivityDSN extends ActivityBase {
|
||||||
|
private TextView tvHeaders;
|
||||||
|
private ContentLoadingProgressBar pbWait;
|
||||||
|
private Group grpReady;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -45,25 +51,35 @@ public class ActivityDSN extends ActivityBase {
|
||||||
getSupportActionBar().setSubtitle("DSN");
|
getSupportActionBar().setSubtitle("DSN");
|
||||||
setContentView(R.layout.activity_dsn);
|
setContentView(R.layout.activity_dsn);
|
||||||
|
|
||||||
final TextView tvHeaders = findViewById(R.id.tvHeaders);
|
tvHeaders = findViewById(R.id.tvHeaders);
|
||||||
final ContentLoadingProgressBar pbWait = findViewById(R.id.pbWait);
|
pbWait = findViewById(R.id.pbWait);
|
||||||
final Group grpReady = findViewById(R.id.grpReady);
|
grpReady = findViewById(R.id.grpReady);
|
||||||
|
|
||||||
grpReady.setVisibility(View.GONE);
|
grpReady.setVisibility(View.GONE);
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
load();
|
||||||
if (uri == null) {
|
}
|
||||||
pbWait.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
} else
|
|
||||||
pbWait.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
Log.i("Disposition uri=" + uri);
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
super.onNewIntent(intent);
|
||||||
|
setIntent(intent);
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load() {
|
||||||
|
Uri uri = getIntent().getData();
|
||||||
|
Log.i("DSN uri=" + uri);
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable("uri", uri);
|
args.putParcelable("uri", uri);
|
||||||
|
|
||||||
new SimpleTask<Result>() {
|
new SimpleTask<Result>() {
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute(Bundle args) {
|
||||||
|
pbWait.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bundle args) {
|
protected void onPostExecute(Bundle args) {
|
||||||
pbWait.setVisibility(View.GONE);
|
pbWait.setVisibility(View.GONE);
|
||||||
|
@ -73,6 +89,9 @@ public class ActivityDSN extends ActivityBase {
|
||||||
protected Result onExecute(Context context, Bundle args) throws Throwable {
|
protected Result onExecute(Context context, Bundle args) throws Throwable {
|
||||||
Uri uri = args.getParcelable("uri");
|
Uri uri = args.getParcelable("uri");
|
||||||
|
|
||||||
|
if (uri == null)
|
||||||
|
throw new FileNotFoundException();
|
||||||
|
|
||||||
if (!"content".equals(uri.getScheme()) &&
|
if (!"content".equals(uri.getScheme()) &&
|
||||||
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||||
Log.w("DSN uri=" + uri);
|
Log.w("DSN uri=" + uri);
|
||||||
|
|
Loading…
Reference in a new issue