Factorized wait layout and chat room popup error + added it to contact's details view

This commit is contained in:
Sylvain Berfini 2017-12-01 11:23:48 +01:00
parent 2948b31ff3
commit f14e4e6f3f
8 changed files with 148 additions and 164 deletions

View file

@ -186,22 +186,6 @@
</LinearLayout> </LinearLayout>
<RelativeLayout <include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
android:id="@+id/waitScreen"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99c4c4c4">
<ProgressBar
android:indeterminate="true"
android:indeterminateTint="@color/colorA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</ProgressBar>
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -134,23 +134,7 @@
</LinearLayout> </LinearLayout>
<RelativeLayout <include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
android:id="@+id/waitScreen"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99c4c4c4">
<ProgressBar
android:indeterminate="true"
android:indeterminateTint="@color/colorA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</ProgressBar>
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -1,114 +1,122 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@color/colorH"
android:orientation="vertical" >
<LinearLayout <LinearLayout
android:orientation="horizontal" android:layout_width="match_parent"
android:background="@color/colorF" android:layout_height="match_parent"
android:layout_width="match_parent" android:background="@color/colorH"
android:layout_height="60dp"> android:orientation="vertical" >
<ImageView <LinearLayout
android:id="@+id/back" android:orientation="horizontal"
android:src="@drawable/back" android:background="@color/colorF"
android:background="@drawable/toolbar_button" android:layout_width="match_parent"
android:contentDescription="@string/content_description_back" android:layout_height="60dp">
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="18dp"/>
<View <ImageView
android:layout_width="0dp" android:id="@+id/back"
android:layout_height="match_parent" android:src="@drawable/back"
android:layout_weight="0.4"/> android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="18dp"/>
<ImageView <View
android:id="@+id/deleteContact" android:layout_width="0dp"
android:src="@drawable/delete" android:layout_height="match_parent"
android:background="@drawable/toolbar_button" android:layout_weight="0.4"/>
android:contentDescription="@string/content_description_delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="15dp"/>
<ImageView <ImageView
android:id="@+id/editContact" android:id="@+id/deleteContact"
android:src="@drawable/edit" android:src="@drawable/delete"
android:background="@drawable/toolbar_button" android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_edit" android:contentDescription="@string/content_description_delete"
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="15dp"/> android:padding="15dp"/>
</LinearLayout> <ImageView
android:id="@+id/editContact"
android:src="@drawable/edit"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="15dp"/>
<ScrollView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:paddingTop="20dp"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout <LinearLayout
android:id="@+id/avatar_layout" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:paddingTop="20dp"
android:gravity="center"> android:gravity="center"
android:orientation="vertical">
<ImageView <RelativeLayout
android:id="@+id/contact_picture" android:id="@+id/avatar_layout"
android:src="@drawable/avatar" android:layout_width="match_parent"
android:contentDescription="@string/content_description_contact_picture" android:layout_height="wrap_content"
android:layout_width="100dp" android:gravity="center">
android:layout_height="100dp"
android:adjustViewBounds="true"
android:layout_alignParentLeft="true"/>
<ImageView <ImageView
android:id="@+id/mask" android:id="@+id/contact_picture"
android:src="@drawable/avatar_mask" android:src="@drawable/avatar"
android:layout_width="100dp" android:contentDescription="@string/content_description_contact_picture"
android:layout_height="100dp" android:layout_width="100dp"
android:adjustViewBounds="true" android:layout_height="100dp"
android:layout_alignParentLeft="true"/> android:adjustViewBounds="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout> <ImageView
android:id="@+id/mask"
android:src="@drawable/avatar_mask"
android:layout_width="100dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:layout_alignParentLeft="true"/>
<TextView </RelativeLayout>
android:id="@+id/contact_name"
style="@style/font5"
android:maxLines="1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView <TextView
android:id="@+id/contactOrganization" android:id="@+id/contact_name"
style="@style/font9" style="@style/font5"
android:maxLines="1" android:maxLines="1"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TableLayout <TextView
android:id="@+id/controls" android:id="@+id/contactOrganization"
android:layout_width="match_parent" style="@style/font9"
android:layout_height="wrap_content" android:maxLines="1"
android:stretchColumns="*" android:layout_gravity="center"
android:paddingTop="10dp"/> android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout> <TableLayout
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:paddingTop="10dp"/>
</ScrollView> </LinearLayout>
</LinearLayout> </ScrollView>
</LinearLayout>
<include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
</RelativeLayout>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99c4c4c4">
<ProgressBar
android:indeterminate="true"
android:indeterminateTint="@color/colorA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</ProgressBar>
</RelativeLayout>

