Merge pull request #1520 from saqura/self_handle_orientation
Handle some orientation changes manually
This commit is contained in:
commit
ec473a4437
|
@ -39,6 +39,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConversationActivity"
|
android:name=".ui.ConversationActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="stateHidden">
|
android:windowSoftInputMode="stateHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -95,14 +96,17 @@
|
||||||
android:launchMode="singleTask"/>
|
android:launchMode="singleTask"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.EditAccountActivity"
|
android:name=".ui.EditAccountActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="stateHidden|adjustResize"/>
|
android:windowSoftInputMode="stateHidden|adjustResize"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConferenceDetailsActivity"
|
android:name=".ui.ConferenceDetailsActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/title_activity_conference_details"
|
android:label="@string/title_activity_conference_details"
|
||||||
android:windowSoftInputMode="stateHidden"/>
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ContactDetailsActivity"
|
android:name=".ui.ContactDetailsActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/title_activity_contact_details"
|
android:label="@string/title_activity_contact_details"
|
||||||
android:windowSoftInputMode="stateHidden"/>
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.IntentSender.SendIntentException;
|
import android.content.IntentSender.SendIntentException;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
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;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
|
||||||
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConferenceOptionsPushed {
|
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);
|
inviteToConversation(mConversation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private LinearLayout mMainLayout;
|
||||||
private TextView mYourNick;
|
private TextView mYourNick;
|
||||||
private ImageView mYourPhoto;
|
private ImageView mYourPhoto;
|
||||||
private ImageButton mEditNickButton;
|
private ImageButton mEditNickButton;
|
||||||
|
@ -187,6 +190,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_muc_details);
|
setContentView(R.layout.activity_muc_details);
|
||||||
|
mMainLayout = (LinearLayout) findViewById(R.id.muc_main_layout);
|
||||||
mYourNick = (TextView) findViewById(R.id.muc_your_nick);
|
mYourNick = (TextView) findViewById(R.id.muc_your_nick);
|
||||||
mYourPhoto = (ImageView) findViewById(R.id.your_photo);
|
mYourPhoto = (ImageView) findViewById(R.id.your_photo);
|
||||||
mEditNickButton = (ImageButton) findViewById(R.id.edit_nick_button);
|
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() {
|
private void updateView() {
|
||||||
final MucOptions mucOptions = mConversation.getMucOptions();
|
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||||
final User self = mucOptions.getSelf();
|
final User self = mucOptions.getSelf();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender.SendIntentException;
|
import android.content.IntentSender.SendIntentException;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -99,6 +100,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private LinearLayout mainLayout;
|
||||||
private Jid accountJid;
|
private Jid accountJid;
|
||||||
private Jid contactJid;
|
private Jid contactJid;
|
||||||
private TextView contactJidTv;
|
private TextView contactJidTv;
|
||||||
|
@ -197,6 +199,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
|
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
|
||||||
setContentView(R.layout.activity_contact_details);
|
setContentView(R.layout.activity_contact_details);
|
||||||
|
|
||||||
|
mainLayout = (LinearLayout) findViewById(R.id.details_main_layout);
|
||||||
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
contactJidTv = (TextView) findViewById(R.id.details_contactjid);
|
||||||
accountJidTv = (TextView) findViewById(R.id.details_account);
|
accountJidTv = (TextView) findViewById(R.id.details_account);
|
||||||
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
lastseen = (TextView) findViewById(R.id.details_lastseen);
|
||||||
|
@ -297,6 +300,12 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged (Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
UIHelper.resetChildMargins(mainLayout);
|
||||||
|
}
|
||||||
|
|
||||||
private void populateView() {
|
private void populateView() {
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
setTitle(contact.getDisplayName());
|
setTitle(contact.getDisplayName());
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.AlertDialog.Builder;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
|
@ -51,6 +52,7 @@ import eu.siacs.conversations.xmpp.pep.Avatar;
|
||||||
public class EditAccountActivity extends XmppActivity implements OnAccountUpdate,
|
public class EditAccountActivity extends XmppActivity implements OnAccountUpdate,
|
||||||
OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast {
|
OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast {
|
||||||
|
|
||||||
|
private LinearLayout mMainLayout;
|
||||||
private AutoCompleteTextView mAccountJid;
|
private AutoCompleteTextView mAccountJid;
|
||||||
private EditText mPassword;
|
private EditText mPassword;
|
||||||
private EditText mPasswordConfirm;
|
private EditText mPasswordConfirm;
|
||||||
|
@ -333,6 +335,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_edit_account);
|
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 = (AutoCompleteTextView) findViewById(R.id.account_jid);
|
||||||
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
|
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
|
||||||
this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
|
this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
|
||||||
|
@ -479,6 +482,12 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged (Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
UIHelper.resetChildMargins(mMainLayout);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
|
|
@ -441,7 +441,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchToAccount(Account account) {
|
public void switchToAccount(Account account) {
|
||||||
switchToAccount(account,false);
|
switchToAccount(account, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchToAccount(Account account, boolean init) {
|
public void switchToAccount(Account account, boolean init) {
|
||||||
|
|
|
@ -3,7 +3,11 @@ package eu.siacs.conversations.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -261,4 +265,21 @@ public class UIHelper {
|
||||||
body = body.replace("?","").replace("¿","");
|
body = body.replace("?","").replace("¿","");
|
||||||
return LOCATION_QUESTIONS.contains(body);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
android:background="@color/grey200" >
|
android:background="@color/grey200" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/details_main_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
android:layout_alignParentTop="true" >
|
android:layout_alignParentTop="true" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/account_main_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
android:background="@color/grey200">
|
android:background="@color/grey200">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/muc_main_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
Loading…
Reference in a new issue