77import android .content .Context ;
88import android .content .DialogInterface ;
99import android .content .Intent ;
10+ import android .content .pm .PackageInfo ;
1011import android .content .pm .PackageManager ;
1112import android .database .Cursor ;
1213import android .graphics .drawable .ColorDrawable ;
2324import android .support .v7 .app .AlertDialog ;
2425import android .support .v7 .app .AppCompatActivity ;
2526import android .util .Log ;
27+ import android .view .Menu ;
28+ import android .view .MenuItem ;
2629import android .view .View ;
2730import android .view .ViewGroup ;
31+ import android .view .Window ;
32+ import android .webkit .WebView ;
2833import android .widget .ScrollView ;
2934import android .widget .TextView ;
3035import android .widget .Toast ;
3540import com .github .hiteshsondhi88 .libffmpeg .LoadBinaryResponseHandler ;
3641import com .github .hiteshsondhi88 .libffmpeg .exceptions .FFmpegCommandAlreadyRunningException ;
3742import com .github .hiteshsondhi88 .libffmpeg .exceptions .FFmpegNotSupportedException ;
43+ import com .google .common .collect .ImmutableMap ;
3844
3945import org .apache .commons .io .comparator .LastModifiedFileComparator ;
4046import org .florescu .android .rangeseekbar .RangeSeekBar ;
4147
4248import java .io .File ;
4349import java .util .ArrayList ;
4450import java .util .Arrays ;
51+ import java .util .Calendar ;
4552import java .util .List ;
53+ import java .util .Map ;
4654
4755import videoeditor .bhuvnesh .com .ffmpegvideoeditor .R ;
4856
@@ -57,8 +65,7 @@ public class MainActivity extends AppCompatActivity {
5765 private FFmpeg ffmpeg ;
5866 private ProgressDialog progressDialog ;
5967 private Uri selectedVideoUri ;
60- private static final String TAG = "BHUVNESH" ;
61- private static final String POSITION = "position" ;
68+ private static final String TAG = "VideoEditor" ;
6269 private static final String FILEPATH = "filepath" ;
6370 private int choice = 0 ;
6471 private int stopPosition ;
@@ -339,7 +346,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
339346
340347 @ Override
341348 public void onPrepared (MediaPlayer mp ) {
342- // TODO Auto-generated method stub
343349 duration = mp .getDuration () / 1000 ;
344350 tvLeft .setText ("00:00:00" );
345351
@@ -870,11 +876,8 @@ public static boolean deleteDir(File dir) {
870876 * other file-based ContentProviders.
871877 */
872878 private String getPath (final Context context , final Uri uri ) {
873-
874- final boolean isKitKat = Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ;
875-
876879 // DocumentProvider
877- if (isKitKat && DocumentsContract .isDocumentUri (context , uri )) {
880+ if (DocumentsContract .isDocumentUri (context , uri )) {
878881 // ExternalStorageProvider
879882 if (isExternalStorageDocument (uri )) {
880883 final String docId = DocumentsContract .getDocumentId (uri );
@@ -983,11 +986,120 @@ private boolean isMediaDocument(Uri uri) {
983986
984987 private Dialog showSingleOptionTextDialog (Context mContext ) {
985988 Dialog textDialog = new Dialog (mContext , R .style .DialogAnimation );
986- textDialog .getWindow ().setLayout (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT );
987- textDialog .getWindow ().setBackgroundDrawable (new ColorDrawable (android .graphics .Color .TRANSPARENT ));
989+ Window window = textDialog .getWindow ();
990+ if (window != null )
991+ {
992+ window .setLayout (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT );
993+ window .setBackgroundDrawable (new ColorDrawable (android .graphics .Color .TRANSPARENT ));
994+ }
988995 textDialog .setContentView (R .layout .dialog_singleoption_text );
989996 textDialog .setCancelable (false );
990997 return textDialog ;
991998 }
992999
1000+ @ Override
1001+ public boolean onCreateOptionsMenu (Menu menu )
1002+ {
1003+ getMenuInflater ().inflate (R .menu .main_menu , menu );
1004+ return super .onCreateOptionsMenu (menu );
1005+ }
1006+
1007+ @ Override
1008+ public boolean onOptionsItemSelected (MenuItem item )
1009+ {
1010+ int id = item .getItemId ();
1011+
1012+ if (id == R .id .action_about )
1013+ {
1014+ displayAboutDialog ();
1015+ return true ;
1016+ }
1017+
1018+ return super .onOptionsItemSelected (item );
1019+ }
1020+
1021+ private void displayAboutDialog ()
1022+ {
1023+ final Map <String , String > USED_LIBRARIES = ImmutableMap .of
1024+ (
1025+ "Commons IO" , "https://commons.apache.org/proper/commons-io/" ,
1026+ "FFmpeg" , "https://www.ffmpeg.org/" ,
1027+ "FFmpeg Android" , "http://writingminds.github.io/ffmpeg-android/" ,
1028+ "Guava" , "https://github.com/google/guava" ,
1029+ "Range SeekBar" , "https://github.com/anothem/android-range-seek-bar"
1030+ );
1031+
1032+ final Map <String , String > USED_ASSETS = ImmutableMap .of
1033+ (
1034+ "Film by Mint Shirt" , "https://thenounproject.com/term/film/395618/"
1035+ );
1036+
1037+ StringBuilder libs = new StringBuilder ().append ("<ul>" );
1038+ for (Map .Entry <String , String > entry : USED_LIBRARIES .entrySet ())
1039+ {
1040+ libs .append ("<li><a href=\" " ).append (entry .getValue ()).append ("\" >" ).append (entry .getKey ()).append ("</a></li>" );
1041+ }
1042+ libs .append ("</ul>" );
1043+
1044+ StringBuilder resources = new StringBuilder ().append ("<ul>" );
1045+ for (Map .Entry <String , String > entry : USED_ASSETS .entrySet ())
1046+ {
1047+ resources .append ("<li><a href=\" " ).append (entry .getValue ()).append ("\" >" ).append (entry .getKey ()).append ("</a></li>" );
1048+ }
1049+ resources .append ("</ul>" );
1050+
1051+ String appName = getString (R .string .app_name );
1052+ int year = Calendar .getInstance ().get (Calendar .YEAR );
1053+
1054+ String version = "?" ;
1055+ try
1056+ {
1057+ PackageInfo pi = getPackageManager ().getPackageInfo (getPackageName (), 0 );
1058+ version = pi .versionName ;
1059+ }
1060+ catch (PackageManager .NameNotFoundException e )
1061+ {
1062+ Log .w (TAG , "Package name not found" , e );
1063+ }
1064+
1065+ WebView wv = new WebView (this );
1066+ String html =
1067+ "<meta http-equiv=\" content-type\" content=\" text/html; charset=utf-8\" />" +
1068+ "<h1>" +
1069+ String .format (getString (R .string .about_title_fmt ),
1070+ "<a href=\" " + getString (R .string .app_webpage_url )) + "\" >" +
1071+ appName +
1072+ "</a>" +
1073+ "</h1><p>" +
1074+ appName +
1075+ " " +
1076+ String .format (getString (R .string .debug_version_fmt ), version ) +
1077+ "</p><p>" +
1078+ String .format (getString (R .string .app_revision_fmt ),
1079+ "<a href=\" " + getString (R .string .app_revision_url ) + "\" >" +
1080+ getString (R .string .app_revision_url ) +
1081+ "</a>" ) +
1082+ "</p><hr/><p>" +
1083+ String .format (getString (R .string .app_copyright_fmt ), year ) +
1084+ "</p><hr/><p>" +
1085+ getString (R .string .app_license ) +
1086+ "</p><hr/><p>" +
1087+ String .format (getString (R .string .app_libraries ), appName , libs .toString ()) +
1088+ "</p><hr/><p>" +
1089+ String .format (getString (R .string .app_resources ), appName , resources .toString ());
1090+
1091+ wv .loadDataWithBaseURL ("file:///android_res/drawable/" , html , "text/html" , "utf-8" , null );
1092+ new AlertDialog .Builder (this )
1093+ .setView (wv )
1094+ .setCancelable (true )
1095+ .setPositiveButton (R .string .ok , new DialogInterface .OnClickListener ()
1096+ {
1097+ public void onClick (DialogInterface dialog , int which )
1098+ {
1099+ dialog .dismiss ();
1100+ }
1101+ })
1102+ .show ();
1103+ }
1104+
9931105}
0 commit comments