Added context menu for history log, chat threads and chat messages
This commit is contained in:
parent
9751e6a842
commit
0807e6c5cd
12 changed files with 96 additions and 11 deletions
BIN
res/drawable/call_disabled.png
Normal file
BIN
res/drawable/call_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
res/drawable/call_state_outgoing_default.png
Normal file
BIN
res/drawable/call_state_outgoing_default.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -2,6 +2,8 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/chat_send_message_over" />
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/chat_send_message_disabled" />
|
||||
<item
|
||||
android:drawable="@drawable/chat_send_message_default" />
|
||||
</selector>
|
||||
|
|
BIN
res/drawable/chat_send_message_disabled.png
Normal file
BIN
res/drawable/chat_send_message_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -3,7 +3,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.linphone.ui.AddressText
|
||||
android:id="@+id/Adress"
|
||||
|
@ -19,7 +19,7 @@
|
|||
android:layout_gravity="center" />
|
||||
|
||||
<org.linphone.ui.Numpad
|
||||
android:id="@+id/Dialer"
|
||||
android:id="@+id/Dialer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.15" />
|
||||
|
|
|
@ -254,6 +254,7 @@
|
|||
<string name="pref_help_username">Example: john if your account is john@sip.linphone.org</string>
|
||||
<string name="pref_help_domain">sip.linphone.org if your account is john@sip.linphone.org</string>
|
||||
|
||||
<string name="delete">Delete</string>
|
||||
<string name="chat">Chat</string>
|
||||
<string name="add_to_contacts">Add to contacts</string>
|
||||
<string name="status_connected">CONNECTED</string>
|
||||
|
|
|
@ -29,7 +29,10 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -102,6 +105,18 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneO
|
|||
return view;
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
messagesLayout.removeAllViews();
|
||||
List<ChatMessage> messagesList = LinphoneActivity.instance().getChatMessages(sipUri);
|
||||
|
||||
previousMessageID = -1;
|
||||
for (ChatMessage msg : messagesList) {
|
||||
displayMessage(msg.getId(), msg.getMessage(), msg.getTimestamp(), msg.isIncoming(), messagesLayout);
|
||||
}
|
||||
|
||||
scrollToEnd();
|
||||
}
|
||||
|
||||
private void displayMessage(final int id, final String message, final String time, final boolean isIncoming, final RelativeLayout layout) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -109,10 +124,24 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneO
|
|||
BubbleChat bubble = new BubbleChat(layout.getContext(), id, message, time, isIncoming, previousMessageID);
|
||||
previousMessageID = id;
|
||||
layout.addView(bubble.getView());
|
||||
registerForContextMenu(bubble.getView());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.add(0, v.getId(), 0, getString(R.string.delete));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
LinphoneActivity.instance().deleteMessage(item.getItemId());
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -24,11 +24,15 @@ import org.linphone.core.LinphoneCoreFactory;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -53,6 +57,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
View view = inflater.inflate(R.layout.chatlist, container, false);
|
||||
chatList = (ListView) view.findViewById(R.id.chatList);
|
||||
chatList.setOnItemClickListener(this);
|
||||
registerForContextMenu(chatList);
|
||||
|
||||
edit = (ImageView) view.findViewById(R.id.edit);
|
||||
edit.setOnClickListener(this);
|
||||
|
@ -74,6 +79,23 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
mConversations = LinphoneActivity.instance().getChatList();
|
||||
chatList.setAdapter(new ChatListAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.add(0, v.getId(), 0, getString(R.string.delete));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||
String sipUri = (String) info.targetView.getTag();
|
||||
|
||||
LinphoneActivity.instance().removeFromChatList(sipUri);
|
||||
mConversations = LinphoneActivity.instance().getChatList();
|
||||
chatList.setAdapter(new ChatListAdapter());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.core.Log;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
@ -103,6 +105,11 @@ public class ChatStorage {
|
|||
return chatList;
|
||||
}
|
||||
|
||||
public void deleteMessage(int id) {
|
||||
db.delete(TABLE_NAME, "id LIKE " + id, null);
|
||||
Log.d("db.delete(TABLE_NAME, \"id LIKE \" + " + id + ", null);");
|
||||
}
|
||||
|
||||
class ChatHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final int DATABASE_VERSION = 1;
|
||||
|
|
|
@ -31,11 +31,15 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -60,6 +64,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
|
||||
historyList = (ListView) view.findViewById(R.id.historyList);
|
||||
historyList.setOnItemClickListener(this);
|
||||
registerForContextMenu(historyList);
|
||||
|
||||
allCalls = (ImageView) view.findViewById(R.id.allCalls);
|
||||
allCalls.setOnClickListener(this);
|
||||
|
@ -85,6 +90,22 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.add(0, v.getId(), 0, getString(R.string.delete));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||
LinphoneCallLog log = mLogs.get(info.position);
|
||||
LinphoneManager.getLc().removeCallLog(log);
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
|
|
@ -579,6 +579,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
return currentFragment;
|
||||
}
|
||||
|
||||
public void deleteMessage(int id) {
|
||||
if (chatStorage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chatStorage.deleteMessage(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
|
||||
|
|
|
@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.ui;
|
||||
|
||||
import org.linphone.DialerFragment;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
|
@ -49,7 +48,9 @@ public class Digit extends Button implements AddressAware {
|
|||
int after) {
|
||||
super.onTextChanged(text, start, before, after);
|
||||
|
||||
if (text == null || text.length() < 1) return;
|
||||
if (text == null || text.length() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
DialKeyListener lListener = new DialKeyListener();
|
||||
setOnClickListener(lListener);
|
||||
|
@ -57,11 +58,9 @@ public class Digit extends Button implements AddressAware {
|
|||
|
||||
if ("0+".equals(text)) {
|
||||
setOnLongClickListener(lListener);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Digit(Context context, AttributeSet attrs, int style) {
|
||||
super(context, attrs, style);
|
||||
setLongClickable(true);
|
||||
|
@ -70,7 +69,6 @@ public class Digit extends Button implements AddressAware {
|
|||
public Digit(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLongClickable(true);
|
||||
|
||||
}
|
||||
|
||||
public Digit(Context context) {
|
||||
|
@ -78,9 +76,6 @@ public class Digit extends Button implements AddressAware {
|
|||
setLongClickable(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private class DialKeyListener implements OnClickListener, OnTouchListener, OnLongClickListener {
|
||||
final CharSequence mKeyCode;
|
||||
boolean mIsDtmfStarted;
|
||||
|
@ -104,7 +99,7 @@ public class Digit extends Button implements AddressAware {
|
|||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.stopDtmf();
|
||||
mIsDtmfStarted =false;
|
||||
if (lc.isIncall() && !DialerFragment.instance().mVisible) {
|
||||
if (lc.isIncall()) {
|
||||
lc.sendDtmf(mKeyCode.charAt(0));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue