mirror of https://github.com/tasks/tasks
Added Google OAuth as a login option in astrid.com login
parent
4569ca6bee
commit
2143ddb461
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* ASTRID: Android's Simple Task Recording Dashboard
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 Tim Su
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
package com.todoroo.astrid.actfm;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import com.timsu.astrid.R;
|
||||||
|
import com.todoroo.andlib.service.Autowired;
|
||||||
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||||
|
import com.todoroo.andlib.service.RestClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @author timsu
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OAuthLoginActivity extends Activity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL to display
|
||||||
|
*/
|
||||||
|
public static final String URL_TOKEN = "u"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resultant URL data
|
||||||
|
*/
|
||||||
|
public static final String DATA_RESPONSE = "response"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@Autowired RestClient restClient;
|
||||||
|
|
||||||
|
// --- ui initialization
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
DependencyInjectionService.getInstance().inject(this);
|
||||||
|
|
||||||
|
setContentView(R.layout.oauth_login_activity);
|
||||||
|
setTitle(R.string.actfm_ALA_login_title);
|
||||||
|
|
||||||
|
final String urlParam = getIntent().getStringExtra(URL_TOKEN);
|
||||||
|
|
||||||
|
final WebView webView = (WebView)findViewById(R.id.browser);
|
||||||
|
|
||||||
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
webView.getSettings().setSavePassword(false);
|
||||||
|
webView.getSettings().setSupportZoom(true);
|
||||||
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
super.onPageFinished(view, url);
|
||||||
|
System.err.println("page finished loading: " + url);
|
||||||
|
|
||||||
|
String data;
|
||||||
|
try {
|
||||||
|
data = restClient.get(url);
|
||||||
|
System.err.println("DATA: " + data);
|
||||||
|
|
||||||
|
if(data.startsWith("{")) { //$NON-NLS-1$
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(DATA_RESPONSE, data);
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e("astrid", "error-load-url", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
webView.loadUrl(urlParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 896 B |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
@ -0,0 +1,18 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/actfm_OLA_prompt"/>
|
||||||
|
|
||||||
|
<WebView android:id="@+id/browser"
|
||||||
|
android:layout_weight="100"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue