Fixed send logs magic dialog menu option

This commit is contained in:
Sylvain Berfini 2019-04-03 14:28:47 +02:00
parent d26776317a
commit b64d62cc4a
2 changed files with 21 additions and 25 deletions

View file

@ -1702,10 +1702,31 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
@Override
public void onEcCalibrationAudioUninit(Core lc) {}
private void sendLogs(Context context, String info) {
final String appName = context.getString(R.string.app_name);
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(
Intent.EXTRA_EMAIL,
new String[] {context.getString(R.string.about_bugreport_email)});
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
i.putExtra(Intent.EXTRA_TEXT, info);
i.setType("application/zip");
try {
LinphoneActivity.instance().startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Log.e(ex);
}
}
@Override
public void onLogCollectionUploadStateChanged(
Core linphoneCore, LogCollectionUploadState state, String info) {
Log.d("[Manager] Log upload state: " + state.toString() + ", info = " + info);
if (state == LogCollectionUploadState.Delivered) {
sendLogs(LinphoneService.instance().getApplicationContext(), info);
}
}
@Override

View file

@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.app.Fragment;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -35,12 +33,10 @@ import androidx.core.content.ContextCompat;
import org.linphone.BuildConfig;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneService;
import org.linphone.R;
import org.linphone.core.Core;
import org.linphone.core.Core.LogCollectionUploadState;
import org.linphone.core.CoreListenerStub;
import org.linphone.core.tools.Log;
import org.linphone.settings.LinphonePreferences;
public class AboutFragment extends Fragment implements OnClickListener {
@ -95,9 +91,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
|| state == LogCollectionUploadState.NotDelivered) {
mUploadInProgress = false;
if (mProgress != null) mProgress.dismiss();
if (state == LogCollectionUploadState.Delivered) {
sendLogs(LinphoneService.instance().getApplicationContext(), info);
}
}
}
};
@ -125,24 +118,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
mProgress.show();
}
private void sendLogs(Context context, String info) {
final String appName = context.getString(R.string.app_name);
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(
Intent.EXTRA_EMAIL,
new String[] {context.getString(R.string.about_bugreport_email)});
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
i.putExtra(Intent.EXTRA_TEXT, info);
i.setType("application/zip");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Log.e(ex);
}
}
@Override
public void onPause() {
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();