From a5084da2c801d7ce3ffdac27707c4d1a3a905620 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 20 Sep 2012 16:45:25 +0200 Subject: [PATCH] Some text added under image buttons + animation for history delete all button like iOS --- ...e_disabled.png => toolsbar_background.png} | Bin res/drawable/history_delete.xml | 2 - res/drawable/switch_button_text_color.xml | 7 ++ res/layout/chatlist.xml | 24 ++++-- res/layout/contact.xml | 16 +++- res/layout/contacts_list.xml | 24 ++++-- res/layout/history.xml | 43 +++++++--- res/layout/history_simple.xml | 43 +++++++--- res/values-FR/strings.xml | 10 +++ res/values/color.xml | 2 + res/values/strings.xml | 10 +++ src/org/linphone/ChatListFragment.java | 8 +- src/org/linphone/ContactFragment.java | 7 +- src/org/linphone/ContactsFragment.java | 8 +- src/org/linphone/HistoryFragment.java | 81 ++++++++++++++++-- src/org/linphone/HistorySimpleFragment.java | 81 ++++++++++++++++-- src/org/linphone/LinphoneActivity.java | 1 - 17 files changed, 296 insertions(+), 71 deletions(-) rename res/drawable-hdpi/{history_delete_disabled.png => toolsbar_background.png} (100%) create mode 100644 res/drawable/switch_button_text_color.xml diff --git a/res/drawable-hdpi/history_delete_disabled.png b/res/drawable-hdpi/toolsbar_background.png similarity index 100% rename from res/drawable-hdpi/history_delete_disabled.png rename to res/drawable-hdpi/toolsbar_background.png diff --git a/res/drawable/history_delete.xml b/res/drawable/history_delete.xml index 291afe4bf..e284ffd1f 100644 --- a/res/drawable/history_delete.xml +++ b/res/drawable/history_delete.xml @@ -2,8 +2,6 @@ - diff --git a/res/drawable/switch_button_text_color.xml b/res/drawable/switch_button_text_color.xml new file mode 100644 index 000000000..a849928bc --- /dev/null +++ b/res/drawable/switch_button_text_color.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/res/layout/chatlist.xml b/res/layout/chatlist.xml index 6bfe204df..bc0f8bfb0 100644 --- a/res/layout/chatlist.xml +++ b/res/layout/chatlist.xml @@ -10,30 +10,42 @@ android:layout_height="wrap_content" android:orientation="horizontal"> - - - - - - - - + android:orientation="horizontal" + android:background="@drawable/toolsbar_background"> - - - - - + android:orientation="horizontal" + android:background="@drawable/toolsbar_background"> - - - - - Annuler Retour Allons-y + + Nouveau chat + Modifier + Valider + Tous + SIP + Nouveau contact + Tous + Manqués + Tout supprimer Petite Moyenne diff --git a/res/values/color.xml b/res/values/color.xml index b6432d57c..9816b0f78 100644 --- a/res/values/color.xml +++ b/res/values/color.xml @@ -6,6 +6,8 @@ #ffb9c4cb #ff5b656f #ff7e8e9e + #ff41484f + #ffa6b3bf #ffe4edf2 #ffd8d8d8 diff --git a/res/values/strings.xml b/res/values/strings.xml index e76508c1e..c7cbfaad7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -323,6 +323,16 @@ Cancel Back Let\'s go + + New conversation + Edit + Okay + All + SIP + New contact + All + Missed + Delete All Small Medium diff --git a/src/org/linphone/ChatListFragment.java b/src/org/linphone/ChatListFragment.java index 54e9cf696..b63aec6a1 100644 --- a/src/org/linphone/ChatListFragment.java +++ b/src/org/linphone/ChatListFragment.java @@ -47,7 +47,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte private LayoutInflater mInflater; private List mConversations, mDrafts; private ListView chatList; - private ImageView edit, ok, newDiscussion; + private TextView edit, ok, newDiscussion; private EditText fastNewChat; private boolean isEditMode = false; @@ -61,11 +61,11 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte chatList.setOnItemClickListener(this); registerForContextMenu(chatList); - edit = (ImageView) view.findViewById(R.id.edit); + edit = (TextView) view.findViewById(R.id.edit); edit.setOnClickListener(this); - newDiscussion = (ImageView) view.findViewById(R.id.newDiscussion); + newDiscussion = (TextView) view.findViewById(R.id.newDiscussion); newDiscussion.setOnClickListener(this); - ok = (ImageView) view.findViewById(R.id.ok); + ok = (TextView) view.findViewById(R.id.ok); ok.setOnClickListener(this); fastNewChat = (EditText) view.findViewById(R.id.newFastChat); diff --git a/src/org/linphone/ContactFragment.java b/src/org/linphone/ContactFragment.java index 0074c8649..354f653b8 100644 --- a/src/org/linphone/ContactFragment.java +++ b/src/org/linphone/ContactFragment.java @@ -30,7 +30,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TableLayout; import android.widget.TextView; @@ -39,7 +38,7 @@ import android.widget.TextView; */ public class ContactFragment extends Fragment implements OnClickListener { private Contact contact; - private ImageView editContact, newContact; + private TextView editContact, newContact; private LayoutInflater inflater; private View view; @@ -64,9 +63,9 @@ public class ContactFragment extends Fragment implements OnClickListener { this.inflater = inflater; view = inflater.inflate(R.layout.contact, container, false); - editContact = (ImageView) view.findViewById(R.id.editContact); + editContact = (TextView) view.findViewById(R.id.editContact); editContact.setOnClickListener(this); - newContact = (ImageView) view.findViewById(R.id.newContact); + newContact = (TextView) view.findViewById(R.id.newContact); newContact.setOnClickListener(this); return view; diff --git a/src/org/linphone/ContactsFragment.java b/src/org/linphone/ContactsFragment.java index ad5db9e4f..345bee6f3 100644 --- a/src/org/linphone/ContactsFragment.java +++ b/src/org/linphone/ContactsFragment.java @@ -47,7 +47,7 @@ import android.widget.TextView; public class ContactsFragment extends Fragment implements OnClickListener, OnItemClickListener { private LayoutInflater mInflater; private ListView contactsList; - private ImageView allContacts, linphoneContacts, newContact; + private TextView allContacts, linphoneContacts, newContact; private boolean onlyDisplayLinphoneContacts; private int lastKnownPosition; private AlphabetIndexer indexer; @@ -68,13 +68,13 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte contactsList = (ListView) view.findViewById(R.id.contactsList); contactsList.setOnItemClickListener(this); - allContacts = (ImageView) view.findViewById(R.id.allContacts); + allContacts = (TextView) view.findViewById(R.id.allContacts); allContacts.setOnClickListener(this); - linphoneContacts = (ImageView) view.findViewById(R.id.linphoneContacts); + linphoneContacts = (TextView) view.findViewById(R.id.linphoneContacts); linphoneContacts.setOnClickListener(this); - newContact = (ImageView) view.findViewById(R.id.newContact); + newContact = (TextView) view.findViewById(R.id.newContact); newContact.setOnClickListener(this); newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0); diff --git a/src/org/linphone/HistoryFragment.java b/src/org/linphone/HistoryFragment.java index f6adb8f78..f3c91e867 100644 --- a/src/org/linphone/HistoryFragment.java +++ b/src/org/linphone/HistoryFragment.java @@ -38,6 +38,9 @@ import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.animation.Animation.AnimationListener; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListView; @@ -53,7 +56,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil private Handler mHandler = new Handler(); private ExpandableListView historyList; private LayoutInflater mInflater; - private ImageView allCalls, missedCalls, edit, ok, deleteAll; + private TextView allCalls, missedCalls, edit, ok, deleteAll; private boolean onlyDisplayMissedCalls, isEditMode; private SparseArray> mLogs; @@ -67,23 +70,23 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil historyList.setOnChildClickListener(this); historyList.setOnGroupClickListener(this); - deleteAll = (ImageView) view.findViewById(R.id.deleteAll); + deleteAll = (TextView) view.findViewById(R.id.deleteAll); deleteAll.setOnClickListener(this); - deleteAll.setEnabled(false); + deleteAll.setVisibility(View.INVISIBLE); - allCalls = (ImageView) view.findViewById(R.id.allCalls); + allCalls = (TextView) view.findViewById(R.id.allCalls); allCalls.setOnClickListener(this); - missedCalls = (ImageView) view.findViewById(R.id.missedCalls); + missedCalls = (TextView) view.findViewById(R.id.missedCalls); missedCalls.setOnClickListener(this); allCalls.setEnabled(false); onlyDisplayMissedCalls = false; - edit = (ImageView) view.findViewById(R.id.edit); + edit = (TextView) view.findViewById(R.id.edit); edit.setOnClickListener(this); - ok = (ImageView) view.findViewById(R.id.ok); + ok = (TextView) view.findViewById(R.id.ok); ok.setOnClickListener(this); return view; @@ -195,13 +198,13 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil else if (id == R.id.ok) { edit.setVisibility(View.VISIBLE); ok.setVisibility(View.GONE); - deleteAll.setEnabled(false); + hideDeleteAllButton(); isEditMode = false; } else if (id == R.id.edit) { edit.setVisibility(View.GONE); ok.setVisibility(View.VISIBLE); - deleteAll.setEnabled(true); + showDeleteAllButton(); isEditMode = true; } else if (id == R.id.deleteAll) { @@ -247,6 +250,66 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil return false; } + private void hideDeleteAllButton() { + if (deleteAll == null || deleteAll.getVisibility() != View.VISIBLE) { + return; + } + + if (getActivity().getResources().getBoolean(R.bool.disable_animations)) { + deleteAll.setVisibility(View.INVISIBLE); + } else { + Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right_to_left); + animation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + deleteAll.setVisibility(View.INVISIBLE); + animation.setAnimationListener(null); + } + }); + deleteAll.startAnimation(animation); + } + } + + private void showDeleteAllButton() { + if (deleteAll == null || deleteAll.getVisibility() == View.VISIBLE) { + return; + } + + if (getActivity().getResources().getBoolean(R.bool.disable_animations)) { + deleteAll.setVisibility(View.VISIBLE); + } else { + Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right); + animation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + deleteAll.setVisibility(View.VISIBLE); + animation.setAnimationListener(null); + } + }); + deleteAll.startAnimation(animation); + } + } + class CallHistoryAdapter extends BaseExpandableListAdapter { private Bitmap missedCall, outgoingCall, incomingCall; diff --git a/src/org/linphone/HistorySimpleFragment.java b/src/org/linphone/HistorySimpleFragment.java index 29d37d87c..a445a6b53 100644 --- a/src/org/linphone/HistorySimpleFragment.java +++ b/src/org/linphone/HistorySimpleFragment.java @@ -38,6 +38,9 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; @@ -52,7 +55,7 @@ import android.widget.TextView; public class HistorySimpleFragment extends Fragment implements OnClickListener, OnItemClickListener { private ListView historyList; private LayoutInflater mInflater; - private ImageView allCalls, missedCalls, edit, ok, deleteAll; + private TextView allCalls, missedCalls, edit, ok, deleteAll; private boolean onlyDisplayMissedCalls, isEditMode; private List mLogs; @@ -66,23 +69,23 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, historyList.setOnItemClickListener(this); registerForContextMenu(historyList); - deleteAll = (ImageView) view.findViewById(R.id.deleteAll); + deleteAll = (TextView) view.findViewById(R.id.deleteAll); deleteAll.setOnClickListener(this); - deleteAll.setEnabled(false); + deleteAll.setVisibility(View.INVISIBLE); - allCalls = (ImageView) view.findViewById(R.id.allCalls); + allCalls = (TextView) view.findViewById(R.id.allCalls); allCalls.setOnClickListener(this); - missedCalls = (ImageView) view.findViewById(R.id.missedCalls); + missedCalls = (TextView) view.findViewById(R.id.missedCalls); missedCalls.setOnClickListener(this); allCalls.setEnabled(false); onlyDisplayMissedCalls = false; - edit = (ImageView) view.findViewById(R.id.edit); + edit = (TextView) view.findViewById(R.id.edit); edit.setOnClickListener(this); - ok = (ImageView) view.findViewById(R.id.ok); + ok = (TextView) view.findViewById(R.id.ok); ok.setOnClickListener(this); return view; @@ -133,13 +136,13 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, else if (id == R.id.ok) { edit.setVisibility(View.VISIBLE); ok.setVisibility(View.GONE); - deleteAll.setEnabled(false); + hideDeleteAllButton(); isEditMode = false; } else if (id == R.id.edit) { edit.setVisibility(View.GONE); ok.setVisibility(View.VISIBLE); - deleteAll.setEnabled(true); + showDeleteAllButton(); isEditMode = true; } else if (id == R.id.deleteAll) { @@ -172,6 +175,66 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, } } + private void hideDeleteAllButton() { + if (deleteAll == null || deleteAll.getVisibility() != View.VISIBLE) { + return; + } + + if (getActivity().getResources().getBoolean(R.bool.disable_animations)) { + deleteAll.setVisibility(View.INVISIBLE); + } else { + Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right_to_left); + animation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + deleteAll.setVisibility(View.INVISIBLE); + animation.setAnimationListener(null); + } + }); + deleteAll.startAnimation(animation); + } + } + + private void showDeleteAllButton() { + if (deleteAll == null || deleteAll.getVisibility() == View.VISIBLE) { + return; + } + + if (getActivity().getResources().getBoolean(R.bool.disable_animations)) { + deleteAll.setVisibility(View.VISIBLE); + } else { + Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left_to_right); + animation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + deleteAll.setVisibility(View.VISIBLE); + animation.setAnimationListener(null); + } + }); + deleteAll.startAnimation(animation); + } + } + class CallHistoryAdapter extends BaseAdapter { private Bitmap missedCall, outgoingCall, incomingCall; diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 4de25ac91..c6146b9a9 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -59,7 +59,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.Fragment.SavedState; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentManager.BackStackEntry; import android.support.v4.app.FragmentTransaction; import android.view.Gravity; import android.view.KeyEvent;