Search in sources :

Example 6 with Project

use of org.storymaker.app.model.Project in project storymaker by StoryMaker.

the class SoundCloudUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(SoundCloudSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, SoundCloudSiteController.SITE_KEY);
    // FIXME deal with lack of auth credentials here
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back 
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_soundcloud));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to SoundCloud, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to SoundCloud, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) SoundCloudSiteController(io.scal.secureshare.controller.SoundCloudSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 7 with Project

use of org.storymaker.app.model.Project in project storymaker by StoryMaker.

the class ProjectsActivity method initListView.

public void initListView(ListView list) {
    list.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            final Project project = mListProjects.get(arg2);
            AlertDialog.Builder builder = new AlertDialog.Builder(ProjectsActivity.this);
            builder.setMessage(R.string.delete_project_).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    deleteProject(project);
                }
            }).setNegativeButton(android.R.string.no, null).show();
            return false;
        }
    });
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Project project = mListProjects.get(position);
            Intent intent = null;
            intent = new Intent(ProjectsActivity.this, SceneEditorActivity.class);
            intent.putExtra("template_path", project.getTemplatePath());
            intent.putExtra("story_mode", project.getStoryType());
            intent.putExtra("pid", project.getId());
            intent.putExtra("title", project.getTitle());
            startActivity(intent);
        }
    });
    refreshProjects();
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Project(org.storymaker.app.model.Project)

Example 8 with Project

use of org.storymaker.app.model.Project in project storymaker by StoryMaker.

the class FlickrUploader method start.

@Override
public void start() {
    Timber.d("start()");
    final SiteController controller = SiteController.getSiteController(FlickrSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, Auth.SITE_FLICKR);
    if (path != null) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            @Override
            public void run() {
                Timber.d("run()");
                // FIXME, this might not be wise to run on the main thread flickr, does the flickr SDK automatically run itself on a backgroundthread?
                HashMap<String, String> valueMap = publishJob.getMetadata();
                // need to extract raw photos
                // what happened to STORY_TYPE_PHOTO?
                // TODO: currently checking preferences, will revisit when ui is updated
                SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
                boolean uploadPhotos = sharedPref.getBoolean("pphotoformat", false);
                if ((publishJob.getProject().getStoryType() == Project.STORY_TYPE_ESSAY) && uploadPhotos) {
                    ArrayList<Media> photos = publishJob.getProject().getMediaAsList();
                    String photoString = "";
                    for (Media photo : photos) {
                        photoString = photoString + photo.getPath() + ";";
                    }
                    // drop trailing ;
                    photoString = photoString.substring(0, photoString.length() - 1);
                    valueMap.put(FlickrSiteController.PHOTO_SET_KEY, photoString);
                }
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.e("flickr upload failed, file path is null");
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AuthTable(org.storymaker.app.model.AuthTable) Media(org.storymaker.app.model.Media) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) FlickrSiteController(io.scal.secureshare.controller.FlickrSiteController) PublishJob(org.storymaker.app.model.PublishJob) Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth)

Example 9 with Project

use of org.storymaker.app.model.Project in project storymaker by StoryMaker.

the class S3Uploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(S3SiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    // FIXME deal with lack of auth credentials here
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back 
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                //                    controller.upload(auth.convertToAccountObject(), valueMap);
                controller.upload(null, valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to S3, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to S3, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) S3SiteController(io.scal.secureshare.controller.S3SiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 10 with Project

use of org.storymaker.app.model.Project in project storymaker by StoryMaker.

the class SSHUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(SSHSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, SSHSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        //  FIXME move to strings.xml
        jobProgress(mJob, 0, "Uploading to SSH server...");
        HashMap<String, String> valueMap = publishJob.getMetadata();
        addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
        controller.upload(auth.convertToAccountObject(), valueMap);
    } else {
        Timber.d("Can't upload to SSH, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to SSH server, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) SiteController(io.scal.secureshare.controller.SiteController) SSHSiteController(io.scal.secureshare.controller.SSHSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Aggregations

Project (org.storymaker.app.model.Project)12 PublishJob (org.storymaker.app.model.PublishJob)9 SiteController (io.scal.secureshare.controller.SiteController)6 Auth (org.storymaker.app.model.Auth)6 AuthTable (org.storymaker.app.model.AuthTable)6 Handler (android.os.Handler)5 File (java.io.File)5 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)2 Parcelable (android.os.Parcelable)2 IOException (java.io.IOException)2 MediaProjectManager (org.storymaker.app.media.MediaProjectManager)2 Job (org.storymaker.app.model.Job)2 Media (org.storymaker.app.model.Media)2 ProjectTable (org.storymaker.app.model.ProjectTable)2 Scene (org.storymaker.app.model.Scene)2 FullMetadata (scal.io.liger.model.FullMetadata)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1