Less intrusive asking for help

pull/156/head
M66B 6 years ago
parent d159989066
commit 8fbbb64684

@ -47,8 +47,6 @@ import android.view.View;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.Toast; import android.widget.Toast;
@ -69,7 +67,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bugsnag.android.Bugsnag;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import org.json.JSONArray; import org.json.JSONArray;
@ -415,7 +412,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new Handler().post(checkIntent); new Handler().post(checkIntent);
checkFirst(); checkFirst();
checkBugsnag();
checkCrash(); checkCrash();
pgpService = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain"); pgpService = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain");
@ -674,52 +670,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
} }
private void checkBugsnag() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("first", true) ||
prefs.getBoolean("crash_reports", false) ||
prefs.getBoolean("crash_reports_confirmed", false))
return;
final View dview = LayoutInflater.from(this).inflate(R.layout.dialog_error_reporting, null);
final Button btnInfo = dview.findViewById(R.id.btnInfo);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final Intent info = new Intent(Intent.ACTION_VIEW);
info.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq104"));
info.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
btnInfo.setVisibility(
info.resolveActivity(getPackageManager()) == null ? View.GONE : View.VISIBLE);
btnInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(info);
}
});
new DialogBuilderLifecycle(this, this)
.setView(dview)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.edit().putBoolean("crash_reports", true).apply();
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("crash_reports_confirmed", true).apply();
Bugsnag.startSession();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("crash_reports_confirmed", true).apply();
}
})
.show();
}
private void checkCrash() { private void checkCrash() {
new SimpleTask<Long>() { new SimpleTask<Long>() {
@Override @Override

@ -165,6 +165,7 @@ public class ApplicationEx extends Application {
ignore.add("java.net.UnknownHostException"); ignore.add("java.net.UnknownHostException");
ignore.add("java.net.SocketTimeoutException"); ignore.add("java.net.SocketTimeoutException");
ignore.add("java.net.SocketException"); ignore.add("java.net.SocketException");
// android.accounts.OperationCanceledException
ignore.add("javax.mail.StoreClosedException"); ignore.add("javax.mail.StoreClosedException");
ignore.add("javax.mail.FolderClosedException"); ignore.add("javax.mail.FolderClosedException");

@ -33,6 +33,7 @@ import android.net.ConnectivityManager;
import android.net.Network; import android.net.Network;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.net.NetworkRequest; import android.net.NetworkRequest;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Parcel; import android.os.Parcel;
@ -53,6 +54,7 @@ import android.view.ViewGroup;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.SeekBar; import android.widget.SeekBar;
@ -83,6 +85,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bugsnag.android.Bugsnag;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
@ -1966,6 +1969,8 @@ public class FragmentMessages extends FragmentBase {
} }
}); });
} }
checkReporting();
} }
@Override @Override
@ -2029,6 +2034,67 @@ public class FragmentMessages extends FragmentBase {
} }
}; };
private void checkReporting() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("crash_reports", false) ||
prefs.getBoolean("crash_reports_asked", false))
return;
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_help, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
askReporting();
}
});
snackbar.show();
}
private void askReporting() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_error_reporting, null);
final Button btnInfo = dview.findViewById(R.id.btnInfo);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final Intent info = new Intent(Intent.ACTION_VIEW);
info.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq104"));
info.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
btnInfo.setVisibility(
info.resolveActivity(getContext().getPackageManager()) == null ? View.GONE : View.VISIBLE);
btnInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(info);
}
});
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setView(dview)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.edit().putBoolean("crash_reports", true).apply();
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("crash_reports_asked", true).apply();
Bugsnag.startSession();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("crash_reports_asked", true).apply();
}
})
.show();
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_messages, menu); inflater.inflate(R.menu.menu_messages, menu);

@ -437,6 +437,7 @@
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string> <string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
<string name="title_ask_edit_ref">Edit reformatted replied/forwarded message text?</string> <string name="title_ask_edit_ref">Edit reformatted replied/forwarded message text?</string>
<string name="title_ask_delete_local">Delete local messages which are stored on the remote server too?</string> <string name="title_ask_delete_local">Delete local messages which are stored on the remote server too?</string>
<string name="title_ask_help">Help improve FairEmail</string>
<string name="title_ask_reporting">Send error reports?</string> <string name="title_ask_reporting">Send error reports?</string>
<string name="title_reporting_why">Error reporting will help improve FairEmail</string> <string name="title_reporting_why">Error reporting will help improve FairEmail</string>

Loading…
Cancel
Save