Display minimalist progress dialog when uploading logs
This commit is contained in:
parent
bf923b2afa
commit
e892b12530
3 changed files with 74 additions and 22 deletions
|
@ -19,13 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
@ -38,6 +47,9 @@ public class AboutFragment extends Fragment implements OnClickListener {
|
|||
View sendLogButton = null;
|
||||
View resetLogButton = null;
|
||||
ImageView cancel;
|
||||
LinphoneCoreListenerBase mListener;
|
||||
private ProgressDialog progress;
|
||||
private boolean uploadInProgress;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -62,22 +74,82 @@ public class AboutFragment extends Fragment implements OnClickListener {
|
|||
resetLogButton = view.findViewById(R.id.reset_log);
|
||||
resetLogButton.setOnClickListener(this);
|
||||
resetLogButton.setVisibility(org.linphone.LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
|
||||
|
||||
mListener = new LinphoneCoreListenerBase() {
|
||||
@Override
|
||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) {
|
||||
if (state == LogCollectionUploadState.LogCollectionUploadStateInProgress) {
|
||||
displayUploadLogsInProgress();
|
||||
} else if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered || state == LogCollectionUploadState.LogCollectionUploadStateNotDelivered) {
|
||||
uploadInProgress = false;
|
||||
if (progress != null) progress.dismiss();
|
||||
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
|
||||
sendLogs(LinphoneService.instance().getApplicationContext(), info);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void displayUploadLogsInProgress() {
|
||||
if (uploadInProgress) {
|
||||
return;
|
||||
}
|
||||
uploadInProgress = true;
|
||||
|
||||
progress = ProgressDialog.show(LinphoneActivity.instance(), null, null);
|
||||
Drawable d = new ColorDrawable(getResources().getColor(R.color.colorE));
|
||||
d.setAlpha(200);
|
||||
progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
|
||||
progress.getWindow().setBackgroundDrawable(d);
|
||||
progress.setContentView(R.layout.progress_dialog);
|
||||
progress.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() {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.removeListener(mListener);
|
||||
}
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.addListener(mListener);
|
||||
}
|
||||
|
||||
if (org.linphone.LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.ABOUT);
|
||||
}
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -970,22 +970,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
startActivityForResult(intent, CALL_ACTIVITY);
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a sensor to track phoneOrientation changes
|
||||
*/
|
||||
|
|
|
@ -1467,10 +1467,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
@Override
|
||||
public void uploadStateChanged(LinphoneCore linphoneCore, LogCollectionUploadState state, String info) {
|
||||
Log.d("Log upload state: " + state.toString() + ", info = " + info);
|
||||
|
||||
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
|
||||
LinphoneActivity.instance().sendLogs(LinphoneService.instance().getApplicationContext(),info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue