Merge pull request #75 from ubulem/master

Latest java part
This commit is contained in:
berkut 2017-05-22 15:44:02 +03:00 committed by GitHub
commit a3754330bd
22 changed files with 486 additions and 417 deletions

View File

@ -3,7 +3,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.android.tools.build:gradle:2.3.2'
} }
} }
@ -20,13 +20,13 @@ task clean(type: Delete) {
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 24 compileSdkVersion 25
buildToolsVersion "24.0.3" buildToolsVersion "25.0.3"
defaultConfig { defaultConfig {
applicationId "mobi.MultiCraft" applicationId "mobi.MultiCraft"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 24 targetSdkVersion 25
} }
Properties props = new Properties() Properties props = new Properties()
props.load(new FileInputStream(file("local.properties"))) props.load(new FileInputStream(file("local.properties")))
@ -50,5 +50,5 @@ android {
} }
dependencies { dependencies {
compile 'com.android.support:support-v4:24.2.0' compile 'com.android.support:support-v4:25.3.1'
} }

View File

@ -2,11 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mobi.MultiCraft" package="mobi.MultiCraft"
android:installLocation="auto" android:installLocation="auto"
android:versionCode="25" android:versionCode="52"
android:versionName="@string/ver"> android:versionName="@string/ver">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />

View File

@ -0,0 +1,13 @@
package mobi.MultiCraft;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
public class FireIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
String tkn = FirebaseInstanceId.getInstance().getToken();
// Log.d("App", "Token [" + tkn + "]");
}
}

View File

@ -0,0 +1,40 @@
package mobi.MultiCraft;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class FireMsgService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
// Create Notification
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.update)
.setContentTitle(getString(R.string.message))
.setSound(uri)
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1410, notificationBuilder.build());
}
}

View File

