mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-14 05:25:07 -05:00
Start of confirm activity. Now correctly links the two spinners ( protocol and sockettype ) to allow selecting between multiple configuration options.
This commit is contained in:
parent
277bfb879f
commit
3d2a37418f
@ -5,7 +5,7 @@
|
|||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spinner_hostname"
|
android:id="@+id/spinner_protocol"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawSelectorOnTop="true"
|
android:drawSelectorOnTop="true"
|
||||||
@ -13,12 +13,12 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spinner_protocol"
|
android:id="@+id/spinner_sockettype"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawSelectorOnTop="true"
|
android:drawSelectorOnTop="true"
|
||||||
android:prompt="@string/account_setup_basics_email_hint"
|
android:prompt="@string/account_setup_basics_email_hint"
|
||||||
android:layout_below="@id/spinner_hostname"
|
android:layout_below="@id/spinner_protocol"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
8
res/layout/account_setup_confirm_spinners_item.xml
Normal file
8
res/layout/account_setup_confirm_spinners_item.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:textSize="16sp" >
|
||||||
|
</TextView>
|
@ -10,16 +10,21 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo;
|
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 java.util.List;
|
||||||
|
|
||||||
public class AccountSetupConfirmIncoming extends K9Activity implements View.OnClickListener {
|
public class AccountSetupConfirmIncoming extends K9Activity implements View.OnClickListener, OnItemSelectedListener {
|
||||||
|
|
||||||
private static final String EXTRA_ACCOUNT = "account";
|
private static final String EXTRA_ACCOUNT = "account";
|
||||||
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
private static final String EXTRA_CONFIG_INFO = "configInfo";
|
||||||
@ -48,7 +53,7 @@ public class AccountSetupConfirmIncoming extends K9Activity implements View.OnCl
|
|||||||
|
|
||||||
// gui elements
|
// gui elements
|
||||||
Spinner mProtocolSpinner;
|
Spinner mProtocolSpinner;
|
||||||
Spinner mHostnameSpinner;
|
Spinner mSocketTypeSpinner;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstance){
|
public void onCreate(Bundle savedInstance){
|
||||||
@ -56,7 +61,7 @@ public class AccountSetupConfirmIncoming extends K9Activity implements View.OnCl
|
|||||||
setContentView(R.layout.account_setup_confirm);
|
setContentView(R.layout.account_setup_confirm);
|
||||||
|
|
||||||
// initialise gui elements from inflated layout
|
// initialise gui elements from inflated layout
|
||||||
mHostnameSpinner = (Spinner) findViewById(R.id.spinner_hostname);
|
mSocketTypeSpinner = (Spinner) findViewById(R.id.spinner_sockettype);
|
||||||
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
mProtocolSpinner = (Spinner) findViewById(R.id.spinner_protocol);
|
||||||
|
|
||||||
// get the data out of our intent
|
// get the data out of our intent
|
||||||
@ -70,13 +75,19 @@ public class AccountSetupConfirmIncoming extends K9Activity implements View.OnCl
|
|||||||
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
mConfigInfo = getIntent().getParcelableExtra(EXTRA_CONFIG_INFO);
|
||||||
|
|
||||||
// attach data to gui elements
|
// attach data to gui elements
|
||||||
// TODO: could make it's own layout xml..
|
ArrayAdapter<ServerType> protocolAdapter = new ArrayAdapter<ServerType>(this,
|
||||||
ArrayAdapter<ServerType> protocolAdapter =
|
R.layout.account_setup_confirm_spinners_item, mConfigInfo.getAvailableIncomingServerTypes());
|
||||||
new ArrayAdapter<ServerType>(this, R.layout.account_setup_index_list_item, mConfigInfo.getAvailableIncomingServerTypes());
|
mProtocolSpinner.setAdapter(protocolAdapter);
|
||||||
mHostnameSpinner.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
|
// attach the listeners
|
||||||
|
mProtocolSpinner.setOnItemSelectedListener(this);
|
||||||
|
mSocketTypeSpinner.setOnItemSelectedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,4 +95,24 @@ public class AccountSetupConfirmIncoming extends K9Activity implements View.OnCl
|
|||||||
//To change body of implemented methods use File | Settings | File Templates.
|
//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:
|
||||||
|
// 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) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user