From 18ab8264130bb07ef5cf1f43cb5f3c5a6faacb06 Mon Sep 17 00:00:00 2001 From: Mishiranu Date: Tue, 20 Sep 2016 02:18:50 +0300 Subject: [PATCH] Fix "More table" layout Retain "More table" visibility on screen orientation change --- .../conversations/ui/EditAccountActivity.java | 20 ++++++- src/main/res/layout/activity_edit_account.xml | 52 +++++++++++++++---- src/main/res/layout/activity_muc_details.xml | 6 ++- 3 files changed, 65 insertions(+), 13 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 83364ca2c..cc178179b 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -519,6 +519,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener); this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener); this.mMoreTable = (TableLayout) findViewById(R.id.server_info_more); + if (savedInstanceState != null && savedInstanceState.getBoolean("showMoreTable")) { + changeMoreTableVisibility(true); + } final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, @@ -584,6 +587,15 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate return super.onCreateOptionsMenu(menu); } + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more); + if (showMoreInfo.isVisible()) { + showMoreInfo.setChecked(mMoreTable.getVisibility() == View.VISIBLE); + } + return super.onPrepareOptionsMenu(menu); + } + @Override protected void onStart() { super.onStart(); @@ -628,6 +640,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate if (mAccount != null) { savedInstanceState.putString("account", mAccount.getJid().toBareJid().toString()); savedInstanceState.putBoolean("initMode", mInitMode); + savedInstanceState.putBoolean("showMoreTable", mMoreTable.getVisibility() == View.VISIBLE); } super.onSaveInstanceState(savedInstanceState); } @@ -695,8 +708,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate startActivity(showBlocklistIntent); break; case R.id.action_server_info_show_more: - mMoreTable.setVisibility(item.isChecked() ? View.GONE : View.VISIBLE); - item.setChecked(!item.isChecked()); + changeMoreTableVisibility(!item.isChecked()); break; case R.id.action_change_password_on_server: gotoChangePassword(null); @@ -720,6 +732,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate return super.onOptionsItemSelected(item); } + private void changeMoreTableVisibility(boolean visible) { + mMoreTable.setVisibility(visible ? View.VISIBLE : View.GONE); + } + private void gotoChangePassword(String newPassword) { final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class); changePasswordIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toString()); diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index 555f18ffe..64393b25a 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -221,6 +221,7 @@ + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -250,6 +254,7 @@ android:id="@+id/server_info_more" android:layout_width="match_parent" android:layout_height="wrap_content" + android:shrinkColumns="0" android:stretchColumns="1" android:visibility="gone"> @@ -262,13 +267,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_pep" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -283,13 +291,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_blocking" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -304,13 +315,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_stream_management" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -325,13 +339,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_roster_version" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -346,13 +363,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_carbon_messages" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -367,13 +387,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_mam" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -388,13 +411,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_csi" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -409,13 +435,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_push" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> @@ -428,13 +457,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_http_upload" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody"/> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end"/> diff --git a/src/main/res/layout/activity_muc_details.xml b/src/main/res/layout/activity_muc_details.xml index 7ff91e15d..f4e45598f 100644 --- a/src/main/res/layout/activity_muc_details.xml +++ b/src/main/res/layout/activity_muc_details.xml @@ -141,6 +141,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/muc_info_more" + android:shrinkColumns="0" android:stretchColumns="1" android:visibility="gone"> @@ -153,13 +154,16 @@ android:layout_height="wrap_content" android:text="@string/server_info_mam" android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody" /> + android:textSize="?attr/TextSizeBody" + android:singleLine="true" + android:ellipsize="end" />