Styled up producteev login activity. Next need to hook up to actual api calls

pull/14/head
Tim Su 16 years ago
parent 01c6874c69
commit 6784b38cb1

@ -314,7 +314,11 @@
</intent-filter>
</activity>
<activity android:name="com.todoroo.astrid.producteev.ProducteevLoginActivity"
android:theme="@style/Theme" />
android:theme="@style/Theme">
<intent-filter> <!-- temporary -->
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<service android:name="com.todoroo.astrid.producteev.ProducteevBackgroundService"/>
<!-- rmilk -->

@ -20,13 +20,15 @@
package com.todoroo.astrid.producteev;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
@ -34,9 +36,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DialogUtilities;
/**
* This activity displays a <code>WebView</code> that allows users to log in to
* the synchronization provider requested. A callback method determines whether
* their login was successful and therefore whether to dismiss the dialog.
* This activity allows users to sign in or log in to Producteev
*
* @author arne.jans
*
@ -46,26 +46,6 @@ public class ProducteevLoginActivity extends Activity {
@Autowired
DialogUtilities dialogUtilities;
// --- callback
/** Callback interface */
public interface SyncLoginCallback {
/**
* Verifies whether the user's login attempt was successful. Will be
* called off of the UI thread, use the handler to post messages.
*
* @return error string, or null if sync was successful
*/
public String verifyLogin(Handler handler, String email, String password);
}
protected static SyncLoginCallback callback = null;
/** Sets callback method */
public static void setCallback(SyncLoginCallback newCallback) {
callback = newCallback;
}
// --- ui initialization
public ProducteevLoginActivity() {
@ -77,69 +57,56 @@ public class ProducteevLoginActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.producteev_login_activity);
setTitle(R.string.producteev_PLA_title);
// terms clicking
findViewById(R.id.terms).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.producteev.com/#terms"))); //$NON-NLS-1$
}
});
final EditText emailEditText = (EditText) findViewById(R.id.Poducteev_EMail_EditText);
final EditText passwordEditText = (EditText) findViewById(R.id.Producteev_Password_EditText);
Button cancel = (Button) findViewById(R.id.cancel);
Button login = (Button) findViewById(R.id.done);
final TextView errors = (TextView) findViewById(R.id.error);
final EditText emailEditText = (EditText) findViewById(R.id.email);
final EditText passwordEditText = (EditText) findViewById(R.id.password);
final View newUserLayout = findViewById(R.id.newUserLayout);
login.setOnClickListener(new OnClickListener() {
Button signIn = (Button) findViewById(R.id.signIn);
signIn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final Handler handler = new Handler();
if (callback == null) {
finish();
return;
}
final String email = emailEditText.getText().toString();
final String password = passwordEditText.getText().toString();
if (email == null || email.length() == 0) {
// no email given
Toast.makeText(ProducteevLoginActivity.this,
R.string.producteev_MLA_email_empty,
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED);
finish();
return;
}
if (password == null || password.length() == 0) {
// no password given
Toast.makeText(ProducteevLoginActivity.this,
R.string.producteev_MLA_password_empty,
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED);
finish();
return;
}
new Thread(new Runnable() {
public void run() {
final String result = callback.verifyLogin(handler,
email, password);
if (result == null) {
finish();
} else {
// display the error
handler.post(new Runnable() {
public void run() {
dialogUtilities.okDialog(
ProducteevLoginActivity.this,
result, null);
}
});
}
errors.setVisibility(View.GONE);
if(newUserLayout.getVisibility() == View.VISIBLE)
newUserLayout.setVisibility(View.GONE);
else {
Editable email = emailEditText.getText();
Editable password = passwordEditText.getText();
if(email.length() == 0 || password.length() == 0) {
errors.setVisibility(View.VISIBLE);
errors.setText(R.string.producteev_PLA_errorEmpty);
}
}).start();
}
}
});
cancel.setOnClickListener(new OnClickListener() {
Button createNew = (Button) findViewById(R.id.createNew);
createNew.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_CANCELED);
finish();
errors.setVisibility(View.GONE);
if(newUserLayout.getVisibility() != View.VISIBLE)
newUserLayout.setVisibility(View.VISIBLE);
else {
Editable email = emailEditText.getText();
Editable password = passwordEditText.getText();
if(email.length() == 0 || password.length() == 0) {
errors.setVisibility(View.VISIBLE);
errors.setText(R.string.producteev_PLA_errorEmpty);
}
//
}
}
});
}
}

