Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit a01cd08

Browse files
committed
Added authors dialog;
1 parent c0fd01c commit a01cd08

File tree

6 files changed

+181
-12
lines changed

6 files changed

+181
-12
lines changed

project/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityAbout.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import android.text.Spanned;
1111
import android.text.style.ForegroundColorSpan;
1212
import android.text.style.UnderlineSpan;
13-
import android.view.MenuItem;
1413
import android.view.View;
1514
import android.widget.TextView;
1615
import android.widget.Toast;
1716

17+
import eu.vcmi.vcmi.content.DialogAuthors;
1818
import eu.vcmi.vcmi.util.GeneratedVersion;
1919
import eu.vcmi.vcmi.util.Utils;
2020

@@ -23,6 +23,8 @@
2323
*/
2424
public class ActivityAbout extends ActivityWithToolbar
2525
{
26+
private static final String DIALOG_AUTHORS_TAG = "DIALOG_AUTHORS_TAG";
27+
2628
@Override
2729
protected void onCreate(@Nullable final Bundle savedInstanceState)
2830
{
@@ -70,7 +72,8 @@ private void initControl(final int textViewResId, final String text)
7072

7173
private void onBtnAuthorsPressed(final View v)
7274
{
73-
// TODO authors view (dialog?)
75+
final DialogAuthors dialogAuthors = new DialogAuthors();
76+
dialogAuthors.show(getSupportFragmentManager(), DIALOG_AUTHORS_TAG);
7477
}
7578

7679
private void onBtnLibsPressed(final View v)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package eu.vcmi.vcmi.content;
2+
3+
import android.annotation.SuppressLint;
4+
import android.app.Dialog;
5+
import android.os.Bundle;
6+
import android.support.annotation.NonNull;
7+
import android.support.v4.app.DialogFragment;
8+
import android.support.v7.app.AlertDialog;
9+
import android.view.LayoutInflater;
10+
import android.view.View;
11+
import android.widget.TextView;
12+
13+
import java.io.IOException;
14+
15+
import eu.vcmi.vcmi.R;
16+
import eu.vcmi.vcmi.util.FileUtil;
17+
import eu.vcmi.vcmi.util.Log;
18+
19+
/**
20+
* @author F
21+
*/
22+
public class DialogAuthors extends DialogFragment
23+
{
24+
@NonNull
25+
@Override
26+
public Dialog onCreateDialog(final Bundle savedInstanceState)
27+
{
28+
final LayoutInflater inflater = LayoutInflater.from(getActivity());
29+
@SuppressLint("InflateParams") final View inflated = inflater.inflate(R.layout.dialog_authors, null, false);
30+
final TextView vcmiAuthorsView = (TextView) inflated.findViewById(R.id.dialog_authors_vcmi);
31+
loadAuthorsContent(vcmiAuthorsView);
32+
return new AlertDialog.Builder(getActivity())
33+
.setView(inflated)
34+
.create();
35+
}
36+
37+
private void loadAuthorsContent(final TextView vcmiAuthorsView)
38+
{
39+
try
40+
{
41+
// to be checked if this should be converted to async load (not really a file operation so it should be okay)
42+
final String authorsContent = FileUtil.read(getResources().openRawResource(R.raw.authors));
43+
vcmiAuthorsView.setText(authorsContent);
44+
}
45+
catch (final IOException e)
46+
{
47+
Log.e(this, "Could not load authors content", e);
48+
}
49+
}
50+
}

project/vcmi-app/src/main/java/eu/vcmi/vcmi/util/FileUtil.java

+24-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.io.FileReader;
1313
import java.io.FileWriter;
1414
import java.io.IOException;
15+
import java.io.InputStream;
16+
import java.io.InputStreamReader;
1517
import java.util.zip.ZipEntry;
1618
import java.util.zip.ZipInputStream;
1719

@@ -25,18 +27,19 @@ public class FileUtil
2527
{
2628
private static final int BUFFER_SIZE = 4096;
2729

30+
public static String read(final InputStream stream) throws IOException
31+
{
32+
try (InputStreamReader reader = new InputStreamReader(stream))
33+
{
34+
return readInternal(reader);
35+
}
36+
}
37+
2838
public static String read(final File file) throws IOException
2939
{
3040
try (FileReader reader = new FileReader(file))
3141
{
32-
final char[] buffer = new char[BUFFER_SIZE];
33-
int currentRead;
34-
final StringBuilder content = new StringBuilder();
35-
while ((currentRead = reader.read(buffer, 0, BUFFER_SIZE)) >= 0)
36-
{
37-
content.append(buffer, 0, currentRead);
38-
}
39-
return content.toString();
42+
return readInternal(reader);
4043
}
4144
catch (final FileNotFoundException ignored)
4245
{
@@ -45,6 +48,18 @@ public static String read(final File file) throws IOException
4548
}
4649
}
4750

51+
private static String readInternal(final InputStreamReader reader) throws IOException
52+
{
53+
final char[] buffer = new char[BUFFER_SIZE];
54+
int currentRead;
55+
final StringBuilder content = new StringBuilder();
56+
while ((currentRead = reader.read(buffer, 0, BUFFER_SIZE)) >= 0)
57+
{
58+
content.append(buffer, 0, currentRead);
59+
}
60+
return content.toString();
61+
}
62+
4863
public static void write(final File file, final String data) throws IOException
4964
{
5065
if (!ensureWriteable(file))
@@ -101,7 +116,7 @@ public static boolean copyFile(final File srcFile, final File dstFile)
101116
{
102117
return false;
103118
}
104-
119+
105120
final File dstDir = dstFile.getParentFile();
106121
if (!dstDir.exists())
107122
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
7+
<LinearLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"
10+
android:orientation="vertical">
11+
12+
<android.support.v7.widget.AppCompatTextView
13+
style="@style/VCMI.Text.LauncherSection"
14+
android:text="VCMI authors" />
15+
16+
17+
<android.support.v7.widget.AppCompatTextView
18+
android:id="@+id/dialog_authors_vcmi"
19+
style="@style/VCMI.Text"
20+
android:padding="@dimen/side_margin" />
21+
22+
<include layout="@layout/inc_separator" />
23+
24+
<!-- TODO should this be separate or just merged with vcmi authors? -->
25+
<android.support.v7.widget.AppCompatTextView
26+
style="@style/VCMI.Text.LauncherSection"
27+
android:text="Launcher authors" />
28+
29+
<android.support.v7.widget.AppCompatTextView
30+
android:id="@+id/dialog_authors_launcher"
31+
style="@style/VCMI.Text"
32+
android:padding="@dimen/side_margin"
33+
android:text="Fay" />
34+
</LinearLayout>
35+
</ScrollView>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
VCMI PROJECT CODE CONTRIBUTORS:
2+
3+
Michał Urbańczyk aka Tow, <[email protected]>
4+
* project originator; programming, making releases, website
5+
maintenance, reverse engineering, general support.
6+
7+
Mateusz B. aka Tow dragon, <[email protected]>
8+
* general support, battle support, support for many Heroes 3 config files, reverse engineering, ERM/VERM parser and interpreter
9+
10+
Stefan Pavlov aka Ste, <[email protected]>
11+
* minor fixes in pregame
12+
13+
Yifeng Sun aka phoebus118, <[email protected]>
14+
* a part of .snd handling, minor fixes and updates
15+
16+
Andrea Palmate aka afxgroup, <[email protected]>
17+
* GCC/AmigaOS4 compatibility updates and makefile
18+
19+
Vadim Glazunov aka neweagle, <[email protected]>
20+
* minor GCC/Linux compatibility changes
21+
22+
Rafal R. aka ambtrip, <[email protected]>
23+
* GeniusAI (battles)
24+
25+
Lukasz Wychrystenko aka tezeriusz, <[email protected]>
26+
* minor GCC/Linux compatibility changes, code review
27+
28+
Xiaomin Ding, <[email protected]>
29+
* smack videos player
30+
31+
Tom Zielinski aka Warmonger, <[email protected]>
32+
* game objects, mechanics
33+
34+
Frank Zago aka ubuntux, <>
35+
* GCC/Linux compatibility changes, sound/music support, video support on Linux
36+
37+
Trevor Standley aka tstandley, <>
38+
* adventure map part of Genius AI
39+
40+
Rickard Westerlund aka Onion Knight, <[email protected]>
41+
* battle functionality and general support
42+
43+
Ivan Savenko, <[email protected]>
44+
* GCC/Linux support, client development, general support
45+
46+
Benjamin Gentner aka beegee, <>
47+
* battle support, programming
48+
49+
Alexey aka Macron1Robot, <>
50+
* minor modding changes
51+
52+
Alexander Shishkin aka alexvins,
53+
* MinGW platform support, modding related programming
54+
55+
Arseniy Shestakov aka SXX, <[email protected]>
56+
* pathfinding improvements, programming
57+
58+
Vadim Markovtsev, <[email protected]>
59+
* resolving problems with macOS, bug fixes

update_internal_assets.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
import hashlib
5+
import shutil
56

67
p = os.path
78

@@ -42,4 +43,10 @@ def createHash(path, outPath):
4243
continue
4344
writeFolder(zf, path[0], path[1])
4445

45-
createHash(pathOutInternalData, pathOutHash)
46+
createHash(pathOutInternalData, pathOutHash)
47+
48+
#copy authors file into app resources so that we can display it in about view
49+
try:
50+
shutil.copy2(dir + "/ext/vcmi/AUTHORS", dir + "/project/vcmi-app/src/main/res/raw/authors.txt")
51+
except IOError as e:
52+
print("Could not update authors file: " + e.strerror)

0 commit comments

Comments
 (0)