Commit 00b3e8f6 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Updated license year to 2020 + fixed crash when new version is available

parent 4889bd83
Pipeline #17660 failed with stages
in 49 seconds
......@@ -20,10 +20,8 @@
package org.linphone;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
......@@ -31,7 +29,6 @@ import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.telephony.PhoneStateListener;
......@@ -64,7 +61,6 @@ import org.linphone.core.ProxyConfig;
import org.linphone.core.Reason;
import org.linphone.core.Tunnel;
import org.linphone.core.TunnelConfig;
import org.linphone.core.VersionUpdateCheckResult;
import org.linphone.core.tools.Log;
import org.linphone.settings.LinphonePreferences;
import org.linphone.utils.LinphoneUtils;
......@@ -216,50 +212,6 @@ public class LinphoneManager implements SensorEventListener {
}
}
@Override
public void onVersionUpdateCheckResultReceived(
Core core,
VersionUpdateCheckResult result,
String version,
String url) {
if (result == VersionUpdateCheckResult.NewVersionAvailable) {
final String urlToUse = url;
final String versionAv = version;
LinphoneUtils.dispatchOnUIThreadAfter(
new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder =
new AlertDialog.Builder(mContext);
builder.setMessage(
getString(R.string.update_available)
+ ": "
+ versionAv);
builder.setCancelable(false);
builder.setNeutralButton(
getString(R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialogInterface,
int i) {
if (urlToUse != null) {
Intent urlIntent =
new Intent(
Intent.ACTION_VIEW);
urlIntent.setData(
Uri.parse(urlToUse));
mContext.startActivity(urlIntent);
}
}
});
builder.show();
}
},
1000);
}
}
@Override
public void onFriendListCreated(Core core, FriendList list) {
if (LinphoneContext.isReady()) {
......@@ -793,20 +745,6 @@ public class LinphoneManager implements SensorEventListener {
/* Other stuff */
public void checkForUpdate() {
String url = LinphonePreferences.instance().getCheckReleaseUrl();
if (url != null && !url.isEmpty()) {
int lastTimestamp = LinphonePreferences.instance().getLastCheckReleaseTimestamp();
int currentTimeStamp = (int) System.currentTimeMillis();
int interval =
mContext.getResources().getInteger(R.integer.time_between_update_check); // 24h
if (lastTimestamp == 0 || currentTimeStamp - lastTimestamp >= interval) {
mCore.checkForUpdate(BuildConfig.VERSION_NAME);
LinphonePreferences.instance().setLastCheckReleaseTimestamp(currentTimeStamp);
}
}
}
public void enableDeviceRingtone(boolean use) {
if (use) {
mCore.setRing(null);
......
......@@ -94,10 +94,6 @@ public class LinphoneLauncherActivity extends Activity implements ServiceWaitThr
}
}
if (getResources().getBoolean(R.bool.check_for_update_when_app_starts)) {
LinphoneManager.getInstance().checkForUpdate();
}
Intent intent = new Intent();
intent.setClass(LinphoneLauncherActivity.this, classToStart);
if (getIntent() != null && getIntent().getExtras() != null) {
......
......@@ -20,6 +20,8 @@
package org.linphone.dialer;
import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
......@@ -35,6 +37,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import org.linphone.BuildConfig;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.activities.MainActivity;
......@@ -44,11 +47,13 @@ import org.linphone.contacts.ContactsManager;
import org.linphone.core.Call;
import org.linphone.core.Core;
import org.linphone.core.CoreListenerStub;
import org.linphone.core.VersionUpdateCheckResult;
import org.linphone.core.tools.Log;
import org.linphone.dialer.views.AddressText;
import org.linphone.dialer.views.Digit;
import org.linphone.dialer.views.EraseButton;
import org.linphone.settings.LinphonePreferences;
import org.linphone.utils.LinphoneUtils;
public class DialerActivity extends MainActivity implements AddressText.AddressChangedListener {
private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
......@@ -103,6 +108,50 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
Core core, Call call, Call.State state, String message) {
updateLayout();
}
@Override
public void onVersionUpdateCheckResultReceived(
Core core,
VersionUpdateCheckResult result,
String version,
String url) {
if (result == VersionUpdateCheckResult.NewVersionAvailable) {
final String urlToUse = url;
final String versionAv = version;
LinphoneUtils.dispatchOnUIThreadAfter(
new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder =
new AlertDialog.Builder(DialerActivity.this);
builder.setMessage(
getString(R.string.update_available)
+ ": "
+ versionAv);
builder.setCancelable(false);
builder.setNeutralButton(
getString(R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialogInterface,
int i) {
if (urlToUse != null) {
Intent urlIntent =
new Intent(
Intent.ACTION_VIEW);
urlIntent.setData(
Uri.parse(urlToUse));
startActivity(urlIntent);
}
}
});
builder.show();
}
},
1000);
}
}
};
// On dialer we ask for all permissions
......@@ -181,6 +230,28 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
super.onDestroy();
}
@Override
protected void onStart() {
super.onStart();
if (getResources().getBoolean(R.bool.check_for_update_when_app_starts)) {
checkForUpdate();
}
}
private void checkForUpdate() {
String url = LinphonePreferences.instance().getCheckReleaseUrl();
if (url != null && !url.isEmpty()) {
int lastTimestamp = LinphonePreferences.instance().getLastCheckReleaseTimestamp();
int currentTimeStamp = (int) System.currentTimeMillis();
int interval = getResources().getInteger(R.integer.time_between_update_check); // 24h
if (lastTimestamp == 0 || currentTimeStamp - lastTimestamp >= interval) {
LinphoneManager.getCore().checkForUpdate(BuildConfig.VERSION_NAME);
LinphonePreferences.instance().setLastCheckReleaseTimestamp(currentTimeStamp);
}
}
}
private void initUI(View view) {
mAddress = view.findViewById(R.id.address);
mAddress.setAddressListener(this);
......
......@@ -18,7 +18,7 @@
<string name="user_agent" translatable="false">LinphoneAndroid</string>
<string name="temp_photo_name" translatable="false">linphone-android-photo-temp</string>
<string name="temp_photo_name_with_date" translatable="false">linphone-android-photo-%s</string>
<string name="about_text" translatable="false">GNU General Public License V3\n © 2010–2019 Belledonne Communications</string>
<string name="about_text" translatable="false">GNU General Public License V3\n © 2010–2020 Belledonne Communications</string>
<string name="about_bugreport_email" translatable="false">linphone-android@belledonne-communications.com</string>
<string name="notification_service_channel_id" translatable="false">linphone_notification_service_id</string>
<string name="notification_channel_id" translatable="false">linphone_notification_id</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment