From 7687c00aacfc3de7cc01b309d61e2cf3a7d5d060 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Thu, 18 Feb 2016 10:56:13 +0100 Subject: [PATCH] Update fragment when item list removed --- res/layout/empty_fragment.xml | 15 ++++++++ src/org/linphone/ChatListFragment.java | 5 +++ src/org/linphone/ContactsListFragment.java | 9 +++-- src/org/linphone/EmptyFragment.java | 40 ++++++++++++++++++++++ src/org/linphone/FragmentsAvailable.java | 1 + src/org/linphone/HistoryListFragment.java | 9 ++--- src/org/linphone/LinphoneActivity.java | 12 ++++++- 7 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 res/layout/empty_fragment.xml create mode 100644 src/org/linphone/EmptyFragment.java diff --git a/res/layout/empty_fragment.xml b/res/layout/empty_fragment.xml new file mode 100644 index 000000000..684b8b6dd --- /dev/null +++ b/res/layout/empty_fragment.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/src/org/linphone/ChatListFragment.java b/src/org/linphone/ChatListFragment.java index bdd9828bc..59637d30c 100644 --- a/src/org/linphone/ChatListFragment.java +++ b/src/org/linphone/ChatListFragment.java @@ -139,6 +139,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte editList.setVisibility(View.GONE); topbar.setVisibility(View.VISIBLE); refresh(); + if(getResources().getBoolean(R.bool.isTablet)){ + displayFirstChat(); + } } public int getNbItemsChecked(){ @@ -188,6 +191,8 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte public void displayFirstChat(){ if(mConversations.size() > 0) { LinphoneActivity.instance().displayChat(mConversations.get(0)); + } else { + LinphoneActivity.instance().displayEmptyFragment(); } } diff --git a/src/org/linphone/ContactsListFragment.java b/src/org/linphone/ContactsListFragment.java index 379faa6ef..9681e177e 100644 --- a/src/org/linphone/ContactsListFragment.java +++ b/src/org/linphone/ContactsListFragment.java @@ -320,11 +320,16 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O editList.setVisibility(View.GONE); topbar.setVisibility(View.VISIBLE); invalidate(); + if(getResources().getBoolean(R.bool.isTablet)){ + displayFirstContact(); + } } public void displayFirstContact(){ - if(contactsList.getAdapter().getCount() > 0){ - LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0),false); + if(contactsList.getAdapter().getCount() > 0) { + LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0), false); + } else { + LinphoneActivity.instance().displayEmptyFragment(); } } diff --git a/src/org/linphone/EmptyFragment.java b/src/org/linphone/EmptyFragment.java new file mode 100644 index 000000000..25116b4af --- /dev/null +++ b/src/org/linphone/EmptyFragment.java @@ -0,0 +1,40 @@ +package org.linphone; +/* +AboutFragment.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 android.os.Bundle; +import android.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * @author Sylvain Berfini + */ +public class EmptyFragment extends Fragment { + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.empty_fragment, container, false); + return view; + } + +} diff --git a/src/org/linphone/FragmentsAvailable.java b/src/org/linphone/FragmentsAvailable.java index 75d3ef223..081c685c8 100644 --- a/src/org/linphone/FragmentsAvailable.java +++ b/src/org/linphone/FragmentsAvailable.java @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. public enum FragmentsAvailable { UNKNOW, DIALER, + EMPTY, HISTORY_LIST, HISTORY_DETAIL, CONTACTS_LIST, diff --git a/src/org/linphone/HistoryListFragment.java b/src/org/linphone/HistoryListFragment.java index b8ffe0a6d..c0adbb69a 100644 --- a/src/org/linphone/HistoryListFragment.java +++ b/src/org/linphone/HistoryListFragment.java @@ -37,9 +37,6 @@ import android.view.LayoutInflater; 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.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -50,7 +47,6 @@ import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.RelativeLayout; import android.widget.TextView; /** @@ -131,6 +127,8 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On } else { LinphoneActivity.instance().displayHistoryDetail(mLogs.get(0).getTo().toString(), mLogs.get(0)); } + } else { + LinphoneActivity.instance().displayEmptyFragment(); } } @@ -335,6 +333,9 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext())); } + if(getResources().getBoolean(R.bool.isTablet)){ + displayFirstLog(); + } } class CallHistoryAdapter extends BaseAdapter { diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 894c4e64d..d316da70a 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -461,13 +461,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta } transaction.replace(R.id.fragmentContainer2, newFragment); } else { + if(newFragmentType == FragmentsAvailable.EMPTY) { + ll.setVisibility(View.VISIBLE); + transaction.replace(R.id.fragmentContainer2, new EmptyFragment()); + } + if (newFragmentType == FragmentsAvailable.DIALER || newFragmentType == FragmentsAvailable.ABOUT || newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) { ll.setVisibility(View.GONE); } else { - ll.setVisibility(View.INVISIBLE); + ll.setVisibility(View.VISIBLE); + transaction.replace(R.id.fragmentContainer2, new EmptyFragment()); } if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) { @@ -544,6 +550,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta } } + public void displayEmptyFragment(){ + changeCurrentFragment(FragmentsAvailable.HISTORY_LIST,new Bundle()); + } + @SuppressLint("SimpleDateFormat") private String secondsToDisplayableString(int secs) { SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");