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>
<RelativeLayout
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>
<include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
</RelativeLayout>

View file

@ -134,23 +134,7 @@
</LinearLayout>
<RelativeLayout
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>
<include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
</RelativeLayout>

View file

@ -1,114 +1,122 @@
<?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_height="match_parent"
android:background="@color/colorH"
android:orientation="vertical" >
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorH"
android:orientation="vertical" >
<ImageView
android:id="@+id/back"
android:src="@drawable/back"
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"/>
<LinearLayout
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"/>
<ImageView
android:id="@+id/back"
android:src="@drawable/back"
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
android:id="@+id/deleteContact"
android:src="@drawable/delete"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="15dp"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"/>
<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"/>
<ImageView
android:id="@+id/deleteContact"
android:src="@drawable/delete"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
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
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:gravity="center"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/avatar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/contact_picture"
android:src="@drawable/avatar"
android:contentDescription="@string/content_description_contact_picture"
android:layout_width="100dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:layout_alignParentLeft="true"/>
<RelativeLayout
android:id="@+id/avatar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<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"/>
<ImageView
android:id="@+id/contact_picture"
android:src="@drawable/avatar"
android:contentDescription="@string/content_description_contact_picture"
android:layout_width="100dp"
android:layout_height="100dp"
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
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"/>
</RelativeLayout>
<TextView
android:id="@+id/contactOrganization"
style="@style/font9"
android:maxLines="1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
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"/>
<TableLayout
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:paddingTop="10dp"/>
<TextView
android:id="@+id/contactOrganization"
style="@style/font9"
android:maxLines="1"
android:layout_gravity="center"
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();
}
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){
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

View file

@ -253,22 +253,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
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
public void onSaveInstanceState(Bundle outState) {
if (mContactsSelected != null && mContactsSelected.size() > 0) {
@ -318,7 +302,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
} else if (newState == ChatRoom.State.CreationFailed) {
mWaitLayout.setVisibility(View.GONE);
displayChatRoomError();
LinphoneActivity.instance().displayChatRoomError();
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());
} else if (newState == ChatRoom.State.CreationFailed) {
mWaitLayout.setVisibility(View.GONE);
displayChatRoomError();
LinphoneActivity.instance().displayChatRoomError();
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);
}
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() {
if (mAdminStateChangedDialog != null) mAdminStateChangedDialog.dismiss();

View file

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