Hide advanced account settings by default (in general, we'll try to find them out automatically).

This commit is contained in:
B. Petersen
2017-03-13 23:12:56 +01:00
parent 4f6f0b4685
commit 545a2ddc24
8 changed files with 158 additions and 87 deletions
@@ -52,7 +52,7 @@ import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.EditTextCell;
import com.b44t.ui.Cells.ShadowSectionCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -64,7 +64,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
private int rowSectionBasic;
private int rowAddr;
private int rowMailPw;
private int rowInfoBelowMailPw2;
private int rowOpenAdvOpions;
private int rowSectionMail;
private int rowMailServer;
@@ -80,26 +80,26 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
private int rowInfoBelowSendPw;
private int rowCount;
private final int typeInfo = 0; // no gaps here!
private final int typeTextEntry = 1;
private final int typeShadowSection = 2;
private final int typeSection = 3;
private final int ROWTYPE_INFO = 0; // no gaps here!
private final int ROWTYPE_TEXT_ENTRY = 1;
private final int ROWTYPE_SHADOW_BREAK = 2;
private final int ROWTYPE_HEADLINE = 3;
EditTextCell addrCell; // warning all these objects may be null!
EditTextCell mailPwCell;
EditTextCell mailServerCell;
EditTextCell mailPortCell;
EditTextCell mailUserCell;
EditTextCell sendPwCell;
EditTextCell sendServerCell;
EditTextCell sendPortCell;
EditTextCell sendUserCell;
private EditTextCell addrCell; // warning all these objects may be null!
private EditTextCell mailPwCell;
private EditTextCell mailServerCell;
private EditTextCell mailPortCell;
private EditTextCell mailUserCell;
private EditTextCell sendPwCell;
private EditTextCell sendServerCell;
private EditTextCell sendPortCell;
private EditTextCell sendUserCell;
// misc.
private View doneButton;
private final static int done_button = 1;
private final int ID_DONE_BUTTON = 1;
private ProgressDialog progressDialog = null;
boolean fromIntro;
private boolean fromIntro;
private boolean m_expanded = false;
public AccountSettingsActivity(Bundle args) {
super();
@@ -114,28 +114,62 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
NotificationCenter.getInstance().addObserver(this, NotificationCenter.connectionStateChanged);
rowCount = 0;
rowSectionBasic = rowCount++;
rowAddr = rowCount++;
rowMailPw = rowCount++;
rowInfoBelowMailPw2 = rowCount++;
m_expanded = false;
if( !MrMailbox.getConfig("mail_user", "").isEmpty()
|| !MrMailbox.getConfig("mail_server", "").isEmpty()
|| !MrMailbox.getConfig("mail_port", "").isEmpty()
|| !MrMailbox.getConfig("send_user", "").isEmpty()
|| !MrMailbox.getConfig("send_pw", "").isEmpty()
|| !MrMailbox.getConfig("send_server", "").isEmpty()
|| !MrMailbox.getConfig("send_port", "").isEmpty() ) {
m_expanded = true;
}
rowSectionMail = rowCount++;
rowMailUser = rowCount++; // should be the first additional option, the loginname is the component, that cannot be configured automatically (if not derivable from the address)
rowMailServer = rowCount++;
rowMailPort = rowCount++;
rowBreak2 = rowCount++;
rowSectionSend = rowCount++;
rowSendUser = rowCount++;
rowSendPw = rowCount++;
rowSendServer = rowCount++;
rowSendPort = rowCount++;
rowInfoBelowSendPw = rowCount++;
calculateRows();
return true;
}
private void calculateRows()
{
rowCount = 0;
rowSectionBasic = rowCount++;
rowAddr = rowCount++;
rowMailPw = rowCount++;
rowOpenAdvOpions = rowCount++;
if( m_expanded ) {
rowSectionMail = rowCount++;
rowMailUser = rowCount++; // should be the first additional option, the loginname is the component, that cannot be configured automatically (if not derivable from the address)
rowMailServer = rowCount++;
rowMailPort = rowCount++;
rowBreak2 = rowCount++;
rowSectionSend = rowCount++;
rowSendUser = rowCount++;
rowSendPw = rowCount++;
rowSendServer = rowCount++;
rowSendPort = rowCount++;
}
else {
rowSectionMail = -1;
rowMailUser = -1;
rowMailServer = -1;
rowMailPort = -1;
rowBreak2 = -1;
rowSectionSend = -1;
rowSendUser = -1;
rowSendPw = -1;
rowSendServer = -1;
rowSendPort = -1;
}
rowInfoBelowSendPw = rowCount++;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
@@ -171,14 +205,14 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
else {
finishFragment();
}
} else if (id == done_button) {
} else if (id == ID_DONE_BUTTON) {
saveData();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
menu.addItemWithWidth(ID_DONE_BUTTON, R.drawable.ic_done, AndroidUtilities.dp(56));
// create object to hold the whole view
fragmentView = new FrameLayout(context);
@@ -198,6 +232,11 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) {
if( i==rowOpenAdvOpions ) {
m_expanded = !m_expanded;
calculateRows();
listAdapter.notifyDataSetChanged();
}
}
});
@@ -208,13 +247,6 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
// Warning: the widgets are created as needed and may not be present!
String v;
/*
if( !isModified() && MrMailbox.MrMailboxIsConfigured(MrMailbox.hMailbox)!=0 ) {
finishFragment();
return; // nothing to do
}
*/
if( addrCell!=null) {
v = addrCell.getValue().trim();
MrMailbox.setConfig("addr", v.isEmpty() ? null : v);
@@ -380,8 +412,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
@Override
public boolean isEnabled(int i) {
return (i == rowAddr || i==rowMailPw || i==rowMailServer || i==rowMailPort|| i==rowMailUser
|| i==rowSendServer || i==rowSendPort || i==rowSendUser || i== rowSendPw);
return !(i==rowSectionBasic || i==rowSectionMail || i==rowBreak2 || i==rowSectionSend || i==rowInfoBelowSendPw);
}
@Override
@@ -407,7 +438,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType__(i);
if (type == typeTextEntry) {
if (type == ROWTYPE_TEXT_ENTRY) {
if (i == rowAddr) {
if( addrCell==null) {
addrCell = new EditTextCell(mContext);
@@ -484,7 +515,7 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
view = sendPwCell;
}
}
else if (type == typeSection) {
else if (type == ROWTYPE_HEADLINE) {
if (view == null) {
view = new HeaderCell(mContext);
view.setBackgroundColor(0xffffffff);
@@ -497,22 +528,25 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
((HeaderCell) view).setText(LocaleController.getString("OutboxHeadline", R.string.OutboxHeadline));
}
}
else if (type == typeShadowSection) {
else if (type == ROWTYPE_SHADOW_BREAK) {
if (view == null) {
view = new ShadowSectionCell(mContext);
}
}
else if (type == typeInfo) {
else if (type == ROWTYPE_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if( i==rowInfoBelowMailPw2) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyAccoutExplain", R.string.MyAccountExplain)+"\n");
view.setBackgroundResource(R.drawable.greydivider); // has shadow top+bottom
if( i== rowOpenAdvOpions) {
((TextInfoCell) view).setText(LocaleController.getString("MyAccoutExplain", R.string.MyAccountExplain),
m_expanded? " \u2212" /*minus-sign*/ : "+", m_expanded /*draw bottom border?*/);
view.setBackgroundResource(m_expanded? R.drawable.greydivider : R.drawable.greydivider_bottom); // has shadow top+bottom
}
else if( i==rowInfoBelowSendPw) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyAccountExplain2", R.string.MyAccountExplain2));
view.setBackgroundResource(R.drawable.greydivider_bottom);
((TextInfoCell) view).setText(LocaleController.getString("MyAccountExplain2", R.string.MyAccountExplain2));
if( m_expanded ) {
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
}
return view;
@@ -526,15 +560,15 @@ public class AccountSettingsActivity extends BaseFragment implements Notificatio
private int getItemViewType__(int i) {
if (i == rowAddr || i==rowMailPw || i==rowMailServer || i==rowMailPort|| i==rowMailUser
|| i==rowSendServer || i==rowSendPort || i==rowSendUser || i== rowSendPw ) {
return typeTextEntry;
return ROWTYPE_TEXT_ENTRY;
}
else if( i==rowSectionBasic || i==rowSectionMail || i==rowSectionSend ) {
return typeSection;
return ROWTYPE_HEADLINE;
}
else if( i== rowBreak2) {
return typeShadowSection;
return ROWTYPE_SHADOW_BREAK;
}
return typeInfo;
return ROWTYPE_INFO;
}
@Override
@@ -41,7 +41,7 @@ import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -194,10 +194,10 @@ public class CacheControlActivity extends BaseFragment {
}
} else if (type == ROWTYPE_TEXT_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == rowKeepMediaInfo) {
((TextInfoPrivacyCell) view).setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
((TextInfoCell) view).setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
@@ -206,9 +206,7 @@ public class CacheControlActivity extends BaseFragment {
@Override
public int getItemViewType(int i) {
if (i == rowKeepMediaSetting) {
return ROWTYPE_TEXT_SETTING;
} else if (i == rowKeepMediaInfo) {
if (i == rowKeepMediaInfo) {
return ROWTYPE_TEXT_INFO;
}
return ROWTYPE_TEXT_SETTING;
@@ -68,7 +68,7 @@ public class EditTextCell extends FrameLayout {
labelTextView.setSingleLine(true);
labelTextView.setPadding(0, 0, 0, 0);
addView(labelTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
17, 10, 17, 0));
17, 8, 17, 0));
editView = new EditText(context);
@@ -1,7 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -24,7 +23,6 @@
package com.b44t.ui.Cells;
import android.content.Context;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
@@ -33,23 +31,29 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.Theme;
public class TextInfoPrivacyCell extends FrameLayout {
public class TextInfoCell extends FrameLayout {
private TextView textView;
private TextView iconView;
public TextInfoPrivacyCell(Context context) {
private final int iconDp = 34;
public TextInfoCell(Context context) {
super(context);
textView = new TextView(context);
textView.setTextColor(0xff808080);
textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17));
textView.setMovementMethod(LinkMovementMethod.getInstance());
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
addView(textView);
iconView = new TextView(context);
iconView.setTextColor(0xff000000);
iconView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, iconDp);
iconView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
addView(iconView);
}
@Override
@@ -57,8 +61,43 @@ public class TextInfoPrivacyCell extends FrameLayout {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
public void setText(CharSequence text) {
public void setText(CharSequence text)
{
setText(text, null, true);
}
public void setText(CharSequence text, CharSequence icon, boolean borderBotton)
{
textView.setText(text);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) textView.getLayoutParams();
lp.width = LayoutHelper.WRAP_CONTENT;
lp.height = LayoutHelper.WRAP_CONTENT;
lp.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
lp.leftMargin = AndroidUtilities.dp(17);
lp.topMargin = AndroidUtilities.dp(13);
lp.rightMargin = AndroidUtilities.dp(17 + (icon!=null?iconDp:0));
lp.bottomMargin = borderBotton? AndroidUtilities.dp(13) : 0;
textView.setLayoutParams(lp);
if( icon != null )
{
iconView.setText(icon);
iconView.setVisibility(VISIBLE);
lp = (FrameLayout.LayoutParams) iconView.getLayoutParams();
lp.width = LayoutHelper.WRAP_CONTENT;
lp.height = LayoutHelper.WRAP_CONTENT;
lp.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP;
lp.leftMargin = AndroidUtilities.dp(17);
lp.topMargin = AndroidUtilities.dp(3);
lp.rightMargin = AndroidUtilities.dp(20);
iconView.setLayoutParams(lp);
}
else
{
iconView.setVisibility(GONE);
}
}
public void setTextColor(int color) {
@@ -47,7 +47,7 @@ import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.EditTextCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -238,10 +238,10 @@ public class NameSettingsActivity extends BaseFragment {
}
} else if (type == typeInfo) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if( i==rowDisplaynameInfo) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("MyNameExplain", R.string.MyNameExplain));
((TextInfoCell) view).setText(LocaleController.getString("MyNameExplain", R.string.MyNameExplain));
}
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
@@ -69,7 +69,7 @@ import com.b44t.ui.ActionBar.ActionBarMenuItem;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.TextCheckCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.NumberPicker;
@@ -687,17 +687,17 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
}
} else if (viewType == 2) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == passcodeDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("ChangePasscodeInfo", R.string.ChangePasscodeInfo));
((TextInfoCell) view).setText(LocaleController.getString("ChangePasscodeInfo", R.string.ChangePasscodeInfo));
if (autoLockDetailRow != -1) {
view.setBackgroundResource(R.drawable.greydivider);
} else {
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
} else if (i == autoLockDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("AutoLockInfo", R.string.AutoLockInfo));
((TextInfoCell) view).setText(LocaleController.getString("AutoLockInfo", R.string.AutoLockInfo));
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
}
@@ -44,7 +44,7 @@ import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Cells.TextCheckCell;
import com.b44t.ui.Cells.TextInfoPrivacyCell;
import com.b44t.ui.Cells.TextInfoCell;
import com.b44t.ui.Cells.TextSettingsCell;
import com.b44t.ui.Components.LayoutHelper;
@@ -301,10 +301,10 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
}
} else if (type == TYPE_TEXT_INFO) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view = new TextInfoCell(mContext);
}
if (i == secretDetailRow) {
((TextInfoPrivacyCell) view).setText("");
((TextInfoCell) view).setText("");
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
} else if (type == TYPE_HEADER) {
@@ -85,7 +85,7 @@ public class SettingsAdvActivity extends BaseFragment {
sendByEnterRow = rowCount++;
raiseToSpeakRow = rowCount++; // outgoing message
enableAnimationsRow = -1;//rowCount++; -- for now, we disable this option, maybe we can add it later to a "view" settings, however, in general, this should be more a system-option
cacheRow =rowCount++;
cacheRow = -1;// for now, the - non-functional - page is reachable by the "storage settings" in the "android App Settings" only
languageRow = rowCount++;
finalShadowRow = rowCount++;