Fix last commit
This commit is contained in:
parent
69f1888b4f
commit
f47ff85423
2 changed files with 28 additions and 29 deletions
|
@ -38,7 +38,6 @@ max_calls=10
|
||||||
|
|
||||||
[app]
|
[app]
|
||||||
activation_code_length=4
|
activation_code_length=4
|
||||||
debug=1
|
|
||||||
|
|
||||||
[in-app-purchase]
|
[in-app-purchase]
|
||||||
server_url=https://sip3.linphone.org:444/inapp.php
|
server_url=https://sip3.linphone.org:444/inapp.php
|
||||||
|
|
|
@ -100,12 +100,12 @@ public final class LinphoneUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNumberAddress(String numberOrAddress) {
|
public static boolean isNumberAddress(String numberOrAddress) {
|
||||||
LinphoneProxyConfig proxy = LinphoneManager.getLc().createProxyConfig();
|
LinphoneProxyConfig proxy = LinphoneManager.getLc().createProxyConfig();
|
||||||
return proxy.normalizePhoneNumber(numberOrAddress) != null;
|
return proxy.normalizePhoneNumber(numberOrAddress) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStrictSipAddress(String numberOrAddress) {
|
public static boolean isStrictSipAddress(String numberOrAddress) {
|
||||||
return isSipAddress(numberOrAddress) && numberOrAddress.startsWith("sip:");
|
return isSipAddress(numberOrAddress) && numberOrAddress.startsWith("sip:");
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public final class LinphoneUtils {
|
||||||
|
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) {
|
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) {
|
||||||
if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) {
|
if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) {
|
||||||
return false; // continue
|
return false; // continue
|
||||||
|
@ -204,7 +204,7 @@ public final class LinphoneUtils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Bitmap downloadBitmap(Uri uri) {
|
public static Bitmap downloadBitmap(Uri uri) {
|
||||||
URL url;
|
URL url;
|
||||||
|
@ -223,7 +223,7 @@ public final class LinphoneUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setImagePictureFromUri(Context c, ImageView view, Uri pictureUri, Uri thumbnailUri) {
|
public static void setImagePictureFromUri(Context c, ImageView view, Uri pictureUri, Uri thumbnailUri) {
|
||||||
if (pictureUri == null) {
|
if (pictureUri == null) {
|
||||||
view.setImageResource(R.drawable.avatar);
|
view.setImageResource(R.drawable.avatar);
|
||||||
|
@ -294,7 +294,7 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
|
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
|
||||||
// return a modifiable list
|
// return a modifiable list
|
||||||
return new ArrayList<LinphoneCall>(Arrays.asList(lc.getCalls()));
|
return new ArrayList<LinphoneCall>(Arrays.asList(lc.getCalls()));
|
||||||
|
@ -353,41 +353,41 @@ public final class LinphoneUtils {
|
||||||
public static int pixelsToDpi(Resources res, int pixels) {
|
public static int pixelsToDpi(Resources res, int pixels) {
|
||||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics());
|
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCallRunning(LinphoneCall call)
|
public static boolean isCallRunning(LinphoneCall call)
|
||||||
{
|
{
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneCall.State state = call.getState();
|
LinphoneCall.State state = call.getState();
|
||||||
|
|
||||||
return state == LinphoneCall.State.Connected ||
|
return state == LinphoneCall.State.Connected ||
|
||||||
state == LinphoneCall.State.CallUpdating ||
|
state == LinphoneCall.State.CallUpdating ||
|
||||||
state == LinphoneCall.State.CallUpdatedByRemote ||
|
state == LinphoneCall.State.CallUpdatedByRemote ||
|
||||||
state == LinphoneCall.State.StreamsRunning ||
|
state == LinphoneCall.State.StreamsRunning ||
|
||||||
state == LinphoneCall.State.Resuming;
|
state == LinphoneCall.State.Resuming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCallEstablished(LinphoneCall call) {
|
public static boolean isCallEstablished(LinphoneCall call) {
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneCall.State state = call.getState();
|
LinphoneCall.State state = call.getState();
|
||||||
|
|
||||||
return isCallRunning(call) ||
|
return isCallRunning(call) ||
|
||||||
state == LinphoneCall.State.Paused ||
|
state == LinphoneCall.State.Paused ||
|
||||||
state == LinphoneCall.State.PausedByRemote ||
|
state == LinphoneCall.State.PausedByRemote ||
|
||||||
state == LinphoneCall.State.Pausing;
|
state == LinphoneCall.State.Pausing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHighBandwidthConnection(Context context){
|
public static boolean isHighBandwidthConnection(Context context){
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo info = cm.getActiveNetworkInfo();
|
NetworkInfo info = cm.getActiveNetworkInfo();
|
||||||
return (info != null && info.isConnected() && isConnectionFast(info.getType(),info.getSubtype()));
|
return (info != null && info.isConnected() && isConnectionFast(info.getType(),info.getSubtype()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isConnectionFast(int type, int subType){
|
private static boolean isConnectionFast(int type, int subType){
|
||||||
if (type == ConnectivityManager.TYPE_MOBILE) {
|
if (type == ConnectivityManager.TYPE_MOBILE) {
|
||||||
switch (subType) {
|
switch (subType) {
|
||||||
|
@ -400,7 +400,7 @@ public final class LinphoneUtils {
|
||||||
//in doubt, assume connection is good.
|
//in doubt, assume connection is good.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearLogs() {
|
public static void clearLogs() {
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(new String[] { "logcat", "-c" });
|
Runtime.getRuntime().exec(new String[] { "logcat", "-c" });
|
||||||
|
@ -449,7 +449,7 @@ public final class LinphoneUtils {
|
||||||
|
|
||||||
if( zipLogs(sb, zipFilePath) ) {
|
if( zipLogs(sb, zipFilePath) ) {
|
||||||
final String appName = (context != null) ? context.getString(R.string.app_name) : "Linphone(?)";
|
final String appName = (context != null) ? context.getString(R.string.app_name) : "Linphone(?)";
|
||||||
|
|
||||||
Uri zipURI = Uri.parse("file://" + zipFilePath);
|
Uri zipURI = Uri.parse("file://" + zipFilePath);
|
||||||
Intent i = new Intent(Intent.ACTION_SEND);
|
Intent i = new Intent(Intent.ACTION_SEND);
|
||||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
|
i.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
|
||||||
|
@ -460,7 +460,7 @@ public final class LinphoneUtils {
|
||||||
try {
|
try {
|
||||||
context.startActivity(Intent.createChooser(i, "Send mail..."));
|
context.startActivity(Intent.createChooser(i, "Send mail..."));
|
||||||
} catch (android.content.ActivityNotFoundException ex) {
|
} catch (android.content.ActivityNotFoundException ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void recursiveFileRemoval(File root) {
|
public static void recursiveFileRemoval(File root) {
|
||||||
if (!root.delete()) {
|
if (!root.delete()) {
|
||||||
if (root.isDirectory()) {
|
if (root.isDirectory()) {
|
||||||
|
@ -490,12 +490,12 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDisplayableUsernameFromAddress(String sipAddress) {
|
public static String getDisplayableUsernameFromAddress(String sipAddress) {
|
||||||
String username = sipAddress;
|
String username = sipAddress;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc == null) return username;
|
if (lc == null) return username;
|
||||||
|
|
||||||
if (username.startsWith("sip:")) {
|
if (username.startsWith("sip:")) {
|
||||||
username = username.substring(4);
|
username = username.substring(4);
|
||||||
}
|
}
|
||||||
|
@ -515,12 +515,12 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFullAddressFromUsername(String username) {
|
public static String getFullAddressFromUsername(String username) {
|
||||||
String sipAddress = username;
|
String sipAddress = username;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc == null) return sipAddress;
|
if (lc == null) return sipAddress;
|
||||||
|
|
||||||
if (!sipAddress.startsWith("sip:")) {
|
if (!sipAddress.startsWith("sip:")) {
|
||||||
sipAddress = "sip:" + sipAddress;
|
sipAddress = "sip:" + sipAddress;
|
||||||
}
|
}
|
||||||
|
@ -535,20 +535,20 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return sipAddress;
|
return sipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeImage(Context context, LinphoneChatMessage msg) {
|
public static void storeImage(Context context, LinphoneChatMessage msg) {
|
||||||
if (msg == null || msg.getFileTransferInformation() == null || msg.getAppData() == null) return;
|
if (msg == null || msg.getFileTransferInformation() == null || msg.getAppData() == null) return;
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppData());
|
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppData());
|
||||||
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
|
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
|
||||||
if (bm == null) return;
|
if (bm == null) return;
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(Images.Media.TITLE, file.getName());
|
values.put(Images.Media.TITLE, file.getName());
|
||||||
String extension = msg.getFileTransferInformation().getSubtype();
|
String extension = msg.getFileTransferInformation().getSubtype();
|
||||||
values.put(Images.Media.MIME_TYPE, "image/" + extension);
|
values.put(Images.Media.MIME_TYPE, "image/" + extension);
|
||||||
ContentResolver cr = context.getContentResolver();
|
ContentResolver cr = context.getContentResolver();
|
||||||
Uri path = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
Uri path = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||||
|
|
||||||
OutputStream stream;
|
OutputStream stream;
|
||||||
try {
|
try {
|
||||||
stream = cr.openOutputStream(path);
|
stream = cr.openOutputStream(path);
|
||||||
|
@ -557,7 +557,7 @@ public final class LinphoneUtils {
|
||||||
} else {
|
} else {
|
||||||
bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
|
bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
file.delete();
|
file.delete();
|
||||||
bm.recycle();
|
bm.recycle();
|
||||||
|
@ -632,7 +632,7 @@ public final class LinphoneUtils {
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountAlreadyActivated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountAlreadyActivated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountActivated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountActivated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.Ok)) {
|
|| status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||||
return "allo";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue