Search in sources :

Example 16 with Photo

use of com.trovebox.android.common.model.Photo in project mobile-android by photo.

the class ShareUtils method shareViaEMail.

/**
     * Shares the specified photo via email. The email application should be
     * installed on the user device
     * 
     * @param photo
     * @param context
     * @param loadingControl the loading control for token retrieval operation
     */
public static void shareViaEMail(Photo photo, final Context context, LoadingControl loadingControl) {
    RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() {

        @Override
        public void run(Photo photo) {
            String mailId = "";
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", mailId, null));
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, CommonUtils.getStringResource(R.string.share_email_default_title));
            String url = PhotoUtils.getShareUrl(photo);
            String bodyText = CommonUtils.getStringResource(R.string.share_email_default_body, url, url);
            emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(bodyText));
            context.startActivity(Intent.createChooser(emailIntent, CommonUtils.getStringResource(R.string.share_email_send_title)));
        }
    };
    PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo, runnable, null, loadingControl);
}
Also used : RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) Photo(com.trovebox.android.common.model.Photo) Intent(android.content.Intent)

Example 17 with Photo

use of com.trovebox.android.common.model.Photo in project mobile-android by photo.

the class ShareUtils method shareViaSystem.

/**
     * Shares the specified photo url via system share menu.
     * 
     * @param photo
     * @param context
     * @param loadingControl the loading control for token retrieval operation
     */
public static void shareViaSystem(Photo photo, final Context context, LoadingControl loadingControl) {
    RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() {

        @Override
        public void run(Photo photo) {
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, CommonUtils.getStringResource(R.string.share_system_default_title));
            String url = PhotoUtils.getShareUrl(photo);
            String bodyText = CommonUtils.getStringResource(R.string.share_system_default_body, url, url);
            shareIntent.putExtra(Intent.EXTRA_TEXT, bodyText);
            context.startActivity(Intent.createChooser(shareIntent, CommonUtils.getStringResource(R.string.share_system_send_title)));
        }
    };
    PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo, runnable, null, loadingControl);
}
Also used : RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) Photo(com.trovebox.android.common.model.Photo) Intent(android.content.Intent)

Aggregations

Photo (com.trovebox.android.common.model.Photo)17 Intent (android.content.Intent)5 IOException (java.io.IOException)5 JSONException (org.json.JSONException)5 ClientProtocolException (org.apache.http.client.ClientProtocolException)4 View (android.view.View)3 TextView (android.widget.TextView)3 UploadMetaData (com.trovebox.android.common.net.UploadMetaData)3 UploadResponse (com.trovebox.android.common.net.UploadResponse)3 RunnableWithParameter (com.trovebox.android.common.util.RunnableWithParameter)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 IntentFilter (android.content.IntentFilter)2 OnClickListener (android.view.View.OnClickListener)2 Button (android.widget.Button)2 PhotoResponse (com.trovebox.android.common.net.PhotoResponse)2 PhotosResponse (com.trovebox.android.common.net.PhotosResponse)2 Notification (android.app.Notification)1