@ -21,7 +21,8 @@ public class GameActivity extends NativeActivity {
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);
// startAd(this, true); // if (!isAdsDisabled())
// startAd(this, true);
messageReturnCode = -1; messageReturnCode = -1;
messageReturnValue = ""; messageReturnValue = "";
makeFullScreen(); makeFullScreen();
@ -47,7 +48,8 @@ public class GameActivity extends NativeActivity {
@Override @Override
protected void onRestart() { protected void onRestart() {
super.onRestart(); super.onRestart();
// startAd(this, false); // if (!isAdsDisabled())
// startAd(this, false);
} }
@Override @Override

View File

@ -16,7 +16,6 @@ import android.view.View.OnKeyListener;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
public class InputDialogActivity extends Activity { public class InputDialogActivity extends Activity {
private AlertDialog alertDialog; private AlertDialog alertDialog;
@ -28,7 +27,7 @@ public class InputDialogActivity extends Activity {
int editType = b.getInt("editType"); int editType = b.getInt("editType");
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater(); LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog, null); View dialogView = inflater.inflate(R.layout.input_dialog, null);
builder.setView(dialogView); builder.setView(dialogView);
final EditText editText = (EditText) dialogView.findViewById(R.id.editText); final EditText editText = (EditText) dialogView.findViewById(R.id.editText);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -1,7 +1,6 @@
package mobi.MultiCraft; package mobi.MultiCraft;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -10,18 +9,20 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.StatFs;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.io.File; import java.io.File;
@ -32,34 +33,34 @@ import java.io.OutputStream;
import java.util.Arrays; import java.util.Arrays;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static mobi.MultiCraft.PermissionManager.permissionsRejected;
import static mobi.MultiCraft.PermissionManager.permissionsToRequest;
import static mobi.MultiCraft.PreferencesHelper.TAG_BUILD_NUMBER; import static mobi.MultiCraft.PreferencesHelper.TAG_BUILD_NUMBER;
import static mobi.MultiCraft.PreferencesHelper.TAG_LAUNCH_TIMES; import static mobi.MultiCraft.PreferencesHelper.TAG_LAUNCH_TIMES;
import static mobi.MultiCraft.PreferencesHelper.TAG_SHORTCUT_CREATED;
import static mobi.MultiCraft.PreferencesHelper.getBuildNumber; import static mobi.MultiCraft.PreferencesHelper.getBuildNumber;
import static mobi.MultiCraft.PreferencesHelper.getLaunchTimes; import static mobi.MultiCraft.PreferencesHelper.getLaunchTimes;
import static mobi.MultiCraft.PreferencesHelper.isCreateShortcut; import static mobi.MultiCraft.PreferencesHelper.isRestored;
import static mobi.MultiCraft.PreferencesHelper.loadSettings; import static mobi.MultiCraft.PreferencesHelper.loadSettings;
import static mobi.MultiCraft.PreferencesHelper.saveSettings; import static mobi.MultiCraft.PreferencesHelper.saveSettings;
public class MainActivity extends Activity implements WVersionManager.ActivityListener { public class MainActivity extends Activity implements WVersionManager.ActivityListener {
public final static int REQUEST_CODE = 104;
private final static String TAG = "Error";
private final static String FILES = Environment.getExternalStorageDirectory() + "/Files.zip";
private final static String WORLDS = Environment.getExternalStorageDirectory() + "/worlds.zip";
private final static String GAMES = Environment.getExternalStorageDirectory() + "/games.zip";
private final static String NOMEDIA = ".nomedia";
private final static int COARSE_LOCATION_RESULT = 100; private final static int COARSE_LOCATION_RESULT = 100;
private final static int WRITE_EXTERNAL_RESULT = 101; private final static int WRITE_EXTERNAL_RESULT = 101;
private final static int ALL_PERMISSIONS_RESULT = 102; private final static int ALL_PERMISSIONS_RESULT = 102;
private static final String UPDATE_LINK = "https://raw.githubusercontent.com/MoNTE48/MultiCraft-links/master/ver.txt";
public final static String TAG = "Error";
public final static String CREATE_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
public final static String FILES = Environment.getExternalStorageDirectory() + "/Files.zip";
public final static String WORLDS = Environment.getExternalStorageDirectory() + "/worlds.zip";
public final static String GAMES = Environment.getExternalStorageDirectory() + "/games.zip";
public final static String NOMEDIA = ".nomedia";
private ProgressDialog mProgressDialog; private ProgressDialog mProgressDialog;
private String dataFolder = "/Android/data/mobi.MultiCraft/files/"; private String dataFolder = "/Android/data/mobi.MultiCraft/files/";
private String unzipLocation = Environment.getExternalStorageDirectory() + dataFolder; private String unzipLocation = Environment.getExternalStorageDirectory() + dataFolder;
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private Utilities util; private TextView mLoading;
private ImageView iv;
private WVersionManager versionManager = null; private WVersionManager versionManager = null;
private PermissionManager pm = null; private PermissionManager pm = null;
private BroadcastReceiver myReceiver = new BroadcastReceiver() { private BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override @Override
@ -69,12 +70,13 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(progress); mProgressBar.setProgress(progress);
} else { } else {
util.createNomedia(); createNomedia();
runGame(); runGame();
} }
} }
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -87,52 +89,88 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
finish(); finish();
return; return;
} }
int i = getLaunchTimes(); addLaunchTimes();
i++; getPermissions();
saveSettings(TAG_LAUNCH_TIMES, i); // if (!isAdsDisabled())
pm = new PermissionManager(this); // initAd(this);
String[] permList = pm.requestPermissions();
if (permList.length > 0) {
ActivityCompat.requestPermissions(this, permList, ALL_PERMISSIONS_RESULT);
} else {
init();
}
} }
@Override @Override
public void isShowUpdateDialog(boolean flag) { protected void onResume() {
if (flag) { super.onResume();
versionManager.showDialog(); makeFullScreen();
versionManager.setCallback(new WVersionManager.Callback() { }
@Override
public void onPositive() {
versionManager.updateNow(versionManager.getUpdateUrl());
finish();
}
@Override @Override
public void onNegative() { protected void onDestroy() {
versionManager.ignoreThisVersion(); super.onDestroy();
checkRateDialog(); dismissProgressDialog();
} unregisterReceiver(myReceiver);
}
@Override //helpful utilities
public void onRemind() { private void addLaunchTimes() {
versionManager.remindMeLater(versionManager.getReminderTimer()); int i = getLaunchTimes();
checkRateDialog(); i++;
} saveSettings(TAG_LAUNCH_TIMES, i);
}); }
} else {
checkRateDialog(); private void deleteFiles(String path) {
File file = new File(path);
if (file.exists()) {
String deleteCmd = "rm -r " + path;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(deleteCmd);
} catch (IOException e) {
Log.e(TAG, "delete files failed: " + e.getLocalizedMessage());
}
} }
} }
private void checkNewVersion() {
versionManager = new WVersionManager(this);
versionManager.setVersionContentUrl("http://pastebin.com/raw/aeM2bmSB");
versionManager.checkVersion();
private void createDataFolder() {
File folder = new File(unzipLocation);
if (!(folder.exists()))
folder.mkdirs();
}
private void deleteZip(String... filesArray) {
for (String fileName : filesArray) {
File file = new File(fileName);
if (file.exists())
file.delete();
}
}
private void createNomedia() {
File myFile = new File(unzipLocation, NOMEDIA);
if (!myFile.exists())
try {
myFile.createNewFile();
} catch (IOException e) {
Log.e(TAG, "nomedia has not been created: " + e.getMessage());
}
}
//interface
private void addImageView(int pos) {
int marginTop = pos == 0 ? 48 : 288;
RelativeLayout rl = (RelativeLayout) findViewById(R.id.activity_main);
iv = new ImageView(this);
iv.setBackgroundResource(R.drawable.logo);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
lp.setMargins(0, marginTop, 0, 0);
iv.requestLayout();
iv.setLayoutParams(lp);
rl.addView(iv);
}
private void hideViews() {
mProgressBar.setVisibility(View.GONE);
iv.setVisibility(View.GONE);
mLoading.setVisibility(View.GONE);
} }
public void makeFullScreen() { public void makeFullScreen() {
@ -150,50 +188,41 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
} }
} }
@Override private void showSpinnerDialog(int message) {
protected void onDestroy() { if (mProgressDialog == null) {
super.onDestroy(); mProgressDialog = new ProgressDialog(MainActivity.this);
dismissProgressDialog(); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
unregisterReceiver(myReceiver); mProgressDialog.setCancelable(false);
}
mProgressDialog.setMessage(getString(message));
mProgressDialog.show();
} }
@Override private void dismissProgressDialog() {
protected void onResume() { if (mProgressDialog != null && mProgressDialog.isShowing()) {
super.onResume(); mProgressDialog.dismiss();
makeFullScreen(); }
} }
private void addShortcut() {
saveSettings(TAG_SHORTCUT_CREATED, false);
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction(CREATE_SHORTCUT);
getApplicationContext().sendBroadcast(addIntent);
}
@SuppressWarnings("deprecation")
public void init() { public void init() {
RateMe.onStart(this); RateMe.onStart(this);
if (isCreateShortcut())
addShortcut();
mProgressBar = (ProgressBar) findViewById(R.id.PB1); mProgressBar = (ProgressBar) findViewById(R.id.PB1);
Drawable draw; mLoading = (TextView) findViewById(R.id.tv_progress_circle);
draw = getResources().getDrawable(R.drawable.custom_progress_bar); Drawable draw = ContextCompat.getDrawable(this, R.drawable.custom_progress_bar);
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgressDrawable(draw); mProgressBar.setProgressDrawable(draw);
util = new Utilities(); createDataFolder();
util.createDataFolder(); checkAppVersion();
util.checkVersion();
} }
private boolean isNetworkConnected() { //permission block
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); private void getPermissions() {
return cm.getActiveNetworkInfo() != null; pm = new PermissionManager(this);
String[] permList = pm.requestPermissions();
if (permList.length > 0) {
ActivityCompat.requestPermissions(this, permList, ALL_PERMISSIONS_RESULT);
} else {
init();
}
} }
private void requestPermissionAfterExplain() { private void requestPermissionAfterExplain() {
@ -225,14 +254,14 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
case COARSE_LOCATION_RESULT: case COARSE_LOCATION_RESULT:
break; break;
case ALL_PERMISSIONS_RESULT: case ALL_PERMISSIONS_RESULT:
for (String perms : permissionsToRequest) { for (String perms : PermissionManager.permissionsToRequest) {
if (!pm.hasPermission(perms)) { if (!pm.hasPermission(perms)) {
permissionsRejected.add(perms); PermissionManager.permissionsRejected.add(perms);
} }
} }
if (permissionsRejected.size() == 0) { if (PermissionManager.permissionsRejected.size() == 0) {
init(); init();
} else if (!Arrays.asList(permissionsRejected.toArray()).contains(WRITE_EXTERNAL_STORAGE)) { } else if (!Arrays.asList(PermissionManager.permissionsRejected.toArray()).contains(WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(this, R.string.location, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.location, Toast.LENGTH_SHORT).show();
init(); init();
} else { } else {
@ -242,22 +271,7 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
} }
} }
private void showSpinnerDialog(int message) { //game logic
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(MainActivity.this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.setCancelable(false);
}
mProgressDialog.setMessage(getString(message));
mProgressDialog.show();
}
private void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
private void checkRateDialog() { private void checkRateDialog() {
if (RateMe.shouldShowRateDialog()) { if (RateMe.shouldShowRateDialog()) {
hideViews(); hideViews();
@ -284,23 +298,49 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
} }
} }
public void runGame() { @Override
util.deleteZip(FILES); public void isShowUpdateDialog(boolean flag) {
util.deleteZip(WORLDS); if (flag) {
util.deleteZip(GAMES); versionManager.showDialog();
if (isNetworkConnected()) { versionManager.setCallback(new WVersionManager.Callback() {
checkNewVersion(); @Override
public void onPositive() {
versionManager.updateNow(versionManager.getUpdateUrl());
finish();
}
@Override
public void onNegative() {
versionManager.ignoreThisVersion();
checkRateDialog();
}
@Override
public void onRemind() {
versionManager.remindMeLater(versionManager.getReminderTimer());
checkRateDialog();
}
});
} else { } else {
startGameActivity(); checkRateDialog();
} }
} }
private void hideViews() { private void checkUrlVersion() {
mProgressBar.setVisibility(View.GONE); versionManager = new WVersionManager(this);
findViewById(R.id.imageView).setVisibility(View.GONE); versionManager.setVersionContentUrl(UPDATE_LINK);
findViewById(R.id.tv_progress_circle).setVisibility(View.GONE); versionManager.checkVersion();
} }
public void runGame() {
deleteZip(FILES, WORLDS, GAMES);
Intent intent = new Intent(this, BillingActivity.class);
startActivityForResult(intent, REQUEST_CODE);
}
private void startGameActivity() { private void startGameActivity() {
Intent intent = new Intent(MainActivity.this, GameActivity.class); Intent intent = new Intent(MainActivity.this, GameActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
@ -316,6 +356,42 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// check if the request code is same as what is passed here it is 2
if (requestCode == REQUEST_CODE) {
if ((data != null) && (data.getBooleanExtra("isCheckNewVersion", false))) {
checkUrlVersion();
} else {
startGameActivity();
}
} else startGameActivity();
}
private void startDeletion(boolean isAll) {
if (isAll) {
new DeleteTask().execute(unzipLocation);
} else {
new DeleteTask().execute(unzipLocation + "builtin", unzipLocation + "games", unzipLocation + "debug.txt");
}
}
private void checkAppVersion() {
if (!isRestored() && getBuildNumber().equals(getString(R.string.ver))) {
addImageView(1);
runGame();
} else if (getBuildNumber().equals("0")) {
addImageView(0);
saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
startDeletion(true);
} else {
addImageView(0);
saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
startDeletion(false);
}
}
private class DeleteTask extends AsyncTask<String, Void, Void> { private class DeleteTask extends AsyncTask<String, Void, Void> {
String location; String location;
@ -329,7 +405,7 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
protected Void doInBackground(String... params) { protected Void doInBackground(String... params) {
location = params[0]; location = params[0];
for (String p : params) { for (String p : params) {
util.deleteFiles(p); deleteFiles(p);
} }
return null; return null;
} }
@ -354,7 +430,8 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); mProgressBar.setVisibility(View.VISIBLE);
mLoading.setVisibility(View.VISIBLE);
} }
@Override @Override
@ -369,14 +446,11 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
@Override @Override
protected void onPostExecute(String result) { protected void onPostExecute(String result) {
if (util.getAvailableSpaceInMB() > 15) { try {
try { startUnzipService(zips);
startUnzipService(zips); } catch (IOException e) {
} catch (IOException e) { Log.e(TAG, "unzip failed: " + e.getMessage());
Log.e(TAG, "unzip failed: " + e.getMessage()); }
}
} else
Toast.makeText(MainActivity.this, R.string.not_enough_space, Toast.LENGTH_LONG).show();
} }
private void copyAssets(String zipName) { private void copyAssets(String zipName) {
@ -404,76 +478,5 @@ public class MainActivity extends Activity implements WVersionManager.ActivityLi
} }
} }
private class Utilities {
private void createDataFolder() {
File folder = new File(unzipLocation);
if (!(folder.exists()))
folder.mkdirs();
}
private void deleteZip(String fileName) {
File file = new File(fileName);
if (file.exists())
file.delete();
}
private void startDeletion(boolean isAll) {
if (isAll) {
new DeleteTask().execute(unzipLocation);
} else {
new DeleteTask().execute(unzipLocation + "games", unzipLocation + "debug.txt");
}
}
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private long getAvailableSpaceInMB() {
final long SIZE_KB = 1024L;
final long SIZE_MB = SIZE_KB * SIZE_KB;
long availableSpace;
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
if (Build.VERSION.SDK_INT > 17) {
availableSpace = stat.getAvailableBlocksLong() * stat.getBlockSizeLong();
} else {
availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
}
return availableSpace / SIZE_MB;
}
void checkVersion() {
if (getBuildNumber().equals(getString(R.string.ver))) {
runGame();
} else if (getBuildNumber().equals("0")) {
saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
startDeletion(true);
} else {
saveSettings(TAG_BUILD_NUMBER, getString(R.string.ver));
startDeletion(false);
}
}
private void deleteFiles(String path) {
File file = new File(path);
if (file.exists()) {
String deleteCmd = "rm -r " + path;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(deleteCmd);
} catch (IOException e) {
Log.e(TAG, "delete files failed: " + e.getLocalizedMessage());
}
}
}
void createNomedia() {
File myFile = new File(unzipLocation, NOMEDIA);
if (!myFile.exists())
try {
myFile.createNewFile();
} catch (IOException e) {
Log.e(TAG, "nomedia has not been created: " + e.getMessage());
}
}
}
} }

