Some fixes + choice to use old history list
This commit is contained in:
parent
8341021cfd
commit
3a66c0490c
9 changed files with 374 additions and 3 deletions
49
res/layout/history_cell_simple.xml
Normal file
49
res/layout/history_cell_simple.xml
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/list_selector"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_call_direction"
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/call_status_incoming"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sipUri"
|
||||
android:lines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_detail"
|
||||
android:id="@+id/detail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/list_detail"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.9"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/list_delete"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp" />
|
||||
|
||||
</LinearLayout>
|
64
res/layout/history_simple.xml
Normal file
64
res/layout/history_simple.xml
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_all_calls"
|
||||
android:id="@+id/allCalls"
|
||||
android:src="@drawable/history_all"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_missed_calls"
|
||||
android:id="@+id/missedCalls"
|
||||
android:src="@drawable/history_missed"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_edit"
|
||||
android:id="@+id/edit"
|
||||
android:src="@drawable/history_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_validate"
|
||||
android:id="@+id/ok"
|
||||
android:src="@drawable/ok"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/historyList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@android:color/darker_gray"
|
||||
android:cacheColorHint="@color/transparent"
|
||||
android:dividerHeight="1dp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -79,6 +79,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:layout="@layout/status" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
||||
|
||||
<!-- Interface settings -->
|
||||
<bool name="use_simple_history">true</bool>
|
||||
<bool name="hide_camera_settings">false</bool>
|
||||
<bool name="hide_wizard">false</bool>
|
||||
<bool name="hide_accounts">false</bool>
|
||||
|
|
|
@ -262,7 +262,8 @@
|
|||
android:switchTextOn="@string/yes"
|
||||
android:switchTextOff="@string/no"
|
||||
android:key="@string/pref_debug_key"
|
||||
android:title="@string/pref_debug" android:enabled="true"/>
|
||||
android:title="@string/pref_debug"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:title="@string/pref_network_title">
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
<CheckBoxPreference
|
||||
android:title="@string/pref_enable_outbound_proxy"
|
||||
android:dialogMessage="@string/pref_help_outbound_proxy"
|
||||
android:summary="@string/pref_help_outbound_proxy"
|
||||
android:persistent="true"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
|
|
249
src/org/linphone/HistorySimpleFragment.java
Normal file
249
src/org/linphone/HistorySimpleFragment.java
Normal file
|
@ -0,0 +1,249 @@
|
|||
package org.linphone;
|
||||
/*
|
||||
HistoryFragment.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.core.CallDirection;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCallLog;
|
||||
import org.linphone.core.LinphoneCallLog.CallStatus;
|
||||
|
||||
import android.content.Context;
|
||||
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;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class HistorySimpleFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||
private ListView historyList;
|
||||
private LayoutInflater mInflater;
|
||||
private ImageView allCalls, missedCalls, edit, ok;
|
||||
private boolean onlyDisplayMissedCalls, isEditMode;
|
||||
private List<LinphoneCallLog> mLogs;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mInflater = inflater;
|
||||
View view = inflater.inflate(R.layout.history_simple, container, false);
|
||||
|
||||
historyList = (ListView) view.findViewById(R.id.historyList);
|
||||
historyList.setOnItemClickListener(this);
|
||||
registerForContextMenu(historyList);
|
||||
|
||||
allCalls = (ImageView) view.findViewById(R.id.allCalls);
|
||||
allCalls.setOnClickListener(this);
|
||||
missedCalls = (ImageView) view.findViewById(R.id.missedCalls);
|
||||
missedCalls.setOnClickListener(this);
|
||||
allCalls.setEnabled(false);
|
||||
onlyDisplayMissedCalls = false;
|
||||
edit = (ImageView) view.findViewById(R.id.edit);
|
||||
edit.setOnClickListener(this);
|
||||
ok = (ImageView) view.findViewById(R.id.ok);
|
||||
ok.setOnClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (LinphoneActivity.isInstanciated())
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY);
|
||||
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
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();
|
||||
|
||||
if (id == R.id.allCalls) {
|
||||
allCalls.setEnabled(false);
|
||||
missedCalls.setEnabled(true);
|
||||
onlyDisplayMissedCalls = false;
|
||||
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
}
|
||||
else if (id == R.id.missedCalls) {
|
||||
allCalls.setEnabled(true);
|
||||
missedCalls.setEnabled(false);
|
||||
onlyDisplayMissedCalls = true;
|
||||
}
|
||||
else if (id == R.id.ok) {
|
||||
edit.setVisibility(View.VISIBLE);
|
||||
ok.setVisibility(View.GONE);
|
||||
isEditMode = false;
|
||||
}
|
||||
else if (id == R.id.edit) {
|
||||
edit.setVisibility(View.GONE);
|
||||
ok.setVisibility(View.VISIBLE);
|
||||
isEditMode = true;
|
||||
}
|
||||
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
|
||||
if (isEditMode) {
|
||||
LinphoneCallLog log = mLogs.get(position);
|
||||
LinphoneManager.getLc().removeCallLog(log);
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
} else {
|
||||
LinphoneCallLog log = mLogs.get(position);
|
||||
LinphoneAddress address;
|
||||
if (log.getDirection() == CallDirection.Incoming) {
|
||||
address = log.getFrom();
|
||||
} else {
|
||||
address = log.getTo();
|
||||
}
|
||||
LinphoneActivity.instance().displayHistoryDetail(address.asStringUriOnly(), log);
|
||||
}
|
||||
}
|
||||
|
||||
class CallHistoryAdapter extends BaseAdapter {
|
||||
private Bitmap missedCall, outgoingCall, incomingCall;
|
||||
|
||||
CallHistoryAdapter(Context aContext) {
|
||||
missedCall = BitmapFactory.decodeResource(getResources(), R.drawable.call_status_missed);
|
||||
|
||||
if (onlyDisplayMissedCalls) {
|
||||
List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>();
|
||||
for (LinphoneCallLog log : mLogs) {
|
||||
if (log.getStatus() == CallStatus.Missed) {
|
||||
missedCalls.add(log);
|
||||
}
|
||||
}
|
||||
mLogs = missedCalls;
|
||||
} else {
|
||||
outgoingCall = BitmapFactory.decodeResource(getResources(), R.drawable.call_status_outgoing);
|
||||
incomingCall = BitmapFactory.decodeResource(getResources(), R.drawable.call_status_incoming);
|
||||
}
|
||||
}
|
||||
public int getCount() {
|
||||
return mLogs.size();
|
||||
}
|
||||
|
||||
public Object getItem(int position) {
|
||||
return mLogs.get(position);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
} else {
|
||||
view = mInflater.inflate(R.layout.history_cell_simple, parent,false);
|
||||
}
|
||||
|
||||
LinphoneCallLog log = mLogs.get(position);
|
||||
LinphoneAddress address;
|
||||
|
||||
TextView contact = (TextView) view.findViewById(R.id.sipUri);
|
||||
ImageView detail = (ImageView) view.findViewById(R.id.detail);
|
||||
ImageView delete = (ImageView) view.findViewById(R.id.delete);
|
||||
ImageView callDirection = (ImageView) view.findViewById(R.id.icon);
|
||||
|
||||
|
||||
if (log.getDirection() == CallDirection.Incoming) {
|
||||
address = log.getFrom();
|
||||
if (log.getStatus() == CallStatus.Missed) {
|
||||
callDirection.setImageBitmap(missedCall);
|
||||
} else {
|
||||
callDirection.setImageBitmap(incomingCall);
|
||||
}
|
||||
} else {
|
||||
address = log.getTo();
|
||||
callDirection.setImageBitmap(outgoingCall);
|
||||
}
|
||||
|
||||
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());
|
||||
String displayName = address.getDisplayName();
|
||||
String sipUri = address.asStringUriOnly();
|
||||
|
||||
if (displayName == null) {
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||
} else {
|
||||
contact.setText(sipUri);
|
||||
}
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(address.getDisplayName())) {
|
||||
contact.setText(LinphoneUtils.getUsernameFromAddress(address.getDisplayName()));
|
||||
} else {
|
||||
contact.setText(displayName);
|
||||
}
|
||||
}
|
||||
view.setTag(sipUri);
|
||||
|
||||
if (isEditMode) {
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
detail.setVisibility(View.GONE);
|
||||
} else {
|
||||
delete.setVisibility(View.GONE);
|
||||
detail.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -185,7 +185,11 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
|
||||
switch (newFragmentType) {
|
||||
case HISTORY:
|
||||
newFragment = new HistoryFragment();
|
||||
if (getResources().getBoolean(R.bool.use_simple_history)) {
|
||||
newFragment = new HistorySimpleFragment();
|
||||
} else {
|
||||
newFragment = new HistoryFragment();
|
||||
}
|
||||
break;
|
||||
case HISTORY_DETAIL:
|
||||
newFragment = new HistoryDetailFragment();
|
||||
|
|
|
@ -308,7 +308,7 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
|||
videoSettings.removeAll();
|
||||
videoSettings.setLayoutResource(R.layout.hidden);
|
||||
|
||||
CheckBoxPreference enableVideo = (CheckBoxPreference) findPreference(R.string.pref_video_enable_key);
|
||||
Preference enableVideo = findPreference(R.string.pref_video_enable_key);
|
||||
enableVideo.setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue