Restored tablet layout
This commit is contained in:
parent
e63759ee59
commit
1b1f5c70ee
10 changed files with 80 additions and 175 deletions
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isTablet">false</bool>
|
||||
<bool name="isTablet">true</bool>
|
||||
</resources>
|
||||
|
|
|
@ -369,27 +369,6 @@ public final class LinphoneUtils {
|
|||
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) {
|
||||
String name = filePath;
|
||||
int i = filePath.lastIndexOf('/');
|
||||
|
|
|
@ -145,7 +145,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
private View contacts_selected, history_selected, dialer_selected, chat_selected;
|
||||
private RelativeLayout mTopBar;
|
||||
private ImageView cancel;
|
||||
private FragmentsAvailable pendingFragmentTransaction, currentFragment;
|
||||
private FragmentsAvailable pendingFragmentTransaction, currentFragment, leftFragment;
|
||||
private Fragment fragment;
|
||||
private List<FragmentsAvailable> fragmentsHistory;
|
||||
private Fragment.SavedState dialerSavedState;
|
||||
|
@ -334,7 +334,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
missedChats = (TextView) findViewById(R.id.missed_chats);
|
||||
}
|
||||
|
||||
private boolean isTablet() {
|
||||
public boolean isTablet() {
|
||||
return getResources().getBoolean(R.bool.isTablet);
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
((ContactsListFragment) fragment).displayFirstContact();
|
||||
break;
|
||||
case CHAT_LIST:
|
||||
//TODO((ChatListFragment) fragment).displayFirstChat();
|
||||
((ChatListFragment) fragment).displayFirstChat();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -517,13 +517,19 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
transaction.commitAllowingStateLoss();
|
||||
getFragmentManager().executePendingTransactions();
|
||||
} else {
|
||||
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) {
|
||||
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment) || newFragmentType.shouldAddItselfToTheRightOf(leftFragment)) {
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
|
||||
if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) {
|
||||
transaction.addToBackStack(newFragmentType.toString());
|
||||
}
|
||||
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 {
|
||||
if (newFragmentType == FragmentsAvailable.EMPTY) {
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
|
@ -534,7 +540,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
if (newFragmentType == FragmentsAvailable.DIALER
|
||||
|| newFragmentType == FragmentsAvailable.ABOUT
|
||||
|| newFragmentType == FragmentsAvailable.SETTINGS
|
||||
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
|
||||
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS
|
||||
|| newFragmentType == FragmentsAvailable.CREATE_CHAT
|
||||
|| newFragmentType == FragmentsAvailable.INFO_GROUP_CHAT) {
|
||||
ll.setVisibility(View.GONE);
|
||||
} else {
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
|
@ -702,9 +710,21 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
|
||||
public void goToChat(String sipUri) {
|
||||
if (isTablet()) {
|
||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
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().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);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) {
|
||||
/*ChatFragment chatFragment = (ChatFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri, message, fileUri);*/
|
||||
//TODO
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) {
|
||||
GroupChatFragment chatFragment = (GroupChatFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(sipUri);
|
||||
} else {
|
||||
displayChat(sipUri, message, fileUri, pictureUri, thumbnailUri, displayName, lAddress);
|
||||
}
|
||||
|
@ -872,13 +891,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
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) {
|
||||
statusFragment = fragment;
|
||||
}
|
||||
|
@ -971,42 +983,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
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
|
||||
public void setAddresGoToDialerAndCall(String number, String name, Uri photo) {
|
||||
// Bundle extras = new Bundle();
|
||||
|
@ -1207,14 +1183,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
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() {
|
||||
checkAndRequestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 0);
|
||||
}
|
||||
|
@ -1223,14 +1191,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
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() {
|
||||
checkAndRequestPermission(Manifest.permission.WRITE_CONTACTS, 0);
|
||||
}
|
||||
|
@ -1869,29 +1829,4 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -329,8 +329,12 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mAllContactsSelected.setVisibility(View.INVISIBLE);
|
||||
updateList();
|
||||
} else if (id == R.id.back) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChatList();
|
||||
} else {
|
||||
mContactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().popBackStack();
|
||||
}
|
||||
} else if (id == R.id.next) {
|
||||
if (mChatRoomAddress == null && mChatRoomSubject == null) {
|
||||
if (mContactsSelected.size() == 1) {
|
||||
|
|
|
@ -138,6 +138,16 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
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
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -234,6 +234,17 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
|
||||
}
|
||||
|
||||
public void changeDisplayedChat(String sipUri) {
|
||||
mRemoteSipUri = sipUri;
|
||||
mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri);
|
||||
|
||||
initChatRoom();
|
||||
displayChatRoomHeader();
|
||||
displayChatRoomHistory();
|
||||
|
||||
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ContactsManager.removeContactsListener(this);
|
||||
|
|
|
@ -123,7 +123,11 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mIsAlreadyCreatedGroup) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asStringUriOnly());
|
||||
} else {
|
||||
getFragmentManager().popBackStack();
|
||||
}
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChatCreator(null, mParticipants, null, true);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ImdnFragment extends Fragment {
|
|||
private ImageView mBackButton;
|
||||
private ChatBubbleViewHolder mBubble;
|
||||
|
||||
private String mMessageId;
|
||||
private String mRoomUri, mMessageId;
|
||||
private Address mRoomAddr;
|
||||
private ChatRoom mRoom;
|
||||
|
||||
|
@ -61,8 +61,8 @@ public class ImdnFragment extends Fragment {
|
|||
|
||||
String roomUri;
|
||||
if (getArguments() != null) {
|
||||
roomUri = getArguments().getString("SipUri");
|
||||
mRoomAddr = LinphoneManager.getLc().createAddress(roomUri);
|
||||
mRoomUri = getArguments().getString("SipUri");
|
||||
mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
|
||||
mMessageId = getArguments().getString("MessageId");
|
||||
}
|
||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
@ -81,8 +81,12 @@ public class ImdnFragment extends Fragment {
|
|||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChat(mRoomUri);
|
||||
} else {
|
||||
LinphoneActivity.instance().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mRead = view.findViewById(R.id.read_layout);
|
||||
|
|
|
@ -38,51 +38,6 @@ public enum FragmentsAvailable {
|
|||
GROUP_CHAT,
|
||||
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) {
|
||||
switch (this) {
|
||||
case HISTORY_DETAIL:
|
||||
|
@ -97,8 +52,11 @@ public enum FragmentsAvailable {
|
|||
case CHAT:
|
||||
return fragment == CHAT_LIST || fragment == CHAT;
|
||||
|
||||
case CREATE_CHAT:
|
||||
return fragment == CHAT_LIST || fragment == CREATE_CHAT;
|
||||
case GROUP_CHAT:
|
||||
return fragment == CHAT_LIST || fragment == GROUP_CHAT;
|
||||
|
||||
case MESSAGE_IMDN:
|
||||
return fragment == GROUP_CHAT || fragment == MESSAGE_IMDN;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 25e640640000e2ea691c4eb6137e8edebf6b3a52
|
||||
Subproject commit 312f1e41b217b1cb69bcad193046b01774be5341
|
Loading…
Reference in a new issue