diff --git a/res/layout/account_setup_confirm.xml b/res/layout/account_setup_confirm.xml
index 3855b8ce4..8693df528 100644
--- a/res/layout/account_setup_confirm.xml
+++ b/res/layout/account_setup_confirm.xml
@@ -1,6 +1,6 @@
-
@@ -64,7 +64,6 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"/>
@@ -79,18 +78,54 @@
-
-
+
+
+
+
+
-
-
-
+ android:layout_marginTop="4dp"
+ android:layout_below="@id/confirm_serverbrowse_buttons">
+
+
+
-
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java b/src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java
index a70853f5e..531b3d301 100644
--- a/src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java
+++ b/src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java
@@ -6,9 +6,18 @@ package com.fsck.k9.activity.setup;
the final settings.
*/
+/*
+ NOTE:
+ For now there is code and codepaths to enable support multiple hosts for the exact same settings. A user can then
+ 'browse' through the available hosts. This consists of 2 auto hidden/unhidden buttons and the necessary callbacks.
+ The need for this is questionable, if the devs/community decide for, I'll finish the code, if not it will be removed.
+ */
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.text.method.MovementMethod;
import android.view.View;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener;
@@ -20,6 +29,7 @@ import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.SocketType;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.Server;
+import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.InformationBlock;
import java.util.List;
public abstract class AbstractSetupConfirmActivity extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
@@ -29,7 +39,6 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
private static final String EXTRA_EMAIL = "email";
private static final String EXTRA_PASSWORD = "password";
-
public static void actionConfirmIncoming(Context context, Account account, AutoconfigInfo info) {
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
@@ -46,19 +55,24 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
}
// data
- Account mAccount;
- AutoconfigInfo mConfigInfo;
+ protected Account mAccount;
+ protected AutoconfigInfo mConfigInfo;
// references to current selections ( easier to code with )
- Server mCurrentServer;
- ServerType mCurrentType;
- SocketType mCurrentSocket;
+ private Server mCurrentServer;
+ private ServerType mCurrentType;
+ private SocketType mCurrentSocket;
+ private List extends Server> mCurrentServerList;
// gui elements
- Spinner mProtocolSpinner;
- Spinner mSocketTypeSpinner;
- TextView mServerInfoText;
- Button mOkButton;
+ private Spinner mProtocolSpinner;
+ private Spinner mSocketTypeSpinner;
+ private TextView mServerInfoText;
+ private Button mOkButton;
+ private TextView mServerCountLabel;
+ private RelativeLayout mServerBrowseButtons;
+ private RelativeLayout mServerDocumentation;
+ private TextView mDocumentationLinks;
// difference between incomming & outgoing
protected abstract List extends Server> getServers();
@@ -75,6 +89,11 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
mServerInfoText = (TextView) findViewById(R.id.server_information);
mOkButton = (Button) findViewById(R.id.confirm_ok_button);
+ mServerCountLabel = (TextView) findViewById(R.id.server_count_label);
+ mDocumentationLinks = (TextView) findViewById(R.id.server_documentation_content);
+
+ mServerBrowseButtons = (RelativeLayout) findViewById(R.id.confirm_serverbrowse_buttons);
+ mServerDocumentation = (RelativeLayout) findViewById(R.id.confirm_documentation_part);
// get the data out of our intent
// if no blank account passed make one
@@ -97,6 +116,12 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
R.layout.account_setup_confirm_spinners_item, matchingSocketTypeList);
mSocketTypeSpinner.setAdapter(socketTypeAdapter);
+ // if there is extra information, display it
+ if( mConfigInfo.hasExtraInfo() ){
+ fillDocumentation(mDocumentationLinks, mConfigInfo.documentation);
+ mServerDocumentation.setVisibility(View.VISIBLE);
+ }
+
// attach the listeners
mProtocolSpinner.setOnItemSelectedListener(this);
mSocketTypeSpinner.setOnItemSelectedListener(this);
@@ -105,8 +130,17 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
@Override
public void onClick(View view) {
- if( view.getId() == R.id.confirm_ok_button ){
- Toast.makeText(this,"go go go", 400).show();
+ switch( view.getId() ){
+ case R.id.confirm_ok_button:
+ finishAction();
+ finish();
+ break;
+ case R.id.confirm_next_server_button:
+ // TODO: write this,... it will probably never be used since no isp has 2 host for exact the same thing
+ break;
+ case R.id.confirm_prev_server_button:
+ // TODO: write this,... it will probably never be used since no isp has 2 host for exact the same thing
+ break;
}
}
@@ -124,12 +158,39 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
case R.id.spinner_sockettype:
// this is called on setup too so it initialises the view too
mCurrentSocket = (SocketType) mSocketTypeSpinner.getAdapter().getItem(pos);
- mCurrentServer = mConfigInfo.getFilteredServerList(getServers(),mCurrentType, null, mCurrentSocket).get(0);
+ mCurrentServerList = mConfigInfo.getFilteredServerList(getServers(), mCurrentType, null, mCurrentSocket);
+ mCurrentServer = mCurrentServerList.get(0);
setServerInfo(mCurrentServer);
+ setServerCount(1);
+ toggleServerChooseButtons();
break;
}
}
+ private void toggleServerChooseButtons() {
+ if( mCurrentServerList.size() > 1 ){
+ mServerBrowseButtons.setVisibility(View.VISIBLE);
+ }else{
+ mServerBrowseButtons.setVisibility(View.GONE);
+ }
+ }
+
+ // TODO: if language is provided check against locale, now we just take the first index
+ // TODO: use table layout
+ private void fillDocumentation(TextView view, List info) {
+ if( info == null ) return;
+ String tmpString = (String) view.getText();
+
+ for( InformationBlock infoBlock : info ){
+ tmpString += "\n"+infoBlock.descriptions.get(0).getSecond()+
+ " Read
";
+ }
+
+ view.setText(Html.fromHtml(tmpString));
+ view.setMovementMethod(LinkMovementMethod.getInstance());
+ }
+
+
private void setServerInfo(Server mCurrentServer) {
// TODO: string resources
mServerInfoText.setText("Host: "+mCurrentServer.hostname+"\n"+
@@ -137,6 +198,10 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
"Authentication: "+mCurrentServer.authentication);
}
+ private void setServerCount(int count){
+ mServerCountLabel.setText("( "+count+" / "+mCurrentServerList.size()+" )");
+ }
+
@Override
public void onNothingSelected(AdapterView> adapterView) {}
}