Restored tablet layout

This commit is contained in:
Sylvain Berfini 2018-04-03 15:07:48 +02:00
parent e63759ee59
commit 1b1f5c70ee
10 changed files with 80 additions and 175 deletions

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<bool name="isTablet">false</bool> <bool name="isTablet">true</bool>
</resources> </resources>

View file

@ -369,27 +369,6 @@ public final class LinphoneUtils {
return true; return true;
} }
public static boolean zipLogs(StringBuilder sb, String toZipFile){
boolean success = false;
try {
FileOutputStream zip = new FileOutputStream(toZipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(zip));
ZipEntry entry = new ZipEntry("logs.txt");
out.putNextEntry(entry);
out.write(sb.toString().getBytes());
out.close();
success = true;
} catch (Exception e){
Log.e("Exception when trying to zip the logs: " + e.getMessage());
}
return success;
}
public static String getNameFromFilePath(String filePath) { public static String getNameFromFilePath(String filePath) {
String name = filePath; String name = filePath;
int i = filePath.lastIndexOf('/'); int i = filePath.lastIndexOf('/');

View file

@ -145,7 +145,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
private View contacts_selected, history_selected, dialer_selected, chat_selected; private View contacts_selected, history_selected, dialer_selected, chat_selected;
private RelativeLayout mTopBar; private RelativeLayout mTopBar;
private ImageView cancel; private ImageView cancel;
private FragmentsAvailable pendingFragmentTransaction, currentFragment; private FragmentsAvailable pendingFragmentTransaction, currentFragment, leftFragment;
private Fragment fragment; private Fragment fragment;
private List<FragmentsAvailable> fragmentsHistory; private List<FragmentsAvailable> fragmentsHistory;
private Fragment.SavedState dialerSavedState; private Fragment.SavedState dialerSavedState;
@ -334,7 +334,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
missedChats = (TextView) findViewById(R.id.missed_chats); missedChats = (TextView) findViewById(R.id.missed_chats);
} }
private boolean isTablet() { public boolean isTablet() {
return getResources().getBoolean(R.bool.isTablet); return getResources().getBoolean(R.bool.isTablet);
} }
@ -451,7 +451,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
((ContactsListFragment) fragment).displayFirstContact(); ((ContactsListFragment) fragment).displayFirstContact();
break; break;
case CHAT_LIST: case CHAT_LIST:
//TODO((ChatListFragment) fragment).displayFirstChat(); ((ChatListFragment) fragment).displayFirstChat();
break; break;
} }
} else { } else {
@ -517,13 +517,19 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
transaction.commitAllowingStateLoss(); transaction.commitAllowingStateLoss();
getFragmentManager().executePendingTransactions(); getFragmentManager().executePendingTransactions();
} else { } else {
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) { if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment) || newFragmentType.shouldAddItselfToTheRightOf(leftFragment)) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) { if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) {
transaction.addToBackStack(newFragmentType.toString()); transaction.addToBackStack(newFragmentType.toString());
} }
transaction.replace(R.id.fragmentContainer2, newFragment); transaction.replace(R.id.fragmentContainer2, newFragment);
leftFragment = currentFragment;
if (newFragmentType == FragmentsAvailable.GROUP_CHAT && leftFragment != FragmentsAvailable.CHAT_LIST) {
leftFragment = FragmentsAvailable.CHAT_LIST;
transaction.replace(R.id.fragmentContainer, new ChatListFragment());
}
} else { } else {
if (newFragmentType == FragmentsAvailable.EMPTY) { if (newFragmentType == FragmentsAvailable.EMPTY) {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
@ -534,7 +540,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
if (newFragmentType == FragmentsAvailable.DIALER if (newFragmentType == FragmentsAvailable.DIALER
|| newFragmentType == FragmentsAvailable.ABOUT || newFragmentType == FragmentsAvailable.ABOUT
|| newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.SETTINGS
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) { || newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS
|| newFragmentType == FragmentsAvailable.CREATE_CHAT
|| newFragmentType == FragmentsAvailable.INFO_GROUP_CHAT) {
ll.setVisibility(View.GONE); ll.setVisibility(View.GONE);
} else { } else {
ll.setVisibility(View.VISIBLE); ll.setVisibility(View.VISIBLE);
@ -702,9 +710,21 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} }
public void goToChat(String sipUri) { public void goToChat(String sipUri) {
Bundle extras = new Bundle(); if (isTablet()) {
extras.putString("SipUri", sipUri); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras); if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) {
GroupChatFragment chatFragment = (GroupChatFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri);
} else {
Bundle extras = new Bundle();
extras.putString("SipUri", sipUri);
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
}
} else {
Bundle extras = new Bundle();
extras.putString("SipUri", sipUri);
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
}
LinphoneService.instance().resetMessageNotifCount(); LinphoneService.instance().resetMessageNotifCount();
LinphoneService.instance().removeMessageNotification(); LinphoneService.instance().removeMessageNotification();
@ -758,12 +778,11 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} }
} }
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) { if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.GROUP_CHAT) {
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) { if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) {
/*ChatFragment chatFragment = (ChatFragment) fragment2; GroupChatFragment chatFragment = (GroupChatFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri, message, fileUri);*/ chatFragment.changeDisplayedChat(sipUri);
//TODO
} else { } else {
displayChat(sipUri, message, fileUri, pictureUri, thumbnailUri, displayName, lAddress); displayChat(sipUri, message, fileUri, pictureUri, thumbnailUri, displayName, lAddress);
} }
@ -872,13 +891,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
dialer_selected.setVisibility(View.VISIBLE); dialer_selected.setVisibility(View.VISIBLE);
} }
public void onMessageSent(String to, String message) {
Fragment fragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (fragment.getClass() == ChatListFragment.class) {
////TODO ((ChatListFragment)fragment).refresh();
}
}
public void updateStatusFragment(StatusFragment fragment) { public void updateStatusFragment(StatusFragment fragment) {
statusFragment = fragment; statusFragment = fragment;
} }
@ -971,42 +983,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
return dialog; return dialog;
} }
public Dialog displayWrongPasswordDialog(final String username, final String realm, final String domain){
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
d.setAlpha(200);
dialog.setContentView(R.layout.input_dialog);
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(d);
TextView customText = (TextView) dialog.findViewById(R.id.customText);
customText.setText(getString(R.string.error_bad_credentials));
Button retry = (Button) dialog.findViewById(R.id.retry);
Button cancel = (Button) dialog.findViewById(R.id.cancel);
retry.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String newPassword = ((EditText) dialog.findViewById(R.id.password)).getText().toString();
AuthInfo authInfo = Factory.instance().createAuthInfo(username, null, newPassword, null, realm, domain);
LinphoneManager.getLc().addAuthInfo(authInfo);
LinphoneManager.getLc().refreshRegisters();
dialog.dismiss();
}
});
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
return dialog;
}
@Override @Override
public void setAddresGoToDialerAndCall(String number, String name, Uri photo) { public void setAddresGoToDialerAndCall(String number, String name, Uri photo) {
// Bundle extras = new Bundle(); // Bundle extras = new Bundle();
@ -1207,14 +1183,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
return true; return true;
} }
public void checkAndRequestReadPhoneStatePermission() {
checkAndRequestPermission(Manifest.permission.READ_PHONE_STATE, 0);
}
public void checkAndRequestReadExternalStoragePermission() {
checkAndRequestPermission(Manifest.permission.READ_EXTERNAL_STORAGE, 0);
}
public void checkAndRequestExternalStoragePermission() { public void checkAndRequestExternalStoragePermission() {
checkAndRequestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 0); checkAndRequestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 0);
} }
@ -1223,14 +1191,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
checkAndRequestPermission(Manifest.permission.CAMERA, 0); checkAndRequestPermission(Manifest.permission.CAMERA, 0);
} }
public void checkAndRequestReadContactsPermission() {
checkAndRequestPermission(Manifest.permission.READ_CONTACTS, PERMISSIONS_REQUEST_CONTACTS);
}
public void checkAndRequestInappPermission() {
checkAndRequestPermission(Manifest.permission.GET_ACCOUNTS, PERMISSIONS_REQUEST_CONTACTS);
}
public void checkAndRequestWriteContactsPermission() { public void checkAndRequestWriteContactsPermission() {
checkAndRequestPermission(Manifest.permission.WRITE_CONTACTS, 0); checkAndRequestPermission(Manifest.permission.WRITE_CONTACTS, 0);
} }
@ -1869,29 +1829,4 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} }
return -1; return -1;
} }
public String getCVSPathFromOtherUri(String path) {
Uri contactUri = Uri.parse(path);
ContentResolver cr = getContentResolver();
InputStream stream = null;
try {
stream = cr.openInputStream(contactUri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
StringBuffer fileContent = new StringBuffer("");
int ch;
try {
while( (ch = stream.read()) != -1)
fileContent.append((char)ch);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String data = new String(fileContent);
return data;
}
} }

View file

@ -329,8 +329,12 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
mAllContactsSelected.setVisibility(View.INVISIBLE); mAllContactsSelected.setVisibility(View.INVISIBLE);
updateList(); updateList();
} else if (id == R.id.back) { } else if (id == R.id.back) {
mContactsSelectedLayout.removeAllViews(); if (LinphoneActivity.instance().isTablet()) {
LinphoneActivity.instance().popBackStack(); LinphoneActivity.instance().goToChatList();
} else {
mContactsSelectedLayout.removeAllViews();
LinphoneActivity.instance().popBackStack();
}
} else if (id == R.id.next) { } else if (id == R.id.next) {
if (mChatRoomAddress == null && mChatRoomSubject == null) { if (mChatRoomAddress == null && mChatRoomSubject == null) {
if (mContactsSelected.size() == 1) { if (mContactsSelected.size() == 1) {

View file

@ -138,6 +138,16 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
mNoChatHistory.setVisibility(mChatRoomsAdapter.getCount() == 0 ? View.VISIBLE : View.GONE); mNoChatHistory.setVisibility(mChatRoomsAdapter.getCount() == 0 ? View.VISIBLE : View.GONE);
} }
public void displayFirstChat() {
ChatRoomsAdapter adapter = (ChatRoomsAdapter)mChatRoomsList.getAdapter();
if (adapter != null && adapter.getCount() > 0) {
ChatRoom room = (ChatRoom) adapter.getItem(0);
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
} else {
LinphoneActivity.instance().displayEmptyFragment();
}
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();

View file

@ -234,6 +234,17 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress); LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
} }
public void changeDisplayedChat(String sipUri) {
mRemoteSipUri = sipUri;
mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri);
initChatRoom();
displayChatRoomHeader();
displayChatRoomHistory();
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
}
@Override @Override
public void onPause() { public void onPause() {
ContactsManager.removeContactsListener(this); ContactsManager.removeContactsListener(this);

View file

@ -123,7 +123,11 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (mIsAlreadyCreatedGroup) { if (mIsAlreadyCreatedGroup) {
getFragmentManager().popBackStack(); if (LinphoneActivity.instance().isTablet()) {
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asStringUriOnly());
} else {
getFragmentManager().popBackStack();
}
} else { } else {
LinphoneActivity.instance().goToChatCreator(null, mParticipants, null, true); LinphoneActivity.instance().goToChatCreator(null, mParticipants, null, true);
} }

View file

@ -50,7 +50,7 @@ public class ImdnFragment extends Fragment {
private ImageView mBackButton; private ImageView mBackButton;
private ChatBubbleViewHolder mBubble; private ChatBubbleViewHolder mBubble;
private String mMessageId; private String mRoomUri, mMessageId;
private Address mRoomAddr; private Address mRoomAddr;
private ChatRoom mRoom; private ChatRoom mRoom;
@ -61,8 +61,8 @@ public class ImdnFragment extends Fragment {
String roomUri; String roomUri;
if (getArguments() != null) { if (getArguments() != null) {
roomUri = getArguments().getString("SipUri"); mRoomUri = getArguments().getString("SipUri");
mRoomAddr = LinphoneManager.getLc().createAddress(roomUri); mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
mMessageId = getArguments().getString("MessageId"); mMessageId = getArguments().getString("MessageId");
} }
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
@ -81,7 +81,11 @@ public class ImdnFragment extends Fragment {
mBackButton.setOnClickListener(new View.OnClickListener() { mBackButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
LinphoneActivity.instance().onBackPressed(); if (LinphoneActivity.instance().isTablet()) {
LinphoneActivity.instance().goToChat(mRoomUri);
} else {
LinphoneActivity.instance().onBackPressed();
}
} }
}); });