View file

@ -952,6 +952,22 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
toast.show(); toast.show();
} }
public void displayChatRoomError() {
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.chat_room_creation_failed));
Button delete = dialog.findViewById(R.id.delete_button);
Button cancel = dialog.findViewById(R.id.cancel);
delete.setVisibility(View.GONE);
cancel.setText(getString(R.string.ok));
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
public Dialog displayDialog(String text){ public Dialog displayDialog(String text){
Dialog dialog = new Dialog(this); Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

View file

@ -253,22 +253,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
updateListSelected(); updateListSelected();
} }
private void displayChatRoomError() {
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.chat_room_creation_failed));
Button delete = dialog.findViewById(R.id.delete_button);
Button cancel = dialog.findViewById(R.id.cancel);
delete.setVisibility(View.GONE);
cancel.setText(getString(R.string.ok));
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
if (mContactsSelected != null && mContactsSelected.size() > 0) { if (mContactsSelected != null && mContactsSelected.size() > 0) {
@ -318,7 +302,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly()); LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
} else if (newState == ChatRoom.State.CreationFailed) { } else if (newState == ChatRoom.State.CreationFailed) {
mWaitLayout.setVisibility(View.GONE); mWaitLayout.setVisibility(View.GONE);
displayChatRoomError(); LinphoneActivity.instance().displayChatRoomError();
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !"); Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
} }
} }

View file

@ -181,7 +181,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly()); LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
} else if (newState == ChatRoom.State.CreationFailed) { } else if (newState == ChatRoom.State.CreationFailed) {
mWaitLayout.setVisibility(View.GONE); mWaitLayout.setVisibility(View.GONE);
displayChatRoomError(); LinphoneActivity.instance().displayChatRoomError();
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !"); Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
} }
} }
@ -293,22 +293,6 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
mAddParticipantsButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.GONE); mAddParticipantsButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.GONE);
} }
private void displayChatRoomError() {
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.chat_room_creation_failed));
Button delete = dialog.findViewById(R.id.delete_button);
Button cancel = dialog.findViewById(R.id.cancel);
delete.setVisibility(View.GONE);
cancel.setText(getString(R.string.ok));
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
private void displayMeAdminStatusUpdated() { private void displayMeAdminStatusUpdated() {
if (mAdminStateChangedDialog != null) mAdminStateChangedDialog.dismiss(); if (mAdminStateChangedDialog != null) mAdminStateChangedDialog.dismiss();

View file

@ -42,6 +42,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TableLayout; import android.widget.TableLayout;
import android.widget.TextView; import android.widget.TextView;
@ -49,6 +50,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
private LinphoneContact contact; private LinphoneContact contact;
private ImageView editContact, deleteContact, back; private ImageView editContact, deleteContact, back;
private TextView organization; private TextView organization;
private RelativeLayout mWaitLayout;
private LayoutInflater inflater; private LayoutInflater inflater;
private View view; private View view;
private boolean displayChatAddressOnly = false; private boolean displayChatAddressOnly = false;
@ -74,15 +76,17 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
if (room != null) { if (room != null) {
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly()); LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
} else { } else {
//TODO wait layout mWaitLayout.setVisibility(View.VISIBLE);
ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject)); ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
chatRoom.setListener(new ChatRoomListenerStub() { chatRoom.setListener(new ChatRoomListenerStub() {
@Override @Override
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) { public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
if (newState == ChatRoom.State.Created) { if (newState == ChatRoom.State.Created) {
mWaitLayout.setVisibility(View.GONE);
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly()); LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
} else if (newState == ChatRoom.State.CreationFailed) { } else if (newState == ChatRoom.State.CreationFailed) {
//TODO error mWaitLayout.setVisibility(View.GONE);
LinphoneActivity.instance().displayChatRoomError();
Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !"); Log.e("Group chat room for address " + cr.getPeerAddress() + " has failed !");
} }
} }
@ -103,6 +107,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly"); displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly");
} }
mWaitLayout = view.findViewById(R.id.waitScreen);
mWaitLayout.setVisibility(View.GONE);
editContact = view.findViewById(R.id.editContact); editContact = view.findViewById(R.id.editContact);
editContact.setOnClickListener(this); editContact.setOnClickListener(this);