/**
   Copyright (c) 2014 Rory Hool
   
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 **/

/**
   Copyright (c) 2014 Rory Hool
   
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 **/

package com.roryhool.videomanipulation;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.roryhool.commonvideolibrary.Intents;
import com.roryhool.commonvideolibrary.UriHelper;

public class MainActivity extends Activity {

   private int SELECT_VIDEO_CODE = 100;

   LinearLayout mSelectedVideoLayout;

   Uri mUri;

   @Override
   public void onCreate( Bundle savedInstanceState ) {
      super.onCreate( savedInstanceState );

      setContentView( R.layout.activity_main );

      mSelectedVideoLayout = (LinearLayout) findViewById( R.id.selected_video_layout );
   }

   public void onSelectClicked( View view ) {
      startActivityForResult( Intents.GetLaunchVideoChooserIntent( this ), SELECT_VIDEO_CODE );
   }

   @Override
   public void onActivityResult( int requestCode, int resultCode, Intent data ) {

      if ( data != null ) {

         mUri = data.getData();

         if ( mUri.getScheme().equals( "content" ) ) {
            String path = UriHelper.ContentUriToFilePath( this, mUri );
            mUri = Uri.parse( path );
         }

         mSelectedVideoLayout.setVisibility( View.VISIBLE );
      }
   }

   public void onRotateClicked( View view ) {
      Intent intent = new Intent( this, RotationActivity.class );
      intent.setData( mUri );
      startActivity( intent );
   }

   public void onJoinClicked( View view ) {
      Intent intent = new Intent( this, JoinActivity.class );
      intent.setData( mUri );
      startActivity( intent );
   }

   public void onTrimClicked( View view ) {
      Intent intent = new Intent( this, TrimActivity.class );
      intent.setData( mUri );
      startActivity( intent );
   }

   public void onResampleClicked( View view ) {
      Intent intent = new Intent( this, ResampleActivity.class );
      intent.setData( mUri );
      startActivity( intent );
   }

}

@@ -1292,22 +1292,96 @@
 content.
-Intent
+Context;%0Aimport android.content.Intent;%0Aimport android.content.SharedPreferences
 ;%0Aimport
@@ -1632,16 +1632,87 @@
 vity %7B%0A%0A
+   private static final String RECENT_VIDEO_KEY = %22RECENT_VIDEO_KEY%22;%0A%0A
    priva
@@ -2042,24 +2042,244 @@
 eo_layout );
+%0A%0A      SharedPreferences settings = getPreferences( Context.MODE_PRIVATE );%0A      String video = settings.getString( RECENT_VIDEO_KEY, null );%0A      if ( video != null ) %7B%0A         loadUri( Uri.parse( video ) );%0A      %7D
 %0A   %7D%0A%0A   pu
@@ -2520,68 +2520,359 @@
 ) %7B%0A
-%0A
       
-if ( data != null ) %7B%0A%0A         mUri = data.getData()
+loadUri( data.getData() );%0A   %7D%0A%0A   private void loadUri( Uri uri ) %7B%0A%0A      if ( uri != null ) %7B%0A%0A         SharedPreferences settings = getPreferences( Context.MODE_PRIVATE );%0A         SharedPreferences.Editor editor = settings.edit();%0A         editor.putString( RECENT_VIDEO_KEY, uri.toString() );%0A         editor.apply();%0A%0A         mUri = uri
 ;%0A%0A 

Save most recently selected video, load on app startup, makes testing easier