mirror of
https://github.com/etesync/android
synced 2025-05-30 12:49:06 +00:00
Optimize soft keyboard handling, make resource detection dialog not cancelable
This commit is contained in:
parent
2414b42867
commit
0f0acd62a3
@ -17,8 +17,8 @@ android {
|
|||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
|
|
||||||
versionCode 83
|
versionCode 84
|
||||||
versionName "0.9.1-beta1"
|
versionName "0.9.1"
|
||||||
|
|
||||||
buildConfigField "java.util.Date", "buildTime", "new java.util.Date()"
|
buildConfigField "java.util.Date", "buildTime", "new java.util.Date()"
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.setup.AddAccountActivity"
|
android:name=".ui.setup.AddAccountActivity"
|
||||||
android:excludeFromRecents="true" >
|
android:excludeFromRecents="true">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.settings.SettingsActivity"
|
android:name=".ui.settings.SettingsActivity"
|
||||||
|
@ -9,6 +9,7 @@ package at.bitfire.davdroid.ui.setup;
|
|||||||
|
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
@ -18,6 +19,7 @@ import android.view.MenuInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -28,90 +30,101 @@ import at.bitfire.davdroid.R;
|
|||||||
import at.bitfire.davdroid.resource.ServerInfo;
|
import at.bitfire.davdroid.resource.ServerInfo;
|
||||||
|
|
||||||
public class LoginEmailFragment extends Fragment implements TextWatcher {
|
public class LoginEmailFragment extends Fragment implements TextWatcher {
|
||||||
|
|
||||||
protected EditText editEmail, editPassword;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
protected EditText editEmail, editPassword;
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View v = inflater.inflate(R.layout.setup_login_email, container, false);
|
|
||||||
|
|
||||||
editEmail = (EditText)v.findViewById(R.id.email_address);
|
|
||||||
editEmail.addTextChangedListener(this);
|
|
||||||
editPassword = (EditText)v.findViewById(R.id.password);
|
|
||||||
editPassword.addTextChangedListener(this);
|
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
inflater.inflate(R.menu.only_next, menu);
|
View v = inflater.inflate(R.layout.setup_login_email, container, false);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.next:
|
|
||||||
try {
|
|
||||||
String email = editEmail.getText().toString();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putSerializable(QueryServerDialogFragment.KEY_SERVER_INFO, new ServerInfo(
|
|
||||||
new URI("mailto:" + email),
|
|
||||||
email,
|
|
||||||
editPassword.getText().toString(),
|
|
||||||
true
|
|
||||||
));
|
|
||||||
|
|
||||||
DialogFragment dialog = new QueryServerDialogFragment();
|
editEmail = (EditText)v.findViewById(R.id.email_address);
|
||||||
dialog.setArguments(args);
|
editEmail.addTextChangedListener(this);
|
||||||
dialog.show(getFragmentManager(), QueryServerDialogFragment.class.getName());
|
|
||||||
} catch(URISyntaxException e) {
|
editPassword = (EditText)v.findViewById(R.id.password);
|
||||||
Constants.log.debug("Invalid email address", e);
|
editPassword.addTextChangedListener(this);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.only_next, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.next:
|
||||||
|
try {
|
||||||
|
String email = editEmail.getText().toString();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(QueryServerDialogFragment.KEY_SERVER_INFO, new ServerInfo(
|
||||||
|
new URI("mailto:" + email),
|
||||||
|
email,
|
||||||
|
editPassword.getText().toString(),
|
||||||
|
true
|
||||||
|
));
|
||||||
|
|
||||||
|
DialogFragment dialog = new QueryServerDialogFragment();
|
||||||
|
dialog.setArguments(args);
|
||||||
|
dialog.show(getFragmentManager(), QueryServerDialogFragment.class.getName());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
Constants.log.debug("Invalid email address", e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// set focus and show soft keyboard
|
||||||
|
if (editEmail.requestFocus()) {
|
||||||
|
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(editEmail, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// input validation
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
boolean emailOk = false,
|
||||||
|
passwordOk = editPassword.getText().length() > 0;
|
||||||
|
|
||||||
|
String email = editEmail.getText().toString();
|
||||||
|
try {
|
||||||
|
URI uri = new URI("mailto:" + email);
|
||||||
|
if (uri.isOpaque()) {
|
||||||
|
int pos = email.lastIndexOf("@");
|
||||||
|
if (pos != -1)
|
||||||
|
emailOk = !email.substring(pos + 1).isEmpty();
|
||||||
}
|
}
|
||||||
break;
|
} catch (URISyntaxException e) {
|
||||||
default:
|
// invalid mailto: URI
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
MenuItem item = menu.findItem(R.id.next);
|
||||||
// input validation
|
item.setEnabled(emailOk && passwordOk);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
|
||||||
boolean emailOk = false,
|
|
||||||
passwordOk = editPassword.getText().length() > 0;
|
|
||||||
|
|
||||||
String email = editEmail.getText().toString();
|
@Override
|
||||||
try {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
URI uri = new URI("mailto:" + email);
|
}
|
||||||
if (uri.isOpaque()) {
|
|
||||||
int pos = email.lastIndexOf("@");
|
|
||||||
if (pos != -1)
|
|
||||||
emailOk = !email.substring(pos+1).isEmpty();
|
|
||||||
}
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
// invalid mailto: URI
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem item = menu.findItem(R.id.next);
|
|
||||||
item.setEnabled(emailOk && passwordOk);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ package at.bitfire.davdroid.ui.setup;
|
|||||||
|
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -19,6 +20,7 @@ import android.view.MenuInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
@ -34,120 +36,130 @@ import at.bitfire.davdroid.R;
|
|||||||
import at.bitfire.davdroid.resource.ServerInfo;
|
import at.bitfire.davdroid.resource.ServerInfo;
|
||||||
|
|
||||||
public class LoginURLFragment extends Fragment implements TextWatcher {
|
public class LoginURLFragment extends Fragment implements TextWatcher {
|
||||||
|
|
||||||
protected Spinner spnrScheme;
|
protected Spinner spnrScheme;
|
||||||
protected TextView textHttpWarning;
|
protected TextView textHttpWarning;
|
||||||
protected EditText editBaseURI, editUserName, editPassword;
|
protected EditText editBaseURI, editUserName, editPassword;
|
||||||
protected CheckBox checkboxPreemptive;
|
protected CheckBox checkboxPreemptive;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.setup_login_url, container, false);
|
View v = inflater.inflate(R.layout.setup_login_url, container, false);
|
||||||
|
|
||||||
// protocol selection spinner
|
|
||||||
textHttpWarning = (TextView)v.findViewById(R.id.http_warning);
|
|
||||||
|
|
||||||
spnrScheme = (Spinner)v.findViewById(R.id.login_scheme);
|
|
||||||
spnrScheme.setOnItemSelectedListener(new OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
String scheme = parent.getAdapter().getItem(position).toString();
|
|
||||||
textHttpWarning.setVisibility(scheme.equals("https://") ? View.GONE : View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// protocol selection spinner
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
textHttpWarning = (TextView)v.findViewById(R.id.http_warning);
|
||||||
}
|
|
||||||
});
|
|
||||||
spnrScheme.setSelection(1); // HTTPS
|
|
||||||
|
|
||||||
// other input fields
|
spnrScheme = (Spinner)v.findViewById(R.id.login_scheme);
|
||||||
editBaseURI = (EditText)v.findViewById(R.id.login_host_path);
|
spnrScheme.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
editBaseURI.addTextChangedListener(this);
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
editUserName = (EditText)v.findViewById(R.id.userName);
|
String scheme = parent.getAdapter().getItem(position).toString();
|
||||||
editUserName.addTextChangedListener(this);
|
textHttpWarning.setVisibility(scheme.equals("https://") ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
editPassword = (EditText)v.findViewById(R.id.password);
|
|
||||||
editPassword.addTextChangedListener(this);
|
|
||||||
|
|
||||||
checkboxPreemptive = (CheckBox) v.findViewById(R.id.auth_preemptive);
|
|
||||||
|
|
||||||
// hook into action bar
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
inflater.inflate(R.menu.only_next, menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.next:
|
|
||||||
try {
|
|
||||||
ServerInfo serverInfo = new ServerInfo(
|
|
||||||
getBaseURI(),
|
|
||||||
editUserName.getText().toString(),
|
|
||||||
editPassword.getText().toString(),
|
|
||||||
checkboxPreemptive.isChecked()
|
|
||||||
);
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putSerializable(QueryServerDialogFragment.KEY_SERVER_INFO, serverInfo);
|
|
||||||
DialogFragment dialog = new QueryServerDialogFragment();
|
|
||||||
dialog.setArguments(args);
|
|
||||||
dialog.show(getFragmentManager(), null);
|
|
||||||
} catch(URISyntaxException e) {
|
|
||||||
Constants.log.debug("Invalid URI", e);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private URI getBaseURI() throws URISyntaxException {
|
|
||||||
String scheme = spnrScheme.getSelectedItem().toString(),
|
|
||||||
host_path = editBaseURI.getText().toString();
|
|
||||||
return new URI(scheme + host_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
// input validation
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
}
|
||||||
@Override
|
});
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
spnrScheme.setSelection(1); // HTTPS
|
||||||
boolean usernameOk = editUserName.getText().length() > 0,
|
|
||||||
passwordOk = editPassword.getText().length() > 0,
|
|
||||||
urlOk = false;
|
|
||||||
|
|
||||||
// check host name
|
|
||||||
try {
|
|
||||||
if (!TextUtils.isEmpty(getBaseURI().getHost()))
|
|
||||||
urlOk = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem item = menu.findItem(R.id.next);
|
|
||||||
item.setEnabled(usernameOk && passwordOk && urlOk);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// other input fields
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
editBaseURI = (EditText)v.findViewById(R.id.login_host_path);
|
||||||
}
|
editBaseURI.addTextChangedListener(this);
|
||||||
|
|
||||||
@Override
|
editUserName = (EditText)v.findViewById(R.id.userName);
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
editUserName.addTextChangedListener(this);
|
||||||
getActivity().invalidateOptionsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
editPassword = (EditText)v.findViewById(R.id.password);
|
||||||
public void afterTextChanged(Editable s) {
|
editPassword.addTextChangedListener(this);
|
||||||
}
|
|
||||||
|
checkboxPreemptive = (CheckBox)v.findViewById(R.id.auth_preemptive);
|
||||||
|
|
||||||
|
// hook into action bar
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.only_next, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.next:
|
||||||
|
try {
|
||||||
|
ServerInfo serverInfo = new ServerInfo(
|
||||||
|
getBaseURI(),
|
||||||
|
editUserName.getText().toString(),
|
||||||
|
editPassword.getText().toString(),
|
||||||
|
checkboxPreemptive.isChecked()
|
||||||
|
);
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putSerializable(QueryServerDialogFragment.KEY_SERVER_INFO, serverInfo);
|
||||||
|
DialogFragment dialog = new QueryServerDialogFragment();
|
||||||
|
dialog.setArguments(args);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
Constants.log.debug("Invalid URI", e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// set focus and show soft keyboard
|
||||||
|
if (editBaseURI.requestFocus()) {
|
||||||
|
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(editBaseURI, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private URI getBaseURI() throws URISyntaxException {
|
||||||
|
String scheme = spnrScheme.getSelectedItem().toString(),
|
||||||
|
host_path = editBaseURI.getText().toString();
|
||||||
|
return new URI(scheme + host_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// input validation
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
boolean usernameOk = editUserName.getText().length() > 0,
|
||||||
|
passwordOk = editPassword.getText().length() > 0,
|
||||||
|
urlOk = false;
|
||||||
|
|
||||||
|
// check host name
|
||||||
|
try {
|
||||||
|
if (!TextUtils.isEmpty(getBaseURI().getHost()))
|
||||||
|
urlOk = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem item = menu.findItem(R.id.next);
|
||||||
|
item.setEnabled(usernameOk && passwordOk && urlOk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -48,29 +50,30 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
ProgressDialog dialog = new ProgressDialog(getActivity());
|
ProgressDialog dialog = new ProgressDialog(getActivity());
|
||||||
dialog.setCancelable(false);
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
|
setCancelable(false);
|
||||||
|
|
||||||
dialog.setTitle(R.string.setup_resource_detection);
|
dialog.setTitle(R.string.setup_resource_detection);
|
||||||
dialog.setIndeterminate(true);
|
dialog.setIndeterminate(true);
|
||||||
dialog.setMessage(getString(R.string.setup_querying_server));
|
dialog.setMessage(getString(R.string.setup_querying_server));
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
@Override
|
Loader<ServerInfo> loader = getLoaderManager().initLoader(0, getArguments(), this);
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
}
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
Loader<ServerInfo> loader = getLoaderManager().initLoader(0, getArguments(), this);
|
@Override
|
||||||
}
|
public Loader<ServerInfo> onCreateLoader(int id, Bundle args) {
|
||||||
|
return new ServerInfoLoader(getActivity(), args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<ServerInfo> onCreateLoader(int id, Bundle args) {
|
|
||||||
return new ServerInfoLoader(getActivity(), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressLint("CommitTransaction")
|
@SuppressLint("CommitTransaction")
|
||||||
public void onLoadFinished(Loader<ServerInfo> loader, ServerInfo serverInfo) {
|
public void onLoadFinished(Loader<ServerInfo> loader, ServerInfo serverInfo) {
|
||||||
if (serverInfo.isEmpty()) {
|
if (serverInfo.isEmpty()) {
|
||||||
// resource detection didn't find anything
|
// resource detection didn't find anything
|
||||||
getFragmentManager().beginTransaction()
|
getFragmentManager().beginTransaction()
|
||||||
@ -78,7 +81,7 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
.commitAllowingStateLoss();
|
.commitAllowingStateLoss();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
((AddAccountActivity) getActivity()).serverInfo = serverInfo;
|
((AddAccountActivity)getActivity()).serverInfo = serverInfo;
|
||||||
|
|
||||||
// resource detection brought some results
|
// resource detection brought some results
|
||||||
Fragment nextFragment;
|
Fragment nextFragment;
|
||||||
@ -93,12 +96,12 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
.commitAllowingStateLoss();
|
.commitAllowingStateLoss();
|
||||||
}
|
}
|
||||||
|
|
||||||
getDialog().dismiss();
|
getDialog().dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoaderReset(Loader<ServerInfo> arg0) {
|
public void onLoaderReset(Loader<ServerInfo> arg0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class NothingDetectedFragment extends DialogFragment {
|
public static class NothingDetectedFragment extends DialogFragment {
|
||||||
@ -135,17 +138,17 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ServerInfoLoader extends AsyncTaskLoader<ServerInfo> {
|
static class ServerInfoLoader extends AsyncTaskLoader<ServerInfo> {
|
||||||
private static final String TAG = "davdroid.ServerInfoLoader";
|
private static final String TAG = "davdroid.ServerInfoLoader";
|
||||||
final Bundle args;
|
final Bundle args;
|
||||||
final Context context;
|
final Context context;
|
||||||
|
|
||||||
public ServerInfoLoader(Context context, Bundle args) {
|
public ServerInfoLoader(Context context, Bundle args) {
|
||||||
super(context);
|
super(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStartLoading() {
|
protected void onStartLoading() {
|
||||||
@ -153,8 +156,8 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerInfo loadInBackground() {
|
public ServerInfo loadInBackground() {
|
||||||
ServerInfo serverInfo = (ServerInfo)args.getSerializable(KEY_SERVER_INFO);
|
ServerInfo serverInfo = (ServerInfo)args.getSerializable(KEY_SERVER_INFO);
|
||||||
|
|
||||||
StringLogger logger = new StringLogger("DavResourceFinder", true);
|
StringLogger logger = new StringLogger("DavResourceFinder", true);
|
||||||
DavResourceFinder finder = new DavResourceFinder(logger, context, serverInfo);
|
DavResourceFinder finder = new DavResourceFinder(logger, context, serverInfo);
|
||||||
@ -174,8 +177,8 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
|||||||
|
|
||||||
serverInfo.setLogs(logger.toString());
|
serverInfo.setLogs(logger.toString());
|
||||||
|
|
||||||
return serverInfo;
|
return serverInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,101 +25,101 @@ import at.bitfire.davdroid.resource.ServerInfo;
|
|||||||
|
|
||||||
public class SelectCollectionsFragment extends ListFragment {
|
public class SelectCollectionsFragment extends ListFragment {
|
||||||
|
|
||||||
protected ServerInfo serverInfo;
|
protected ServerInfo serverInfo;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
serverInfo = ((AddAccountActivity)getActivity()).serverInfo;
|
serverInfo = ((AddAccountActivity)getActivity()).serverInfo;
|
||||||
|
|
||||||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
View v = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
setListAdapter(null);
|
setListAdapter(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
final ListView listView = getListView();
|
|
||||||
listView.setPadding(20, 30, 20, 30);
|
|
||||||
|
|
||||||
View header = getActivity().getLayoutInflater().inflate(R.layout.setup_select_collections_header, getListView(), false);
|
|
||||||
listView.addHeaderView(header, getListView(), false);
|
|
||||||
|
|
||||||
final SelectCollectionsAdapter adapter = new SelectCollectionsAdapter(view.getContext(), serverInfo);
|
final ListView listView = getListView();
|
||||||
setListAdapter(adapter);
|
listView.setPadding(20, 30, 20, 30);
|
||||||
|
|
||||||
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
View header = getActivity().getLayoutInflater().inflate(R.layout.setup_select_collections_header, getListView(), false);
|
||||||
listView.setOnItemClickListener(new OnItemClickListener() {
|
listView.addHeaderView(header, getListView(), false);
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
final SelectCollectionsAdapter adapter = new SelectCollectionsAdapter(view.getContext(), serverInfo);
|
||||||
int itemPosition = position - 1; // one list header view at pos. 0
|
setListAdapter(adapter);
|
||||||
if (adapter.getItemViewType(itemPosition) == SelectCollectionsAdapter.TYPE_ADDRESS_BOOKS_ROW) {
|
|
||||||
// unselect all other address books
|
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||||
for (int pos = 1; pos <= adapter.getNAddressBooks(); pos++)
|
listView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
if (pos != itemPosition)
|
@Override
|
||||||
listView.setItemChecked(pos + 1, false);
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
}
|
int itemPosition = position - 1; // one list header view at pos. 0
|
||||||
|
if (adapter.getItemViewType(itemPosition) == SelectCollectionsAdapter.TYPE_ADDRESS_BOOKS_ROW) {
|
||||||
getActivity().invalidateOptionsMenu();
|
// unselect all other address books
|
||||||
}
|
for (int pos = 1; pos <= adapter.getNAddressBooks(); pos++)
|
||||||
});
|
if (pos != itemPosition)
|
||||||
}
|
listView.setItemChecked(pos + 1, false);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
getActivity().invalidateOptionsMenu();
|
||||||
inflater.inflate(R.menu.only_next, menu);
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
@Override
|
||||||
switch (item.getItemId()) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
case R.id.next:
|
inflater.inflate(R.menu.only_next, menu);
|
||||||
// synchronize only selected collections
|
}
|
||||||
for (ServerInfo.ResourceInfo addressBook : serverInfo.getAddressBooks())
|
|
||||||
addressBook.setEnabled(false);
|
@Override
|
||||||
for (ServerInfo.ResourceInfo calendar : serverInfo.getCalendars())
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
calendar.setEnabled(false);
|
switch (item.getItemId()) {
|
||||||
for (ServerInfo.ResourceInfo todoList : serverInfo.getTaskLists())
|
case R.id.next:
|
||||||
todoList.setEnabled(false);
|
// synchronize only selected collections
|
||||||
|
for (ServerInfo.ResourceInfo addressBook : serverInfo.getAddressBooks())
|
||||||
ListAdapter adapter = getListView().getAdapter();
|
addressBook.setEnabled(false);
|
||||||
for (long id : getListView().getCheckedItemIds()) {
|
for (ServerInfo.ResourceInfo calendar : serverInfo.getCalendars())
|
||||||
int position = (int)id + 1; // +1 because header view is inserted at pos. 0
|
calendar.setEnabled(false);
|
||||||
ServerInfo.ResourceInfo info = (ServerInfo.ResourceInfo)adapter.getItem(position);
|
for (ServerInfo.ResourceInfo todoList : serverInfo.getTaskLists())
|
||||||
info.setEnabled(true);
|
todoList.setEnabled(false);
|
||||||
}
|
|
||||||
|
ListAdapter adapter = getListView().getAdapter();
|
||||||
getFragmentManager().beginTransaction()
|
for (long id : getListView().getCheckedItemIds()) {
|
||||||
.replace(R.id.right_pane, new AccountDetailsFragment())
|
int position = (int)id + 1; // +1 because header view is inserted at pos. 0
|
||||||
.addToBackStack(null)
|
ServerInfo.ResourceInfo info = (ServerInfo.ResourceInfo)adapter.getItem(position);
|
||||||
.commitAllowingStateLoss();
|
info.setEnabled(true);
|
||||||
break;
|
}
|
||||||
default:
|
|
||||||
return false;
|
getFragmentManager().beginTransaction()
|
||||||
}
|
.replace(R.id.right_pane, new AccountDetailsFragment())
|
||||||
return true;
|
.addToBackStack(null)
|
||||||
}
|
.commitAllowingStateLoss();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
// input validation
|
return false;
|
||||||
|
}
|
||||||
@Override
|
return true;
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
}
|
||||||
boolean ok = false;
|
|
||||||
try {
|
|
||||||
ok = getListView().getCheckedItemCount() > 0;
|
// input validation
|
||||||
} catch(IllegalStateException e) {
|
|
||||||
}
|
@Override
|
||||||
MenuItem item = menu.findItem(R.id.next);
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
item.setEnabled(ok);
|
boolean ok = false;
|
||||||
}
|
try {
|
||||||
|
ok = getListView().getCheckedItemCount() > 0;
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
}
|
||||||
|
MenuItem item = menu.findItem(R.id.next);
|
||||||
|
item.setEnabled(ok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
android:id="@+id/password"
|
android:id="@+id/password"
|
||||||
android:layout_gravity="fill_horizontal"
|
android:layout_gravity="fill_horizontal"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:imeOptions="actionGo"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:scrollbars="horizontal"
|
android:scrollbars="horizontal"
|
||||||
|
@ -64,7 +64,6 @@
|
|||||||
android:id="@+id/userName"
|
android:id="@+id/userName"
|
||||||
android:layout_gravity="fill_horizontal"
|
android:layout_gravity="fill_horizontal"
|
||||||
android:inputType="textNoSuggestions|textEmailAddress"
|
android:inputType="textNoSuggestions|textEmailAddress"
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:scrollbars="horizontal"
|
android:scrollbars="horizontal"
|
||||||
@ -78,7 +77,6 @@
|
|||||||
android:id="@+id/password"
|
android:id="@+id/password"
|
||||||
android:layout_gravity="fill_horizontal"
|
android:layout_gravity="fill_horizontal"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:imeOptions="actionGo"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:scrollbars="horizontal"
|
android:scrollbars="horizontal"
|
||||||
|
Loading…
Reference in New Issue
Block a user