More cleanup
This commit is contained in:
parent
884e47df68
commit
b9c09c78a1
5 changed files with 4 additions and 264 deletions
|
@ -168,7 +168,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
private Core mLc;
|
private Core mLc;
|
||||||
private OpenH264DownloadHelper mCodecDownloader;
|
private OpenH264DownloadHelper mCodecDownloader;
|
||||||
private OpenH264DownloadHelperListener mCodecListener;
|
private OpenH264DownloadHelperListener mCodecListener;
|
||||||
private String lastLcStatusMessage;
|
|
||||||
private String basePath;
|
private String basePath;
|
||||||
private static boolean sExited;
|
private static boolean sExited;
|
||||||
private boolean mAudioFocused;
|
private boolean mAudioFocused;
|
||||||
|
@ -190,9 +189,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private WakeLock mProximityWakelock;
|
private WakeLock mProximityWakelock;
|
||||||
private AccountCreator accountCreator;
|
private AccountCreator accountCreator;
|
||||||
private static List<ChatMessage> mPendingChatFileMessage;
|
|
||||||
private static ChatMessage mUploadPendingFileMessage;
|
|
||||||
private boolean mAreDisplayAlertMessage = false;
|
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private Sensor mProximity;
|
private Sensor mProximity;
|
||||||
private boolean mProximitySensingEnabled;
|
private boolean mProximitySensingEnabled;
|
||||||
|
@ -228,7 +224,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
mSensorManager = (SensorManager) c.getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = (SensorManager) c.getSystemService(Context.SENSOR_SERVICE);
|
||||||
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
mR = c.getResources();
|
mR = c.getResources();
|
||||||
mPendingChatFileMessage = new ArrayList<ChatMessage>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
|
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
|
||||||
|
@ -337,21 +332,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
routeAudioToSpeakerHelper(true);
|
routeAudioToSpeakerHelper(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserAgent() {
|
|
||||||
try {
|
|
||||||
StringBuilder userAgent = new StringBuilder();
|
|
||||||
userAgent.append("LinphoneAndroid/" + mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(),0).versionCode);
|
|
||||||
userAgent.append(" (");
|
|
||||||
userAgent.append("Linphone/" + LinphoneManager.getLc().getVersion() + "; ");
|
|
||||||
userAgent.append(Build.DEVICE + " " + Build.MODEL + " Android/" + Build.VERSION.SDK_INT);
|
|
||||||
userAgent.append(")");
|
|
||||||
return userAgent.toString();
|
|
||||||
} catch (NameNotFoundException nnfe) {
|
|
||||||
Log.e(nnfe);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void routeAudioToReceiver() {
|
public void routeAudioToReceiver() {
|
||||||
routeAudioToSpeakerHelper(false);
|
routeAudioToSpeakerHelper(false);
|
||||||
}
|
}
|
||||||
|
@ -510,7 +490,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
LinphoneManager.getLc().setVideoDevice(newDevice);
|
LinphoneManager.getLc().setVideoDevice(newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface AddressType {
|
public interface AddressType {
|
||||||
void setText(CharSequence s);
|
void setText(CharSequence s);
|
||||||
CharSequence getText();
|
CharSequence getText();
|
||||||
void setDisplayedName(String s);
|
void setDisplayedName(String s);
|
||||||
|
@ -518,21 +498,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static interface NewOutgoingCallUiListener {
|
public interface NewOutgoingCallUiListener {
|
||||||
public void onWrongDestinationAddress();
|
public void onWrongDestinationAddress();
|
||||||
public void onCannotGetCallParameters();
|
public void onCannotGetCallParameters();
|
||||||
public void onAlreadyInCall();
|
public void onAlreadyInCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toggleEnableCamera() {
|
|
||||||
if (mLc.inCall()) {
|
|
||||||
boolean enabled = !mLc.getCurrentCall().cameraEnabled();
|
|
||||||
enableCamera(mLc.getCurrentCall(), enabled);
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableCamera(Call call, boolean enable) {
|
public void enableCamera(Call call, boolean enable) {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
call.enableCamera(enable);
|
call.enableCamera(enable);
|
||||||
|
@ -541,12 +512,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendStaticImage(boolean send) {
|
|
||||||
if (mLc.inCall()) {
|
|
||||||
enableCamera(mLc.getCurrentCall(), !send);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playDtmf(ContentResolver r, char dtmf) {
|
public void playDtmf(ContentResolver r, char dtmf) {
|
||||||
try {
|
try {
|
||||||
if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
|
if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
|
||||||
|
@ -867,21 +832,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
// getLc().getConfig().setInt("misc","transient_provisioning",1);
|
// getLc().getConfig().setInt("misc","transient_provisioning",1);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
public boolean detectVideoCodec(String mime) {
|
|
||||||
for (PayloadType videoCodec : mLc.getVideoPayloadTypes()) {
|
|
||||||
if (mime.equals(videoCodec.getMimeType())) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean detectAudioCodec(String mime){
|
|
||||||
for (PayloadType audioCodec : mLc.getAudioPayloadTypes()) {
|
|
||||||
if (mime.equals(audioCodec.getMimeType())) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateNetworkReachability() {
|
public void updateNetworkReachability() {
|
||||||
if (mConnectivityManager == null) return;
|
if (mConnectivityManager == null) return;
|
||||||
|
|
||||||
|
@ -1088,10 +1038,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
updateNetworkReachability();
|
updateNetworkReachability();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface EcCalibrationListener {
|
|
||||||
void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Call ringingCall;
|
private Call ringingCall;
|
||||||
|
|
||||||
private MediaPlayer mRingerPlayer;
|
private MediaPlayer mRingerPlayer;
|
||||||
|
@ -1538,20 +1484,11 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptCall(Call call) {
|
|
||||||
mLc.acceptCall(call);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean acceptCallWithParams(Call call, CallParams params) {
|
public boolean acceptCallWithParams(Call call, CallParams params) {
|
||||||
mLc.acceptCallWithParams(call, params);
|
mLc.acceptCallWithParams(call, params);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String extractIncomingRemoteName(Resources r, Address linphoneAddress) {
|
|
||||||
return extractADisplayName(r, linphoneAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void adjustVolume(int i) {
|
public void adjustVolume(int i) {
|
||||||
if (Build.VERSION.SDK_INT < 15) {
|
if (Build.VERSION.SDK_INT < 15) {
|
||||||
int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM);
|
int oldVolume = mAudioManager.getStreamVolume(LINPHONE_VOLUME_STREAM);
|
||||||
|
@ -1580,22 +1517,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
return instance != null;
|
return instance != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Call getPendingIncomingCall() {
|
|
||||||
Call currentCall = mLc.getCurrentCall();
|
|
||||||
if (currentCall == null) return null;
|
|
||||||
|
|
||||||
Call.State state = currentCall.getState();
|
|
||||||
boolean incomingPending = currentCall.getDir() == Call.Dir.Incoming
|
|
||||||
&& (state == State.IncomingReceived || state == State.IncomingEarlyMedia);
|
|
||||||
|
|
||||||
return incomingPending ? currentCall : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayLinkPhoneNumber() {
|
|
||||||
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
|
||||||
accountCreator.isAccountLinked();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void isAccountWithAlias(){
|
public void isAccountWithAlias(){
|
||||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
long now = new Timestamp(new Date().getTime()).getTime();
|
long now = new Timestamp(new Date().getTime()).getTime();
|
||||||
|
|
|
@ -1438,7 +1438,7 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getServiceNotificationVisibility() {
|
public boolean getServiceNotificationVisibility() {
|
||||||
return getConfig().getBool("app", "show_service_notification", true);
|
return getConfig().getBool("app", "show_service_notification", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceNotificationVisibility(boolean enable) {
|
public void setServiceNotificationVisibility(boolean enable) {
|
||||||
|
|
|
@ -256,10 +256,6 @@ public final class LinphoneService extends Service {
|
||||||
getApplication().registerActivityLifecycleCallbacks(activityCallbacks = new ActivityMonitor());
|
getApplication().registerActivityLifecycleCallbacks(activityCallbacks = new ActivityMonitor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMessageNotifCount() {
|
|
||||||
return mMsgNotifCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetMessageNotifCount() {
|
public void resetMessageNotifCount() {
|
||||||
mMsgNotifCount = 0;
|
mMsgNotifCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +681,6 @@ public final class LinphoneService extends Service {
|
||||||
int.class, Notification.class};
|
int.class, Notification.class};
|
||||||
private static final Class<?>[] mStopFgSign = new Class[] {boolean.class};
|
private static final Class<?>[] mStopFgSign = new Class[] {boolean.class};
|
||||||
|
|
||||||
private Method mSetForeground;
|
|
||||||
private Method mStartForeground;
|
private Method mStartForeground;
|
||||||
private Method mStopForeground;
|
private Method mStopForeground;
|
||||||
private Object[] mSetForegroundArgs = new Object[1];
|
private Object[] mSetForegroundArgs = new Object[1];
|
||||||
|
@ -719,13 +714,6 @@ public final class LinphoneService extends Service {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back on the old API.
|
|
||||||
if (mSetForeground != null) {
|
|
||||||
mSetForegroundArgs[0] = Boolean.TRUE;
|
|
||||||
invokeMethod(mSetForeground, mSetForegroundArgs);
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyWrapper(id, notification);
|
notifyWrapper(id, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,10 +732,6 @@ public final class LinphoneService extends Service {
|
||||||
// Fall back on the old API. Note to cancel BEFORE changing the
|
// Fall back on the old API. Note to cancel BEFORE changing the
|
||||||
// foreground state, since we could be killed at that point.
|
// foreground state, since we could be killed at that point.
|
||||||
mNM.cancel(id);
|
mNM.cancel(id);
|
||||||
if (mSetForeground != null) {
|
|
||||||
mSetForegroundArgs[0] = Boolean.FALSE;
|
|
||||||
invokeMethod(mSetForeground, mSetForegroundArgs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dumpDeviceInformation() {
|
private void dumpDeviceInformation() {
|
||||||
|
@ -883,19 +867,5 @@ public final class LinphoneService extends Service {
|
||||||
.setClass(this, incomingReceivedActivity)
|
.setClass(this, incomingReceivedActivity)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButAlreadyInCall() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButCannotGetCallParameters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButWrongDestinationAddress() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCallEncryptionChanged(final Call call, final boolean encrypted,
|
|
||||||
final String authenticationToken) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -300,40 +300,11 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<Call> getCallsNotInConf(Core lc) {
|
|
||||||
List<Call> l=new ArrayList<Call>();
|
|
||||||
for(Call c : lc.getCalls()){
|
|
||||||
if (!(c.getConference() != null)){
|
|
||||||
l.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final List<Call> getCallsInConf(Core lc) {
|
|
||||||
List<Call> l=new ArrayList<Call>();
|
|
||||||
for(Call c : lc.getCalls()){
|
|
||||||
if ((c.getConference() != null)){
|
|
||||||
l.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final List<Call> getCalls(Core lc) {
|
public static final List<Call> getCalls(Core lc) {
|
||||||
// return a modifiable list
|
// return a modifiable list
|
||||||
return new ArrayList<Call>(Arrays.asList(lc.getCalls()));
|
return new ArrayList<Call>(Arrays.asList(lc.getCalls()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final boolean hasExistingResumeableCall(Core lc) {
|
|
||||||
for (Call c : getCalls(lc)) {
|
|
||||||
if (c.getState() == State.Paused) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final List<Call> getCallsInState(Core lc, Collection<State> states) {
|
public static final List<Call> getCallsInState(Core lc, Collection<State> states) {
|
||||||
List<Call> foundCalls = new ArrayList<Call>();
|
List<Call> foundCalls = new ArrayList<Call>();
|
||||||
for (Call call : getCalls(lc)) {
|
for (Call call : getCalls(lc)) {
|
||||||
|
@ -343,25 +314,6 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return foundCalls;
|
return foundCalls;
|
||||||
}
|
}
|
||||||
public static final List<Call> getRunningOrPausedCalls(Core lc) {
|
|
||||||
return getCallsInState(lc, Arrays.asList(
|
|
||||||
State.Paused,
|
|
||||||
State.PausedByRemote,
|
|
||||||
State.StreamsRunning));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int countConferenceCalls(Core lc) {
|
|
||||||
int count = lc.getConferenceSize();
|
|
||||||
if ((lc.getConference() != null)) count--;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int countVirtualCalls(Core lc) {
|
|
||||||
return lc.getCallsNb() - countConferenceCalls(lc);
|
|
||||||
}
|
|
||||||
public static int countNonConferenceCalls(Core lc) {
|
|
||||||
return lc.getCallsNb() - countConferenceCalls(lc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setVisibility(View v, int id, boolean visible) {
|
public static void setVisibility(View v, int id, boolean visible) {
|
||||||
v.findViewById(id).setVisibility(visible ? VISIBLE : GONE);
|
v.findViewById(id).setVisibility(visible ? VISIBLE : GONE);
|
||||||
|
@ -369,15 +321,6 @@ public final class LinphoneUtils {
|
||||||
public static void setVisibility(View v, boolean visible) {
|
public static void setVisibility(View v, boolean visible) {
|
||||||
v.setVisibility(visible ? VISIBLE : GONE);
|
v.setVisibility(visible ? VISIBLE : GONE);
|
||||||
}
|
}
|
||||||
public static void enableView(View root, int id, OnClickListener l, boolean enable) {
|
|
||||||
View v = root.findViewById(id);
|
|
||||||
v.setVisibility(enable ? VISIBLE : GONE);
|
|
||||||
v.setOnClickListener(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int pixelsToDpi(Resources res, int pixels) {
|
|
||||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCallRunning(Call call)
|
public static boolean isCallRunning(Call call)
|
||||||
{
|
{
|
||||||
|
@ -426,14 +369,6 @@ public final class LinphoneUtils {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearLogs() {
|
|
||||||
try {
|
|
||||||
Runtime.getRuntime().exec(new String[] { "logcat", "-c" });
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean zipLogs(StringBuilder sb, String toZipFile){
|
public static boolean zipLogs(StringBuilder sb, String toZipFile){
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
@ -455,45 +390,6 @@ public final class LinphoneUtils {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void collectLogs(Context context, String email) {
|
|
||||||
BufferedReader br = null;
|
|
||||||
Process p = null;
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
try {
|
|
||||||
p = Runtime.getRuntime().exec(new String[] { "logcat", "-d", "|", "grep", "`adb shell ps | grep " + context.getPackageName() + " | cut -c10-15`" });
|
|
||||||
br = new BufferedReader(new InputStreamReader(p.getInputStream()), 2048);
|
|
||||||
|
|
||||||
String line;
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
sb.append(line);
|
|
||||||
sb.append("\r\n");
|
|
||||||
}
|
|
||||||
String zipFilePath = context.getExternalFilesDir(null).getAbsolutePath() + "/logs.zip";
|
|
||||||
Log.i("Saving logs to " + zipFilePath);
|
|
||||||
|
|
||||||
if( zipLogs(sb, zipFilePath) ) {
|
|
||||||
final String appName = (context != null) ? context.getString(R.string.app_name) : "Linphone(?)";
|
|
||||||
|
|
||||||
Uri zipURI = Uri.parse("file://" + zipFilePath);
|
|
||||||
Intent i = new Intent(Intent.ACTION_SEND);
|
|
||||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
|
|
||||||
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
|
|
||||||
i.putExtra(Intent.EXTRA_TEXT, appName + " logs");
|
|
||||||
i.setType("application/zip");
|
|
||||||
i.putExtra(Intent.EXTRA_STREAM, zipURI);
|
|
||||||
try {
|
|
||||||
context.startActivity(Intent.createChooser(i, "Send mail..."));
|
|
||||||
} catch (android.content.ActivityNotFoundException ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getNameFromFilePath(String filePath) {
|
public static String getNameFromFilePath(String filePath) {
|
||||||
String name = filePath;
|
String name = filePath;
|
||||||
int i = filePath.lastIndexOf('/');
|
int i = filePath.lastIndexOf('/');
|
||||||
|
@ -577,40 +473,6 @@ public final class LinphoneUtils {
|
||||||
return sipAddress;
|
return sipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeImage(Context context, ChatMessage msg) {
|
|
||||||
if (msg == null || msg.getFileTransferInformation() == null || msg.getAppdata() == null) return;
|
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppdata());
|
|
||||||
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
|
|
||||||
if (bm == null) return;
|
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(Images.Media.TITLE, file.getName());
|
|
||||||
String extension = msg.getFileTransferInformation().getSubtype();
|
|
||||||
values.put(Images.Media.MIME_TYPE, "image/" + extension);
|
|
||||||
ContentResolver cr = context.getContentResolver();
|
|
||||||
Uri path = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
|
||||||
|
|
||||||
OutputStream stream;
|
|
||||||
try {
|
|
||||||
stream = cr.openOutputStream(path);
|
|
||||||
if (extension != null && extension.toLowerCase(Locale.getDefault()).equals("png")) {
|
|
||||||
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
|
||||||
} else {
|
|
||||||
bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.close();
|
|
||||||
file.delete();
|
|
||||||
bm.recycle();
|
|
||||||
|
|
||||||
msg.setAppdata(path.toString());
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
Log.e(e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Context getContext() {
|
private static Context getContext() {
|
||||||
if (context == null && LinphoneManager.isInstanciated())
|
if (context == null && LinphoneManager.isInstanciated())
|
||||||
context = LinphoneManager.getInstance().getContext();
|
context = LinphoneManager.getInstance().getContext();
|
||||||
|
@ -723,19 +585,6 @@ public final class LinphoneUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCountry(DialPlan c, EditText dialCode, Button selectCountry, int countryCode) {
|
|
||||||
if( c != null && dialCode != null && selectCountry != null) {
|
|
||||||
dialCode.setText(c.getCountryCallingCode());
|
|
||||||
selectCountry.setText(c.getCountry());
|
|
||||||
} else {
|
|
||||||
if(countryCode != -1){
|
|
||||||
dialCode.setText("+" + countryCode);
|
|
||||||
} else {
|
|
||||||
dialCode.setText("+");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void displayErrorAlert(String msg, Context ctxt) {
|
public static void displayErrorAlert(String msg, Context ctxt) {
|
||||||
if (ctxt != null && msg != null) {
|
if (ctxt != null && msg != null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
||||||
ChatRoom room = (ChatRoom)obj;
|
ChatRoom room = (ChatRoom)obj;
|
||||||
lc.deleteChatRoom(room);
|
lc.deleteChatRoom(room);
|
||||||
}
|
}
|
||||||
mChatRoomsAdapter.refresh();
|
refreshChatRoomsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue