mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-13 13:05:03 -05:00
Added view support for documentation links added by ISP and unfinished support for multiple hosts with same settings.
This commit is contained in:
parent
9e99acd9c9
commit
6ade89ed54
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@ -64,7 +64,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"/>
|
android:layout_alignParentLeft="true"/>
|
||||||
<TextView android:id="@+id/server_count_label"
|
<TextView android:id="@+id/server_count_label"
|
||||||
android:text="( 1 / 1 )"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"/>
|
android:layout_alignParentRight="true"/>
|
||||||
@ -79,18 +78,54 @@
|
|||||||
<!-- ONLY SHOW WHEN USER HAS TO ENTER A USERNAME HIMSELF -->
|
<!-- ONLY SHOW WHEN USER HAS TO ENTER A USERNAME HIMSELF -->
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
|
|
||||||
<!-- SHOULD ONLY BE MADE VISIBLE WHEN THERE ARE MULTIPLE MATCHING SERVERS -->
|
<!-- SHOULD ONLY BE MADE VISIBLE WHEN THERE ARE MULTIPLE MATCHING SERVERS
|
||||||
<!-- TODO -->
|
NOTE: see note at beginning of AbstractSetupConfirmActivity class -->
|
||||||
|
<RelativeLayout android:id="@+id/confirm_serverbrowse_buttons"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_below="@id/server_information">
|
||||||
|
<Button android:id="@+id/confirm_prev_server_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Previous" />
|
||||||
|
<Button android:id="@+id/confirm_next_server_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@id/confirm_prev_server_button"
|
||||||
|
android:text="Next" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- SHOULD ONLY BE MADE VISIBLE WHEN THE XML PROVIDES EXTRA INFORMATION LINKS -->
|
<!-- SHOULD ONLY BE MADE VISIBLE WHEN THE XML PROVIDES EXTRA INFORMATION LINKS -->
|
||||||
<!-- TODO -->
|
<RelativeLayout android:id="@+id/confirm_documentation_part"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
<Button android:id="@+id/confirm_ok_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_below="@id/confirm_serverbrowse_buttons">
|
||||||
android:layout_alignParentBottom="true"
|
<TextView android:id="@+id/server_documentation_header"
|
||||||
android:text="Ok go"/>
|
android:text="Server documentation"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="9dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:background="#AAA"
|
||||||
|
android:layout_alignParentLeft="true"/>
|
||||||
|
<TextView android:id="@+id/server_documentation_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/server_documentation_header"
|
||||||
|
android:padding="8dp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
<RelativeLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
<Button android:id="@+id/confirm_ok_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:text="Ok go"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
@ -6,9 +6,18 @@ package com.fsck.k9.activity.setup;
|
|||||||
the final settings.
|
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.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.text.method.MovementMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
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.ServerType;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.SocketType;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.SocketType;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.Server;
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.Server;
|
||||||
|
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.InformationBlock;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractSetupConfirmActivity extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
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_EMAIL = "email";
|
||||||
private static final String EXTRA_PASSWORD = "password";
|
private static final String EXTRA_PASSWORD = "password";
|
||||||
|
|
||||||
|
|
||||||
public static void actionConfirmIncoming(Context context, Account account, AutoconfigInfo info) {
|
public static void actionConfirmIncoming(Context context, Account account, AutoconfigInfo info) {
|
||||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
||||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||||
@ -46,19 +55,24 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data
|
// data
|
||||||
Account mAccount;
|
protected Account mAccount;
|
||||||
AutoconfigInfo mConfigInfo;
|
protected AutoconfigInfo mConfigInfo;
|
||||||
|
|
||||||
// references to current selections ( easier to code with )
|
// references to current selections ( easier to code with )
|
||||||
Server mCurrentServer;
|
private Server mCurrentServer;
|
||||||
ServerType mCurrentType;
|
private ServerType mCurrentType;
|
||||||
SocketType mCurrentSocket;
|
private SocketType mCurrentSocket;
|
||||||
|
private List<? extends Server> mCurrentServerList;
|
||||||
|
|
||||||
// gui elements
|
// gui elements
|
||||||
Spinner mProtocolSpinner;
|
private Spinner mProtocolSpinner;
|
||||||
Spinner mSocketTypeSpinner;
|
private Spinner mSocketTypeSpinner;
|
||||||
TextView mServerInfoText;
|
private TextView mServerInfoText;
|
||||||
Button mOkButton;
|
private Button mOkButton;
|
||||||
|
private TextView mServerCountLabel;
|
||||||
|
private RelativeLayout mServerBrowseButtons;
|
||||||
|
private RelativeLayout mServerDocumentation;
|
||||||
|
private TextView mDocumentationLinks;
|
||||||
|
|
||||||
// difference between incomming & outgoing
|
// difference between incomming & outgoing
|
||||||
protected abstract List<? extends Server> getServers();
|
protected abstract List<? extends Server> getServers();
|
||||||
@ -75,6 +89,11 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
||||||
mServerInfoText = (TextView) findViewById(R.id.server_information);
|
mServerInfoText = (TextView) findViewById(R.id.server_information);
|
||||||
mOkButton = (Button) findViewById(R.id.confirm_ok_button);
|
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
|
// get the data out of our intent
|
||||||
// if no blank account passed make one
|
// 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);
|
R.layout.account_setup_confirm_spinners_item, matchingSocketTypeList);
|
||||||
mSocketTypeSpinner.setAdapter(socketTypeAdapter);
|
mSocketTypeSpinner.setAdapter(socketTypeAdapter);
|
||||||
|
|
||||||
|
// if there is extra information, display it
|
||||||
|
if( mConfigInfo.hasExtraInfo() ){
|
||||||
|
fillDocumentation(mDocumentationLinks, mConfigInfo.documentation);
|
||||||
|
mServerDocumentation.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
// attach the listeners
|
// attach the listeners
|
||||||
mProtocolSpinner.setOnItemSelectedListener(this);
|
mProtocolSpinner.setOnItemSelectedListener(this);
|
||||||
mSocketTypeSpinner.setOnItemSelectedListener(this);
|
mSocketTypeSpinner.setOnItemSelectedListener(this);
|
||||||
@ -105,8 +130,17 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( view.getId() == R.id.confirm_ok_button ){
|
switch( view.getId() ){
|
||||||
Toast.makeText(this,"go go go", 400).show();
|
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:
|
case R.id.spinner_sockettype:
|
||||||
// this is called on setup too so it initialises the view too
|
// this is called on setup too so it initialises the view too
|
||||||
mCurrentSocket = (SocketType) mSocketTypeSpinner.getAdapter().getItem(pos);
|
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);
|
setServerInfo(mCurrentServer);
|
||||||
|
setServerCount(1);
|
||||||
|
toggleServerChooseButtons();
|
||||||
break;
|
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<InformationBlock> info) {
|
||||||
|
if( info == null ) return;
|
||||||
|
String tmpString = (String) view.getText();
|
||||||
|
|
||||||
|
for( InformationBlock infoBlock : info ){
|
||||||
|
tmpString += "\n"+infoBlock.descriptions.get(0).getSecond()+
|
||||||
|
" <a href=\""+infoBlock.url+"\">Read</a><br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
view.setText(Html.fromHtml(tmpString));
|
||||||
|
view.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setServerInfo(Server mCurrentServer) {
|
private void setServerInfo(Server mCurrentServer) {
|
||||||
// TODO: string resources
|
// TODO: string resources
|
||||||
mServerInfoText.setText("Host: "+mCurrentServer.hostname+"\n"+
|
mServerInfoText.setText("Host: "+mCurrentServer.hostname+"\n"+
|
||||||
@ -137,6 +198,10 @@ public abstract class AbstractSetupConfirmActivity extends K9Activity implements
|
|||||||
"Authentication: "+mCurrentServer.authentication);
|
"Authentication: "+mCurrentServer.authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setServerCount(int count){
|
||||||
|
mServerCountLabel.setText("( "+count+" / "+mCurrentServerList.size()+" )");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> adapterView) {}
|
public void onNothingSelected(AdapterView<?> adapterView) {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user