|
7 | 7 | import android.content.Context; |
8 | 8 | import android.content.DialogInterface; |
9 | 9 | import android.content.Intent; |
| 10 | +import android.content.pm.PackageInfo; |
10 | 11 | import android.content.pm.PackageManager; |
11 | 12 | import android.database.Cursor; |
12 | 13 | import android.graphics.drawable.ColorDrawable; |
|
23 | 24 | import android.support.v7.app.AlertDialog; |
24 | 25 | import android.support.v7.app.AppCompatActivity; |
25 | 26 | import android.util.Log; |
| 27 | +import android.view.Menu; |
| 28 | +import android.view.MenuItem; |
26 | 29 | import android.view.View; |
27 | 30 | import android.view.ViewGroup; |
28 | 31 | import android.view.Window; |
| 32 | +import android.webkit.WebView; |
29 | 33 | import android.widget.ScrollView; |
30 | 34 | import android.widget.TextView; |
31 | 35 | import android.widget.Toast; |
|
36 | 40 | import com.github.hiteshsondhi88.libffmpeg.LoadBinaryResponseHandler; |
37 | 41 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException; |
38 | 42 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException; |
| 43 | +import com.google.common.collect.ImmutableMap; |
39 | 44 |
|
40 | 45 | import org.apache.commons.io.comparator.LastModifiedFileComparator; |
41 | 46 | import org.florescu.android.rangeseekbar.RangeSeekBar; |
42 | 47 |
|
43 | 48 | import java.io.File; |
44 | 49 | import java.util.ArrayList; |
45 | 50 | import java.util.Arrays; |
| 51 | +import java.util.Calendar; |
46 | 52 | import java.util.List; |
| 53 | +import java.util.Map; |
47 | 54 |
|
48 | 55 | import videoeditor.bhuvnesh.com.ffmpegvideoeditor.R; |
49 | 56 |
|
@@ -990,4 +997,109 @@ private Dialog showSingleOptionTextDialog(Context mContext) { |
990 | 997 | return textDialog; |
991 | 998 | } |
992 | 999 |
|
| 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 | + |
993 | 1105 | } |
0 commit comments