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:
commit
913e0b16d5
11 changed files with 67 additions and 30 deletions
|
@ -17,7 +17,6 @@ size=qvga
|
||||||
tunnel=disabled
|
tunnel=disabled
|
||||||
push_notification=1
|
push_notification=1
|
||||||
auto_start=1
|
auto_start=1
|
||||||
debug=0
|
|
||||||
|
|
||||||
[tunnel]
|
[tunnel]
|
||||||
host=
|
host=
|
||||||
|
|
|
@ -228,6 +228,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (from.asStringUriOnly().equals(sipUri)) {
|
if (from.asStringUriOnly().equals(sipUri)) {
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
cr.markAsRead();
|
cr.markAsRead();
|
||||||
|
LinphoneActivity.instance().updateMissedChatCount();
|
||||||
adapter.addMessage(cr.getHistory(1)[0]);
|
adapter.addMessage(cr.getHistory(1)[0]);
|
||||||
|
|
||||||
String externalBodyUrl = message.getExternalBodyUrl();
|
String externalBodyUrl = message.getExternalBodyUrl();
|
||||||
|
|
|
@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.mediastream.Log;
|
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
|
//make sure the application will at least wakes up every 10 mn
|
||||||
Intent newIntent = new Intent(context, KeepAliveReceiver.class);
|
Intent newIntent = new Intent(context, KeepAliveReceiver.class);
|
||||||
PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(context, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);
|
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
|
AlarmManager alarmManager = ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE));
|
||||||
, keepAlivePendingIntent);
|
Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
|
||||||
}
|
}
|
||||||
} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
|
} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
|
||||||
Log.i("[KeepAlive] Screen is on, enable");
|
Log.i("[KeepAlive] Screen is on, enable");
|
||||||
|
|
|
@ -1185,7 +1185,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean willContactsPermissionBeAsked() {
|
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() {
|
public void checkAndRequestWriteContactsPermission() {
|
||||||
|
|
|
@ -1360,13 +1360,21 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean firstTimeAskingForPermission(String permission) {
|
public boolean firstTimeAskingForPermission(String permission) {
|
||||||
|
return firstTimeAskingForPermission(permission, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean firstTimeAskingForPermission(String permission, boolean toggle) {
|
||||||
boolean firstTime = getConfig().getBool("app", permission, true);
|
boolean firstTime = getConfig().getBool("app", permission, true);
|
||||||
if (firstTime) {
|
if (toggle) {
|
||||||
getConfig().setBool("app", permission, false);
|
permissionHasBeenAsked(permission);
|
||||||
}
|
}
|
||||||
return firstTime;
|
return firstTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void permissionHasBeenAsked(String permission) {
|
||||||
|
getConfig().setBool("app", permission, false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDeviceRingtoneEnabled() {
|
public boolean isDeviceRingtoneEnabled() {
|
||||||
int readExternalStorage = mContext.getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, mContext.getPackageName());
|
int readExternalStorage = mContext.getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, mContext.getPackageName());
|
||||||
return getConfig().getBool("app", "device_ringtone", true) && readExternalStorage == PackageManager.PERMISSION_GRANTED;
|
return getConfig().getBool("app", "device_ringtone", true) && readExternalStorage == PackageManager.PERMISSION_GRANTED;
|
||||||
|
|
|
@ -288,9 +288,8 @@ public final class LinphoneService extends Service {
|
||||||
//make sure the application will at least wakes up every 10 mn
|
//make sure the application will at least wakes up every 10 mn
|
||||||
Intent intent = new Intent(this, KeepAliveReceiver.class);
|
Intent intent = new Intent(this, KeepAliveReceiver.class);
|
||||||
PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
|
PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
|
||||||
((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP
|
AlarmManager alarmManager = ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE));
|
||||||
, SystemClock.elapsedRealtime() + 600000
|
Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
|
||||||
, keepAlivePendingIntent);
|
|
||||||
|
|
||||||
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.AlarmManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
|
@ -168,4 +169,8 @@ public class ApiElevenPlus {
|
||||||
public static void setTextAppearance(TextView textview, Context context, int style) {
|
public static void setTextAppearance(TextView textview, Context context, int style) {
|
||||||
textview.setTextAppearance(context, style);
|
textview.setTextAppearance(context, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void scheduleAlarm(AlarmManager alarmManager, int type, long triggerAtMillis, PendingIntent operation) {
|
||||||
|
alarmManager.set(type, triggerAtMillis, operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
32
src/org/linphone/compatibility/ApiNineteenPlus.java
Normal file
32
src/org/linphone/compatibility/ApiNineteenPlus.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +1,7 @@
|
||||||
package org.linphone.compatibility;
|
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.widget.TextView;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyThreePlus.java
|
ApiTwentyThreePlus.java
|
||||||
|
|
|
@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.AlarmManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -130,4 +130,12 @@ public class Compatibility {
|
||||||
ApiElevenPlus.setTextAppearance(textview, context, style);
|
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
|
Loading…
Reference in a new issue