diff --git a/build/android/AndroidManifest.xml.template b/build/android/AndroidManifest.xml.template
index c19c92458..3b882ffe8 100644
--- a/build/android/AndroidManifest.xml.template
+++ b/build/android/AndroidManifest.xml.template
@@ -49,7 +49,6 @@
+
\ No newline at end of file
diff --git a/build/android/res/drawable/custom_progress_bar.xml b/build/android/res/drawable/custom_progress_bar.xml
index 29bc3c858..ec233f276 100644
--- a/build/android/res/drawable/custom_progress_bar.xml
+++ b/build/android/res/drawable/custom_progress_bar.xml
@@ -1,14 +1,13 @@
-
-
+ android:endColor="#808080"
+ android:startColor="#808080" />
diff --git a/build/android/res/layout/activity_main.xml b/build/android/res/layout/activity_main.xml
index 26280d297..a910225b9 100644
--- a/build/android/res/layout/activity_main.xml
+++ b/build/android/res/layout/activity_main.xml
@@ -2,7 +2,7 @@
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#000000">
+ android:background="@drawable/bg">
Загрузка…
Загрузка MultiCraft
Осталось меньше минуты…
- Закрыть
Недостаточно места для распаковки.\nОсвободите пространство в памяти устройства!
- OK
Для корректной работы, игре требуется разрешение записывать в память устройтсва.
\ No newline at end of file
diff --git a/build/android/res/values-v21/styles.xml b/build/android/res/values-v21/styles.xml
new file mode 100644
index 000000000..2417cf7ba
--- /dev/null
+++ b/build/android/res/values-v21/styles.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/android/res/values/strings.xml b/build/android/res/values/strings.xml
index 5497f6dfa..bad627b69 100644
--- a/build/android/res/values/strings.xml
+++ b/build/android/res/values/strings.xml
@@ -2,7 +2,7 @@
MultiCraft
- 1.1.2.2
+ 1.1.3
312077575425
@@ -10,11 +10,9 @@
Loading…
Loading MultiCraft
Less than 1 minute…
- Close
Not enough space for unpack game data.\nPlease free some space on the storage memory!
- OK
Game need permission to write files to storage memory.
diff --git a/build/android/res/values/styles.xml b/build/android/res/values/styles.xml
index 8835e1bbc..a127de09a 100644
--- a/build/android/res/values/styles.xml
+++ b/build/android/res/values/styles.xml
@@ -3,11 +3,8 @@
\ No newline at end of file
diff --git a/build/android/src/mobi/MultiCraft/GameActivity.java b/build/android/src/mobi/MultiCraft/GameActivity.java
index 59c1b64a5..ddd4c7f98 100644
--- a/build/android/src/mobi/MultiCraft/GameActivity.java
+++ b/build/android/src/mobi/MultiCraft/GameActivity.java
@@ -9,16 +9,12 @@ import android.view.WindowManager;
public class GameActivity extends NativeActivity {
static {
-
- System.loadLibrary("vorbis");
System.loadLibrary("gmp");
- System.loadLibrary("ssl");
- System.loadLibrary("crypto");
System.loadLibrary("multicraft");
}
- private int m_MessagReturnCode;
- private String m_MessageReturnValue;
+ private int messageReturnCode;
+ private String messageReturnValue;
public static native void putMessageBoxResult(String text);
@@ -27,8 +23,9 @@ public class GameActivity extends NativeActivity {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// startAd(this, true);
- m_MessagReturnCode = -1;
- m_MessageReturnValue = "";
+ messageReturnCode = -1;
+ messageReturnValue = "";
+ makeFullScreen();
}
@@ -69,10 +66,10 @@ public class GameActivity extends NativeActivity {
if (requestCode == 101) {
if (resultCode == RESULT_OK) {
String text = data.getStringExtra("text");
- m_MessagReturnCode = 0;
- m_MessageReturnValue = text;
+ messageReturnCode = 0;
+ messageReturnValue = text;
} else {
- m_MessagReturnCode = 1;
+ messageReturnCode = 1;
}
}
}
@@ -89,17 +86,17 @@ public class GameActivity extends NativeActivity {
params.putInt("editType", editType);
intent.putExtras(params);
startActivityForResult(intent, 101);
- m_MessageReturnValue = "";
- m_MessagReturnCode = -1;
+ messageReturnValue = "";
+ messageReturnCode = -1;
}
public int getDialogState() {
- return m_MessagReturnCode;
+ return messageReturnCode;
}
public String getDialogValue() {
- m_MessagReturnCode = -1;
- return m_MessageReturnValue;
+ messageReturnCode = -1;
+ return messageReturnValue;
}
public float getDensity() {
diff --git a/build/android/src/mobi/MultiCraft/InputDialogActivity.java b/build/android/src/mobi/MultiCraft/InputDialogActivity.java
index 341fb9e31..823dddd3f 100644
--- a/build/android/src/mobi/MultiCraft/InputDialogActivity.java
+++ b/build/android/src/mobi/MultiCraft/InputDialogActivity.java
@@ -1,30 +1,38 @@
package mobi.MultiCraft;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnKeyListener;
+import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public class InputDialogActivity extends Activity {
private AlertDialog alertDialog;
+ @SuppressLint("InflateParams")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
int editType = b.getInt("editType");
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog, null);
builder.setView(dialogView);
final EditText editText = (EditText) dialogView.findViewById(R.id.editText);
+ final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
if (editType == 3) {
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
@@ -34,23 +42,34 @@ public class InputDialogActivity extends Activity {
@Override
public boolean onKey(View view, int KeyCode, KeyEvent event) {
if (KeyCode == KeyEvent.KEYCODE_ENTER) {
+ imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
pushResult(editText.getText().toString());
return true;
}
return false;
}
});
-
alertDialog = builder.create();
alertDialog.show();
+ alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ pushResult(editText.getText().toString());
+ setResult(Activity.RESULT_CANCELED);
+ alertDialog.dismiss();
+ finish();
+ }
+ });
}
public void pushResult(String text) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && text.matches(".*[А-я].*")) {
+ text = Transliteration.toLatin(text);
+ }
Intent resultData = new Intent();
resultData.putExtra("text", text);
setResult(Activity.RESULT_OK, resultData);
alertDialog.dismiss();
finish();
}
-
}
\ No newline at end of file
diff --git a/build/android/src/mobi/MultiCraft/MainActivity.java b/build/android/src/mobi/MultiCraft/MainActivity.java
index 8d7e8a7c4..6dee623b9 100644
--- a/build/android/src/mobi/MultiCraft/MainActivity.java
+++ b/build/android/src/mobi/MultiCraft/MainActivity.java
@@ -24,7 +24,6 @@ import android.widget.ProgressBar;
import android.widget.Toast;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -46,17 +45,10 @@ public class MainActivity extends Activity {
public final static String NOMEDIA = ".nomedia";
private final static int REQUEST_STORAGE = 0;
private ProgressDialog mProgressDialog;
- private String oldDataFolder = "/MultiCraft";
private String dataFolder = "/Android/data/mobi.MultiCraft/files/";
private String unzipLocation = Environment.getExternalStorageDirectory() + dataFolder;
- private String oldUnzipLocation = Environment.getExternalStorageDirectory() + oldDataFolder;
- private String oldWorldLocation = oldUnzipLocation + "/worlds";
- private String oldGamesLocation = oldUnzipLocation + "/games/MultiCraft_game";
- private String newWorldLocation = unzipLocation + "/worlds";
- private String newGamesLocation = unzipLocation + "/games/MultiCraft_game";
private ProgressBar mProgressBar;
private Utilities util;
- private boolean isCopyOld = false;
private BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -66,11 +58,7 @@ public class MainActivity extends Activity {
mProgressBar.setProgress(progress);
} else {
util.createNomedia();
- if (isCopyOld) {
- new CopyFolderTask().execute(new String[]{oldWorldLocation, newWorldLocation}, new String[]{oldGamesLocation, newGamesLocation});
- } else {
- runGame();
- }
+ runGame();
}
}
};
@@ -103,6 +91,14 @@ public class MainActivity extends Activity {
}
}
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ if (hasFocus) {
+ makeFullScreen();
+ }
+ }
+
@Override
protected void onDestroy() {
super.onDestroy();
@@ -237,29 +233,6 @@ public class MainActivity extends Activity {
}
- private class CopyFolderTask extends AsyncTask {
-
- @Override
- protected Void doInBackground(String[]... params) {
- for (String[] p : params) {
- File src = new File(p[0]);
- File dest = new File(p[1]);
- try {
- util.copyDirectory(src, dest);
- } catch (IOException e) {
- Log.e(TAG, "copy failed: " + e.getMessage());
- }
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(Void aVoid) {
- util.deleteFiles(oldUnzipLocation);
- runGame();
- }
- }
-
private class CopyZip extends AsyncTask {
String[] zips;
@@ -317,17 +290,6 @@ public class MainActivity extends Activity {
private class Utilities {
- /*
- * private void createLangFile() { PrintWriter writer; try { writer =
- * new PrintWriter(unzipLocation + "lang.txt", "UTF-8"); if
- * ("Russian".equals(Locale.getDefault().getDisplayLanguage())) {
- * writer.println("ru"); } else { writer.println("en"); }
- * writer.close(); } catch (Exception e) { Log.e(TAG,
- * e.getLocalizedMessage()); }
- *
- * }
- */
-
private void createDataFolder() {
File folder = new File(unzipLocation);
if (!(folder.exists()))
@@ -371,13 +333,9 @@ public class MainActivity extends Activity {
}
public void checkVersion() {
- if (isFolderEmpty(oldUnzipLocation) && isFolderEmpty(unzipLocation)) {
+ if (isFolderEmpty(unzipLocation)) {
saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
startDeletion(true);
- } else if (!isFolderEmpty(oldUnzipLocation)) {
- saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
- isCopyOld = true;
- startDeletion(true);
} else if (getBuildNumber().equals(getString(R.string.ver))) {
runGame();
} else {
@@ -386,40 +344,6 @@ public class MainActivity extends Activity {
}
}
- public void copyDirectory(File sourceLocation, File targetLocation)
- throws IOException {
-
- if (sourceLocation.isDirectory()) {
- if (!targetLocation.exists() && !targetLocation.mkdirs()) {
- throw new IOException("Cannot create dir " + targetLocation.getAbsolutePath());
- }
-
- String[] children = sourceLocation.list();
- for (String aChildren : children) {
- copyDirectory(new File(sourceLocation, aChildren),
- new File(targetLocation, aChildren));
- }
- } else {
- // make sure the directory we plan to store the recording in exists
- File directory = targetLocation.getParentFile();
- if (directory != null && !directory.exists() && !directory.mkdirs()) {
- throw new IOException("Cannot create dir " + directory.getAbsolutePath());
- }
-
- InputStream in = new FileInputStream(sourceLocation);
- OutputStream out = new FileOutputStream(targetLocation);
-
- // Copy the bits from in stream to out stream
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
- }
-
private void deleteFiles(String path) {
File file = new File(path);
if (file.exists()) {
diff --git a/build/android/src/mobi/MultiCraft/Transliteration.java b/build/android/src/mobi/MultiCraft/Transliteration.java
new file mode 100644
index 000000000..27ceeb1bb
--- /dev/null
+++ b/build/android/src/mobi/MultiCraft/Transliteration.java
@@ -0,0 +1,72 @@
+package mobi.MultiCraft;
+
+public class Transliteration {
+
+ private static final String[] CHAR_TABLE = new String[81];
+ private static final char START_CHAR = 'Ё';
+
+
+ static {
+ CHAR_TABLE['А' - START_CHAR] = "A";
+ CHAR_TABLE['Б' - START_CHAR] = "B";
+ CHAR_TABLE['В' - START_CHAR] = "V";
+ CHAR_TABLE['Г' - START_CHAR] = "G";
+ CHAR_TABLE['Д' - START_CHAR] = "D";
+ CHAR_TABLE['Е' - START_CHAR] = "E";
+ CHAR_TABLE['Ё' - START_CHAR] = "E";
+ CHAR_TABLE['Ж' - START_CHAR] = "ZH";
+ CHAR_TABLE['З' - START_CHAR] = "Z";
+ CHAR_TABLE['И' - START_CHAR] = "I";
+ CHAR_TABLE['Й' - START_CHAR] = "J";
+ CHAR_TABLE['К' - START_CHAR] = "K";
+ CHAR_TABLE['Л' - START_CHAR] = "L";
+ CHAR_TABLE['М' - START_CHAR] = "M";
+ CHAR_TABLE['Н' - START_CHAR] = "N";
+ CHAR_TABLE['О' - START_CHAR] = "O";
+ CHAR_TABLE['П' - START_CHAR] = "P";
+ CHAR_TABLE['Р' - START_CHAR] = "R";
+ CHAR_TABLE['С' - START_CHAR] = "TS";
+ CHAR_TABLE['Т' - START_CHAR] = "T";
+ CHAR_TABLE['У' - START_CHAR] = "U";
+ CHAR_TABLE['Ф' - START_CHAR] = "F";
+ CHAR_TABLE['Х' - START_CHAR] = "H";
+ CHAR_TABLE['Ц' - START_CHAR] = "C";
+ CHAR_TABLE['Ч' - START_CHAR] = "CH";
+ CHAR_TABLE['Ш' - START_CHAR] = "SH";
+ CHAR_TABLE['Щ' - START_CHAR] = "SHCH";
+ CHAR_TABLE['Ъ' - START_CHAR] = "";
+ CHAR_TABLE['Ы' - START_CHAR] = "Y";
+ CHAR_TABLE['Ь' - START_CHAR] = "";
+ CHAR_TABLE['Э' - START_CHAR] = "E";
+ CHAR_TABLE['Ю' - START_CHAR] = "U";
+ CHAR_TABLE['Я' - START_CHAR] = "YA";
+
+ for (int i = 0; i < CHAR_TABLE.length; i++) {
+ char idx = (char) ((char) i + START_CHAR);
+ char lower = new String(new char[]{idx}).toLowerCase().charAt(0);
+ if (CHAR_TABLE[i] != null) {
+ CHAR_TABLE[lower - START_CHAR] = CHAR_TABLE[i].toLowerCase();
+ }
+ }
+ }
+
+ /**
+ * Переводит русский текст в транслит. В результирующей строке
+ * каждая русская буква будет заменена на соответствующую английскую.
+ * Не русские символы останутся прежними.
+ */
+ public static String toLatin(String text) {
+ char charBuffer[] = text.toCharArray();
+ StringBuilder sb = new StringBuilder(text.length());
+ for (char symbol : charBuffer) {
+ int i = symbol - START_CHAR;
+ if (i >= 0 && i < CHAR_TABLE.length) {
+ String replace = CHAR_TABLE[i];
+ sb.append(replace == null ? symbol : replace);
+ } else {
+ sb.append(symbol);
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/build/android/src/mobi/MultiCraft/UnzipService.java b/build/android/src/mobi/MultiCraft/UnzipService.java
index 0ad0d8723..d3add5abe 100644
--- a/build/android/src/mobi/MultiCraft/UnzipService.java
+++ b/build/android/src/mobi/MultiCraft/UnzipService.java
@@ -29,7 +29,7 @@ public class UnzipService extends IntentService {
super("mobi.MultiCraft.UnzipService");
}
- private void _dirChecker(String dir, String unzipLocation) {
+ private void isDir(String dir, String unzipLocation) {
File f = new File(unzipLocation + dir);
if (!f.isDirectory()) {
@@ -48,11 +48,9 @@ public class UnzipService extends IntentService {
mNotifyManager.notify(id, mBuilder.build());
int per = 0;
+ int size = getSummarySize(file);
for (String f : file) {
try {
-
- ZipFile zipSize = new ZipFile(f);
-
try {
FileInputStream fin = new FileInputStream(f);
ZipInputStream zin = new ZipInputStream(fin);
@@ -60,10 +58,10 @@ public class UnzipService extends IntentService {
while ((ze = zin.getNextEntry()) != null) {
if (ze.isDirectory()) {
per++;
- _dirChecker(ze.getName(), location);
+ isDir(ze.getName(), location);
} else {
per++;
- int progress = 100 * per / zipSize.size();
+ int progress = 100 * per / size;
// send update
publishProgress(progress);
FileOutputStream f_out = new FileOutputStream(location + ze.getName());
@@ -79,7 +77,7 @@ public class UnzipService extends IntentService {
}
zin.close();
} catch (FileNotFoundException e) {
- Log.e(TAG, e.getMessage(), e.fillInStackTrace());
+ Log.e(TAG, e.getMessage());
}
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage());
@@ -93,10 +91,23 @@ public class UnzipService extends IntentService {
sendBroadcast(intentUpdate);
}
+ private int getSummarySize(String[] zips) {
+ int size = 0;
+ for (String z : zips) {
+ try {
+ ZipFile zipSize = new ZipFile(z);
+ size += zipSize.size();
+ } catch (IOException e) {
+ Log.e(TAG, e.getLocalizedMessage());
+ }
+ }
+ return size;
+ }
+
@Override
public void onDestroy() {
super.onDestroy();
mNotifyManager.cancel(id);
publishProgress(-1);
}
-}
+}
\ No newline at end of file