├── lib ├── signpost.jar └── signpost-commonshttp4-1.2.1.1.jar ├── libs └── android-support-v4.jar ├── res ├── drawable-hdpi │ ├── ic_list_2cloud.png │ ├── ic_menu_2cloud.png │ ├── ic_tab_2cloud.png │ ├── ic_dialog_2cloud.png │ └── ic_launcher_2cloud.png ├── drawable-ldpi │ ├── ic_list_2cloud.png │ ├── ic_menu_2cloud.png │ ├── ic_tab_2cloud.png │ ├── ic_dialog_2cloud.png │ └── ic_launcher_2cloud.png ├── drawable-mdpi │ ├── ic_list_2cloud.png │ ├── ic_menu_2cloud.png │ ├── ic_tab_2cloud.png │ ├── ic_dialog_2cloud.png │ └── ic_launcher_2cloud.png ├── values │ ├── arrays.xml │ └── strings.xml ├── menu │ └── post_link.xml ├── xml │ └── preferences.xml ├── layout │ ├── billing.xml │ ├── main.xml │ └── add_account.xml └── layout-land │ └── main.xml ├── .gitignore ├── default.properties ├── src └── com │ ├── suchagit │ └── android2cloud │ │ ├── util │ │ ├── CheckTimeRequest.java │ │ ├── PaymentNotificationResponse.java │ │ ├── Base64DecoderException.java │ │ ├── ErrorMethods.java │ │ ├── AddLinkResponse.java │ │ ├── CheckTimeResponse.java │ │ ├── PaymentNotificationRequest.java │ │ ├── AddLinkRequest.java │ │ ├── OAuth.java │ │ ├── OAuthAccount.java │ │ ├── HttpClient.java │ │ └── Security.java │ │ ├── errors │ │ ├── DefaultErrorDialogFragment.java │ │ ├── PostLinkNullLinkDialogFragment.java │ │ ├── IntentWithoutLinkDialogFragment.java │ │ ├── PostLinkNullReceiverDialogFragment.java │ │ ├── SelectLinkDialogFragment.java │ │ ├── BillingCannotConnectDialogFragment.java │ │ ├── OAuthActivityNullUriDialogFragment.java │ │ ├── BillingNotSupportedDialogFragment.java │ │ ├── OAuthWebviewNullIntentDialogFragment.java │ │ ├── NoAccountsDialogFragment.java │ │ ├── CorruptedAccountDialogFragment.java │ │ ├── NoAccountSelectedDialogFragment.java │ │ ├── DeprecatedHostExceptionDialogFragment.java │ │ ├── OverQuotaDialogFragment.java │ │ ├── IncorrectTimeDialogFragment.java │ │ ├── IllegalStateExceptionDialogFragment.java │ │ ├── IllegalArgumentExceptionDialogFragment.java │ │ ├── HttpClientErrorDialogFragment.java │ │ ├── UnsupportedEncodingExceptionDialogFragment.java │ │ ├── OAuthMessageSignerExceptionDialogFragment.java │ │ ├── OAuthNotAuthorizedExceptionDialogFragment.java │ │ ├── OAuthExpectationFailedExceptionDialogFragment.java │ │ ├── PostLinkAuthErrorDialogFragment.java │ │ └── OAuthCommunicationExceptionDialogFragment.java │ │ ├── OAuthWebView.java │ │ ├── Preferences.java │ │ ├── HttpService.java │ │ ├── Consts.java │ │ ├── BillingReceiver.java │ │ ├── ResponseHandler.java │ │ ├── PurchaseObserver.java │ │ ├── Billing.java │ │ ├── OAuthActivity.java │ │ ├── ErrorDialogBuilder.java │ │ ├── PostLinkActivity.java │ │ └── BillingService.java │ └── android │ └── vending │ └── billing │ └── IMarketBillingService.aidl ├── LICENSE.md ├── proguard.cfg ├── AndroidManifest.xml └── README.md /lib/signpost.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/lib/signpost.jar -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_list_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-hdpi/ic_list_2cloud.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_menu_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-hdpi/ic_menu_2cloud.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_tab_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-hdpi/ic_tab_2cloud.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_list_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-ldpi/ic_list_2cloud.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_menu_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-ldpi/ic_menu_2cloud.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_tab_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-ldpi/ic_tab_2cloud.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_list_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-mdpi/ic_list_2cloud.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_menu_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-mdpi/ic_menu_2cloud.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_tab_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-mdpi/ic_tab_2cloud.png -------------------------------------------------------------------------------- /lib/signpost-commonshttp4-1.2.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/lib/signpost-commonshttp4-1.2.1.1.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_dialog_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-hdpi/ic_dialog_2cloud.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_dialog_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-ldpi/ic_dialog_2cloud.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_dialog_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-mdpi/ic_dialog_2cloud.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-hdpi/ic_launcher_2cloud.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_launcher_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-ldpi/ic_launcher_2cloud.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher_2cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2cloud/android2cloud/HEAD/res/drawable-mdpi/ic_launcher_2cloud.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.DS_Store 3 | *.class 4 | *.swp 5 | *java# 6 | *.classpath 7 | *.project 8 | *.settings 9 | bin/ 10 | gen/ 11 | private.txt 12 | -------------------------------------------------------------------------------- /res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /res/menu/post_link.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-8 12 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/CheckTimeRequest.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | import org.apache.http.client.methods.HttpGet; 6 | import org.apache.http.params.CoreProtocolPNames; 7 | 8 | public class CheckTimeRequest extends HttpGet { 9 | 10 | public CheckTimeRequest(String host) throws UnsupportedEncodingException { 11 | super(host+"util/time"); 12 | this.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/PaymentNotificationResponse.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.ResultReceiver; 6 | 7 | public class PaymentNotificationResponse extends ResultReceiver { 8 | private Receiver mReceiver; 9 | 10 | public PaymentNotificationResponse(Handler handler) { 11 | super(handler); 12 | } 13 | 14 | public void setReceiver(Receiver receiver) { 15 | mReceiver = receiver; 16 | } 17 | 18 | public interface Receiver { 19 | public void onReceiveResult(int resultCode, Bundle resultData); 20 | } 21 | 22 | @Override 23 | protected void onReceiveResult(int resultCode, Bundle resultData) { 24 | if(mReceiver != null) { 25 | mReceiver.onReceiveResult(resultCode, resultData); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/android/vending/billing/IMarketBillingService.aidl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.vending.billing; 18 | 19 | import android.os.Bundle; 20 | 21 | interface IMarketBillingService { 22 | /** Given the arguments in bundle form, returns a bundle for results. */ 23 | Bundle sendBillingRequest(in Bundle bundle); 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Second Bit LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/Base64DecoderException.java: -------------------------------------------------------------------------------- 1 | // Copyright 2002, Google, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.suchagit.android2cloud.util; 16 | 17 | /** 18 | * Exception thrown when encountering an invalid Base64 input character. 19 | * 20 | * @author nelson 21 | */ 22 | public class Base64DecoderException extends Exception { 23 | public Base64DecoderException() { 24 | super(); 25 | } 26 | 27 | public Base64DecoderException(String s) { 28 | super(s); 29 | } 30 | 31 | private static final long serialVersionUID = 1L; 32 | } 33 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/ErrorMethods.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import android.content.Intent; 4 | import android.content.pm.PackageManager.NameNotFoundException; 5 | import android.support.v4.app.Fragment; 6 | 7 | public class ErrorMethods { 8 | public static Intent getEmailIntent(Fragment context, String type, String message) { 9 | Intent i = new Intent(Intent.ACTION_SEND); 10 | i.setType("message/rfc822"); 11 | i.putExtra(Intent.EXTRA_EMAIL , new String[]{"android@2cloudproject.com"}); 12 | i.putExtra(Intent.EXTRA_SUBJECT, "In-App Error Report"); 13 | String message_prefix = "Error:\n"; 14 | message_prefix += "Type: "+type+"\n"; 15 | try { 16 | message_prefix += "Version: " + context.getActivity().getPackageManager().getPackageInfo(context.getActivity().getPackageName(), 0 ).versionCode + "\n"; 17 | } catch (NameNotFoundException e) { 18 | message_prefix += "\n"; 19 | } 20 | message_prefix += "Android Version: " + android.os.Build.VERSION.SDK + "\n"; 21 | message_prefix += "Phone: " + android.os.Build.MODEL + "\n"; 22 | message = message_prefix + message; 23 | i.putExtra(Intent.EXTRA_TEXT , message); 24 | return i; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembernames class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembernames class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers enum * { 30 | public static **[] values(); 31 | public static ** valueOf(java.lang.String); 32 | } 33 | 34 | -keep class * implements android.os.Parcelable { 35 | public static final android.os.Parcelable$Creator *; 36 | } 37 | -------------------------------------------------------------------------------- /res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 14 | 15 | 16 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/DefaultErrorDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.R; 4 | 5 | import android.app.AlertDialog; 6 | import android.app.Dialog; 7 | import android.content.DialogInterface; 8 | import android.os.Bundle; 9 | import android.support.v4.app.DialogFragment; 10 | 11 | public class DefaultErrorDialogFragment extends DialogFragment { 12 | 13 | public static DefaultErrorDialogFragment newInstance() { 14 | DefaultErrorDialogFragment frag = new DefaultErrorDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.default_error_message; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(true) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | } 33 | } 34 | ) 35 | .create(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/PostLinkNullLinkDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | 9 | import com.suchagit.android2cloud.R; 10 | 11 | public class PostLinkNullLinkDialogFragment extends DialogFragment { 12 | 13 | public static PostLinkNullLinkDialogFragment newInstance() { 14 | PostLinkNullLinkDialogFragment frag = new PostLinkNullLinkDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.postlink_null_link_error; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(true) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | } 33 | } 34 | ) 35 | .create(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/IntentWithoutLinkDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.R; 4 | 5 | import android.app.AlertDialog; 6 | import android.app.Dialog; 7 | import android.content.DialogInterface; 8 | import android.os.Bundle; 9 | import android.support.v4.app.DialogFragment; 10 | 11 | public class IntentWithoutLinkDialogFragment extends DialogFragment { 12 | 13 | public static IntentWithoutLinkDialogFragment newInstance() { 14 | IntentWithoutLinkDialogFragment frag = new IntentWithoutLinkDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.intent_without_link_error; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(true) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | } 33 | } 34 | ) 35 | .create(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/PostLinkNullReceiverDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | 9 | import com.suchagit.android2cloud.R; 10 | 11 | public class PostLinkNullReceiverDialogFragment extends DialogFragment { 12 | 13 | public static PostLinkNullReceiverDialogFragment newInstance() { 14 | PostLinkNullReceiverDialogFragment frag = new PostLinkNullReceiverDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.postlink_null_receiver_error; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(true) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | } 33 | } 34 | ) 35 | .create(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/SelectLinkDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | 9 | import com.suchagit.android2cloud.PostLinkActivity; 10 | import com.suchagit.android2cloud.R; 11 | 12 | public class SelectLinkDialogFragment extends DialogFragment { 13 | 14 | public static SelectLinkDialogFragment newInstance(Bundle args) { 15 | SelectLinkDialogFragment frag = new SelectLinkDialogFragment(); 16 | frag.setArguments(args); 17 | return frag; 18 | } 19 | 20 | @Override 21 | public Dialog onCreateDialog(Bundle savedInstanceState) { 22 | int title = R.string.select_link_title; 23 | final CharSequence[] choices = getArguments().getCharSequenceArray("choices"); 24 | 25 | return new AlertDialog.Builder(getActivity()) 26 | .setCancelable(false) 27 | .setTitle(title) 28 | .setItems(choices, new DialogInterface.OnClickListener() { 29 | public void onClick(DialogInterface dialog, int item) { 30 | ((PostLinkActivity) getActivity()).linkChosen((String) choices[item]); 31 | } 32 | } 33 | ) 34 | .create(); 35 | } 36 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/BillingCannotConnectDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.R; 4 | 5 | import android.app.AlertDialog; 6 | import android.app.Dialog; 7 | import android.content.DialogInterface; 8 | import android.os.Bundle; 9 | import android.support.v4.app.DialogFragment; 10 | 11 | public class BillingCannotConnectDialogFragment extends DialogFragment { 12 | 13 | public static BillingCannotConnectDialogFragment newInstance() { 14 | BillingCannotConnectDialogFragment frag = new BillingCannotConnectDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.cannot_connect_title; 21 | int body = R.string.cannot_connect_message; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(false) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | getActivity().finish(); 33 | } 34 | } 35 | ) 36 | .create(); 37 | } 38 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/OAuthActivityNullUriDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | 9 | import com.suchagit.android2cloud.R; 10 | 11 | public class OAuthActivityNullUriDialogFragment extends DialogFragment { 12 | 13 | public static OAuthActivityNullUriDialogFragment newInstance() { 14 | OAuthActivityNullUriDialogFragment frag = new OAuthActivityNullUriDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.oauthactivity_null_uri_error; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(false) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | getActivity().finish(); 33 | } 34 | } 35 | ) 36 | .create(); 37 | } 38 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/BillingNotSupportedDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.R; 4 | 5 | import android.app.AlertDialog; 6 | import android.app.Dialog; 7 | import android.content.DialogInterface; 8 | import android.os.Bundle; 9 | import android.support.v4.app.DialogFragment; 10 | 11 | public class BillingNotSupportedDialogFragment extends DialogFragment { 12 | 13 | public static BillingNotSupportedDialogFragment newInstance() { 14 | BillingNotSupportedDialogFragment frag = new BillingNotSupportedDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.billing_not_supported_title; 21 | int body = R.string.billing_not_supported_message; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(false) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | getActivity().finish(); 33 | } 34 | } 35 | ) 36 | .create(); 37 | } 38 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/OAuthWebviewNullIntentDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | 9 | import com.suchagit.android2cloud.R; 10 | 11 | public class OAuthWebviewNullIntentDialogFragment extends DialogFragment { 12 | 13 | public static OAuthWebviewNullIntentDialogFragment newInstance() { 14 | OAuthWebviewNullIntentDialogFragment frag = new OAuthWebviewNullIntentDialogFragment(); 15 | return frag; 16 | } 17 | 18 | @Override 19 | public Dialog onCreateDialog(Bundle savedInstanceState) { 20 | int title = R.string.default_error_title; 21 | int body = R.string.oauthwebview_null_intent_error; 22 | int yesButton = R.string.default_error_ok; 23 | 24 | return new AlertDialog.Builder(getActivity()) 25 | .setCancelable(false) 26 | .setTitle(title) 27 | .setMessage(body) 28 | .setPositiveButton(yesButton, 29 | new DialogInterface.OnClickListener() { 30 | public void onClick(DialogInterface dialog, int whichButton) { 31 | dialog.cancel(); 32 | getActivity().finish(); 33 | } 34 | } 35 | ) 36 | .create(); 37 | } 38 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/NoAccountsDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.OAuthActivity; 4 | import com.suchagit.android2cloud.R; 5 | 6 | import android.app.AlertDialog; 7 | import android.app.Dialog; 8 | import android.content.DialogInterface; 9 | import android.content.Intent; 10 | import android.os.Bundle; 11 | import android.support.v4.app.DialogFragment; 12 | 13 | public class NoAccountsDialogFragment extends DialogFragment { 14 | 15 | public static NoAccountsDialogFragment newInstance() { 16 | NoAccountsDialogFragment frag = new NoAccountsDialogFragment(); 17 | return frag; 18 | } 19 | 20 | @Override 21 | public Dialog onCreateDialog(Bundle savedInstanceState) { 22 | int title = R.string.default_error_title; 23 | int body = R.string.no_accounts_error; 24 | int yesButton = R.string.no_accounts_error_account_button; 25 | 26 | return new AlertDialog.Builder(getActivity()) 27 | .setCancelable(false) 28 | .setTitle(title) 29 | .setMessage(body) 30 | .setPositiveButton(yesButton, 31 | new DialogInterface.OnClickListener() { 32 | public void onClick(DialogInterface dialog, int whichButton) { 33 | Intent i = new Intent(getActivity(), OAuthActivity.class); 34 | getActivity().startActivityForResult(i, 0x1234); 35 | } 36 | } 37 | ) 38 | .create(); 39 | } 40 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/CorruptedAccountDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import com.suchagit.android2cloud.OAuthActivity; 4 | import com.suchagit.android2cloud.R; 5 | 6 | import android.app.AlertDialog; 7 | import android.app.Dialog; 8 | import android.content.DialogInterface; 9 | import android.content.Intent; 10 | import android.os.Bundle; 11 | import android.support.v4.app.DialogFragment; 12 | 13 | public class CorruptedAccountDialogFragment extends DialogFragment { 14 | 15 | public static CorruptedAccountDialogFragment newInstance() { 16 | CorruptedAccountDialogFragment frag = new CorruptedAccountDialogFragment(); 17 | return frag; 18 | } 19 | 20 | @Override 21 | public Dialog onCreateDialog(Bundle savedInstanceState) { 22 | int title = R.string.default_error_title; 23 | int body = R.string.corrupted_account_error; 24 | int yesButton = R.string.corrupted_account_error_account_button; 25 | 26 | return new AlertDialog.Builder(getActivity()) 27 | .setCancelable(false) 28 | .setTitle(title) 29 | .setMessage(body) 30 | .setPositiveButton(yesButton, 31 | new DialogInterface.OnClickListener() { 32 | public void onClick(DialogInterface dialog, int whichButton) { 33 | Intent i = new Intent(getActivity(), OAuthActivity.class); 34 | getActivity().startActivityForResult(i, 0x1234); 35 | } 36 | } 37 | ) 38 | .create(); 39 | } 40 | } -------------------------------------------------------------------------------- /res/layout/billing.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 19 | 20 | 22 | 26 | 30 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/NoAccountSelectedDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.support.v4.app.DialogFragment; 9 | 10 | import com.suchagit.android2cloud.PostLinkActivity; 11 | import com.suchagit.android2cloud.Preferences; 12 | import com.suchagit.android2cloud.R; 13 | 14 | public class NoAccountSelectedDialogFragment extends DialogFragment { 15 | 16 | public static NoAccountSelectedDialogFragment newInstance() { 17 | NoAccountSelectedDialogFragment frag = new NoAccountSelectedDialogFragment(); 18 | return frag; 19 | } 20 | 21 | @Override 22 | public Dialog onCreateDialog(Bundle savedInstanceState) { 23 | int title = R.string.default_error_title; 24 | int body = R.string.no_account_selected_error; 25 | int yesButton = R.string.no_account_selected_error_account_button; 26 | 27 | return new AlertDialog.Builder(getActivity()) 28 | .setCancelable(false) 29 | .setTitle(title) 30 | .setMessage(body) 31 | .setPositiveButton(yesButton, 32 | new DialogInterface.OnClickListener() { 33 | public void onClick(DialogInterface dialog, int whichButton) { 34 | Intent i = new Intent(getActivity(), Preferences.class); 35 | getActivity().startActivityForResult(i, PostLinkActivity.EDIT_SETTINGS_REQ_CODE); 36 | } 37 | } 38 | ) 39 | .create(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/DeprecatedHostExceptionDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.support.v4.app.DialogFragment; 9 | 10 | import com.suchagit.android2cloud.PostLinkActivity; 11 | import com.suchagit.android2cloud.Preferences; 12 | import com.suchagit.android2cloud.R; 13 | 14 | public class DeprecatedHostExceptionDialogFragment extends DialogFragment { 15 | 16 | public static DeprecatedHostExceptionDialogFragment newInstance() { 17 | DeprecatedHostExceptionDialogFragment frag = new DeprecatedHostExceptionDialogFragment(); 18 | return frag; 19 | } 20 | 21 | @Override 22 | public Dialog onCreateDialog(Bundle savedInstanceState) { 23 | int title = R.string.default_error_title; 24 | int body = R.string.deprecated_host_error; 25 | int yesButton = R.string.default_error_ok; 26 | 27 | return new AlertDialog.Builder(getActivity()) 28 | .setCancelable(false) 29 | .setTitle(title) 30 | .setMessage(body) 31 | .setPositiveButton(yesButton, 32 | new DialogInterface.OnClickListener() { 33 | public void onClick(DialogInterface dialog, int whichButton) { 34 | Intent i = new Intent(getActivity(), Preferences.class); 35 | getActivity().startActivityForResult(i, PostLinkActivity.EDIT_SETTINGS_REQ_CODE); 36 | } 37 | } 38 | ) 39 | .create(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/AddLinkResponse.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import org.json.JSONException; 4 | import org.json.JSONObject; 5 | 6 | import android.os.Bundle; 7 | import android.os.Handler; 8 | import android.os.ResultReceiver; 9 | import android.util.Log; 10 | 11 | public class AddLinkResponse extends ResultReceiver { 12 | private Receiver mReceiver; 13 | 14 | public AddLinkResponse(Handler handler) { 15 | super(handler); 16 | } 17 | 18 | public void setReceiver(Receiver receiver) { 19 | mReceiver = receiver; 20 | } 21 | 22 | public interface Receiver { 23 | public void onReceiveResult(int resultCode, Bundle resultData); 24 | } 25 | 26 | @Override 27 | protected void onReceiveResult(int resultCode, Bundle resultData) { 28 | if (mReceiver != null) { 29 | Bundle newData = new Bundle(); 30 | if(resultCode == HttpClient.STATUS_COMPLETE) { 31 | try { 32 | JSONObject json = new JSONObject(resultData.getString("raw_result")); 33 | newData.putInt("response_code", json.getInt("code")); 34 | newData.putString("link", json.getString("link")); 35 | newData.putString("raw_result", resultData.getString("raw_result")); 36 | } catch (JSONException e) { 37 | newData.putInt("response_code", 500); 38 | newData.putString("type", "client_error"); 39 | Log.d("AddLinkResponse", resultData.getString("raw_result")); 40 | Log.d("AddLinkResponse", e.getMessage()); 41 | } 42 | } else if(resultCode == HttpClient.STATUS_ERROR) { 43 | newData = resultData; 44 | } 45 | mReceiver.onReceiveResult(resultCode, newData); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/OverQuotaDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.support.v4.app.DialogFragment; 9 | 10 | import com.suchagit.android2cloud.Billing; 11 | import com.suchagit.android2cloud.PostLinkActivity; 12 | import com.suchagit.android2cloud.R; 13 | 14 | public class OverQuotaDialogFragment extends DialogFragment { 15 | 16 | public static OverQuotaDialogFragment newInstance() { 17 | OverQuotaDialogFragment frag = new OverQuotaDialogFragment(); 18 | return frag; 19 | } 20 | 21 | @Override 22 | public Dialog onCreateDialog(Bundle savedInstanceState) { 23 | int title = R.string.over_quota_error_title; 24 | int body = R.string.over_quota_error; 25 | int yesButton = R.string.default_error_ok; 26 | int noButton = R.string.over_quota_error_pay_button; 27 | 28 | return new AlertDialog.Builder(getActivity()) 29 | .setCancelable(true) 30 | .setTitle(title) 31 | .setMessage(body) 32 | .setPositiveButton(yesButton, 33 | new DialogInterface.OnClickListener() { 34 | public void onClick(DialogInterface dialog, int whichButton) { 35 | dialog.cancel(); 36 | } 37 | } 38 | ).setNegativeButton(noButton, 39 | new DialogInterface.OnClickListener() { 40 | public void onClick(DialogInterface dialog, int which) { 41 | Intent i = new Intent(getActivity(), Billing.class); 42 | getActivity().startActivityForResult(i, PostLinkActivity.BILLING_INTENT_CODE); 43 | } 44 | }) 45 | .create(); 46 | } 47 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/CheckTimeResponse.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import org.json.JSONException; 4 | import org.json.JSONObject; 5 | 6 | import android.os.Bundle; 7 | import android.os.Handler; 8 | import android.os.ResultReceiver; 9 | import android.util.Log; 10 | 11 | public class CheckTimeResponse extends ResultReceiver { 12 | private Receiver mReceiver; 13 | private Bundle passThrough; 14 | 15 | public CheckTimeResponse(Handler handler) { 16 | super(handler); 17 | } 18 | 19 | public void setReceiver(Receiver receiver) { 20 | mReceiver = receiver; 21 | } 22 | 23 | public void setPassThrough(Bundle error) { 24 | passThrough = error; 25 | } 26 | 27 | public Bundle getPassThrough() { 28 | return passThrough; 29 | } 30 | 31 | public interface Receiver { 32 | public void onReceiveResult(int resultCode, Bundle resultData); 33 | } 34 | 35 | @Override 36 | protected void onReceiveResult(int resultCode, Bundle resultData) { 37 | if (mReceiver != null) { 38 | Bundle newData = new Bundle(); 39 | if(resultCode == HttpClient.STATUS_COMPLETE) { 40 | try { 41 | JSONObject json = new JSONObject(resultData.getString("raw_result")); 42 | newData.putInt("response_code", json.getInt("code")); 43 | newData.putString("timestamp", json.getString("timestamp")); 44 | newData.putString("raw_result", resultData.getString("raw_result")); 45 | } catch (JSONException e) { 46 | newData.putInt("response_code", 500); 47 | newData.putString("type", "client_error"); 48 | Log.d("CheckTimeResponse", resultData.getString("raw_result")); 49 | Log.d("CheckTimeResponse", e.getMessage()); 50 | } 51 | } else if(resultCode == HttpClient.STATUS_ERROR) { 52 | newData = resultData; 53 | } 54 | mReceiver.onReceiveResult(resultCode, newData); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/PaymentNotificationRequest.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.apache.http.NameValuePair; 8 | import org.apache.http.client.entity.UrlEncodedFormEntity; 9 | import org.apache.http.client.methods.HttpPost; 10 | import org.apache.http.message.BasicNameValuePair; 11 | import org.apache.http.params.CoreProtocolPNames; 12 | 13 | public class PaymentNotificationRequest extends HttpPost { 14 | 15 | private String orderNumber; 16 | private String itemId; 17 | private List data; 18 | 19 | public void setOrderNumber(String newOrderNumber) { 20 | this.orderNumber = newOrderNumber; 21 | } 22 | 23 | public String getOrderNumber() { 24 | return this.orderNumber; 25 | } 26 | 27 | public void setItemId(String newItemId) { 28 | this.itemId = newItemId; 29 | } 30 | 31 | public String getItemId() { 32 | return this.itemId; 33 | } 34 | 35 | public void addData(String name, String value) { 36 | if(this.data == null) { 37 | this.data = new ArrayList(); 38 | } 39 | this.data.add(new BasicNameValuePair(name, value)); 40 | } 41 | 42 | public void clearData() { 43 | this.data.clear(); 44 | } 45 | 46 | public List getData() { 47 | return this.data; 48 | } 49 | 50 | public PaymentNotificationRequest(String host, String orderNumber, String itemId) throws UnsupportedEncodingException { 51 | super(host+"payments/notification"); 52 | this.setOrderNumber(orderNumber); 53 | this.setItemId(itemId); 54 | this.addData("order_number", this.getOrderNumber()); 55 | this.addData("item_id", this.getItemId()); 56 | this.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false); 57 | this.addHeader("Content-Type", "application/x-www-form-urlencoded"); 58 | UrlEncodedFormEntity entity = null; 59 | entity = new UrlEncodedFormEntity(this.getData(), "UTF-8"); 60 | this.setEntity(entity); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/errors/IncorrectTimeDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.errors; 2 | 3 | import android.app.AlertDialog; 4 | import android.app.Dialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.support.v4.app.DialogFragment; 9 | 10 | import com.suchagit.android2cloud.R; 11 | 12 | public class IncorrectTimeDialogFragment extends DialogFragment { 13 | 14 | public static IncorrectTimeDialogFragment newInstance(Bundle args) { 15 | IncorrectTimeDialogFragment frag = new IncorrectTimeDialogFragment(); 16 | frag.setArguments(args); 17 | return frag; 18 | } 19 | 20 | @Override 21 | public Dialog onCreateDialog(Bundle savedInstanceState) { 22 | int title = R.string.default_error_title; 23 | int body = R.string.incorrect_time_error; 24 | int yesButton = R.string.default_error_ok; 25 | int noButton = R.string.incorrect_time_error_time_button; 26 | 27 | //final String timezone = getArguments().getString("timezone"); 28 | //final String friendlyTime = getArguments().getString("friendlyTime"); 29 | 30 | return new AlertDialog.Builder(getActivity()) 31 | .setCancelable(false) 32 | .setTitle(title) 33 | .setMessage(body) 34 | .setPositiveButton(yesButton, 35 | new DialogInterface.OnClickListener() { 36 | public void onClick(DialogInterface dialog, int whichButton) { 37 | dialog.cancel(); 38 | getActivity().finish(); 39 | } 40 | } 41 | ) 42 | .setNegativeButton(noButton, 43 | new DialogInterface.OnClickListener() { 44 | public void onClick(DialogInterface dialog, int id) { 45 | Intent i = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS); 46 | getActivity().startActivity(i); 47 | } 48 | }) 49 | .create(); 50 | } 51 | } -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/OAuthWebView.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.support.v4.app.DialogFragment; 8 | import android.support.v4.app.FragmentActivity; 9 | import android.view.Window; 10 | import android.webkit.WebChromeClient; 11 | import android.webkit.WebView; 12 | import android.webkit.WebViewClient; 13 | 14 | import com.suchagit.android2cloud.errors.OAuthWebviewNullIntentDialogFragment; 15 | import com.suchagit.android2cloud.util.OAuth; 16 | 17 | public class OAuthWebView extends FragmentActivity { 18 | 19 | @Override 20 | public void onCreate(Bundle savedInstanceState){ 21 | super.onCreate(savedInstanceState); 22 | getWindow().requestFeature(Window.FEATURE_PROGRESS); 23 | String request_url = ""; 24 | if(this.getIntent() != null && this.getIntent().getDataString() != null){ 25 | request_url = this.getIntent().getDataString(); 26 | } else { 27 | showDialog(R.string.oauthwebview_null_intent_error); 28 | DialogFragment errorFragment = OAuthWebviewNullIntentDialogFragment.newInstance(); 29 | errorFragment.show(getSupportFragmentManager(), "dialog"); 30 | } 31 | WebView browser= new WebView(this); 32 | setContentView(browser); 33 | 34 | browser.getSettings().setJavaScriptEnabled(true); 35 | 36 | final Activity activity = this; 37 | browser.setWebChromeClient(new WebChromeClient() { 38 | public void onProgressChanged(WebView view, int progress) { 39 | activity.setProgress(progress * 1000); 40 | } 41 | }); 42 | browser.setWebViewClient(new WebViewClient(){ 43 | 44 | @Override 45 | public void onPageFinished(WebView view, String url){ 46 | super.onPageFinished(view, url); 47 | Uri uri = Uri.parse(url); 48 | if(("/" + OAuth.CALLBACK).equals(uri.getPath())){ 49 | Intent intent = new Intent(OAuthWebView.this, OAuthActivity.class); 50 | intent.setData(uri); 51 | setResult(RESULT_OK, intent); 52 | finish(); 53 | } 54 | } 55 | }); 56 | browser.loadUrl(request_url); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/AddLinkRequest.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.apache.http.NameValuePair; 8 | import org.apache.http.client.entity.UrlEncodedFormEntity; 9 | import org.apache.http.client.methods.HttpPost; 10 | import org.apache.http.message.BasicNameValuePair; 11 | import org.apache.http.params.CoreProtocolPNames; 12 | 13 | public class AddLinkRequest extends HttpPost { 14 | 15 | private String link; 16 | private String sender; 17 | private String receiver; 18 | private List data; 19 | 20 | public void setLink(String url) { 21 | this.link = url; 22 | } 23 | 24 | public String getLink() { 25 | return this.link; 26 | } 27 | 28 | public void setSender(String newSender) { 29 | this.sender = newSender; 30 | } 31 | 32 | public String getSender() { 33 | return this.sender; 34 | } 35 | 36 | public void setReceiver(String newReceiver) { 37 | this.receiver = newReceiver; 38 | } 39 | 40 | public String getReceiver() { 41 | return this.receiver; 42 | } 43 | 44 | public void addData(String name, String value) { 45 | if(this.data == null) { 46 | this.data = new ArrayList(); 47 | } 48 | this.data.add(new BasicNameValuePair(name, value)); 49 | } 50 | 51 | public void clearData() { 52 | this.data.clear(); 53 | } 54 | 55 | public List getData() { 56 | return this.data; 57 | } 58 | 59 | public AddLinkRequest(String host, String receiver, String sender, String link) throws UnsupportedEncodingException { 60 | super(host+"links/add"); 61 | this.setReceiver(receiver); 62 | this.setSender(sender); 63 | this.setLink(link); 64 | this.addData("link", this.getLink()); 65 | this.addData("name", this.getSender()); 66 | this.addData("receiver", this.getReceiver()); 67 | this.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false); 68 | this.addHeader("Content-Type", "application/x-www-form-urlencoded"); 69 | UrlEncodedFormEntity entity = null; 70 | entity = new UrlEncodedFormEntity(this.getData(), "UTF-8"); 71 | this.setEntity(entity); 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 55 | -------------------------------------------------------------------------------- /src/com/suchagit/android2cloud/util/OAuth.java: -------------------------------------------------------------------------------- 1 | package com.suchagit.android2cloud.util; 2 | 3 | import oauth.signpost.OAuthConsumer; 4 | import oauth.signpost.OAuthProvider; 5 | import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; 6 | import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; 7 | import oauth.signpost.exception.OAuthCommunicationException; 8 | import oauth.signpost.exception.OAuthExpectationFailedException; 9 | import oauth.signpost.exception.OAuthMessageSignerException; 10 | import oauth.signpost.exception.OAuthNotAuthorizedException; 11 | import android.net.Uri; 12 | 13 | public class OAuth { 14 | 15 | private static OAuthProvider provider; 16 | private static OAuthConsumer consumer; 17 | 18 | private static final String REQUEST_TOKEN_URL = "_ah/OAuthGetRequestToken"; 19 | private static final String ACCESS_TOKEN_URL = "_ah/OAuthGetAccessToken"; 20 | private static final String AUTHORISE_TOKEN_URL = "_ah/OAuthAuthorizeToken?btmpl=mobile"; 21 | 22 | public static final String CALLBACK = "callback/android/"; 23 | public static final int INTENT_ID = 0x1234; 24 | 25 | 26 | public static OAuthConsumer makeConsumer() { 27 | return new CommonsHttpOAuthConsumer(HttpClient.CONSUMER_KEY, HttpClient.CONSUMER_SECRET); 28 | } 29 | 30 | public static OAuthProvider makeProvider(String host) { 31 | String request_token_url = host + REQUEST_TOKEN_URL; 32 | String access_token_url = host + ACCESS_TOKEN_URL; 33 | String authorise_token_url = host + AUTHORISE_TOKEN_URL; 34 | return new CommonsHttpOAuthProvider(request_token_url, access_token_url, authorise_token_url); 35 | } 36 | 37 | public static String getRequestUrl(String host, String account) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException { 38 | if(consumer == null) { 39 | consumer = makeConsumer(); 40 | } 41 | 42 | if(provider == null) { 43 | provider = makeProvider(host); 44 | } 45 | account = Uri.encode(account); 46 | String target = provider.retrieveRequestToken(consumer, host+CALLBACK+"?account="+account); 47 | return target; 48 | } 49 | 50 | public static OAuthConsumer getAccessToken(String host, String verifier) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException { 51 | if(provider == null) { 52 | provider = makeProvider(host); 53 | } 54 | 55 | if(consumer == null) { 56 | consumer = makeConsumer(); 57 | } 58 | provider.retrieveAccessToken(consumer, verifier); 59 | return consumer; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 4 | 7 | 9 | 13 | 14 | 17 | 21 | 22 |