diff --git a/res/values/non_localizable_strings.xml b/res/values/non_localizable_strings.xml
index c399ded77..5cdfe6343 100644
--- a/res/values/non_localizable_strings.xml
+++ b/res/values/non_localizable_strings.xml
@@ -169,4 +169,15 @@
SRTP
ZRTP
DTLS
+
+ Debug
+
+ - Enable logs
+ - Cancel
+
+
+ - Disable logs
+ - Send logs
+ - Cancel
+
diff --git a/src/org/linphone/AboutFragment.java b/src/org/linphone/AboutFragment.java
index e19c2be33..7a190cfa3 100644
--- a/src/org/linphone/AboutFragment.java
+++ b/src/org/linphone/AboutFragment.java
@@ -19,11 +19,8 @@ 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.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@@ -41,7 +38,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
View exitButton = null;
View sendLogButton = null;
View resetLogButton = null;
- private LinphoneCoreListenerBase mListener;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -69,39 +65,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
exitButton = view.findViewById(R.id.exit);
exitButton.setOnClickListener(this);
exitButton.setVisibility(View.VISIBLE);
-
- LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
- if (lc != null) {
- mListener = new LinphoneCoreListenerBase(){
- @Override
- public void uploadProgressIndication(LinphoneCore linphoneCore, int offset, int total) {
- if(total > 0)
- Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
- }
-
- @Override
- public void uploadStateChanged(LinphoneCore linphoneCore, LogCollectionUploadState state, String info) {
- Log.d("Log upload state: " + state.toString() + ", info = " + info);
-
- if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
- final String appName = getString(R.string.app_name);
-
- Intent i = new Intent(Intent.ACTION_SEND);
- i.putExtra(Intent.EXTRA_EMAIL, new String[]{ 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);
- }
- }
- }
- };
- lc.addListener(mListener);
- }
return view;
}
@@ -141,11 +104,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
@Override
public void onDestroy() {
- LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
- if (lc != null) {
- lc.removeListener(mListener);
- }
-
super.onDestroy();
}
diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java
index fc43382fa..8f7c9d192 100644
--- a/src/org/linphone/ChatFragment.java
+++ b/src/org/linphone/ChatFragment.java
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.security.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
@@ -634,7 +635,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
private void pickImage() {
List cameraIntents = new ArrayList();
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name) + Calendar.getInstance().getTime());
+ File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())));
imageToUploadUri = Uri.fromFile(file);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
cameraIntents.add(captureIntent);
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
index f29081502..0010f40e9 100644
--- a/src/org/linphone/LinphoneActivity.java
+++ b/src/org/linphone/LinphoneActivity.java
@@ -932,6 +932,22 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
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
*/
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index ea5ff88bc..ff27593cb 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -1286,14 +1286,18 @@ public class LinphoneManager implements LinphoneCoreListener {
}
@Override
- public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
-
+ public void uploadProgressIndication(LinphoneCore linphoneCore, int offset, int total) {
+ if(total > 0)
+ Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
}
@Override
- public void uploadStateChanged(LinphoneCore lc,
- LogCollectionUploadState state, String info) {
+ 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
diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java
index 6435929b5..db0d0043b 100644
--- a/src/org/linphone/LinphonePreferences.java
+++ b/src/org/linphone/LinphonePreferences.java
@@ -1155,4 +1155,16 @@ public class LinphonePreferences {
public String getInAppPurchaseValidatingServerUrl() {
return getConfig().getString("in-app-purchase", "server_url", null);
}
+
+ public String getDebugPopupAddress(){
+ return getConfig().getString("app", "debug_popup_magic", null);
+ }
+
+ public void enableDebugLogs(Boolean debugMode){
+ getConfig().setBool("app", "debug_logs_enabled", debugMode);
+ }
+
+ public Boolean isDebugLogsEnabled(){
+ return getConfig().getBool("app", "debug_logs_enabled", false);
+ }
}
diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java
index 191026039..528d6eebb 100644
--- a/src/org/linphone/ui/Digit.java
+++ b/src/org/linphone/ui/Digit.java
@@ -24,9 +24,12 @@ import org.linphone.LinphonePreferences;
import org.linphone.LinphoneService;
import org.linphone.R;
import org.linphone.core.LinphoneCore;
+import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -118,9 +121,47 @@ public class Digit extends Button implements AddressAware {
if (lBegin >= 0) {
mAddress.getEditableText().insert(lBegin,String.valueOf(mKeyCode));
}
+
+ if(LinphonePreferences.instance().getDebugPopupAddress() != null
+ && mAddress.getText().toString().equals(LinphonePreferences.instance().getDebugPopupAddress())){
+ displayDebugPopup();
+ }
}
}
+ public void displayDebugPopup(){
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext());
+ alertDialog.setTitle(getContext().getString(R.string.debug_popup_title));
+ if(LinphonePreferences.instance().isDebugLogsEnabled()) {
+ alertDialog.setItems(getContext().getResources().getStringArray(R.array.popup_send_log), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if(which == 0){
+ LinphonePreferences.instance().enableDebugLogs(false);
+ LinphoneCoreFactory.instance().enableLogCollection(false);
+ }
+ if(which == 1) {
+ LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
+ if (lc != null) {
+ lc.uploadLogCollection();
+ }
+ }
+ }
+ });
+
+ } else {
+ alertDialog.setItems(getContext().getResources().getStringArray(R.array.popup_enable_log), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if(which == 0) {
+ LinphonePreferences.instance().enableDebugLogs(true);
+ LinphoneCoreFactory.instance().enableLogCollection(true);
+ }
+ }
+ });
+ }
+ alertDialog.show();
+ mAddress.getEditableText().clear();
+ }
+
public boolean onTouch(View v, MotionEvent event) {
if (!mPlayDtmf) return false;
if (!linphoneServiceReady()) return true;
diff --git a/submodules/linphone b/submodules/linphone
index 7a5f88122..f1b42dc29 160000
--- a/submodules/linphone
+++ b/submodules/linphone
@@ -1 +1 @@
-Subproject commit 7a5f881221815f2621e876d3a677840053969d54
+Subproject commit f1b42dc2995fa4f934c4313e94aca0bc63d58c7a