Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Ready to release 1.0.9.2.Tired with Google Play reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
fengberd committed Sep 9, 2017
1 parent 4e98576 commit 451436f
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 135 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "net.fengberd.minecraftpe_server"
minSdkVersion 14
targetSdkVersion 21
versionCode 1091
versionName "1.0.9.1"
versionCode 1092
versionName "1.0.9.2"
vectorDrawables.useSupportLibrary = true
}

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/assets/urls.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": 1,
"jenkins": {
"nukkit": [
"MengCraft|http://ci.mengcraft.com:8080/job/nukkit/",
Expand All @@ -16,5 +17,7 @@
"[Abandoned]ClearSky-PHP7 (ZXDA)|https://jenkins.zxda.net/job/ClearSky-PHP7/",
"[Abandoned]ClearSky-PHP5 (ZXDA)|https://jenkins.zxda.net/job/ClearSky-PHP5/"
]
}
},
"source_code": "https://github.com/fengberd/PocketServer",
"binaries_download": "https://www.dropbox.com/sh/bk5l4pn1pzc406b/AABzdxQENP6vw_q3p0nrfyTaa?dl=0"
}
117 changes: 116 additions & 1 deletion app/src/main/java/moe/berd/pocket_server/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

public class MainActivity extends Activity implements Handler.Callback
{
public static Handler actionHandler=null;
public final static int ACTION_STOP_SERVICE=1, ACTION_START_FAILED_WARNING=2;

public final static int CHOOSE_PHP_CODE=1, CHOOSE_JAVA_CODE=2;

public static Intent serverIntent=null;
public static Handler actionHandler=null;
public static JSONObject urls_json=null;

public static boolean nukkitMode=false, ansiMode=false;

Expand Down Expand Up @@ -69,6 +70,12 @@ public void onCreate(Bundle savedInstanceState)
setContentView(R.layout.activity_main);

ConfigProvider.init(getSharedPreferences("config",0));

if(ConfigProvider.getBoolean("FirstRun",true))
{
showReadmeDialog();
}

ansiMode=ConfigProvider.getBoolean("ANSIMode",nukkitMode);
nukkitMode=ConfigProvider.getBoolean("NukkitMode",nukkitMode);

Expand All @@ -91,6 +98,8 @@ public void onCreate(Bundle savedInstanceState)
toast(e.getMessage());
}

reloadUrls();

actionHandler=new Handler(this);
serverIntent=new Intent(this,ServerService.class);

Expand Down Expand Up @@ -200,6 +209,9 @@ public boolean onOptionsItemSelected(MenuItem item)
stopService(serverIntent);
fragment_main.refreshElements();
break;
case R.id.menu_readme:
showReadmeDialog();
break;
default:
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -273,6 +285,84 @@ public void run()
});
}

public void reloadUrls()
{
try
{
File file=new File(ServerUtils.getAppFilesDirectory(),"urls.json");
if(!file.exists())
{
copyAsset("urls.json",file);
}
if(file.length()<2)
{
file.delete();
reloadUrls();
return;
}

int current_version=0;
InputStream is=getAssets().open("urls.json");
byte[] data=new byte[is.available()];
is.read(data);
is.close();
current_version=new JSONObject(new String(data,"UTF-8")).getInt("version");

is=new FileInputStream(file);
data=new byte[(int)file.length()];
is.read(data);
is.close();
JSONObject json=new JSONObject(new String(data,"UTF-8"));

if(!json.has("version") || json.getInt("version")<current_version)
{
file.delete();
reloadUrls();
return;
}

urls_json=json;

JSONObject jenkins=json.getJSONObject("jenkins");
{
JSONArray nukkit=jenkins.getJSONArray("nukkit");
{
fragment_main.jenkins_nukkit=new String[nukkit.length()];
for(int i=0;i<fragment_main.jenkins_nukkit.length;i++)
{
fragment_main.jenkins_nukkit[i]=nukkit.getString(i);
}
}
JSONArray pocketmine=jenkins.getJSONArray("pocketmine");
{
fragment_main.jenkins_pocketmine=new String[pocketmine.length()];
for(int i=0;i<fragment_main.jenkins_pocketmine.length;i++)
{
fragment_main.jenkins_pocketmine[i]=pocketmine.getString(i);
}
}
}
}
catch(Exception e)
{
toast(e.toString());
}
}

public boolean openUrlFromJson(String key)
{
try
{
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(urls_json.getString(key))));
return true;
}
catch(JSONException e)
{
toast(e.toString());
}
return false;
}

public void switchFragment(Fragment target,int title)
{
try
Expand Down Expand Up @@ -389,6 +479,31 @@ public void run()
}
}

public void showReadmeDialog()
{
new AlertDialog.Builder(MainActivity.this).setTitle(R.string.dialog_readme_title)
.setCancelable(false)
.setMessage(getString(R.string.dialog_readme_message))
.setNegativeButton(R.string.dialog_readme_exit,new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog,int which)
{
finish();
}
})
.setPositiveButton(R.string.dialog_readme_continue,new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog,int which)
{
ConfigProvider.set("FirstRun",false);
}
})
.create()
.show();
}

public String getInternetString(String url)
{
try
Expand Down
Loading

0 comments on commit 451436f

Please sign in to comment.