Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 43c5c36

Browse files
author
Mitch Talmadge
committed
Added Copyright notice, began writing tests
1 parent 5601fe2 commit 43c5c36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+903
-35
lines changed

Emoji-Tools.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
<orderEntry type="library" name="Maven: org.python:jython-standalone:2.7.0" level="project" />
1717
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
1818
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
19+
<orderEntry type="module-library" scope="TEST">
20+
<library name="JUnit4">
21+
<CLASSES>
22+
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
23+
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
24+
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
25+
</CLASSES>
26+
<JAVADOC />
27+
<SOURCES />
28+
</library>
29+
</orderEntry>
1930
</component>
2031
<component name="org.twodividedbyzero.idea.findbugs">
2132
<option name="_basePreferences">

src/main/java/com/AptiTekk/AptiAPI/AptiAPI.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.InputStreamReader;
77
import java.net.HttpURLConnection;
88
import java.net.URL;
9+
import java.net.UnknownHostException;
910
import java.nio.charset.StandardCharsets;
1011
import java.util.ArrayList;
1112

@@ -15,16 +16,14 @@ public class AptiAPI {
1516
private static final String API_VERSION = "V1";
1617
private static final String TOKEN_GENERATOR = "TokenGenerator.php";
1718
private static final String ERROR_REPORTER = "ErrorReporter.php";
18-
19+
protected final ArrayList<AptiAPIListener> APIListeners = new ArrayList<>();
1920
private final int projectID;
2021

21-
private final ArrayList<AptiAPIListener> APIListeners = new ArrayList<>();
22-
2322
public AptiAPI(int projectID) {
2423
this.projectID = projectID;
2524
}
2625

27-
public void sendErrorReport(String report) {
26+
public boolean sendErrorReport(String report) {
2827

2928
try {
3029

@@ -33,20 +32,20 @@ public void sendErrorReport(String report) {
3332

3433
if (tokenResponse == null) {
3534
displayError("Could not generate token -- Null response!");
36-
return;
35+
return false;
3736
}
3837

3938
System.out.println("Response: " + tokenResponse);
4039

4140
String[] responseSplit = tokenResponse.split(":");
4241
if (responseSplit.length < 3) {
4342
displayError("Token response length is < 3!");
44-
return;
43+
return false;
4544
}
4645

4746
if (responseSplit[1].equals("FAILURE")) {
4847
displayError("Could not submit report: " + responseSplit[2]);
49-
return;
48+
return false;
5049
}
5150

5251
String token = responseSplit[2];
@@ -60,20 +59,20 @@ public void sendErrorReport(String report) {
6059
displayError("Could not submit report: Null response");
6160
}
6261

63-
System.out.println("Response: " + errorReportResponse);
64-
6562
responseSplit = tokenResponse.split(":");
6663
if (responseSplit.length < 2) {
6764
displayError("Could not submit report: Token response length is < 2");
68-
return;
65+
return false;
6966
}
7067

7168
if (responseSplit[1].equals("FAILURE")) {
7269
displayError("Could not submit report: " + responseSplit[2]);
70+
return false;
7371
}
7472
} catch (Exception e) {
7573
e.printStackTrace();
7674
}
75+
return true;
7776
}
7877

7978
public void addAPIListener(AptiAPIListener listener) {
@@ -120,11 +119,6 @@ private String POSTData(String url, String data) {
120119
wr.flush();
121120
wr.close();
122121

123-
int responseCode = con.getResponseCode();
124-
System.out.println("\nSending 'POST' request to URL : " + url);
125-
System.out.println("Post parameters : " + data);
126-
System.out.println("Response Code : " + responseCode);
127-
128122
BufferedReader in = new BufferedReader(
129123
new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8));
130124
String inputLine;
@@ -136,6 +130,9 @@ private String POSTData(String url, String data) {
136130
in.close();
137131

138132
return response.toString();
133+
} catch (UnknownHostException e) {
134+
displayError("Could not connect to Error Reporter. Is your Internet working?");
135+
System.exit(0);
139136
} catch (IOException e) {
140137
e.printStackTrace();
141138
}

src/main/java/com/AptiTekk/AptiAPI/AptiCrypto.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ public String bytesToHex(byte[] data) {
4646
}
4747
}
4848

49+
public byte[] hexToBytes(String str) {
50+
if (str == null) {
51+
return null;
52+
} else if (str.length() < 2) {
53+
return null;
54+
} else {
55+
int len = str.length() / 2;
56+
byte[] buffer = new byte[len];
57+
for (int i = 0; i < len; i++) {
58+
buffer[i] = (byte) Integer.parseInt(
59+
str.substring(i * 2, i * 2 + 2), 16);
60+
}
61+
return buffer;
62+
}
63+
}
64+
4965
public String encrypt(String plainData) throws Exception {
5066

5167
// Make sure the plainData length should be multiple with 16
@@ -63,4 +79,12 @@ public String encrypt(String plainData) throws Exception {
6379
return bytesToHex(encrypted);
6480
}
6581

82+
public String decrypt(String encrData) throws Exception {
83+
this.cipher.init(Cipher.DECRYPT_MODE, this.keySpec, this.ivSpec);
84+
byte[] outText = this.cipher.doFinal(hexToBytes(encrData));
85+
86+
String decrData = new String(outText).trim();
87+
return decrData;
88+
}
89+
6690
}

src/main/java/me/MitchT/EmojiTools/ConsoleManager.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
package me.MitchT.EmojiTools;
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
220

3-
import com.sun.istack.internal.NotNull;
21+
package me.MitchT.EmojiTools;
422

523
import java.io.IOException;
624
import java.io.OutputStream;
@@ -20,6 +38,7 @@ public ConsoleManager() {
2038
this.originalErrStream = new PrintStream(System.err);
2139

2240
this.outStream = new OutputStream() {
41+
2342
@Override
2443
public void write(final int b) throws IOException {
2544
for (ConsoleListener listener : consoleListeners) {
@@ -29,7 +48,6 @@ public void write(final int b) throws IOException {
2948
}
3049

3150
@Override
32-
@NotNull
3351
public void write(byte[] b, int off, int len) throws IOException {
3452
for (ConsoleListener listener : consoleListeners) {
3553
listener.write(new String(b, off, len));
@@ -38,7 +56,6 @@ public void write(byte[] b, int off, int len) throws IOException {
3856
}
3957

4058
@Override
41-
@NotNull
4259
public void write(byte[] b) throws IOException {
4360
write(b, 0, b.length);
4461
}
@@ -54,7 +71,6 @@ public void write(final int b) throws IOException {
5471
}
5572

5673
@Override
57-
@NotNull
5874
public void write(byte[] b, int off, int len) throws IOException {
5975
for (ConsoleListener listener : consoleListeners) {
6076
listener.write(new String(b, off, len));
@@ -63,7 +79,6 @@ public void write(byte[] b, int off, int len) throws IOException {
6379
}
6480

6581
@Override
66-
@NotNull
6782
public void write(byte[] b) throws IOException {
6883
write(b, 0, b.length);
6984
}

src/main/java/me/MitchT/EmojiTools/Conversion/ConversionManager.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion;
222

323
import me.MitchT.EmojiTools.GUI.ConversionDialog;

src/main/java/me/MitchT/EmojiTools/Conversion/ConversionThread.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion;
222

323
import me.MitchT.EmojiTools.Conversion.Converter.Converter;

src/main/java/me/MitchT/EmojiTools/Conversion/Converter/Converter.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion.Converter;
222

323
import com.jcraft.jzlib.Deflater;

src/main/java/me/MitchT/EmojiTools/Conversion/Converter/PNGChunk.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion.Converter;
222

323
import java.io.DataInputStream;

src/main/java/me/MitchT/EmojiTools/Conversion/Converter/PNGFilterHandler.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion.Converter;
222

323
public class PNGFilterHandler {

src/main/java/me/MitchT/EmojiTools/Conversion/Converter/PNGIHDRChunk.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* Emoji Tools helps users and developers of Android, iOS, and OS X extract, modify, and repackage Emoji fonts.
3+
* Copyright (C) 2015 Mitch Talmadge
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* Contact Mitch Talmadge at mitcht@liveforcode.net
19+
*/
20+
121
package me.MitchT.EmojiTools.Conversion.Converter;
222

323
public class PNGIHDRChunk extends PNGChunk {

0 commit comments

Comments
 (0)