diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-10-26 09:30:08 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-10-26 09:30:08 +0100 |
commit | ec473a4437b3bff88e80404b7012ae15d3c09c3d (patch) | |
tree | 568a9531b27bff5b3211db65d09cd6a7f6c1afb6 /src/main/java/eu | |
parent | d4877177b7b8b14a70a0826fd182b8f9598607b0 (diff) | |
parent | 48f172fc9e9a464ee220afd2a82b719ec5b984e9 (diff) |
Merge pull request #1520 from saqura/self_handle_orientation
Handle some orientation changes manually
Diffstat (limited to 'src/main/java/eu')
5 files changed, 50 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 42ce5349..20195256 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -6,6 +6,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; import android.content.IntentSender.SendIntentException; +import android.content.res.Configuration; import android.graphics.Bitmap; import android.os.Build; import android.os.Bundle; @@ -41,6 +42,7 @@ import eu.siacs.conversations.entities.MucOptions.User; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate; +import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.jid.Jid; public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConferenceOptionsPushed { @@ -53,6 +55,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers inviteToConversation(mConversation); } }; + private LinearLayout mMainLayout; private TextView mYourNick; private ImageView mYourPhoto; private ImageButton mEditNickButton; @@ -187,6 +190,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_muc_details); + mMainLayout = (LinearLayout) findViewById(R.id.muc_main_layout); mYourNick = (TextView) findViewById(R.id.muc_your_nick); mYourPhoto = (ImageView) findViewById(R.id.your_photo); mEditNickButton = (ImageButton) findViewById(R.id.edit_nick_button); @@ -450,6 +454,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } } + @Override + public void onConfigurationChanged (Configuration newConfig) { + super.onConfigurationChanged(newConfig); + UIHelper.resetChildMargins(mMainLayout); + } + private void updateView() { final MucOptions mucOptions = mConversation.getMucOptions(); final User self = mucOptions.getSelf(); diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 10bdaab1..ebac6feb 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -7,6 +7,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; @@ -99,6 +100,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } } }; + private LinearLayout mainLayout; private Jid accountJid; private Jid contactJid; private TextView contactJidTv; @@ -197,6 +199,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd this.messageFingerprint = getIntent().getStringExtra("fingerprint"); setContentView(R.layout.activity_contact_details); + mainLayout = (LinearLayout) findViewById(R.id.details_main_layout); contactJidTv = (TextView) findViewById(R.id.details_contactjid); accountJidTv = (TextView) findViewById(R.id.details_account); lastseen = (TextView) findViewById(R.id.details_lastseen); @@ -297,6 +300,12 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd return true; } + @Override + public void onConfigurationChanged (Configuration newConfig) { + super.onConfigurationChanged(newConfig); + UIHelper.resetChildMargins(mainLayout); + } + private void populateView() { invalidateOptionsMenu(); setTitle(contact.getDisplayName()); diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index e57a7b68..180fc8b8 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -5,6 +5,7 @@ import android.app.AlertDialog.Builder; import android.app.PendingIntent; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.graphics.Bitmap; import android.os.Bundle; import android.security.KeyChain; @@ -51,6 +52,7 @@ import eu.siacs.conversations.xmpp.pep.Avatar; public class EditAccountActivity extends XmppActivity implements OnAccountUpdate, OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast { + private LinearLayout mMainLayout; private AutoCompleteTextView mAccountJid; private EditText mPassword; private EditText mPasswordConfirm; @@ -333,6 +335,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_account); + this.mMainLayout = (LinearLayout) findViewById(R.id.account_main_layout); this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid); this.mAccountJid.addTextChangedListener(this.mTextWatcher); this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label); @@ -480,6 +483,12 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } @Override + public void onConfigurationChanged (Configuration newConfig) { + super.onConfigurationChanged(newConfig); + UIHelper.resetChildMargins(mMainLayout); + } + + @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.action_show_block_list: diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 0cdae2cd..aa03a61d 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -441,7 +441,7 @@ public abstract class XmppActivity extends Activity { } public void switchToAccount(Account account) { - switchToAccount(account,false); + switchToAccount(account, false); } public void switchToAccount(Account account, boolean init) { diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index cac23f07..8a73d35f 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -3,7 +3,11 @@ package eu.siacs.conversations.utils; import android.content.Context; import android.text.format.DateFormat; import android.text.format.DateUtils; +import android.util.DisplayMetrics; import android.util.Pair; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; import java.util.ArrayList; import java.util.Arrays; @@ -261,4 +265,21 @@ public class UIHelper { body = body.replace("?","").replace("¿",""); return LOCATION_QUESTIONS.contains(body); } + + public static void resetChildMargins(LinearLayout view) { + int childCount = view.getChildCount(); + for (int i = 0; i < childCount; i++) { + UIHelper.resetMargins(view.getChildAt(i)); + } + } + + private static void resetMargins(View view) { + LinearLayout.MarginLayoutParams marginLayoutParams = new LinearLayout.MarginLayoutParams(view.getLayoutParams()); + marginLayoutParams.setMargins(view.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin)); + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(marginLayoutParams); + view.setLayoutParams(layoutParams); + } } |