Add check for new version
This commit is contained in:
parent
7a33c85a1f
commit
0938a88a1d
3 changed files with 30 additions and 2 deletions
|
@ -17,7 +17,7 @@ auto_answer_replacing_calls=1
|
|||
ping_with_options=0
|
||||
rls_uri=
|
||||
use_cpim=1
|
||||
linphone_specs=groupchat
|
||||
linphone_specs=groupchat
|
||||
|
||||
[rtp]
|
||||
audio_rtp_port=7076
|
||||
|
@ -42,6 +42,7 @@ history_max_size=100
|
|||
enable_basic_to_client_group_chat_room_migration=0
|
||||
enable_simple_group_chat_message_state=0
|
||||
aggregate_imdn=1
|
||||
version_check_url_root=https://www.linphone.org/releases
|
||||
|
||||
[app]
|
||||
activation_code_length=4
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="link_account">Link your account</string>
|
||||
<string name="update_available">An update is available</string>
|
||||
|
||||
<!-- Launch screen -->
|
||||
<string name="app_description">the <i>libre</i> SIP client</string>
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.app.ProgressDialog;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
@ -691,6 +692,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
String versionName = mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(), 0).versionName;
|
||||
if (versionName == null) {
|
||||
versionName = String.valueOf(mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(), 0).versionCode);
|
||||
} else {
|
||||
//Api to check version can't use version code
|
||||
mLc.checkForUpdate(versionName);
|
||||
}
|
||||
mLc.setUserAgent("LinphoneAndroid", versionName);
|
||||
} catch (NameNotFoundException e) {
|
||||
|
@ -1618,7 +1622,29 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
|
||||
@Override
|
||||
public void onVersionUpdateCheckResultReceived(Core lc, VersionUpdateCheckResult result, String version, String url) {
|
||||
|
||||
if (result == VersionUpdateCheckResult.NewVersionAvailable) {
|
||||
final String urlToUse = url;
|
||||
final String versionAv = version;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
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));
|
||||
getContext().startActivity(urlIntent);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue