Merge branch 'master' of https://github.com/MultiCraftProject/MultiCraftPrivate with 15/15 changes
This commit is contained in:
commit
6ab679d710
37
build/android/res/layout/dialog_template.xml
Normal file
37
build/android/res/layout/dialog_template.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@android:color/white" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
style="?android:attr/buttonBarStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/negative"
|
||||||
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="@android:color/white" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/positive"
|
||||||
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="@android:color/white" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingBottom="2dip"
|
|
||||||
android:paddingLeft="12dip"
|
|
||||||
android:paddingRight="12dip"
|
|
||||||
android:paddingTop="6dip">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingBottom="4dip"
|
|
||||||
android:text="@string/dialog_instruction" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/rta_message"
|
android:id="@+id/rta_message"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/rta_dialog_title"
|
android:layout_gravity="center"
|
||||||
android:layout_gravity="center" />
|
android:text="@string/rta_dialog_title" />
|
||||||
|
|
||||||
<RatingBar
|
<RatingBar
|
||||||
android:id="@+id/ratingBar"
|
android:id="@+id/ratingBar"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
android:numStars="5"
|
android:numStars="5"
|
||||||
android:stepSize="1.0" />
|
android:stepSize="1.0" />
|
||||||
|
|
||||||
@ -31,11 +31,11 @@
|
|||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:cursorVisible="false"
|
android:cursorVisible="false"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:focusableInTouchMode="false"
|
android:focusableInTouchMode="false"
|
||||||
android:layout_height="64dp"
|
|
||||||
android:hint="@string/rate_description" />
|
android:hint="@string/rate_description" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -43,8 +43,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:enabled="false"
|
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:textColor="#00ced1"
|
android:enabled="false"
|
||||||
android:text="@string/rate_submit" />
|
android:text="@string/rate_submit"
|
||||||
|
android:textColor="#00ced1" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -6,8 +6,8 @@
|
|||||||
<string name="warning">Во время загрузки не закрывайте приложение. \nИгра запустится через несколько секунд…</string>
|
<string name="warning">Во время загрузки не закрывайте приложение. \nИгра запустится через несколько секунд…</string>
|
||||||
<string name="rm_old">Подготовка к обновлению…</string>
|
<string name="rm_old">Подготовка к обновлению…</string>
|
||||||
<string name="copy">Копирование…</string>
|
<string name="copy">Копирование…</string>
|
||||||
<string name="notification_title">Загрузка</string>
|
<string name="notification_title">Загрузка MultiCraft</string>
|
||||||
<string name="notification_description">Загрузка файлов игры…</string>
|
<string name="notification_description">Осталось меньше минуты…</string>
|
||||||
|
|
||||||
<!-- диалог оценки -->
|
<!-- диалог оценки -->
|
||||||
<string name="rta_dialog_title">Оцените MultiCraft Beta — Бесплатный Майнер!</string>
|
<string name="rta_dialog_title">Оцените MultiCraft Beta — Бесплатный Майнер!</string>
|
||||||
@ -29,8 +29,8 @@
|
|||||||
<string name="update_ignore">Игнорировать</string>
|
<string name="update_ignore">Игнорировать</string>
|
||||||
|
|
||||||
<!-- инструкция -->
|
<!-- инструкция -->
|
||||||
<string name="dialog_instruction">Привет! После загрузки игры нажмите Play.\nЧтобы поставить блок, быстро тапните 2 раза там, куда хотите его поставить!\nЧтобы разъединить блоки в инвентаре, возьмите блок в руку и одновременно прикоснитесь пальцами к двум ячейкам. Вставится половина стопки. Нажмите на другую ячейку и вставится вторая половина!</string>
|
<string name="dialog_instruction">Привет! После загрузки игры нажмите Play.\nЧтобы поставить блок, нажмите на экран.\nЧтобы разрушить блок, удерживайте палец на экране.</string>
|
||||||
<string name="ok">Понял</string>
|
<string name="ok">Закрыть</string>
|
||||||
<string name="forget">Не напоминать</string>
|
<string name="forget">Не напоминать</string>
|
||||||
|
|
||||||
<!-- недостаточно места -->
|
<!-- недостаточно места -->
|
||||||
|
4
build/android/res/values/color.xml
Normal file
4
build/android/res/values/color.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="semi_transparent">#80000000</color>
|
||||||
|
</resources>
|
@ -13,27 +13,27 @@
|
|||||||
|
|
||||||
<!-- preparation for start -->
|
<!-- preparation for start -->
|
||||||
<string name="loading">Loading…</string>
|
<string name="loading">Loading…</string>
|
||||||
<string name="warning">Do not stop the application while it is unpacking or updating. The game will start in few seconds.…</string>
|
<string name="warning">When unpacking, do not wrap application.\nGame will start in few second…</string>
|
||||||
<string name="rm_old">Preparing to update…</string>
|
<string name="rm_old">Preparing to update…</string>
|
||||||
<string name="copy">Copying…</string>
|
<string name="copy">Copying…</string>
|
||||||
<string name="notification_title">Downloading</string>
|
<string name="notification_title">Downloading MultiCraft</string>
|
||||||
<string name="notification_description">Downloading game data…</string>
|
<string name="notification_description">Less than 1 minute…</string>
|
||||||
|
|
||||||
<!-- weak phone dialog -->
|
<!-- weak phone dialog -->
|
||||||
<string name="memory_title">Warning!</string>
|
<string name="memory_title">Warning!</string>
|
||||||
<string name="memory_warning">Your device\'s memory is too low for seamless playing</string>
|
<string name="memory_warning">Your device\'s memory is too low for seamless playing</string>
|
||||||
<string name="memory_continue">Continue</string>
|
<string name="memory_continue">Continue</string>
|
||||||
<string name="memory_close">Close</string>
|
<string name="memory_close">Close</string>
|
||||||
<string name="memory_lags">Lag is possible. Please don\'t rate this game badly.</string>
|
<string name="memory_lags">Lags are possible. Please don\'t rate this game badly.</string>
|
||||||
|
|
||||||
<!-- update dialog -->
|
<!-- update dialog -->
|
||||||
<string name="update_yes">An update is available!</string>
|
<string name="update_yes">Update now!</string>
|
||||||
<string name="update_no">Remind me later…</string>
|
<string name="update_no">Remind me later…</string>
|
||||||
<string name="update_ignore">Ignore</string>
|
<string name="update_ignore">Ignore</string>
|
||||||
|
|
||||||
<!-- instruction dialog -->
|
<!-- instruction dialog -->
|
||||||
<string name="dialog_instruction">Hello! After loading, select the world and press Play. \nTo place an item, tap and release where you want to put it (or quickly tap twice).\nTo split blocks inside inventory take the block and simultaneously touch the two cells; the first half will be inserted on first cell. Click on another cell for inserting the second half</string>
|
<string name="dialog_instruction">Hello! After game loading select the world and press Play. \nTo put a block tap on screen.\nTo destroy a block long tap on screen.</string>
|
||||||
<string name="ok">Got it</string>
|
<string name="ok">Close</string>
|
||||||
<string name="forget">Don\'t remind</string>
|
<string name="forget">Don\'t remind</string>
|
||||||
|
|
||||||
<!-- free space dialog -->
|
<!-- free space dialog -->
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.MoNTE48.MultiCraft;
|
package com.MoNTE48.MultiCraft;
|
||||||
|
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.TAG_SHORTCUT_CREATED;
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.isCreateShortcut;
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.saveSettings;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -14,7 +18,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -28,7 +31,6 @@ import android.widget.TextView;
|
|||||||
import com.MoNTE48.MultiCraft.Utilities.IUtilitiesCallback;
|
import com.MoNTE48.MultiCraft.Utilities.IUtilitiesCallback;
|
||||||
|
|
||||||
public class MainActivity extends Activity implements IUtilitiesCallback {
|
public class MainActivity extends Activity implements IUtilitiesCallback {
|
||||||
public static final String SHORTCUT_NAME = "shortcut";
|
|
||||||
private final String TAG = MainActivity.class.getName();
|
private final String TAG = MainActivity.class.getName();
|
||||||
public final String FILES = "Files.zip";
|
public final String FILES = "Files.zip";
|
||||||
public final String NOMEDIA = ".nomedia";
|
public final String NOMEDIA = ".nomedia";
|
||||||
@ -49,18 +51,13 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
util = new Utilities(this);
|
util = new Utilities(this);
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
registerReceivers();
|
registerReceivers();
|
||||||
SharedPreferences settings = getSharedPreferences(SHORTCUT_NAME, 0);
|
|
||||||
boolean doNotExecute = settings.getBoolean("doNotExecute", false);
|
|
||||||
if (!doNotExecute)
|
|
||||||
addShortcut();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
if (util.getTotalMemoryInMB() < 800 || util.getCoresCount() < 2) {
|
if (util.getTotalMemoryInMB() < 800 || util.getCoresCount() < 2) {
|
||||||
util.showMemoryDialog(MainActivity.this);
|
util.showMemoryDialog();
|
||||||
} else {
|
} else {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -80,10 +77,7 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addShortcut() {
|
private void addShortcut() {
|
||||||
SharedPreferences settings = getSharedPreferences(SHORTCUT_NAME, 0);
|
saveSettings(this, TAG_SHORTCUT_CREATED, false);
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
|
||||||
editor.putBoolean("doNotExecute", true);
|
|
||||||
editor.apply();
|
|
||||||
Intent shortcutIntent = new Intent(getApplicationContext(),
|
Intent shortcutIntent = new Intent(getApplicationContext(),
|
||||||
MainActivity.class);
|
MainActivity.class);
|
||||||
shortcutIntent.setAction(Intent.ACTION_MAIN);
|
shortcutIntent.setAction(Intent.ACTION_MAIN);
|
||||||
@ -100,6 +94,9 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void init() {
|
public void init() {
|
||||||
|
PreferencesHelper.loadSettings(this);
|
||||||
|
if (isCreateShortcut())
|
||||||
|
addShortcut();
|
||||||
mProgressTextView = (TextView) findViewById(R.id.progress_textView);
|
mProgressTextView = (TextView) findViewById(R.id.progress_textView);
|
||||||
mProgressBar = (ProgressBar) findViewById(R.id.PB1);
|
mProgressBar = (ProgressBar) findViewById(R.id.PB1);
|
||||||
Drawable draw;
|
Drawable draw;
|
||||||
@ -116,6 +113,11 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
checkVersion();
|
checkVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishMe() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
private void registerReceivers() {
|
private void registerReceivers() {
|
||||||
myBroadcastReceiver = new MyBroadcastReceiver();
|
myBroadcastReceiver = new MyBroadcastReceiver();
|
||||||
myBroadcastReceiver_Update = new MyBroadcastReceiver_Update();
|
myBroadcastReceiver_Update = new MyBroadcastReceiver_Update();
|
||||||
@ -153,7 +155,7 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
+ "games/MultiCraft II", unzipLocation + "tmp");
|
+ "games/MultiCraft II", unzipLocation + "tmp");
|
||||||
break;
|
break;
|
||||||
case CURRENT:
|
case CURRENT:
|
||||||
startBetweenActivity();
|
startNativeActivity();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -162,7 +164,7 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startBetweenActivity() {
|
private void startNativeActivity() {
|
||||||
showSpinnerDialog(R.string.loading);
|
showSpinnerDialog(R.string.loading);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -197,7 +199,7 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String result = intent.getStringExtra(UnzipService.EXTRA_KEY_OUT);
|
String result = intent.getStringExtra(UnzipService.EXTRA_KEY_OUT);
|
||||||
if ("Success".equals(result))
|
if ("Success".equals(result))
|
||||||
startBetweenActivity();
|
startNativeActivity();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +281,7 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
util.showNotEnoughSpaceDialog(MainActivity.this);
|
util.showNotEnoughSpaceDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAssets(String zipName) {
|
private void copyAssets(String zipName) {
|
||||||
@ -311,9 +313,9 @@ public class MainActivity extends Activity implements IUtilitiesCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
dismissProgressDialog();
|
dismissProgressDialog();
|
||||||
unregisterReceiver(myBroadcastReceiver);
|
unregisterReceiver(myBroadcastReceiver);
|
||||||
unregisterReceiver(myBroadcastReceiver_Update);
|
unregisterReceiver(myBroadcastReceiver_Update);
|
||||||
super.onDestroy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.MoNTE48.MultiCraft;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class PreferencesHelper {
|
||||||
|
private static final String SETTINGS = "settings";
|
||||||
|
public static final String TAG_SHORTCUT_CREATED = "createShortcut";
|
||||||
|
public static final String TAG_HELP_SHOWED = "showHelp";
|
||||||
|
private static boolean createShortcut, showHelp;
|
||||||
|
|
||||||
|
public static boolean isCreateShortcut() {
|
||||||
|
return createShortcut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isShowHelp() {
|
||||||
|
return showHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadSettings(Context c) {
|
||||||
|
|
||||||
|
SharedPreferences settings = c.getSharedPreferences(SETTINGS,
|
||||||
|
Context.MODE_PRIVATE);
|
||||||
|
if (settings.getAll().size() == 0) {
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.clear();
|
||||||
|
editor.commit();
|
||||||
|
createShortcut = true;
|
||||||
|
showHelp = true;
|
||||||
|
} else {
|
||||||
|
createShortcut = settings.getBoolean(TAG_SHORTCUT_CREATED, true);
|
||||||
|
showHelp = settings.getBoolean(TAG_HELP_SHOWED, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveSettings(Context c, String tag, boolean bool) {
|
||||||
|
SharedPreferences settings = c.getSharedPreferences(SETTINGS,
|
||||||
|
Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putBoolean(tag, bool);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,6 @@ public class UnzipService extends IntentService {
|
|||||||
String file = intent.getStringExtra(EXTRA_KEY_IN_FILE);
|
String file = intent.getStringExtra(EXTRA_KEY_IN_FILE);
|
||||||
String location = intent.getStringExtra(EXTRA_KEY_IN_LOCATION);
|
String location = intent.getStringExtra(EXTRA_KEY_IN_LOCATION);
|
||||||
// Displays the progress bar for the first time.
|
// Displays the progress bar for the first time.
|
||||||
mBuilder.setProgress(100, 0, false);
|
|
||||||
int id = 1;
|
int id = 1;
|
||||||
mNotifyManager.notify(id, mBuilder.build());
|
mNotifyManager.notify(id, mBuilder.build());
|
||||||
int per = 0;
|
int per = 0;
|
||||||
@ -71,8 +70,7 @@ public class UnzipService extends IntentService {
|
|||||||
intentUpdate.addCategory(Intent.CATEGORY_DEFAULT);
|
intentUpdate.addCategory(Intent.CATEGORY_DEFAULT);
|
||||||
intentUpdate.putExtra(EXTRA_KEY_UPDATE, progress);
|
intentUpdate.putExtra(EXTRA_KEY_UPDATE, progress);
|
||||||
sendBroadcast(intentUpdate);
|
sendBroadcast(intentUpdate);
|
||||||
mBuilder.setProgress(100, progress, false);
|
// mNotifyManager.notify(id, mBuilder.build());
|
||||||
mNotifyManager.notify(id, mBuilder.build());
|
|
||||||
FileOutputStream f_out = new FileOutputStream(location
|
FileOutputStream f_out = new FileOutputStream(location
|
||||||
+ ze.getName());
|
+ ze.getName());
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
@ -93,9 +91,6 @@ public class UnzipService extends IntentService {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, e.getLocalizedMessage());
|
Log.e(TAG, e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
// mBuilder.setContentText(getString(R.string.complete));
|
|
||||||
// mBuilder.setProgress(0, 0, false);
|
|
||||||
// mNotifyManager.notify(id, mBuilder.build());
|
|
||||||
mNotifyManager.cancel(id);
|
mNotifyManager.cancel(id);
|
||||||
Intent intentResponse = new Intent();
|
Intent intentResponse = new Intent();
|
||||||
intentResponse.setAction(ACTION_MyIntentService);
|
intentResponse.setAction(ACTION_MyIntentService);
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.MoNTE48.MultiCraft;
|
package com.MoNTE48.MultiCraft;
|
||||||
|
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.TAG_HELP_SHOWED;
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.isShowHelp;
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.saveSettings;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
@ -11,16 +15,18 @@ import mobi.MultiCraft.R;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.MoNTE48.RateME.RateThisApp;
|
import com.MoNTE48.RateME.RateThisApp;
|
||||||
@ -30,22 +36,25 @@ import com.winsontan520.wversionmanager.library.WVersionManager;
|
|||||||
* Helpful utilities used in MainActivity
|
* Helpful utilities used in MainActivity
|
||||||
*/
|
*/
|
||||||
public class Utilities {
|
public class Utilities {
|
||||||
|
private Button positive, negative;
|
||||||
|
private Dialog dialog;
|
||||||
|
|
||||||
public enum VERSIONS {
|
public enum VERSIONS {
|
||||||
CURRENT, OLD
|
CURRENT, OLD
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String TAG = Utilities.class.getName();
|
private final String TAG = Utilities.class.getName();
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
public static final String PREFS_NAME = "ShowFirstTime";
|
|
||||||
|
|
||||||
public final String STABLE_VER = "1.0.1";
|
public final String STABLE_VER = "1.0.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for MainActivity init method
|
* Callback for MainActivity init and finishMe methods
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface IUtilitiesCallback {
|
public interface IUtilitiesCallback {
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
void finishMe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IUtilitiesCallback callerActivity;
|
private IUtilitiesCallback callerActivity;
|
||||||
@ -55,38 +64,45 @@ public class Utilities {
|
|||||||
callerActivity = (IUtilitiesCallback) activity;
|
callerActivity = (IUtilitiesCallback) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dialogInit(int panel, int positiveBtn, int negativeBtn,
|
||||||
|
int messageText) {
|
||||||
|
dialog = new Dialog(mContext);
|
||||||
|
dialog.requestWindowFeature(panel);
|
||||||
|
dialog.setContentView(R.layout.dialog_template);
|
||||||
|
positive = (Button) dialog.findViewById(R.id.positive);
|
||||||
|
negative = (Button) dialog.findViewById(R.id.negative);
|
||||||
|
TextView message = (TextView) dialog.findViewById(R.id.message);
|
||||||
|
positive.setText(positiveBtn);
|
||||||
|
negative.setText(negativeBtn);
|
||||||
|
message.setText(messageText);
|
||||||
|
dialog.setCancelable(false);
|
||||||
|
dialog.getWindow().setBackgroundDrawable(
|
||||||
|
new ColorDrawable(R.color.semi_transparent));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
public void showHelpDialog() {
|
public void showHelpDialog() {
|
||||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
dialogInit(Window.FEATURE_NO_TITLE, R.string.ok, R.string.forget,
|
||||||
View messageView = inflater.inflate(R.layout.instruction_dialog, null,
|
R.string.dialog_instruction);
|
||||||
false);
|
positive.setOnClickListener(new OnClickListener() {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
|
||||||
builder.setView(messageView);
|
|
||||||
builder.setPositiveButton(R.string.ok,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
|
dialog.dismiss();
|
||||||
RateThisApp.showRateDialogIfNeeded(mContext);
|
RateThisApp.showRateDialogIfNeeded(mContext);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.forget,
|
negative.setOnClickListener(new OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
String checkBoxResult = "checked";
|
dialog.dismiss();
|
||||||
SharedPreferences settings = mContext
|
saveSettings(mContext, TAG_HELP_SHOWED, false);
|
||||||
.getSharedPreferences(PREFS_NAME, 0);
|
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
|
||||||
editor.putString("skipMessage", checkBoxResult);
|
|
||||||
editor.apply();
|
|
||||||
RateThisApp.showRateDialogIfNeeded(mContext);
|
RateThisApp.showRateDialogIfNeeded(mContext);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
SharedPreferences settings = mContext.getSharedPreferences(PREFS_NAME,
|
if (isShowHelp()) {
|
||||||
0);
|
dialog.show();
|
||||||
String skipMessage = settings.getString("skipMessage", "NOT checked");
|
}
|
||||||
if (!"checked".equalsIgnoreCase(skipMessage))
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showVersionDialog() {
|
public void showVersionDialog() {
|
||||||
@ -103,43 +119,43 @@ public class Utilities {
|
|||||||
.getResources().getText(R.string.update_ignore));
|
.getResources().getText(R.string.update_ignore));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMemoryDialog(final Activity activity) {
|
public void showMemoryDialog() {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
dialogInit(Window.FEATURE_OPTIONS_PANEL, R.string.memory_continue,
|
||||||
builder.setTitle(R.string.memory_title);
|
R.string.memory_close, R.string.memory_warning);
|
||||||
builder.setMessage(R.string.memory_warning);
|
positive.setOnClickListener(new OnClickListener() {
|
||||||
builder.setPositiveButton(R.string.memory_continue,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
|
dialog.dismiss();
|
||||||
Toast.makeText(mContext, R.string.memory_lags,
|
Toast.makeText(mContext, R.string.memory_lags,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
callerActivity.init();
|
callerActivity.init();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.memory_close,
|
negative.setOnClickListener(new OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
activity.finish();
|
dialog.dismiss();
|
||||||
|
callerActivity.finishMe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setCancelable(false);
|
dialog.show();
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNotEnoughSpaceDialog(final Activity activity) {
|
public void showNotEnoughSpaceDialog() {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
dialogInit(Window.FEATURE_OPTIONS_PANEL, R.string.space_ok,
|
||||||
builder.setTitle(R.string.memory_title);
|
R.string.memory_close, R.string.not_enough_space);
|
||||||
builder.setMessage(R.string.not_enough_space);
|
negative.setVisibility(View.GONE);
|
||||||
builder.setPositiveButton(R.string.space_ok,
|
positive.setOnClickListener(new OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
activity.finish();
|
dialog.dismiss();
|
||||||
|
Toast.makeText(mContext, R.string.memory_lags,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
callerActivity.init();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setCancelable(false);
|
dialog.show();
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTotalMemoryInMB() {
|
public long getTotalMemoryInMB() {
|
||||||
|
@ -8,6 +8,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.RatingBar;
|
import android.widget.RatingBar;
|
||||||
@ -119,6 +120,8 @@ public class RateThisApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialog.getWindow().setBackgroundDrawable(
|
||||||
|
new ColorDrawable(R.color.semi_transparent));
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package net.minetest.minetest;
|
package net.minetest.minetest;
|
||||||
|
|
||||||
|
import static com.MoNTE48.MultiCraft.PreferencesHelper.isShowHelp;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import android.app.NativeActivity;
|
import android.app.NativeActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@ -14,28 +17,53 @@ import com.MoNTE48.RateME.RateThisApp;
|
|||||||
public class MtNativeActivity extends NativeActivity implements
|
public class MtNativeActivity extends NativeActivity implements
|
||||||
IUtilitiesCallback {
|
IUtilitiesCallback {
|
||||||
|
|
||||||
|
private ScheduledExecutorService scheduler;
|
||||||
|
private int m_MessagReturnCode;
|
||||||
|
private String m_MessageReturnValue;
|
||||||
|
private Utilities util;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (requestCode == 101) {
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
String text = data.getStringExtra("text");
|
||||||
|
m_MessagReturnCode = 0;
|
||||||
|
m_MessageReturnValue = text;
|
||||||
|
} else {
|
||||||
|
m_MessagReturnCode = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
m_MessagReturnCode = -1;
|
m_MessagReturnCode = -1;
|
||||||
m_MessageReturnValue = "";
|
m_MessageReturnValue = "";
|
||||||
RateThisApp.onStart(this);
|
RateThisApp.onStart(this);
|
||||||
|
util = new Utilities(MtNativeActivity.this);
|
||||||
startDialogs();
|
startDialogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishMe() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
private void startDialogs() {
|
private void startDialogs() {
|
||||||
final Handler handler = new Handler();
|
final Handler handler = new Handler();
|
||||||
handler.postDelayed(new Runnable() {
|
handler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Utilities util = new Utilities(MtNativeActivity.this);
|
|
||||||
util.showHelpDialog();
|
util.showHelpDialog();
|
||||||
SharedPreferences settings = MtNativeActivity.this
|
|
||||||
.getSharedPreferences(Utilities.PREFS_NAME, 0);
|
if (!isShowHelp()) {
|
||||||
String skipMessage = settings.getString("skipMessage",
|
|
||||||
"NOT checked");
|
|
||||||
if ("checked".equalsIgnoreCase(skipMessage)) {
|
|
||||||
if (RateThisApp.shouldShowRateDialog()) {
|
if (RateThisApp.shouldShowRateDialog()) {
|
||||||
RateThisApp
|
RateThisApp
|
||||||
.showRateDialogIfNeeded(MtNativeActivity.this);
|
.showRateDialogIfNeeded(MtNativeActivity.this);
|
||||||
@ -87,19 +115,6 @@ public class MtNativeActivity extends NativeActivity implements
|
|||||||
return getResources().getDisplayMetrics().heightPixels;
|
return getResources().getDisplayMetrics().heightPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
if (requestCode == 101) {
|
|
||||||
if (resultCode == RESULT_OK) {
|
|
||||||
String text = data.getStringExtra("text");
|
|
||||||
m_MessagReturnCode = 0;
|
|
||||||
m_MessageReturnValue = text;
|
|
||||||
} else {
|
|
||||||
m_MessagReturnCode = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("openal");
|
System.loadLibrary("openal");
|
||||||
System.loadLibrary("ogg");
|
System.loadLibrary("ogg");
|
||||||
@ -108,11 +123,4 @@ public class MtNativeActivity extends NativeActivity implements
|
|||||||
System.loadLibrary("crypto");
|
System.loadLibrary("crypto");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int m_MessagReturnCode;
|
|
||||||
private String m_MessageReturnValue;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user