Search in sources :

Example 1 with Project

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

the class PublishActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_publish);
    Intent intent = getIntent();
    String title = intent.getStringExtra(Constants.EXTRA_STORY_TITLE);
    String storyPathInstancePath = intent.getStringExtra(Constants.EXTRA_STORY_INSTANCE_PATH);
    StoryPathLibrary spl = getStoryPathLibrary(storyPathInstancePath);
    if (title == null)
        title = getString(R.string.no_title);
    ArrayList<Parcelable> parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_CLIPS);
    mProject = new Project(this, 1);
    // FIXME this should be split into a method, probably in the model.Project class?
    mProject = new Project(this, 1);
    mProject.setTitle(title);
    // FIXME can we leverage this for the story path file?
    mProject.setTemplatePath("");
    // until we iron out multi medium, we just tied export medium to the medium of the first clip
    final String medium = ((FullMetadata) parcelables.get(0)).getMedium();
    if (medium.equals("photo")) {
        mProject.setStoryType(Project.STORY_TYPE_ESSAY);
    } else if (medium.equals("audio")) {
        mProject.setStoryType(Project.STORY_TYPE_AUDIO);
    } else if (medium.equals("video")) {
        mProject.setStoryType(Project.STORY_TYPE_VIDEO);
    }
    mProject.setTemplatePath(storyPathInstancePath);
    if ((spl != null) && (spl.getPublishProfile() != null)) {
        // FIXME move this into the actual publish step so the user doesn't remove them in the publishfragment info editor
        mProject.setTagsFromStringList(spl.getPublishProfile().getTags());
    }
    mProject.save();
    Scene scene = new Scene(this, parcelables.size());
    scene.setTitle("ligerscene1");
    scene.setProjectId(mProject.getId());
    scene.setProjectIndex(0);
    scene.save();
    // FIXME convert export into project
    int i = 0;
    for (Parcelable p : parcelables) {
        // index, cliptype, path, mimetype
        FullMetadata m = ((FullMetadata) p);
        float trimStartRatio = ((float) m.getStartTime()) / m.getDuration();
        int trimStart = (int) (trimStartRatio * 100) - 1;
        float trimEndRatio = ((float) m.getStopTime()) / m.getDuration();
        int trimEnd = (int) (trimEndRatio * 100) - 1;
        // FIXME hardcoded "video/mp4"
        scene.setMedia(i, m.getFilePath(), m.getFilePath(), "video/mp4", trimStart, trimEnd, m.getDuration(), m.getVolume());
        i++;
    }
    scene.save();
    parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_AUDIOCLIPS);
    if (parcelables != null) {
        i = 0;
        ArrayList<org.storymaker.app.model.AudioClip> audioClipModels = new ArrayList<org.storymaker.app.model.AudioClip>();
        for (Parcelable p : parcelables) {
            AudioClipFull audioClip = ((AudioClipFull) p);
            org.storymaker.app.model.AudioClip ac = org.storymaker.app.model.AudioClip.getInstanceFromLigerAudioClip(this, audioClip, scene.getId(), audioClip.getPath());
            ac.save();
            // TODO this needs to add AudioClip' models to this scene
            audioClipModels.add(ac);
        }
    }
    // FIXME load project
    mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, null);
    mMPM.initProject();
    if (savedInstanceState == null) {
        mPublishFragment = new PublishFragment();
        Bundle args = new Bundle();
        //            args.putInt(AddClipsFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
        args.putInt("layout", R.layout.fragment_complete_story);
        args.putInt("scene", 0);
        mPublishFragment.setArguments(args);
        getSupportFragmentManager().beginTransaction().add(R.id.container, mPublishFragment).commit();
    }
}
Also used : MediaProjectManager(org.storymaker.app.media.MediaProjectManager) FullMetadata(scal.io.liger.model.FullMetadata) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Parcelable(android.os.Parcelable) AudioClipFull(scal.io.liger.model.AudioClipFull) Scene(org.storymaker.app.model.Scene) Project(org.storymaker.app.model.Project) StoryPathLibrary(scal.io.liger.model.StoryPathLibrary)

Example 2 with Project

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

the class PublisherBase method publishToStoryMaker.

public String publishToStoryMaker() {
    Job job = getPreferredUploadJob();
    Project project = mPublishJob.getProject();
    String title = project.getTitle();
    String desc = project.getDescription();
    String mediaEmbed = getEmbed(job);
    String[] categories = project.getCategories();
    String medium = getMedium();
    String mediaService = job.getSite();
    // TODO get the id from the preferred job to publish to facebook
    String mediaGuid = job.getResult();
    try {
        String ret = publishToStoryMaker(title, desc, mediaEmbed, categories, medium, mediaService, mediaGuid);
        return ret;
    } catch (IOException ioe) {
        Timber.e(ioe, "failed to publish due to an IOException");
    }
    return null;
}
Also used : Project(org.storymaker.app.model.Project) IOException(java.io.IOException) PublishJob(org.storymaker.app.model.PublishJob) Job(org.storymaker.app.model.Job)

Example 3 with Project

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

the class ArchiveUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    final SiteController controller = SiteController.getSiteController(ArchiveSiteController.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, ArchiveSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_internet_archive));
        HashMap<String, String> valueMap = publishJob.getMetadata();
        addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
        // FIXME need to hookup Account to this
        controller.upload(auth.convertToAccountObject(), valueMap);
    } else {
        Timber.d("Can't upload to Internet Archive server, 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 Internet Archive 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) ArchiveSiteController(io.scal.secureshare.controller.ArchiveSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 4 with Project

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

the class FacebookUploader 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(FacebookSiteController.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, FacebookSiteController.SITE_KEY);
    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_facebook));
                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(FacebookSiteController.PHOTO_SET_KEY, photoString);
                }
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to facebook, 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 facebook, last rendered file doesn't exist.");
    }
}
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) FacebookSiteController(io.scal.secureshare.controller.FacebookSiteController) PublishJob(org.storymaker.app.model.PublishJob) Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) File(java.io.File)

Example 5 with Project

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

the class SSHPublisher method startRender.

public void startRender() {
    Timber.d("startRender");
    Project project = (Project) (new ProjectTable()).get(mContext, mPublishJob.getProjectId());
    if (project.getStoryType() == Project.STORY_TYPE_VIDEO) {
        Job videoRenderJob = new Job(mContext, mPublishJob.getProjectId(), mPublishJob.getId(), JobTable.TYPE_RENDER, null, VideoRenderer.SPEC_KEY);
        mController.enqueueJob(videoRenderJob);
    } else if (project.getStoryType() == Project.STORY_TYPE_AUDIO) {
        Job videoRenderJob = new Job(mContext, mPublishJob.getProjectId(), mPublishJob.getId(), JobTable.TYPE_RENDER, null, AudioRenderer.SPEC_KEY);
        mController.enqueueJob(videoRenderJob);
    } else {
        // skip render, no point
        mController.publishJobSucceeded(mPublishJob, null);
    }
}
Also used : Project(org.storymaker.app.model.Project) Job(org.storymaker.app.model.Job) PublishJob(org.storymaker.app.model.PublishJob) ProjectTable(org.storymaker.app.model.ProjectTable)

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