mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 20:15:03 -05:00
Implements a very simple and basic view for the confirm screens showing filtered account configuration information.
This commit is contained in:
parent
3d2a37418f
commit
252b406d8e
@ -4,21 +4,43 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_protocol"
|
||||
<LinearLayout android:id="@+id/confirm_first_option"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:prompt="@string/account_setup_basics_email_hint"
|
||||
/>
|
||||
android:orientation="horizontal">
|
||||
<TextView android:id="@+id/confirm_type_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Type" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_sockettype"
|
||||
<Spinner android:id="@+id/spinner_protocol"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:layout_toRightOf="@id/confirm_type_label"
|
||||
android:prompt="@string/account_setup_basics_email_hint" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/confirm_second_option"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:prompt="@string/account_setup_basics_email_hint"
|
||||
android:layout_below="@id/spinner_protocol"
|
||||
/>
|
||||
android:orientation="horizontal"
|
||||
android:layout_below="@id/confirm_first_option">
|
||||
<TextView android:id="@+id/confirm_security_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Security" />
|
||||
|
||||
<Spinner android:id="@+id/spinner_sockettype"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
android:prompt="@string/account_setup_basics_email_hint"
|
||||
android:layout_toRightOf="@id/confirm_security_label" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/server_information"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_below="@id/confirm_second_option"/>
|
||||
</RelativeLayout>
|
140
src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java
Normal file
140
src/com/fsck/k9/activity/setup/AbstractSetupConfirmActivity.java
Normal file
@ -0,0 +1,140 @@
|
||||
package com.fsck.k9.activity.setup;
|
||||
|
||||
/*
|
||||
After gathering the necessary information one way or another this activity displays it to the user, eventually warns
|
||||
him it could be false ( no https ), asks for confirmation, allows selection of protocol,... and then goes on to test
|
||||
the final settings.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
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 java.util.List;
|
||||
|
||||
public abstract class AbstractSetupConfirmActivity extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
||||
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||
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());
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static void actionConfirmIncoming(Context context, String email, String password, AutoconfigInfo info){
|
||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
||||
i.putExtra(EXTRA_EMAIL, email);
|
||||
i.putExtra(EXTRA_PASSWORD, password);
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
// data
|
||||
Account mAccount;
|
||||
AutoconfigInfo mConfigInfo;
|
||||
|
||||
// references to current selections ( easier to code with )
|
||||
Server mCurrentServer;
|
||||
ServerType mCurrentType;
|
||||
SocketType mCurrentSocket;
|
||||
|
||||
// gui elements
|
||||
Spinner mProtocolSpinner;
|
||||
Spinner mSocketTypeSpinner;
|
||||
TextView mServerInfoText;
|
||||
|
||||
// difference between incomming & outgoing
|
||||
protected abstract List<? extends Server> getServers();
|
||||
protected abstract List<ServerType> getAvailableServerTypes();
|
||||
protected abstract void finishAction();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstance){
|
||||
super.onCreate(savedInstance);
|
||||
setContentView(R.layout.account_setup_confirm);
|
||||
|
||||
// initialise gui elements from inflated layout
|
||||
mSocketTypeSpinner = (Spinner) findViewById(R.id.spinner_sockettype);
|
||||
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
||||
mServerInfoText = (TextView) findViewById(R.id.server_information);
|
||||
|
||||
// get the data out of our intent
|
||||
// if no blank account passed make one
|
||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
if(accountUuid != null)
|
||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||
else mAccount = Account.getBlankAccount(this,
|
||||
getIntent().getStringExtra(EXTRA_EMAIL),
|
||||
getIntent().getStringExtra(EXTRA_PASSWORD));
|
||||
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
||||
|
||||
// attach data to gui elements
|
||||
ArrayAdapter<ServerType> protocolAdapter = new ArrayAdapter<ServerType>(this,
|
||||
R.layout.account_setup_confirm_spinners_item, getAvailableServerTypes());
|
||||
mProtocolSpinner.setAdapter(protocolAdapter);
|
||||
|
||||
List<SocketType> matchingSocketTypeList = mConfigInfo.getAvailableSocketTypes(
|
||||
mConfigInfo.getFilteredServerList(getServers(),protocolAdapter.getItem(0), null, null));
|
||||
ArrayAdapter<SocketType> socketTypeAdapter = new ArrayAdapter<SocketType>(this,
|
||||
R.layout.account_setup_confirm_spinners_item, matchingSocketTypeList);
|
||||
mSocketTypeSpinner.setAdapter(socketTypeAdapter);
|
||||
|
||||
// attach the listeners
|
||||
mProtocolSpinner.setOnItemSelectedListener(this);
|
||||
mSocketTypeSpinner.setOnItemSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
switch( parent.getId() ){
|
||||
case R.id.spinner_protocol:
|
||||
mCurrentType = (ServerType) mProtocolSpinner.getAdapter().getItem(pos);
|
||||
// now we have to reset the options in sockettype spinner
|
||||
List<SocketType> newTypes = mConfigInfo.getAvailableSocketTypes(
|
||||
mConfigInfo.getFilteredServerList(getServers(),(ServerType) mProtocolSpinner.getAdapter().getItem(pos), null, null));
|
||||
mSocketTypeSpinner.setAdapter(new ArrayAdapter(this, R.layout.account_setup_confirm_spinners_item, newTypes));
|
||||
mSocketTypeSpinner.invalidate();
|
||||
break;
|
||||
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);
|
||||
setServerInfo(mCurrentServer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setServerInfo(Server mCurrentServer) {
|
||||
// TODO: string resources
|
||||
mServerInfoText.setText("Host: "+mCurrentServer.hostname+"\n"+
|
||||
"Port: "+mCurrentServer.port+"\n"+
|
||||
"Authentication: "+mCurrentServer.authentication);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {}
|
||||
}
|
@ -6,113 +6,23 @@ package com.fsck.k9.activity.setup;
|
||||
the final settings.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.SocketType;
|
||||
import java.util.List;
|
||||
|
||||
public class AccountSetupConfirmIncoming extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
||||
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||
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());
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static void actionConfirmIncoming(Context context, String email, String password, AutoconfigInfo info){
|
||||
Intent i = new Intent(context, AccountSetupConfirmIncoming.class);
|
||||
i.putExtra(EXTRA_EMAIL, email);
|
||||
i.putExtra(EXTRA_PASSWORD, password);
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
// data
|
||||
Account mAccount;
|
||||
AutoconfigInfo mConfigInfo;
|
||||
|
||||
// gui elements
|
||||
Spinner mProtocolSpinner;
|
||||
Spinner mSocketTypeSpinner;
|
||||
|
||||
public class AccountSetupConfirmIncoming extends AbstractSetupConfirmActivity{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstance){
|
||||
super.onCreate(savedInstance);
|
||||
setContentView(R.layout.account_setup_confirm);
|
||||
|
||||
// initialise gui elements from inflated layout
|
||||
mSocketTypeSpinner = (Spinner) findViewById(R.id.spinner_sockettype);
|
||||
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
||||
|
||||
// get the data out of our intent
|
||||
// if no blank account passed make one
|
||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
if(accountUuid != null)
|
||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||
else mAccount = Account.getBlankAccount(this,
|
||||
getIntent().getStringExtra(EXTRA_EMAIL),
|
||||
getIntent().getStringExtra(EXTRA_PASSWORD));
|
||||
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
||||
|
||||
// attach data to gui elements
|
||||
ArrayAdapter<ServerType> protocolAdapter = new ArrayAdapter<ServerType>(this,
|
||||
R.layout.account_setup_confirm_spinners_item, mConfigInfo.getAvailableIncomingServerTypes());
|
||||
mProtocolSpinner.setAdapter(protocolAdapter);
|
||||
|
||||
List<SocketType> matchingSocketTypeList = mConfigInfo.getAvailableSocketTypes(
|
||||
mConfigInfo.getIncomingServers(protocolAdapter.getItem(0), null, null));
|
||||
ArrayAdapter<SocketType> socketTypeAdapter = new ArrayAdapter<SocketType>(this,
|
||||
R.layout.account_setup_confirm_spinners_item, matchingSocketTypeList);
|
||||
mSocketTypeSpinner.setAdapter(socketTypeAdapter);
|
||||
|
||||
// attach the listeners
|
||||
mProtocolSpinner.setOnItemSelectedListener(this);
|
||||
mSocketTypeSpinner.setOnItemSelectedListener(this);
|
||||
protected List<? extends AutoconfigInfo.Server> getServers() {
|
||||
return mConfigInfo.incomingServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
protected List<ServerType> getAvailableServerTypes() {
|
||||
return mConfigInfo.getAvailableIncomingServerTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
switch( parent.getId() ){
|
||||
case R.id.spinner_protocol:
|
||||
// now we have to reset the options in sockettype spinner
|
||||
List<SocketType> newTypes = mConfigInfo.getAvailableSocketTypes(
|
||||
mConfigInfo.getIncomingServers((ServerType) mProtocolSpinner.getAdapter().getItem(pos), null, null));
|
||||
mSocketTypeSpinner.setAdapter(new ArrayAdapter(this, R.layout.account_setup_confirm_spinners_item, newTypes));
|
||||
mSocketTypeSpinner.invalidate();
|
||||
break;
|
||||
case R.id.spinner_sockettype:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
protected void finishAction() {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
@ -6,67 +6,23 @@ package com.fsck.k9.activity.setup;
|
||||
the final settings.
|
||||
*/
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.activity.K9Activity;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.ServerType;
|
||||
import java.util.List;
|
||||
|
||||
public class AccountSetupConfirmOutgoing extends K9Activity implements View.OnClickListener{
|
||||
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||
private static final String EXTRA_EMAIL = "email";
|
||||
private static final String EXTRA_PASSWORD = "password";
|
||||
|
||||
|
||||
public static void actionConfirmOutgoing(Context context, Account account, AutoconfigInfo info) {
|
||||
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static void actionConfirmOutgoing(Context context, String email, String password, AutoconfigInfo info){
|
||||
Intent i = new Intent(context, AccountSetupConfirmOutgoing.class);
|
||||
i.putExtra(EXTRA_EMAIL, email);
|
||||
i.putExtra(EXTRA_PASSWORD, password);
|
||||
i.putExtra(EXTRA_CONFIG_INFO, info);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
// data
|
||||
Account mAccount;
|
||||
AutoconfigInfo mConfigInfo;
|
||||
|
||||
public class AccountSetupConfirmOutgoing extends AbstractSetupConfirmActivity{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstance){
|
||||
super.onCreate(savedInstance);
|
||||
setContentView(R.layout.account_setup_confirm);
|
||||
|
||||
// initialise gui elements from inflated layout
|
||||
|
||||
// get the data out of our intent
|
||||
// if no blank account passed make one
|
||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
if(accountUuid != null)
|
||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||
else mAccount = Account.getBlankAccount(this,
|
||||
getIntent().getStringExtra(EXTRA_EMAIL),
|
||||
getIntent().getStringExtra(EXTRA_PASSWORD));
|
||||
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
||||
|
||||
// attach the listeners
|
||||
|
||||
protected List<? extends AutoconfigInfo.Server> getServers() {
|
||||
return mConfigInfo.outgoingServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
protected List<ServerType> getAvailableServerTypes() {
|
||||
return mConfigInfo.getAvailableOutgoingServerTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finishAction() {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
@ -466,7 +466,7 @@ public class AutoconfigInfo implements Parcelable {
|
||||
}
|
||||
|
||||
// filters the list of servers according to the arguments ( list of allowed specifications )
|
||||
private <T extends Server> List<T> getFilteredServerList
|
||||
public <T extends Server> List<T> getFilteredServerList
|
||||
(List<T> serverList, ServerType serverType, AuthenticationType authenticationType, SocketType socketType)
|
||||
{
|
||||
ArrayList<T> servers = new ArrayList<T>();
|
||||
|
Loading…
Reference in New Issue
Block a user