View file

@ -38,51 +38,6 @@ public enum FragmentsAvailable {
GROUP_CHAT, GROUP_CHAT,
MESSAGE_IMDN; MESSAGE_IMDN;
public boolean shouldAnimate() {
return true;
}
public boolean isRightOf(FragmentsAvailable fragment) {
switch (this) {
case HISTORY_LIST:
return fragment == UNKNOW;
case HISTORY_DETAIL:
return HISTORY_LIST.isRightOf(fragment) || fragment == HISTORY_LIST;
case CONTACTS_LIST:
return HISTORY_DETAIL.isRightOf(fragment) || fragment == HISTORY_DETAIL;
case CONTACT_DETAIL:
return CONTACTS_LIST.isRightOf(fragment) || fragment == CONTACTS_LIST;
case CONTACT_EDITOR:
return CONTACT_DETAIL.isRightOf(fragment) || fragment == CONTACT_DETAIL;
case DIALER:
return CONTACT_EDITOR.isRightOf(fragment) || fragment == CONTACT_EDITOR;
case CHAT_LIST:
return DIALER.isRightOf(fragment) || fragment == DIALER;
case SETTINGS:
return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST;
case ABOUT:
case ACCOUNT_SETTINGS:
return SETTINGS.isRightOf(fragment) || fragment == SETTINGS;
case CHAT:
case CREATE_CHAT:
case GROUP_CHAT:
case INFO_GROUP_CHAT:
return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST;
default:
return false;
}
}
public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) { public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) {
switch (this) { switch (this) {
case HISTORY_DETAIL: case HISTORY_DETAIL:
@ -97,10 +52,13 @@ public enum FragmentsAvailable {
case CHAT: case CHAT:
return fragment == CHAT_LIST || fragment == CHAT; return fragment == CHAT_LIST || fragment == CHAT;
case CREATE_CHAT: case GROUP_CHAT:
return fragment == CHAT_LIST || fragment == CREATE_CHAT; return fragment == CHAT_LIST || fragment == GROUP_CHAT;
default: case MESSAGE_IMDN:
return fragment == GROUP_CHAT || fragment == MESSAGE_IMDN;
default:
return false; return false;
} }
} }

@ -1 +1 @@
Subproject commit 25e640640000e2ea691c4eb6137e8edebf6b3a52 Subproject commit 312f1e41b217b1cb69bcad193046b01774be5341