@ -17,7 +17,6 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils;
import com.flurry.android.FlurryAgent;
@ -35,16 +34,13 @@ import com.todoroo.astrid.api.TaskContainer;
import com.todoroo.astrid.common.SyncProvider;
import com.todoroo.astrid.model.Metadata;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.producteev.ProducteevBackgroundService;
import com.todoroo.astrid.producteev.ProducteevLoginActivity;
import com.todoroo.astrid.producteev.ProducteevLoginActivity.SyncLoginCallback;
import com.todoroo.astrid.producteev.ProducteevPreferences;
import com.todoroo.astrid.producteev.ProducteevUtilities;
import com.todoroo.astrid.producteev.api.ApiResponseParseException;
import com.todoroo.astrid.producteev.api.ApiServiceException;
import com.todoroo.astrid.producteev.api.ApiUtilities;
import com.todoroo.astrid.producteev.api.ProducteevInvoker;
import com.todoroo.astrid.rmilk.api.ServiceInternalException;
import com.todoroo.astrid.rmilk.data.MilkNote;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.tags.TagService;
@ -166,23 +162,6 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
// display login-activity
final Context context = ContextManager.getContext();
Intent intent = new Intent(context, ProducteevLoginActivity.class);
ProducteevLoginActivity.setCallback(new SyncLoginCallback() {
public String verifyLogin(final Handler syncLoginHandler, String em, String pass) {
try {
Preferences.setString(R.string.producteev_PPr_email, em);
Preferences.setString(R.string.producteev_PPr_password, pass);
context.startService(new Intent(ProducteevBackgroundService.SYNC_ACTION, null,
context, ProducteevBackgroundService.class));
return null;
} catch (Exception e) {
// didn't work
exceptionService.reportError("producteev-verify-login", e);
if(e instanceof ServiceInternalException)
e = ((ServiceInternalException)e).getEnclosedException();
return context.getString(R.string.producteev_ioerror, e.getMessage());
}
}
});
if(context instanceof Activity)
((Activity)context).startActivityForResult(intent, 0);
else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -1,32 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/pdv_body">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/TextAppearance.GEN_EditLabel"
android:text="@string/producteev_PPr_header" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:scaleType="fitCenter"
android:src="@drawable/pdv_logo" />
<LinearLayout android:orientation="horizontal"
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="10dip"
android:textSize="16sp"
android:textColor="#ffffff"
android:text="@string/producteev_PLA_body" />
<TextView android:id="@+id/error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="20dip"
android:textColor="#ff0000"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="gone" />
<EditText android:id="@+id/email"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/producteev_PLA_email"
android:contentDescription="E-Mail with which you registered to Producteev-service"
android:inputType="textEmailAddress"/>
<EditText android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="Password for your Producteev account"
android:hint="@string/producteev_PLA_password"
android:inputType="textPassword"/>
<LinearLayout android:id="@+id/newUserLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingTop="5dip" android:baselineAligned="false">
android:orientation="vertical"
android:paddingTop="20dip"
android:visibility="gone">
<EditText android:id="@+id/confirmPassword"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/producteev_PLA_confirmPassword"
android:inputType="textPassword"/>
<EditText android:id="@+id/firstName"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/producteev_PLA_firstName"
android:inputType="textPersonName"/>
<EditText android:id="@+id/lastName"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/producteev_PLA_lastName"
android:inputType="textPersonName"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dip"
android:baselineAligned="false">
<Button android:id="@+id/done" android:layout_width="fill_parent"
<Button android:id="@+id/signIn" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="@string/DLG_done" />
android:text="@string/producteev_PLA_signIn" />
<Button android:id="@+id/cancel" android:layout_width="fill_parent"
<Button android:id="@+id/createNew" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="@android:string/cancel" />
android:text="@string/producteev_PLA_createNew" />
</LinearLayout>
<EditText android:layout_height="wrap_content"
android:layout_width="fill_parent" android:hint="E-Mail"
android:contentDescription="E-Mail with which you registered to Producteev-service"
android:id="@+id/Poducteev_EMail_EditText" android:inputType="textEmailAddress"></EditText>
<EditText android:layout_height="wrap_content"
android:id="@+id/Producteev_Password_EditText"
android:contentDescription="Password for your Producteev account"
android:hint="Password" android:layout_width="fill_parent"
android:inputType="textPassword"></EditText>
<TextView android:id="@+id/terms"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dip"
android:textSize="16sp"
android:textColor="#0000ff"
android:linksClickable="true"
android:text="@string/producteev_PLA_terms" />
</LinearLayout>

@ -12,6 +12,45 @@
<!-- Preferences Title: Producteev -->
<string name="producteev_PPr_header">Producteev</string>
<!-- ================================================= Login Activity == -->
<!-- Activity Title: Producteev Login -->
<string name="producteev_PLA_title">Log In to Producteev</string>
<!-- Instructions: Producteev login -->
<string name="producteev_PLA_body">Sign in with your existing
Producteev account, or create a new account!</string>
<!-- Producteev Terms Link -->
<string name="producteev_PLA_terms">Terms &amp; Conditions</string>
<!-- Sign In Button -->
<string name="producteev_PLA_signIn">Sign In</string>
<!-- Create New User Button -->
<string name="producteev_PLA_createNew">Create New User</string>
<!-- E-mail Address Label -->
<string name="producteev_PLA_email">E-mail</string>
<!-- Password Label -->
<string name="producteev_PLA_password">Password</string>
<!-- Confirm Password Label -->
<string name="producteev_PLA_confirmPassword">Confirm Password</string>
<!-- First Name Label -->
<string name="producteev_PLA_firstName">First Name</string>
<!-- Last Name Label -->
<string name="producteev_PLA_lastName">Last Name</string>
<!-- Error Message when fields aren't filled out -->
<string name="producteev_PLA_errorEmpty">Error: fill out all fields!</string>
<!-- Error Message when passwords don't match -->
<string name="producteev_PLA_errorMatch">Error: passwords don\'t match!</string>
<!-- ================================================ Synchronization == -->
<!-- title for notification tray when synchronizing -->

Loading…
Cancel
Save