Merge branch 'master' into dev_phonenumber

Conflicts:
	src/org/linphone/compatibility/ApiElevenPlus.java
	src/org/linphone/compatibility/ApiTwentyThreePlus.java
	src/org/linphone/compatibility/Compatibility.java
This commit is contained in:
Margaux Clerc 2016-08-11 14:05:44 +02:00
commit 913e0b16d5
11 changed files with 67 additions and 30 deletions

View file

@ -17,7 +17,6 @@ size=qvga
tunnel=disabled
push_notification=1
auto_start=1
debug=0
[tunnel]
host=
@ -25,4 +24,4 @@ port=443
[misc]
log_collection_upload_server_url=https://www.linphone.org:444/lft.php
file_transfer_server_url=https://www.linphone.org:444/lft.php
file_transfer_server_url=https://www.linphone.org:444/lft.php

View file

@ -228,6 +228,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if (from.asStringUriOnly().equals(sipUri)) {
LinphoneService.instance().removeMessageNotification();
cr.markAsRead();
LinphoneActivity.instance().updateMissedChatCount();
adapter.addMessage(cr.getHistory(1)[0]);
String externalBodyUrl = message.getExternalBodyUrl();

View file

@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.linphone;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
@ -57,9 +58,9 @@ public class KeepAliveReceiver extends BroadcastReceiver {
//make sure the application will at least wakes up every 10 mn
Intent newIntent = new Intent(context, KeepAliveReceiver.class);
PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(context, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP
, SystemClock.elapsedRealtime() + 600000
, keepAlivePendingIntent);
AlarmManager alarmManager = ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE));
Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
}
} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
Log.i("[KeepAlive] Screen is on, enable");

View file

@ -1185,7 +1185,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
private boolean willContactsPermissionBeAsked() {
return LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS);
return LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS, false) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS);
}
public void checkAndRequestWriteContactsPermission() {

View file

@ -1360,13 +1360,21 @@ public class LinphonePreferences {
}
public boolean firstTimeAskingForPermission(String permission) {
return firstTimeAskingForPermission(permission, true);
}
public boolean firstTimeAskingForPermission(String permission, boolean toggle) {
boolean firstTime = getConfig().getBool("app", permission, true);
if (firstTime) {
getConfig().setBool("app", permission, false);
if (toggle) {
permissionHasBeenAsked(permission);
}
return firstTime;
}
public void permissionHasBeenAsked(String permission) {
getConfig().setBool("app", permission, false);
}
public boolean isDeviceRingtoneEnabled() {
int readExternalStorage = mContext.getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, mContext.getPackageName());
return getConfig().getBool("app", "device_ringtone", true) && readExternalStorage == PackageManager.PERMISSION_GRANTED;

View file

@ -288,9 +288,8 @@ public final class LinphoneService extends Service {
//make sure the application will at least wakes up every 10 mn
Intent intent = new Intent(this, KeepAliveReceiver.class);
PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP
, SystemClock.elapsedRealtime() + 600000
, keepAlivePendingIntent);
AlarmManager alarmManager = ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE));
Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
}

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import org.linphone.R;
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ContentUris;
@ -168,4 +169,8 @@ public class ApiElevenPlus {
public static void setTextAppearance(TextView textview, Context context, int style) {
textview.setTextAppearance(context, style);
}
public static void scheduleAlarm(AlarmManager alarmManager, int type, long triggerAtMillis, PendingIntent operation) {
alarmManager.set(type, triggerAtMillis, operation);
}
}

View file

@ -0,0 +1,32 @@
package org.linphone.compatibility;
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
/*ApiNineteenPlus.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @author Sylvain Berfini
*/
@TargetApi(19)
public class ApiNineteenPlus {
public static void scheduleAlarm(AlarmManager alarmManager, int type, long triggerAtMillis, PendingIntent operation) {
alarmManager.setExact(type, triggerAtMillis, operation);
}
}

View file

@ -1,23 +1,7 @@
package org.linphone.compatibility;
import java.util.ArrayList;
import org.linphone.R;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents.Insert;
import android.widget.TextView;
import android.annotation.TargetApi;
/*
ApiTwentyThreePlus.java

View file

@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.linphone.mediastream.Version;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
@ -130,4 +130,12 @@ public class Compatibility {
ApiElevenPlus.setTextAppearance(textview, context, style);
}
}
public static void scheduleAlarm(AlarmManager alarmManager, int type, long triggerAtMillis, PendingIntent operation) {
if (Version.sdkAboveOrEqual(Version.API19_KITKAT_44)) {
ApiNineteenPlus.scheduleAlarm(alarmManager, type, triggerAtMillis, operation);
} else {
ApiElevenPlus.scheduleAlarm(alarmManager, type, triggerAtMillis, operation);
}
}
}

@ -1 +1 @@
Subproject commit 958366ce1928bd0aabaf983082faa8c49e501c4a
Subproject commit 8d21acd7f07fa40604dda8cf44fb114b5f637565