Fix fragment back button and add cancel button for contact editor

This commit is contained in:
Margaux Clerc 2016-02-10 12:23:55 +01:00
parent 90c5faa6f8
commit 2ea62bb0c9
4 changed files with 28 additions and 16 deletions

View file

@ -12,14 +12,14 @@
android:layout_height="60dp"> android:layout_height="60dp">
<ImageView <ImageView
android:id="@+id/back" android:id="@+id/cancel"
android:src="@drawable/back" android:src="@drawable/cancel_edit"
android:background="@drawable/toolbar_button" android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_back" android:contentDescription="@string/content_description_back"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.2" android:layout_weight="0.2"
android:padding="18dp"/> android:padding="15dp"/>
<View <View
android:layout_width="0dp" android:layout_width="0dp"
@ -27,7 +27,7 @@
android:layout_weight="0.4"/> android:layout_weight="0.4"/>
<ImageView <ImageView
android:id="@+id/deleteContact" android:id="@+id/delete_contact"
android:src="@drawable/delete" android:src="@drawable/delete"
android:background="@drawable/toolbar_button" android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_delete" android:contentDescription="@string/content_description_delete"

View file

@ -956,8 +956,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
messagesList.setVisibility(View.VISIBLE); messagesList.setVisibility(View.VISIBLE);
contactName.setVisibility(View.VISIBLE); contactName.setVisibility(View.VISIBLE);
edit.setVisibility(View.VISIBLE); edit.setVisibility(View.VISIBLE);
back.setVisibility(View.VISIBLE);
startCall.setVisibility(View.VISIBLE); startCall.setVisibility(View.VISIBLE);
if(getResources().getBoolean(R.bool.isTablet)){
back.setVisibility(View.INVISIBLE);
} else {
back.setOnClickListener(this);
}
newChatConversation = false; newChatConversation = false;
initChatRoom(sipUri); initChatRoom(sipUri);
} }

View file

@ -65,7 +65,7 @@ import android.widget.LinearLayout;
public class ContactEditorFragment extends Fragment { public class ContactEditorFragment extends Fragment {
private View view; private View view;
private ImageView back, edit, ok; private ImageView cancel, deleteContact, ok;
private ImageView addNumber, addSipAddress, contactPicture; private ImageView addNumber, addSipAddress, contactPicture;
private EditText firstName, lastName; private EditText firstName, lastName;
private LayoutInflater inflater; private LayoutInflater inflater;
@ -110,13 +110,15 @@ public class ContactEditorFragment extends Fragment {
view = inflater.inflate(R.layout.contact_edit, container, false); view = inflater.inflate(R.layout.contact_edit, container, false);
ImageView back = (ImageView) view.findViewById(R.id.back); deleteContact = (ImageView) view.findViewById(R.id.delete_contact);
back.setOnClickListener(new OnClickListener() {
@Override cancel = (ImageView) view.findViewById(R.id.cancel);
public void onClick(View v) { cancel.setOnClickListener(new OnClickListener() {
getFragmentManager().popBackStackImmediate(); @Override
} public void onClick(View v) {
}); getFragmentManager().popBackStackImmediate();
}
});
ok = (ImageView) view.findViewById(R.id.ok); ok = (ImageView) view.findViewById(R.id.ok);
ok.setOnClickListener(new OnClickListener() { ok.setOnClickListener(new OnClickListener() {
@ -221,6 +223,8 @@ public class ContactEditorFragment extends Fragment {
lastName.setText(contact.getName()); lastName.setText(contact.getName());
firstName.setText(""); firstName.setText("");
} }
} else {
deleteContact.setVisibility(View.INVISIBLE);
} }
contactPicture = (ImageView) view.findViewById(R.id.contact_picture); contactPicture = (ImageView) view.findViewById(R.id.contact_picture);

View file

@ -454,7 +454,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) { if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
transaction.addToBackStack(newFragmentType.toString()); if(newFragmentType == FragmentsAvailable.CONTACT_EDITOR){
transaction.addToBackStack(newFragmentType.toString());
}
transaction.replace(R.id.fragmentContainer2, newFragment); transaction.replace(R.id.fragmentContainer2, newFragment);
} else { } else {
if (newFragmentType == FragmentsAvailable.DIALER if (newFragmentType == FragmentsAvailable.DIALER