View File

@ -10,13 +10,15 @@ import java.util.ArrayList;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION; import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static mobi.MultiCraft.PreferencesHelper.TAG_RESTORE_BACKUP;
import static mobi.MultiCraft.PreferencesHelper.getLaunchTimes; import static mobi.MultiCraft.PreferencesHelper.getLaunchTimes;
import static mobi.MultiCraft.PreferencesHelper.saveSettings;
class PermissionManager { class PermissionManager {
private Activity activity;
private SharedPreferences sharedPreferences;
static ArrayList<String> permissionsToRequest; static ArrayList<String> permissionsToRequest;
static ArrayList<String> permissionsRejected; static ArrayList<String> permissionsRejected;
private Activity activity;
private SharedPreferences sharedPreferences;
PermissionManager(Activity activity) { PermissionManager(Activity activity) {
this.activity = activity; this.activity = activity;
@ -26,9 +28,7 @@ class PermissionManager {
String[] requestPermissions() { String[] requestPermissions() {
ArrayList<String> permissions = new ArrayList<>(); ArrayList<String> permissions = new ArrayList<>();
permissions.add(WRITE_EXTERNAL_STORAGE); permissions.add(WRITE_EXTERNAL_STORAGE);
if (getLaunchTimes() > 2) { permissions.add(ACCESS_COARSE_LOCATION);
permissions.add(ACCESS_COARSE_LOCATION);
}
//filter out the permissions we have already accepted //filter out the permissions we have already accepted
permissionsToRequest = findUnAskedPermissions(permissions); permissionsToRequest = findUnAskedPermissions(permissions);
//get the permissions we have asked for before but are not granted.. //get the permissions we have asked for before but are not granted..
@ -46,10 +46,14 @@ class PermissionManager {
} }
boolean hasPermission(String permission) { boolean hasPermission(String permission) {
return (ActivityCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED); return ActivityCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED;
} }
private boolean shouldWeAsk(String permission) { private boolean shouldWeAsk(String permission) {
if (getLaunchTimes() > 1 && permission.equals(WRITE_EXTERNAL_STORAGE)) {
sharedPreferences.edit().clear().apply();
saveSettings(TAG_RESTORE_BACKUP, true);
}
return sharedPreferences.getBoolean(permission, true); return sharedPreferences.getBoolean(permission, true);
} }

View File

@ -4,36 +4,47 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
class PreferencesHelper { class PreferencesHelper {
private static final String SETTINGS = "settings";
static final String TAG_SHORTCUT_CREATED = "createShortcut";
static final String TAG_BUILD_NUMBER = "buildNumber"; static final String TAG_BUILD_NUMBER = "buildNumber";
static final String TAG_LAUNCH_TIMES = "launchTimes"; static final String TAG_LAUNCH_TIMES = "launchTimes";
private static boolean createShortcut; static final String TAG_RESTORE_BACKUP = "restoredFromBackup";
private static final String SETTINGS = "settings";
private static final String TAG_DISABLED_ADS = "disabledADS";
private static String buildNumber; private static String buildNumber;
private static SharedPreferences settings;
static boolean isCreateShortcut() { private static SharedPreferences settings;
return createShortcut; private static boolean disabledADS;
static boolean isAdsDisabled() {
return disabledADS;
} }
static String getBuildNumber() { static String getBuildNumber() {
return buildNumber; return buildNumber;
} }
static void loadSettings(final Context context) { static boolean isRestored() {
settings = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE); return settings.getBoolean(TAG_RESTORE_BACKUP, false);
createShortcut = settings.getBoolean(TAG_SHORTCUT_CREATED, true);
buildNumber = settings.getString(TAG_BUILD_NUMBER, "0");
} }
static void saveSettings(String tag, boolean bool) { static void savePurchase(boolean v) {
settings.edit().putBoolean(tag, bool).apply(); disabledADS = v;
settings.edit().putBoolean(TAG_DISABLED_ADS, v).apply();
} }
static int getLaunchTimes() { static int getLaunchTimes() {
return settings.getInt(TAG_LAUNCH_TIMES, 0); return settings.getInt(TAG_LAUNCH_TIMES, 0);
} }
static void loadSettings(final Context context) {
settings = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
buildNumber = settings.getString(TAG_BUILD_NUMBER, "0");
disabledADS = settings.getBoolean(TAG_DISABLED_ADS, false);
}
static void saveSettings(String tag, boolean bool) {
settings.edit().putBoolean(tag, bool).apply();
}
static void saveSettings(String tag, String value) { static void saveSettings(String tag, String value) {
settings.edit().putString(tag, value).apply(); settings.edit().putString(tag, value).apply();
} }
@ -41,4 +52,5 @@ class PreferencesHelper {
static void saveSettings(String tag, int value) { static void saveSettings(String tag, int value) {
settings.edit().putInt(tag, value).apply(); settings.edit().putInt(tag, value).apply();
} }
} }

View File

@ -18,8 +18,8 @@ import java.util.Date;
class RateMe { class RateMe {
private static final int INSTALL_DAYS = 3; private static final int INSTALL_DAYS = 2;
private static final int LAUNCH_TIMES = 2; private static final int LAUNCH_TIMES = 3;
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final String TAG = RateMe.class.getSimpleName(); private static final String TAG = RateMe.class.getSimpleName();
private static final String GOOGLE_PLAY = "https://play.google.com/store/apps/details?id="; private static final String GOOGLE_PLAY = "https://play.google.com/store/apps/details?id=";
@ -78,7 +78,7 @@ class RateMe {
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
} }
dialog.setContentView(R.layout.rate_layout); dialog.setContentView(R.layout.rate_dialog);
dialog.setTitle(R.string.rta_dialog_title); dialog.setTitle(R.string.rta_dialog_title);
RatingBar ratingBar = (RatingBar) dialog.findViewById(R.id.ratingBar); RatingBar ratingBar = (RatingBar) dialog.findViewById(R.id.ratingBar);
@ -133,14 +133,12 @@ class RateMe {
private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) { private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) {
Date installDate = new Date(); Date installDate = new Date();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { PackageManager packMan = context.getPackageManager();
PackageManager packMan = context.getPackageManager(); try {
try { PackageInfo pkgInfo = packMan.getPackageInfo(context.getPackageName(), 0);
PackageInfo pkgInfo = packMan.getPackageInfo(context.getPackageName(), 0); installDate = new Date(pkgInfo.firstInstallTime);
installDate = new Date(pkgInfo.firstInstallTime); } catch (PackageManager.NameNotFoundException e) {
} catch (PackageManager.NameNotFoundException e) { e.printStackTrace();
e.printStackTrace();
}
} }
editor.putLong(KEY_INSTALL_DATE, installDate.getTime()); editor.putLong(KEY_INSTALL_DATE, installDate.getTime());
log("First install: " + installDate.toString()); log("First install: " + installDate.toString());

View File

@ -1,10 +1,10 @@
package mobi.MultiCraft; package mobi.MultiCraft;
import android.app.IntentService; import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import java.io.File; import java.io.File;
@ -40,7 +40,7 @@ public class UnzipService extends IntentService {
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder mBuilder = new Notification.Builder(this); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(getString(R.string.notification_title)) mBuilder.setContentTitle(getString(R.string.notification_title))
.setContentText(getString(R.string.notification_description)).setSmallIcon(R.drawable.update); .setContentText(getString(R.string.notification_description)).setSmallIcon(R.drawable.update);
String[] file = intent.getStringArrayExtra(EXTRA_KEY_IN_FILE); String[] file = intent.getStringArrayExtra(EXTRA_KEY_IN_FILE);

View File

@ -33,13 +33,11 @@ import java.util.Locale;
class WVersionManager { class WVersionManager {
private static final String TAG = "WVersionManager"; private static final String TAG = "WVersionManager";
private static WVersionManager.Callback sCallback = null;
private CustomTagHandler customTagHandler; private CustomTagHandler customTagHandler;
private String PREF_IGNORE_VERSION_CODE = "w.ignore.version.code"; private String PREF_IGNORE_VERSION_CODE = "w.ignore.version.code";
private String PREF_REMINDER_TIME = "w.reminder.time"; private String PREF_REMINDER_TIME = "w.reminder.time";
private String PREF_LAUNCH_TIMES = "w.launch.times"; private String PREF_LAUNCH_TIMES = "w.launch.times";
private Activity activity; private Activity activity;
private Drawable icon; private Drawable icon;
private String title; private String title;
@ -53,17 +51,8 @@ class WVersionManager {
private int mVersionCode; private int mVersionCode;
private AlertDialogButtonListener listener; private AlertDialogButtonListener listener;
private boolean mDialogCancelable = false; private boolean mDialogCancelable = false;
private static WVersionManager.Callback sCallback = null;
private ActivityListener al; private ActivityListener al;
void setCallback(WVersionManager.Callback callback) {
sCallback = callback;
}
interface ActivityListener {
void isShowUpdateDialog(boolean flag);
}
WVersionManager(Activity act) { WVersionManager(Activity act) {
this.activity = act; this.activity = act;
al = (ActivityListener) act; al = (ActivityListener) act;
@ -72,6 +61,10 @@ class WVersionManager {
setLaunchTimes(); setLaunchTimes();
} }
void setCallback(WVersionManager.Callback callback) {
sCallback = callback;
}
private Drawable getDefaultAppIcon() { private Drawable getDefaultAppIcon() {
return activity.getApplicationInfo().loadIcon(activity.getPackageManager()); return activity.getApplicationInfo().loadIcon(activity.getPackageManager());
} }
@ -126,19 +119,24 @@ class WVersionManager {
return updateNowLabel != null ? updateNowLabel : activity.getString(R.string.update); return updateNowLabel != null ? updateNowLabel : activity.getString(R.string.update);
} }
public void setUpdateNowLabel(String updateNowLabel) {
this.updateNowLabel = updateNowLabel;
}
private String getRemindMeLaterLabel() { private String getRemindMeLaterLabel() {
return remindMeLaterLabel != null ? remindMeLaterLabel : activity.getString(R.string.later); return remindMeLaterLabel != null ? remindMeLaterLabel : activity.getString(R.string.later);
} }
public void setRemindMeLaterLabel(String remindMeLaterLabel) {
this.remindMeLaterLabel = remindMeLaterLabel;
}
private String getIgnoreThisVersionLabel() { private String getIgnoreThisVersionLabel() {
return ignoreThisVersionLabel != null ? ignoreThisVersionLabel : activity.getString(R.string.ignore); return ignoreThisVersionLabel != null ? ignoreThisVersionLabel : activity.getString(R.string.ignore);
} }
public void setIgnoreThisVersionLabel(String ignoreThisVersionLabel) {
private void setMessage(String message) { this.ignoreThisVersionLabel = ignoreThisVersionLabel;
this.message = message;
} }
private String getMessage() { private String getMessage() {
@ -146,29 +144,52 @@ class WVersionManager {
return message != null ? message : defaultMessage; return message != null ? message : defaultMessage;
} }
private void setMessage(String message) {
this.message = message;
}
private String getTitle() { private String getTitle() {
String defaultTitle = "New Update Available"; String defaultTitle = "New Update Available";
return title != null ? title : defaultTitle; return title != null ? title : defaultTitle;
} }
public void setTitle(String title) {
this.title = title;
}
private Drawable getIcon() { private Drawable getIcon() {
return icon != null ? icon : getDefaultAppIcon(); return icon != null ? icon : getDefaultAppIcon();
} }
public void setIcon(Drawable icon) {
this.icon = icon;
}
String getUpdateUrl() { String getUpdateUrl() {
return updateUrl != null ? updateUrl : getGooglePlayStoreUrl(); return updateUrl != null ? updateUrl : getGooglePlayStoreUrl();
} }
private void setUpdateUrl(String updateUrl) {
this.updateUrl = updateUrl;
}
private String getVersionContentUrl() { private String getVersionContentUrl() {
return versionContentUrl; return versionContentUrl;
} }
void setVersionContentUrl(String versionContentUrl) {
this.versionContentUrl = versionContentUrl;
}
int getReminderTimer() { int getReminderTimer() {
return reminderTimer > 0 ? reminderTimer : 1; return reminderTimer > 0 ? reminderTimer : 1;
} }
public void setReminderTimer(int minutes) {
if (minutes > 0) {
reminderTimer = minutes;
}
}
void updateNow(String url) { void updateNow(String url) {
if (url != null) { if (url != null) {
@ -183,10 +204,6 @@ class WVersionManager {
} }
void setVersionContentUrl(String versionContentUrl) {
this.versionContentUrl = versionContentUrl;
}
void remindMeLater(int reminderTimer) { void remindMeLater(int reminderTimer) {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@ -196,15 +213,15 @@ class WVersionManager {
setReminderTime(reminderTimeStamp); setReminderTime(reminderTimeStamp);
} }
private long getReminderTime() {
return PreferenceManager.getDefaultSharedPreferences(activity).getLong(PREF_REMINDER_TIME, 0);
}
private void setReminderTime(long reminderTimeStamp) { private void setReminderTime(long reminderTimeStamp) {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putLong(PREF_REMINDER_TIME, reminderTimeStamp) PreferenceManager.getDefaultSharedPreferences(activity).edit().putLong(PREF_REMINDER_TIME, reminderTimeStamp)
.apply(); .apply();
} }
private long getReminderTime() {
return PreferenceManager.getDefaultSharedPreferences(activity).getLong(PREF_REMINDER_TIME, 0);
}
void ignoreThisVersion() { void ignoreThisVersion() {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putInt(PREF_IGNORE_VERSION_CODE, mVersionCode) PreferenceManager.getDefaultSharedPreferences(activity).edit().putInt(PREF_IGNORE_VERSION_CODE, mVersionCode)
.apply(); .apply();
@ -215,6 +232,50 @@ class WVersionManager {
return "market://details?id=" + id; return "market://details?id=" + id;
} }
private int getLaunchTimes() {
return PreferenceManager.getDefaultSharedPreferences(activity).getInt(PREF_LAUNCH_TIMES, 0);
}
private int getCurrentVersionCode() {
int currentVersionCode = 0;
PackageInfo pInfo;
try {
pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
currentVersionCode = pInfo.versionCode;
} catch (NameNotFoundException e) {
// return 0
}
return currentVersionCode;
}
private int getIgnoreVersionCode() {
return PreferenceManager.getDefaultSharedPreferences(activity).getInt(PREF_IGNORE_VERSION_CODE, 1);
}
private CustomTagHandler getCustomTagHandler() {
return customTagHandler;
}
private boolean isDialogCancelable() {
return mDialogCancelable;
}
public void setDialogCancelable(boolean dialogCancelable) {
mDialogCancelable = dialogCancelable;
}
interface ActivityListener {
void isShowUpdateDialog(boolean flag);
}
interface Callback {
void onPositive();
void onNegative();
void onRemind();
}
private class AlertDialogButtonListener implements DialogInterface.OnClickListener { private class AlertDialogButtonListener implements DialogInterface.OnClickListener {
@Override @Override
@ -278,75 +339,52 @@ class WVersionManager {
mVersionCode = 0; mVersionCode = 0;
String content; String content;
String packageName; String packageName;
try { if (result != null) {
if (!result.startsWith("{")) { // for response who append with unknown char try {
result = result.substring(1); if (!result.startsWith("{")) { // for response who append with unknown char
} result = result.substring(1);
String mResult = result; }
// json format from server: String mResult = result;
JSONObject json = (JSONObject) new JSONTokener(mResult).nextValue(); // json format from server:
mVersionCode = json.optInt("version_code"); JSONObject json = (JSONObject) new JSONTokener(mResult).nextValue();
String lang = Locale.getDefault().getLanguage(); mVersionCode = json.optInt("version_code");
if (lang.equals("ru")) { String lang = Locale.getDefault().getLanguage();
content = json.optString("content_ru"); if (lang.equals("ru")) {
} else { content = json.optString("content_ru");
content = json.optString("content_en"); } else {
} content = json.optString("content_en");
packageName = json.optString("package"); }
setUpdateUrl("market://details?id=" + packageName); packageName = json.optString("package");
int currentVersionCode = getCurrentVersionCode(); setUpdateUrl("market://details?id=" + packageName);
if (currentVersionCode < mVersionCode) { int currentVersionCode = getCurrentVersionCode();
if (mVersionCode != getIgnoreVersionCode()) { if (currentVersionCode < mVersionCode) {
setMessage(content); if (mVersionCode != getIgnoreVersionCode()) {
al.isShowUpdateDialog(true); setMessage(content);
} else if (mVersionCode == getIgnoreVersionCode() && getLaunchTimes() % 3 == 0) { al.isShowUpdateDialog(true);
PreferenceManager.getDefaultSharedPreferences(activity).edit().putInt(PREF_LAUNCH_TIMES, 0) } else if (mVersionCode == getIgnoreVersionCode() && getLaunchTimes() % 3 == 0) {
.apply(); PreferenceManager.getDefaultSharedPreferences(activity).edit().putInt(PREF_LAUNCH_TIMES, 0)
setMessage(content); .apply();
al.isShowUpdateDialog(true); setMessage(content);
al.isShowUpdateDialog(true);
} else {
al.isShowUpdateDialog(false);
}
} else { } else {
al.isShowUpdateDialog(false); al.isShowUpdateDialog(false);
} }
} else { } catch (JSONException e) {
Log.e(TAG, "is your server response have valid json format?");
al.isShowUpdateDialog(false);
} catch (Exception e) {
Log.e(TAG, e.toString());
al.isShowUpdateDialog(false); al.isShowUpdateDialog(false);
} }
} catch (JSONException e) { } else {
Log.e(TAG, "is your server response have valid json format?"); al.isShowUpdateDialog(false);
} catch (Exception e) {
Log.e(TAG, e.toString());
} }
} }
} }
private int getLaunchTimes() {
return PreferenceManager.getDefaultSharedPreferences(activity).getInt(PREF_LAUNCH_TIMES, 0);
}
private int getCurrentVersionCode() {
int currentVersionCode = 0;
PackageInfo pInfo;
try {
pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
currentVersionCode = pInfo.versionCode;
} catch (NameNotFoundException e) {
// return 0
}
return currentVersionCode;
}
private int getIgnoreVersionCode() {
return PreferenceManager.getDefaultSharedPreferences(activity).getInt(PREF_IGNORE_VERSION_CODE, 1);
}
private CustomTagHandler getCustomTagHandler() {
return customTagHandler;
}
private boolean isDialogCancelable() {
return mDialogCancelable;
}
private class CustomTagHandler implements Html.TagHandler { private class CustomTagHandler implements Html.TagHandler {
@Override @Override
@ -362,47 +400,4 @@ class WVersionManager {
} }
} }
} }
interface Callback {
void onPositive();
void onNegative();
void onRemind();
}
public void setUpdateNowLabel(String updateNowLabel) {
this.updateNowLabel = updateNowLabel;
}
public void setRemindMeLaterLabel(String remindMeLaterLabel) {
this.remindMeLaterLabel = remindMeLaterLabel;
}
public void setIgnoreThisVersionLabel(String ignoreThisVersionLabel) {
this.ignoreThisVersionLabel = ignoreThisVersionLabel;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public void setTitle(String title) {
this.title = title;
}
private void setUpdateUrl(String updateUrl) {
this.updateUrl = updateUrl;
}
public void setReminderTimer(int minutes) {
if (minutes > 0) {
reminderTimer = minutes;
}
}
public void setDialogCancelable(boolean dialogCancelable) {
mDialogCancelable = dialogCancelable;
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,13 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<padding
android:bottom="3dip"
android:left="3dip"
android:right="3dip"
android:top="3dip" />
<corners android:radius="5dip" />
<gradient
android:centerY="0.50"
android:endColor="#2a2b2f"
android:startColor="#2a2b2f" />
</shape>
</item>
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
<clip> <clip>
<shape> <shape>
<corners android:radius="5dip" />
<gradient <gradient
android:angle="270" android:endColor="#37C830"
android:centerColor="#808080" android:startColor="#37C830" />
android:centerY="1.0"
android:endColor="#808080"
android:startColor="#808080" />
</shape> </shape>
</clip> </clip>
</item> </item>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -4,42 +4,26 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/bg"> android:background="@drawable/bg">
<ImageView <ProgressBar
android:id="@+id/imageView" android:id="@+id/PB1"
style="@style/CustomProgressBar"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:layout_marginLeft="90dp"
android:layout_marginRight="90dp"
android:indeterminate="false"
android:max="100"
android:visibility="gone" />
<TextView
android:id="@+id/tv_progress_circle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_centerInParent="true"
android:layout_centerHorizontal="true" android:background="@android:color/transparent"
android:layout_marginTop="40dp" android:gravity="center"
android:src="@drawable/logo" /> android:text="@string/loading"
android:textColor="#FEFEFE"
<RelativeLayout android:visibility="gone" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="96dp"
android:layout_marginRight="96dp">
<ProgressBar
android:id="@+id/PB1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_centerInParent="true"
android:background="#404040"
android:visibility="gone"
android:indeterminate="false"
android:max="100" />
<TextView
android:id="@+id/tv_progress_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/transparent"
android:gravity="center"
android:text="@string/loading"
android:textColor="#FEFEFE" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -32,7 +32,6 @@
android:hint="@string/rate_description" /> android:hint="@string/rate_description" />
<Button <Button
android:id="@+id/rate_submit"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end"

View File

@ -6,7 +6,7 @@
<string name="loading">Загрузка&#8230;</string> <string name="loading">Загрузка&#8230;</string>
<string name="notification_title">Загрузка MultiCraft</string> <string name="notification_title">Загрузка MultiCraft</string>
<string name="notification_description">Осталось меньше минуты&#8230;</string> <string name="notification_description">Осталось меньше минуты&#8230;</string>
<string name="not_enough_space">Недостаточно места для распаковки.\nОсвободите пространство в памяти устройства!</string>
<!-- разрешения --> <!-- разрешения -->
<string name="explain">Для корректной работы, игре требуется разрешение записывать в память устройтсва.</string> <string name="explain">Для корректной работы, игре требуется разрешение записывать в память устройтсва.</string>
<string name="location">Знание местоположения обеспечивает Вам лучшее взаимодействие с игрой</string> <string name="location">Знание местоположения обеспечивает Вам лучшее взаимодействие с игрой</string>
@ -21,4 +21,6 @@
<string name="ignore">Игнорировать</string> <string name="ignore">Игнорировать</string>
<string name="later">Позже</string> <string name="later">Позже</string>
<string name="update">Обновить</string> <string name="update">Обновить</string>
<!-- reminder -->
<string name="message">Сообщение</string>
</resources> </resources>

View File

@ -18,5 +18,5 @@
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
</style> </style>
<style name="CustomLollipopDialogStyle" parent="android:Theme.Material.Light.Dialog.Alert"/> <style name="CustomLollipopDialogStyle" parent="android:Theme.Material.Light.Dialog.Alert" />
</resources> </resources>

View File

@ -2,8 +2,8 @@
<resources> <resources>
<string name="app_name" translatable="false">MultiCraft</string> <string name="app_name" translatable="false">MultiCraft</string>
<string name="ver" translatable="false">1.1.5</string> <string name="ver" translatable="false">1.1.7</string>
<string name="google_app_id" translatable="false">312077575425</string>
<!-- preparation for start --> <!-- preparation for start -->
<string name="rm_old">Preparing to update&#8230;</string> <string name="rm_old">Preparing to update&#8230;</string>
@ -11,9 +11,6 @@
<string name="notification_title">Loading MultiCraft</string> <string name="notification_title">Loading MultiCraft</string>
<string name="notification_description">Less than 1 minute&#8230;</string> <string name="notification_description">Less than 1 minute&#8230;</string>
<!-- free space dialog -->
<string name="not_enough_space">Not enough space for unpack game data.\nPlease free some space on the storage memory!</string>
<!-- permission block --> <!-- permission block -->
<string name="explain">Game need permission to write files to storage memory.</string> <string name="explain">Game need permission to write files to storage memory.</string>
<string name="location">Location permission provide you better interaction with game</string> <string name="location">Location permission provide you better interaction with game</string>
@ -30,4 +27,6 @@
<string name="later">Later</string> <string name="later">Later</string>
<string name="ignore">Ignore</string> <string name="ignore">Ignore</string>
<!-- reminder -->
<string name="message">Message</string>
</resources> </resources>

View File

@ -18,4 +18,10 @@
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
</style> </style>
<style name="CustomProgressBar" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/custom_progress_bar</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">20dip</item>
</style>
</resources> </resources>