Search in sources :

Example 1 with Scene

use of org.storymaker.app.model.Scene 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 Scene

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

the class MediaProjectManager method initProject.

public void initProject() {
    int clipCount = 0;
    for (Scene s : mProject.getScenesAsArray()) {
        clipCount += s.getClipCount();
    }
    mMediaList = new ArrayList<MediaClip>(clipCount);
    for (int i = 0; i < clipCount; i++) {
        mMediaList.add(null);
    }
    mMediaHelper = new MediaHelper(mActivity, mHandler);
    initExternalStorage(mContext);
}
Also used : Scene(org.storymaker.app.model.Scene) SuppressLint(android.annotation.SuppressLint)

Example 3 with Scene

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

the class StoryMakerDB method onUpgrade.

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Timber.d("updating db from " + oldVersion + " to " + newVersion);
    if ((oldVersion < 2) && (newVersion == 2)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS);
    }
    if ((oldVersion < 3) && (newVersion == 3)) {
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_START);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_END);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_DURATION);
    }
    if ((oldVersion < 4) && (newVersion >= 4)) {
        db.execSQL(StoryMakerDB.Schema.Auth.UPDATE_TABLE_AUTH);
        // migrates storymaker login credentials
        Auth.migrate(mContext, db);
    }
    if ((oldVersion < 5) && (newVersion >= 5)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_UPDATED_AT);
        db.execSQL(StoryMakerDB.Schema.Scenes.UPDATE_TABLE_SCENES_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Scenes.UPDATE_TABLE_SCENES_ADD_UPDATED_AT);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_UPDATED_AT);
        // migrates existing database records and associated files
        Project.migrate(mContext, db);
    }
    if ((oldVersion < 6) && (newVersion >= 6)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_SECTION);
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_LOCATION);
        db.execSQL(StoryMakerDB.Schema.Tags.UPDATE_TABLE_TAGS);
    }
    if ((oldVersion < 7) && (newVersion >= 7)) {
        @SuppressWarnings("unchecked") ArrayList<Scene> scenes = (ArrayList<Scene>) (new SceneTable(db)).getAllAsList(mContext);
        for (Scene scene : scenes) {
            scene.migrateDeleteDupedMedia();
        }
    }
    if ((oldVersion < 8) && (newVersion >= 8)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_DESCRIPTION);
    }
    if ((oldVersion < 9) && (newVersion >= 9)) {
        db.execSQL(StoryMakerDB.Schema.Jobs.CREATE_TABLE_JOBS);
        db.execSQL(StoryMakerDB.Schema.PublishJobs.CREATE_TABLE_PUBLISH_JOBS);
    }
    if ((oldVersion < 10) && (newVersion >= 10)) {
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_VOLUME);
        db.execSQL(Schema.AudioClip.CREATE_TABLE_AUDIO_CLIP);
    }
    if ((oldVersion < 11) && (newVersion >= 11)) {
        // we need to force the server url to .org since beta users have .cc in their sharedprefs and are missing the update
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext.getApplicationContext());
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(StoryMakerApp.STORYMAKER_SERVER_URL_PREFS_KEY, StoryMakerApp.STORYMAKER_DEFAULT_SERVER_URL);
        editor.commit();
    }
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) Scene(org.storymaker.app.model.Scene)

Example 4 with Scene

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

the class SceneEditorActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    //project id
    int pid = intent.getIntExtra("pid", -1);
    ArrayList<Parcelable> parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_CLIPS);
    mSceneIndex = getIntent().getIntExtra("scene", 0);
    if (parcelables != null) {
        // FIXME this should be split into a method, probably in the model.Project class?
        mProject = new Project(this, 1);
        mProject.setTitle("export from liger");
        mProject.setTemplatePath("");
        mProject.setStoryType(Project.STORY_TYPE_VIDEO);
        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);
            scene.setMedia(i, m.getFilePath(), m.getFilePath(), "video/mp4");
            i++;
        }
        scene.save();
        // FIXME load project
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
    } else if (pid != -1) {
        // FIXME ugly
        mProject = (Project) (new ProjectTable()).get(getApplicationContext(), pid);
        Scene scene = null;
        if ((mSceneIndex != -1) && (mSceneIndex < mProject.getScenesAsArray().length)) {
            scene = mProject.getScenesAsArray()[mSceneIndex];
        }
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
        mMPM.initProject();
    } else {
        // FIXME get rid of hardcoded clipCount = 5
        int clipCount = 5;
        String title = intent.getStringExtra("title");
        mProject = new Project(getApplicationContext(), clipCount);
        mProject.setTitle(title);
        mProject.save();
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject);
        mMPM.initProject();
    }
    try {
        if (mProject.getScenesAsList().size() > 1) {
            mTemplate = Template.parseAsset(this, mProject.getTemplatePath(), Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
        } else {
            mTemplate = Template.parseAsset(this, Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
        }
    } catch (Exception e) {
        Timber.e(e, "could not parse templates");
    }
    setContentView(R.layout.activity_scene_editor_no_swipe);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    addPublishFragement();
    actionBar.setTitle(getString(R.string.tab_publish));
    if (intent.hasExtra("auto_capture") && intent.getBooleanExtra("auto_capture", false)) {
        openCaptureMode(0, 0);
    }
}
Also used : Project(org.storymaker.app.model.Project) MediaProjectManager(org.storymaker.app.media.MediaProjectManager) FullMetadata(scal.io.liger.model.FullMetadata) Intent(android.content.Intent) Parcelable(android.os.Parcelable) Scene(org.storymaker.app.model.Scene) ProjectTable(org.storymaker.app.model.ProjectTable) IOException(java.io.IOException) ActionBar(android.app.ActionBar)

Aggregations

Scene (org.storymaker.app.model.Scene)4 Intent (android.content.Intent)2 Parcelable (android.os.Parcelable)2 ArrayList (java.util.ArrayList)2 MediaProjectManager (org.storymaker.app.media.MediaProjectManager)2 Project (org.storymaker.app.model.Project)2 FullMetadata (scal.io.liger.model.FullMetadata)2 SuppressLint (android.annotation.SuppressLint)1 ActionBar (android.app.ActionBar)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 IOException (java.io.IOException)1 ProjectTable (org.storymaker.app.model.ProjectTable)1 SceneTable (org.storymaker.app.model.SceneTable)1 AudioClipFull (scal.io.liger.model.AudioClipFull)1 StoryPathLibrary (scal.io.liger.model.StoryPathLibrary)1