diff --git a/.gitignore b/.gitignore index cb720f5e2..10d46ec48 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ tests/*$py.class tests/build.xml res/.DS_Store bc-android.keystore +res/raw/lpconfig.xsd diff --git a/res/drawable-xhdpi/route_bluetooth_off_default.png b/res/drawable-xhdpi/route_bluetooth_off_default.png deleted file mode 100644 index 01bc1f291..000000000 Binary files a/res/drawable-xhdpi/route_bluetooth_off_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_bluetooth_off_disabled.png b/res/drawable-xhdpi/route_bluetooth_off_disabled.png deleted file mode 100644 index 3d03f1cba..000000000 Binary files a/res/drawable-xhdpi/route_bluetooth_off_disabled.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_bluetooth_off_over.png b/res/drawable-xhdpi/route_bluetooth_off_over.png deleted file mode 100644 index 66112a8d7..000000000 Binary files a/res/drawable-xhdpi/route_bluetooth_off_over.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_bluetooth_on_default.png b/res/drawable-xhdpi/route_bluetooth_on_default.png deleted file mode 100644 index 841c93b65..000000000 Binary files a/res/drawable-xhdpi/route_bluetooth_on_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_phone_off_default.png b/res/drawable-xhdpi/route_phone_off_default.png deleted file mode 100644 index 4510f0bcb..000000000 Binary files a/res/drawable-xhdpi/route_phone_off_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_phone_off_disabled.png b/res/drawable-xhdpi/route_phone_off_disabled.png deleted file mode 100644 index 8c9405533..000000000 Binary files a/res/drawable-xhdpi/route_phone_off_disabled.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_phone_off_over.png b/res/drawable-xhdpi/route_phone_off_over.png deleted file mode 100644 index bc383167e..000000000 Binary files a/res/drawable-xhdpi/route_phone_off_over.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_phone_on_default.png b/res/drawable-xhdpi/route_phone_on_default.png deleted file mode 100644 index 16cc9e2f3..000000000 Binary files a/res/drawable-xhdpi/route_phone_on_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_speaker_off_default.png b/res/drawable-xhdpi/route_speaker_off_default.png deleted file mode 100644 index 908031972..000000000 Binary files a/res/drawable-xhdpi/route_speaker_off_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_speaker_off_disabled.png b/res/drawable-xhdpi/route_speaker_off_disabled.png deleted file mode 100644 index 8294f5251..000000000 Binary files a/res/drawable-xhdpi/route_speaker_off_disabled.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_speaker_off_over.png b/res/drawable-xhdpi/route_speaker_off_over.png deleted file mode 100644 index f6c5ce9f6..000000000 Binary files a/res/drawable-xhdpi/route_speaker_off_over.png and /dev/null differ diff --git a/res/drawable-xhdpi/route_speaker_on_default.png b/res/drawable-xhdpi/route_speaker_on_default.png deleted file mode 100644 index 8cfdc036a..000000000 Binary files a/res/drawable-xhdpi/route_speaker_on_default.png and /dev/null differ diff --git a/res/drawable-xhdpi/routes_bluetooth_off_default.png b/res/drawable-xhdpi/routes_bluetooth_off_default.png new file mode 100644 index 000000000..fa4c9417e Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_off_default.png differ diff --git a/res/drawable-xhdpi/routes_bluetooth_off_disabled.png b/res/drawable-xhdpi/routes_bluetooth_off_disabled.png new file mode 100644 index 000000000..67dedd040 Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_off_disabled.png differ diff --git a/res/drawable-xhdpi/routes_bluetooth_off_over.png b/res/drawable-xhdpi/routes_bluetooth_off_over.png new file mode 100644 index 000000000..a4c2eec95 Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_off_over.png differ diff --git a/res/drawable-xhdpi/routes_bluetooth_on_default.png b/res/drawable-xhdpi/routes_bluetooth_on_default.png new file mode 100644 index 000000000..346db2f9e Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_on_default.png differ diff --git a/res/drawable-xhdpi/routes_bluetooth_on_disabled.png b/res/drawable-xhdpi/routes_bluetooth_on_disabled.png new file mode 100644 index 000000000..d230b127d Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_on_disabled.png differ diff --git a/res/drawable-xhdpi/routes_bluetooth_on_over.png b/res/drawable-xhdpi/routes_bluetooth_on_over.png new file mode 100644 index 000000000..68a2ec19a Binary files /dev/null and b/res/drawable-xhdpi/routes_bluetooth_on_over.png differ diff --git a/res/drawable-xhdpi/routes_phone_off_default.png b/res/drawable-xhdpi/routes_phone_off_default.png new file mode 100644 index 000000000..dccec9086 Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_off_default.png differ diff --git a/res/drawable-xhdpi/routes_phone_off_disabled.png b/res/drawable-xhdpi/routes_phone_off_disabled.png new file mode 100644 index 000000000..9aafeeca9 Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_off_disabled.png differ diff --git a/res/drawable-xhdpi/routes_phone_off_over.png b/res/drawable-xhdpi/routes_phone_off_over.png new file mode 100644 index 000000000..72b5021f2 Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_off_over.png differ diff --git a/res/drawable-xhdpi/routes_phone_on_default.png b/res/drawable-xhdpi/routes_phone_on_default.png new file mode 100644 index 000000000..c82423761 Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_on_default.png differ diff --git a/res/drawable-xhdpi/routes_phone_on_disabled.png b/res/drawable-xhdpi/routes_phone_on_disabled.png new file mode 100644 index 000000000..a4787ecee Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_on_disabled.png differ diff --git a/res/drawable-xhdpi/routes_phone_on_over.png b/res/drawable-xhdpi/routes_phone_on_over.png new file mode 100644 index 000000000..c7e5ff1c8 Binary files /dev/null and b/res/drawable-xhdpi/routes_phone_on_over.png differ diff --git a/res/drawable-xhdpi/routes_selected.png b/res/drawable-xhdpi/routes_selected.png index 9930fd81e..88196d339 100644 Binary files a/res/drawable-xhdpi/routes_selected.png and b/res/drawable-xhdpi/routes_selected.png differ diff --git a/res/drawable-xhdpi/routes_speaker_off_default.png b/res/drawable-xhdpi/routes_speaker_off_default.png new file mode 100644 index 000000000..f641aca07 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_off_default.png differ diff --git a/res/drawable-xhdpi/routes_speaker_off_disabled.png b/res/drawable-xhdpi/routes_speaker_off_disabled.png new file mode 100644 index 000000000..3565c0fe2 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_off_disabled.png differ diff --git a/res/drawable-xhdpi/routes_speaker_off_over.png b/res/drawable-xhdpi/routes_speaker_off_over.png new file mode 100644 index 000000000..a3bd8ee47 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_off_over.png differ diff --git a/res/drawable-xhdpi/routes_speaker_on_default.png b/res/drawable-xhdpi/routes_speaker_on_default.png new file mode 100644 index 000000000..194e34896 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_on_default.png differ diff --git a/res/drawable-xhdpi/routes_speaker_on_disabled.png b/res/drawable-xhdpi/routes_speaker_on_disabled.png new file mode 100644 index 000000000..402b7de14 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_on_disabled.png differ diff --git a/res/drawable-xhdpi/routes_speaker_on_over.png b/res/drawable-xhdpi/routes_speaker_on_over.png new file mode 100644 index 000000000..e32ad0941 Binary files /dev/null and b/res/drawable-xhdpi/routes_speaker_on_over.png differ diff --git a/res/drawable/route_bluetooth_off.xml b/res/drawable/route_bluetooth_off.xml index 56ca08591..50964a542 100644 --- a/res/drawable/route_bluetooth_off.xml +++ b/res/drawable/route_bluetooth_off.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_bluetooth_off_over" /> + android:drawable="@drawable/routes_bluetooth_off_disabled" /> + android:drawable="@drawable/routes_bluetooth_off_default" /> diff --git a/res/drawable/route_bluetooth_on.xml b/res/drawable/route_bluetooth_on.xml index 14b68aa46..257dbd2c6 100644 --- a/res/drawable/route_bluetooth_on.xml +++ b/res/drawable/route_bluetooth_on.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_bluetooth_on_over" /> + android:drawable="@drawable/routes_bluetooth_on_disabled" /> + android:drawable="@drawable/routes_bluetooth_on_default" /> diff --git a/res/drawable/route_receiver_off.xml b/res/drawable/route_receiver_off.xml index 534279dab..c850ff48e 100644 --- a/res/drawable/route_receiver_off.xml +++ b/res/drawable/route_receiver_off.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_phone_off_over" /> + android:drawable="@drawable/routes_phone_off_disabled" /> + android:drawable="@drawable/routes_phone_off_default" /> diff --git a/res/drawable/route_receiver_on.xml b/res/drawable/route_receiver_on.xml index b8012f68e..7b6d830f9 100644 --- a/res/drawable/route_receiver_on.xml +++ b/res/drawable/route_receiver_on.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_phone_on_over" /> + android:drawable="@drawable/routes_phone_on_disabled" /> + android:drawable="@drawable/routes_phone_on_default" /> diff --git a/res/drawable/route_speaker_off.xml b/res/drawable/route_speaker_off.xml index 0fdc55818..699fad44f 100644 --- a/res/drawable/route_speaker_off.xml +++ b/res/drawable/route_speaker_off.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_speaker_off_over" /> + android:drawable="@drawable/routes_speaker_off_disabled" /> + android:drawable="@drawable/routes_speaker_off_default" /> diff --git a/res/drawable/route_speaker_on.xml b/res/drawable/route_speaker_on.xml index 578561c78..59f0124fb 100644 --- a/res/drawable/route_speaker_on.xml +++ b/res/drawable/route_speaker_on.xml @@ -1,9 +1,9 @@ + android:drawable="@drawable/routes_speaker_on_over" /> + android:drawable="@drawable/routes_speaker_on_disabled" /> + android:drawable="@drawable/routes_speaker_on_default" /> diff --git a/res/layout-FR/chat.xml b/res/layout-FR/chat.xml index 8acf785ba..5eeb2081a 100644 --- a/res/layout-FR/chat.xml +++ b/res/layout-FR/chat.xml @@ -31,7 +31,7 @@ - - + - - + - - + - - + latestImageMessages; + private int messagesFilterLimit = 0; + private List messagesList; private ProgressBar progressBar; private int bytesSent; @@ -148,7 +152,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout); messagesLayout = (RelativeLayout) view.findViewById(R.id.messages); - messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView); + messagesScrollView = (LinphoneScrollView) view.findViewById(R.id.chatScrollView); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); sendImage = (TextView) view.findViewById(R.id.sendPicture); @@ -171,6 +175,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } }); + if (savedInstanceState != null) { + messagesFilterLimit = savedInstanceState.getInt("messagesFilterLimit"); + } displayChat(displayName, pictureUri); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); @@ -223,10 +230,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC return view; } + private void refreshMessages() { + messagesList = LinphoneActivity.instance().getChatMessages(sipUri); + } + @Override public void onSaveInstanceState(Bundle outState) { outState.putString("fileToUploadPath", fileToUploadPath); outState.putParcelable("imageToUpload", imageToUpload); + outState.putInt("messagesFilterLimit", messagesFilterLimit); super.onSaveInstanceState(outState); } @@ -255,32 +267,73 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC public void showKeyboardVisibleMode() { LinphoneActivity.instance().hideMenu(true); contactPicture.setVisibility(View.GONE); - scrollToEnd(); + //scrollToEnd(); } public void hideKeyboardVisibleMode() { LinphoneActivity.instance().hideMenu(false); contactPicture.setVisibility(View.VISIBLE); - scrollToEnd(); + //scrollToEnd(); } private void invalidate() { - messagesLayout.removeAllViews(); - List messagesList = LinphoneActivity.instance().getChatMessages(sipUri); + refreshMessages(); - previousMessageID = -1; - ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage(); - for (ChatMessage msg : messagesList) { - if (msg.getMessage() != null) { - displayMessage(msg.getId(), msg.getMessage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout); - } else { - displayImageMessage(msg.getId(), msg.getImage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout); - } - chatStorage.markMessageAsRead(msg.getId()); - } - LinphoneActivity.instance().updateMissedChatCount(); - - scrollToEnd(); + if (messagesFilterLimit == 0) { + if (messagesList.size() > MESSAGES_STEP) + messagesFilterLimit = MESSAGES_STEP; + else + messagesFilterLimit = messagesList.size(); + } else { + if (messagesFilterLimit + MESSAGES_STEP <= messagesList.size()) + messagesFilterLimit += MESSAGES_STEP; + else + messagesFilterLimit = messagesList.size(); + } + invalidate(messagesFilterLimit); + } + + private void invalidate(final int limit) { + messagesLayout.removeAllViews(); + + mHandler.post(new Runnable() { + @Override + public void run() { + + previousMessageID = -1; + ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage(); + + for (int i = messagesList.size() - limit; i < messagesList.size(); i++) { + ChatMessage msg = messagesList.get(i); + if (msg.getMessage() != null) { + displayMessage(msg.getId(), msg.getMessage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout); + } else { + displayImageMessage(msg.getId(), msg.getImage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout); + } + + if (!msg.isRed()) + chatStorage.markMessageAsRead(msg.getId()); + } + LinphoneActivity.instance().updateMissedChatCount(); + + if (limit < messagesList.size()) { + messagesScrollView.setScrollViewListener(new ScrollViewListener() { + @Override + public void OnScrollToTop(final int previousHeight) { + invalidate();mHandler.postDelayed(new Runnable() { + @Override + public void run() { + //Scroll to latest saw message + messagesScrollView.scrollTo(0, messagesLayout.getChildAt(MESSAGES_STEP-1).getBottom()); + } + }, 300); + } + }); + } else { + messagesScrollView.setScrollViewListener(null); + } + } + }); } private void displayChat(String displayName, String pictureUri) { @@ -288,8 +341,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); } else if (displayName == null) { contactName.setText(sipUri); - } - else { + } else { contactName.setText(displayName); } @@ -299,44 +351,37 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC contactPicture.setImageResource(R.drawable.unknown_small); } - messagesScrollView.post(new Runnable() { - @Override - public void run() { - scrollToEnd(); - } - }); + if (messagesFilterLimit == 0) + invalidate(); + else { + invalidate(messagesFilterLimit); + } - invalidate(); + scrollToEnd(); } - private void displayMessage(final int id, final String message, final String time, final boolean isIncoming, final LinphoneChatMessage.State status, final RelativeLayout layout) { - mHandler.post(new Runnable() { - @Override - public void run() { - BubbleChat bubble = new BubbleChat(layout.getContext(), id, message, null, time, isIncoming, status, previousMessageID); - if (!isIncoming) { - lastSentMessageBubble = bubble; - } - previousMessageID = id; - layout.addView(bubble.getView()); - registerForContextMenu(bubble.getView()); - } - }); + private void displayMessage(int id, String message, String time, boolean isIncoming, LinphoneChatMessage.State status, RelativeLayout layout) { + BubbleChat bubble = new BubbleChat(layout.getContext(), id, message, null, time, isIncoming, status, previousMessageID); + if (!isIncoming) { + lastSentMessageBubble = bubble; + } + + View v = bubble.getView(); + previousMessageID = id; + layout.addView(v); + registerForContextMenu(v); } - private void displayImageMessage(final int id, final Bitmap image, final String time, final boolean isIncoming, final LinphoneChatMessage.State status, final RelativeLayout layout) { - mHandler.post(new Runnable() { - @Override - public void run() { - BubbleChat bubble = new BubbleChat(layout.getContext(), id, null, image, time, isIncoming, status, previousMessageID); - if (!isIncoming) { - lastSentMessageBubble = bubble; - } - previousMessageID = id; - layout.addView(bubble.getView()); - registerForContextMenu(bubble.getView()); - } - }); + private void displayImageMessage(int id, Bitmap image, String time, boolean isIncoming, LinphoneChatMessage.State status, RelativeLayout layout) { + BubbleChat bubble = new BubbleChat(layout.getContext(), id, null, image, time, isIncoming, status, previousMessageID); + if (!isIncoming) { + lastSentMessageBubble = bubble; + } + + View v = bubble.getView(); + previousMessageID = id; + layout.addView(v); + registerForContextMenu(v); } public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) { @@ -351,6 +396,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC LinphoneActivity.instance().getChatStorage().deleteDraft(sipUri); } + messagesFilterLimit = 0; sipUri = newSipUri; if (LinphoneActivity.isInstanciated()) { String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri); @@ -444,7 +490,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT); LinphoneActivity.instance().updateChatFragment(this); } - scrollToEnd(); if (LinphoneActivity.isInstanciated()) { String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri); @@ -503,7 +548,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } private void scrollToEnd() { - mHandler.postDelayed(new Runnable() { + messagesScrollView.postDelayed(new Runnable() { @Override public void run() { messagesScrollView.fullScroll(View.FOCUS_DOWN); @@ -519,14 +564,24 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC } } - public void onMessageReceived(int id, LinphoneAddress from, LinphoneChatMessage message) { + public void onMessageReceived(final int id, LinphoneAddress from, final LinphoneChatMessage message) { if (from.asStringUriOnly().equals(sipUri)) { if (message.getText() != null) { - displayMessage(id, message.getText(), String.valueOf(System.currentTimeMillis()), true, null, messagesLayout); + mHandler.post(new Runnable() { + @Override + public void run() { + displayMessage(id, message.getText(), String.valueOf(System.currentTimeMillis()), true, null, messagesLayout); + } + }); } else if (message.getExternalBodyUrl() != null) { byte[] rawImage = LinphoneActivity.instance().getChatStorage().getRawImageFromMessage(id); - Bitmap bm = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length); - displayImageMessage(id, bm, String.valueOf(System.currentTimeMillis()), true, null, messagesLayout); + final Bitmap bm = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length); + mHandler.post(new Runnable() { + @Override + public void run() { + displayImageMessage(id, bm, String.valueOf(System.currentTimeMillis()), true, null, messagesLayout); + } + }); } scrollToEnd(); } diff --git a/src/org/linphone/ChatMessage.java b/src/org/linphone/ChatMessage.java index 081784ef9..185e3f474 100644 --- a/src/org/linphone/ChatMessage.java +++ b/src/org/linphone/ChatMessage.java @@ -33,8 +33,9 @@ public class ChatMessage { private int status; private int id; private Bitmap image; + private boolean isRed; - public ChatMessage(int id, String message, byte[] rawImage, String timestamp, boolean incoming, int status) { + public ChatMessage(int id, String message, byte[] rawImage, String timestamp, boolean incoming, int status, boolean red) { super(); this.id = id; this.message = message; @@ -42,6 +43,7 @@ public class ChatMessage { this.incoming = incoming; this.status = status; this.image = rawImage != null ? BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length) : null; + this.isRed = red; } public int getId() { @@ -83,4 +85,8 @@ public class ChatMessage { public Bitmap getImage() { return image; } + + public boolean isRed() { + return isRed; + } } diff --git a/src/org/linphone/ChatStorage.java b/src/org/linphone/ChatStorage.java index 55680c18e..714de16b1 100644 --- a/src/org/linphone/ChatStorage.java +++ b/src/org/linphone/ChatStorage.java @@ -55,13 +55,23 @@ public class ChatStorage { } public void updateMessageStatus(String to, String message, int status) { - ContentValues values = new ContentValues(); - values.put("status", status); - - String where = "direction LIKE ? AND remoteContact LIKE ? AND message LIKE ?"; String[] whereArgs = { String.valueOf(OUTGOING), to, message }; + Cursor c = db.query(TABLE_NAME, null, "direction LIKE ? AND remoteContact LIKE ? AND message LIKE ?", whereArgs, null, null, "id DESC"); + + String id = null; + if (c.moveToFirst()) { + try { + id = c.getString(c.getColumnIndex("id")); + } catch (Exception e) { + e.printStackTrace(); + } + } + c.close(); - db.update(TABLE_NAME, values, where, whereArgs); + if (id != null && id.length() > 0) { + int intID = Integer.parseInt(id); + updateMessageStatus(to, intID, status); + } } public void updateMessageStatus(String to, int id, int status) { @@ -183,8 +193,9 @@ public class ChatStorage { timestamp = c.getString(c.getColumnIndex("time")); int status = c.getInt(c.getColumnIndex("status")); byte[] rawImage = c.getBlob(c.getColumnIndex("image")); + int read = c.getInt(c.getColumnIndex("read")); - ChatMessage chatMessage = new ChatMessage(id, message, rawImage, timestamp, direction == INCOMING, status); + ChatMessage chatMessage = new ChatMessage(id, message, rawImage, timestamp, direction == INCOMING, status, read == READ); chatMessages.add(chatMessage); } catch (Exception e) { e.printStackTrace(); diff --git a/src/org/linphone/InCallActivity.java b/src/org/linphone/InCallActivity.java index fc4892a19..c03ea1d24 100644 --- a/src/org/linphone/InCallActivity.java +++ b/src/org/linphone/InCallActivity.java @@ -407,6 +407,7 @@ public class InCallActivity extends FragmentActivity implements } else if (id == R.id.routeBluetooth) { LinphoneManager.getInstance().routeAudioToBluetooth(); + isSpeakerEnabled = false; routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on); routeReceiver.setBackgroundResource(R.drawable.route_receiver_off); routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off); @@ -414,6 +415,7 @@ public class InCallActivity extends FragmentActivity implements } else if (id == R.id.routeReceiver) { LinphoneManager.getInstance().routeAudioToReceiver(); + isSpeakerEnabled = false; routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off); routeReceiver.setBackgroundResource(R.drawable.route_receiver_on); routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off); @@ -421,6 +423,7 @@ public class InCallActivity extends FragmentActivity implements } else if (id == R.id.routeSpeaker) { LinphoneManager.getInstance().routeAudioToSpeaker(); + isSpeakerEnabled = true; routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off); routeReceiver.setBackgroundResource(R.drawable.route_receiver_off); routeSpeaker.setBackgroundResource(R.drawable.route_speaker_on); @@ -940,24 +943,7 @@ public class InCallActivity extends FragmentActivity implements } private void hideOrDisplayAudioRoutes() - { - if (isSpeakerEnabled) { - speaker.setBackgroundResource(R.drawable.speaker_on); - routeSpeaker.setBackgroundResource(R.drawable.route_speaker_on); - routeReceiver.setBackgroundResource(R.drawable.route_receiver_off); - routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off); - } else { - speaker.setBackgroundResource(R.drawable.speaker_off); - routeSpeaker.setBackgroundResource(R.drawable.route_speaker_off); - if (LinphoneManager.getInstance().isUsingBluetoothAudioRoute) { - routeReceiver.setBackgroundResource(R.drawable.route_receiver_off); - routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_on); - } else { - routeReceiver.setBackgroundResource(R.drawable.route_receiver_on); - routeBluetooth.setBackgroundResource(R.drawable.route_bluetooth_off); - } - } - + { if (routeSpeaker.getVisibility() == View.VISIBLE) { routeSpeaker.setVisibility(View.INVISIBLE); routeBluetooth.setVisibility(View.INVISIBLE); diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 0611eb66d..50f4f0417 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -971,7 +971,13 @@ public final class LinphoneManager implements LinphoneCoreListener { mLc.enablePayloadType(videoCodec, enable); } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void doDestroy() { + try { + if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) + mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); + } catch (Exception e) {} + try { mTimer.cancel(); mLc.destroy(); diff --git a/src/org/linphone/ui/LinphoneScrollView.java b/src/org/linphone/ui/LinphoneScrollView.java new file mode 100644 index 000000000..39d9a60ab --- /dev/null +++ b/src/org/linphone/ui/LinphoneScrollView.java @@ -0,0 +1,56 @@ +package org.linphone.ui; +/* +LinphoneScrollView.java +Copyright (C) 2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ScrollView; + +/** + * @author Sylvain Berfini + */ +public class LinphoneScrollView extends ScrollView { + private ScrollViewListener scrollViewListener = null; + + public LinphoneScrollView(Context context) { + super(context); + } + + public LinphoneScrollView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public LinphoneScrollView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setScrollViewListener(ScrollViewListener scrollViewListener) { + this.scrollViewListener = scrollViewListener; + } + + @Override + protected void onScrollChanged(int x, int y, int oldx, int oldy) { + super.onScrollChanged(x, y, oldx, oldy); + if (y >= getMeasuredHeight() && scrollViewListener != null) { + //scrollViewListener.OnScrollToBottom(); + } + else if (y == 0 && scrollViewListener != null) { + scrollViewListener.OnScrollToTop(getMeasuredHeight()); + } + } +} diff --git a/src/org/linphone/ui/ScrollViewListener.java b/src/org/linphone/ui/ScrollViewListener.java new file mode 100644 index 000000000..ff964f604 --- /dev/null +++ b/src/org/linphone/ui/ScrollViewListener.java @@ -0,0 +1,26 @@ +package org.linphone.ui; +/* +ScrollViewListener.java +Copyright (C) 2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * @author Sylvain Berfini + */ +public interface ScrollViewListener { + void OnScrollToTop(int previousHeight); +}