Skip to content

Commit 4644cc2

Browse files
committed
Add and Abount dialog
1 parent 67da6c2 commit 4644cc2

File tree

5 files changed

+140
-1
lines changed

5 files changed

+140
-1
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
3939
compile 'com.android.support:cardview-v7:27.0.2'
4040
compile 'commons-io:commons-io:2.5'
41+
compile group: 'com.google.guava', name: 'guava', version: '20.0'
4142
testCompile 'junit:junit:4.12'
4243
}
4344

app/src/main/java/videoeditor/bhuvnesh/com/ffmpegvideoeditor/activity/MainActivity.java

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.content.Context;
88
import android.content.DialogInterface;
99
import android.content.Intent;
10+
import android.content.pm.PackageInfo;
1011
import android.content.pm.PackageManager;
1112
import android.database.Cursor;
1213
import android.graphics.drawable.ColorDrawable;
@@ -23,9 +24,12 @@
2324
import android.support.v7.app.AlertDialog;
2425
import android.support.v7.app.AppCompatActivity;
2526
import android.util.Log;
27+
import android.view.Menu;
28+
import android.view.MenuItem;
2629
import android.view.View;
2730
import android.view.ViewGroup;
2831
import android.view.Window;
32+
import android.webkit.WebView;
2933
import android.widget.ScrollView;
3034
import android.widget.TextView;
3135
import android.widget.Toast;
@@ -36,14 +40,17 @@
3640
import com.github.hiteshsondhi88.libffmpeg.LoadBinaryResponseHandler;
3741
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
3842
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;
43+
import com.google.common.collect.ImmutableMap;
3944

4045
import org.apache.commons.io.comparator.LastModifiedFileComparator;
4146
import org.florescu.android.rangeseekbar.RangeSeekBar;
4247

4348
import java.io.File;
4449
import java.util.ArrayList;
4550
import java.util.Arrays;
51+
import java.util.Calendar;
4652
import java.util.List;
53+
import java.util.Map;
4754

4855
import videoeditor.bhuvnesh.com.ffmpegvideoeditor.R;
4956

@@ -990,4 +997,109 @@ private Dialog showSingleOptionTextDialog(Context mContext) {
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
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<item
4+
android:id="@+id/action_about"
5+
android:title="@string/about"
6+
app:showAsAction="never"/>
7+
</menu>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_revision_url" translatable="false">https://github.com/brarcher/VideoEditor/releases</string>
4+
<string name="app_webpage_url" translatable="false">https://github.com/brarcher/VideoEditor</string>
5+
</resources>

app/src/main/res/values/strings.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<resources>
1+
<resources
2+
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
3+
24
<string name="app_name">Video Editor</string>
35
<string name="rangeSeekBarText">Use RangeSeekbar to select time range for cutting video or extracting images from video(rangeseekbar ineffective for other options)</string>
46
<string name="uploadVideo">Upload\nVideo</string>
@@ -12,4 +14,16 @@
1214
<string name="reverseVideo">Reverse\nVideo</string>
1315
<string name="dialogMessage">The process will take some time.Please be patient.</string>
1416

17+
<string name="ok">OK</string>
18+
19+
<string name="about">About</string>
20+
<string name="app_copyright_fmt">Copyright 2018-<xliff:g>%d</xliff:g> Branden Archer</string>
21+
<string name="app_license">Licensed under the GPLv2.</string>
22+
<string name="about_title_fmt">About <xliff:g id="app_name">%s</xliff:g></string>
23+
<string name="debug_version_fmt">Version: <xliff:g id="version">%s</xliff:g></string>
24+
<string name="app_revision_fmt">Revision Information: <xliff:g id="app_revision_url">%s</xliff:g></string>
25+
<string name="app_libraries"><xliff:g id="app_name">%s</xliff:g> uses the following third-party libraries: <xliff:g id="app_libraries_list">%s</xliff:g></string>
26+
<string name="app_resources"><xliff:g id="app_name">%s</xliff:g> uses the following third-party resources: <xliff:g id="app_resources_list">%s</xliff:g></string>
27+
28+
1529
</resources>

0 commit comments

Comments
 (0)