Fix edit mode in history
This commit is contained in:
parent
2c178d8c5f
commit
9067c12a0c
8 changed files with 89 additions and 92 deletions
7
res/drawable/edit_list_button.xml
Normal file
7
res/drawable/edit_list_button.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/edit_list_disabled" />
|
||||
<item
|
||||
android:drawable="@drawable/edit_list" />
|
||||
</selector>
|
5
res/drawable/edit_list_disabled.xml
Normal file
5
res/drawable/edit_list_disabled.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<bitmap
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/edit_list"
|
||||
android:alpha="0.2" />
|
|
@ -2,7 +2,7 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@color/colorJ" />
|
||||
android:drawable="@color/colorH" />
|
||||
<item
|
||||
android:drawable="@color/colorH" />
|
||||
</selector>
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:src="@drawable/edit_list"
|
||||
android:src="@drawable/edit_list_button"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_edit"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="history_date_format">d MMM</string>
|
||||
<string name="history_detail_date_format">yyyy/MM/dd - HH:mm</string>
|
||||
<string name="history_date_format">EEE, d MMM</string>
|
||||
<string name="history_detail_date_format">yyyy/MM/dd - HH:mm - </string>
|
||||
<string name="messages_date_format">HH:mm d MMM</string>
|
||||
<string name="messages_list_date_format">dd/MM</string>
|
||||
<string name="today_date_format">HH:mm</string>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<string name="domain">Domain</string>
|
||||
<string name="remote_provisioning_url">Provisioning url</string>
|
||||
<string name="email">Email</string>
|
||||
<string name="delete_text">Are you sure you want to delete all your selection ?</string>
|
||||
<string name="delete_text">Are you sure you want to delete your selection ?</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
<style name="font10" parent="@android:style/TextAppearance.Medium">
|
||||
<item name="android:textColor">@color/colorD</item>
|
||||
<item name="android:textSize">26sp</item>
|
||||
<item name="android:textSize">24sp</item>
|
||||
</style>
|
||||
|
||||
<style name="font11" parent="@android:style/TextAppearance.Small">
|
||||
|
@ -67,12 +67,12 @@
|
|||
</style>
|
||||
|
||||
<style name="font12" parent="@android:style/TextAppearance.Small">
|
||||
<item name="android:textColor">@color/colorD</item>
|
||||
<item name="android:textColor">@color/colorE</item>
|
||||
<item name="android:textSize">25sp</item>
|
||||
</style>
|
||||
|
||||
<style name="font13" parent="@android:style/TextAppearance.Small">
|
||||
<item name="android:textColor">@color/colorD</item>
|
||||
<item name="android:textColor">@color/colorE</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.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;
|
||||
|
@ -45,7 +42,6 @@ import android.view.animation.Animation.AnimationListener;
|
|||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -64,7 +60,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
private ListView historyList;
|
||||
private LayoutInflater mInflater;
|
||||
private TextView noCallHistory, noMissedCallHistory;
|
||||
private ImageView missedCalls, allCalls, edit, selectAll, deselectAll, deleteAll;
|
||||
private ImageView missedCalls, allCalls, edit, selectAll, deselectAll, delete;
|
||||
private RelativeLayout allCallsSelected, missedCallsSelected;
|
||||
private boolean onlyDisplayMissedCalls, isEditMode;
|
||||
private List<LinphoneCallLog> mLogs;
|
||||
|
@ -80,11 +76,10 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
|
||||
historyList = (ListView) view.findViewById(R.id.historyList);
|
||||
historyList.setOnItemClickListener(this);
|
||||
registerForContextMenu(historyList);
|
||||
|
||||
deleteAll = (ImageView) view.findViewById(R.id.delete);
|
||||
deleteAll.setOnClickListener(this);
|
||||
deleteAll.setVisibility(View.INVISIBLE);
|
||||
delete = (ImageView) view.findViewById(R.id.delete);
|
||||
delete.setOnClickListener(this);
|
||||
delete.setVisibility(View.INVISIBLE);
|
||||
|
||||
allCalls = (ImageView) view.findViewById(R.id.all_calls);
|
||||
allCalls.setOnClickListener(this);
|
||||
|
@ -117,6 +112,23 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
}
|
||||
|
||||
private void selectAllList(boolean isSelectAll){
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
historyList.setItemChecked(i,isSelectAll);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCallLogs(){
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
if(historyList.isItemChecked(i)){
|
||||
LinphoneCallLog log = mLogs.get(i);
|
||||
LinphoneManager.getLc().removeCallLog(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNotMissedCallsFromLogs() {
|
||||
if (onlyDisplayMissedCalls) {
|
||||
List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>();
|
||||
|
@ -164,76 +176,21 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
if (!hideHistoryListAndDisplayMessageIfEmpty()) {
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
if (id == R.id.edit) {
|
||||
edit.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
deleteAll.setVisibility(View.VISIBLE);
|
||||
isEditMode = true;
|
||||
}
|
||||
if (id == R.id.all_calls) {
|
||||
allCalls.setEnabled(false);
|
||||
allCallsSelected.setVisibility(View.VISIBLE);
|
||||
missedCallsSelected.setVisibility(View.INVISIBLE);
|
||||
missedCalls.setEnabled(true);
|
||||
onlyDisplayMissedCalls = false;
|
||||
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
}
|
||||
if (id == R.id.missed_calls) {
|
||||
allCalls.setEnabled(true);
|
||||
allCallsSelected.setVisibility(View.INVISIBLE);
|
||||
missedCallsSelected.setVisibility(View.VISIBLE);
|
||||
missedCalls.setEnabled(false);
|
||||
onlyDisplayMissedCalls = true;
|
||||
}
|
||||
|
||||
if (!hideHistoryListAndDisplayMessageIfEmpty() && !isEditMode) {
|
||||
historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
}
|
||||
|
||||
if(isEditMode){
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (id == R.id.select_all) {
|
||||
deselectAll.setVisibility(View.VISIBLE);
|
||||
selectAll.setVisibility(View.GONE);
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
historyList.setItemChecked(i, true);
|
||||
}
|
||||
selectAllList(true);
|
||||
return;
|
||||
}
|
||||
if (id == R.id.deselect_all) {
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
historyList.setItemChecked(i, false);
|
||||
}
|
||||
selectAllList(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == R.id.delete) {
|
||||
|
@ -244,13 +201,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
delete.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
if(historyList.isItemChecked(i)){
|
||||
LinphoneCallLog log = mLogs.get(i);
|
||||
LinphoneManager.getLc().removeCallLog(log);
|
||||
}
|
||||
}
|
||||
removeCallLogs();
|
||||
dialog.dismiss();
|
||||
quitEditMode();
|
||||
}
|
||||
|
@ -264,7 +215,41 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
}
|
||||
});
|
||||
dialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == R.id.edit) {
|
||||
edit.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
isEditMode = true;
|
||||
}
|
||||
if (id == R.id.all_calls) {
|
||||
allCalls.setEnabled(false);
|
||||
allCallsSelected.setVisibility(View.VISIBLE);
|
||||
missedCallsSelected.setVisibility(View.INVISIBLE);
|
||||
missedCalls.setEnabled(true);
|
||||
onlyDisplayMissedCalls = false;
|
||||
refresh();
|
||||
}
|
||||
if (id == R.id.missed_calls) {
|
||||
allCalls.setEnabled(true);
|
||||
allCallsSelected.setVisibility(View.INVISIBLE);
|
||||
missedCallsSelected.setVisibility(View.VISIBLE);
|
||||
missedCalls.setEnabled(false);
|
||||
onlyDisplayMissedCalls = true;
|
||||
}
|
||||
|
||||
if (!hideHistoryListAndDisplayMessageIfEmpty()) {
|
||||
historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
}
|
||||
|
||||
if(isEditMode){
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
selectAll.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -288,12 +273,12 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
}
|
||||
|
||||
private void hideDeleteAllButton() {
|
||||
if (deleteAll == null || deleteAll.getVisibility() != View.VISIBLE) {
|
||||
if (delete == null || delete.getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (LinphoneActivity.instance().isAnimationDisabled()) {
|
||||
deleteAll.setVisibility(View.INVISIBLE);
|
||||
delete.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right_to_left);
|
||||
animation.setAnimationListener(new AnimationListener() {
|
||||
|
@ -309,21 +294,21 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
deleteAll.setVisibility(View.INVISIBLE);
|
||||
delete.setVisibility(View.INVISIBLE);
|
||||
animation.setAnimationListener(null);
|
||||
}
|
||||
});
|
||||
deleteAll.startAnimation(animation);
|
||||
delete.startAnimation(animation);
|
||||
}
|
||||
}
|
||||
|
||||
private void showDeleteAllButton() {
|
||||
if (deleteAll == null || deleteAll.getVisibility() == View.VISIBLE) {
|
||||
if (delete == null || delete.getVisibility() == View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (LinphoneActivity.instance().isAnimationDisabled()) {
|
||||
deleteAll.setVisibility(View.VISIBLE);
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right);
|
||||
animation.setAnimationListener(new AnimationListener() {
|
||||
|
@ -339,11 +324,11 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
deleteAll.setVisibility(View.VISIBLE);
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
animation.setAnimationListener(null);
|
||||
}
|
||||
});
|
||||
deleteAll.startAnimation(animation);
|
||||
delete.startAnimation(animation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +336,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
isEditMode = false;
|
||||
selectAll.setVisibility(View.GONE);
|
||||
deselectAll.setVisibility(View.GONE);
|
||||
deleteAll.setVisibility(View.GONE);
|
||||
delete.setVisibility(View.GONE);
|
||||
edit.setVisibility(View.VISIBLE);
|
||||
refresh();
|
||||
if (!hideHistoryListAndDisplayMessageIfEmpty()){
|
||||
|
|
Loading…
Reference in a new issue