From 1c8799cb751480c573e5b5ba2c64230824d61e07 Mon Sep 17 00:00:00 2001 From: FENGberd Date: Sun, 3 Sep 2017 16:37:47 +0800 Subject: [PATCH] Ready to release --- .../pocket_server/activity/MainActivity.java | 11 ++--- .../fragment/ConsoleFragment.java | 29 ++++++++----- .../pocket_server/fragment/MainFragment.java | 29 ++++++++++--- .../berd/pocket_server/utils/ServerUtils.java | 38 ++++++++++++------ .../main/res/drawable-hdpi/content_clear.png | Bin 0 -> 242 bytes .../main/res/drawable-hdpi/content_copy.png | Bin 1386 -> 319 bytes .../res/drawable-hdpi/content_discard.png | Bin 1611 -> 0 bytes .../main/res/drawable-mdpi/content_clear.png | Bin 0 -> 208 bytes .../main/res/drawable-mdpi/content_copy.png | Bin 0 -> 256 bytes .../main/res/drawable-xhdpi/content_clear.png | Bin 0 -> 300 bytes .../main/res/drawable-xhdpi/content_copy.png | Bin 0 -> 400 bytes .../res/drawable-xxhdpi/content_clear.png | Bin 0 -> 434 bytes .../main/res/drawable-xxhdpi/content_copy.png | Bin 0 -> 554 bytes app/src/main/res/layout/fragment_main.xml | 10 ++--- app/src/main/res/menu/console.xml | 2 +- 15 files changed, 75 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/content_clear.png delete mode 100644 app/src/main/res/drawable-hdpi/content_discard.png create mode 100644 app/src/main/res/drawable-mdpi/content_clear.png create mode 100644 app/src/main/res/drawable-mdpi/content_copy.png create mode 100644 app/src/main/res/drawable-xhdpi/content_clear.png create mode 100644 app/src/main/res/drawable-xhdpi/content_copy.png create mode 100644 app/src/main/res/drawable-xxhdpi/content_clear.png create mode 100644 app/src/main/res/drawable-xxhdpi/content_copy.png diff --git a/app/src/main/java/moe/berd/pocket_server/activity/MainActivity.java b/app/src/main/java/moe/berd/pocket_server/activity/MainActivity.java index 7ef5ad8..8186c6c 100644 --- a/app/src/main/java/moe/berd/pocket_server/activity/MainActivity.java +++ b/app/src/main/java/moe/berd/pocket_server/activity/MainActivity.java @@ -85,11 +85,6 @@ public void onCreate(Bundle savedInstanceState) @Override protected void onActivityResult(int requestCode,int resultCode,Intent data) { - if(requestCode!=CHOOSE_PHP_CODE && requestCode!=CHOOSE_JAVA_CODE) - { - super.onActivityResult(requestCode,resultCode,data); - return; - } if(data==null) { return; @@ -116,7 +111,7 @@ public void run() public void run() { processing_dialog.dismiss(); - fragment_main.refreshEnabled(); + fragment_main.refreshElements(); toast(R.string.message_install_success); } }); @@ -179,7 +174,7 @@ public boolean onOptionsItemSelected(MenuItem item) case R.id.menu_kill: ServerUtils.killServer(); stopService(serverIntent); - fragment_main.refreshEnabled(); + fragment_main.refreshElements(); break; default: return super.onOptionsItemSelected(item); @@ -205,7 +200,7 @@ public boolean handleMessage(Message msg) { case ACTION_STOP_SERVICE: stopService(serverIntent); - fragment_main.refreshEnabled(); + fragment_main.refreshElements(); break; default: return false; diff --git a/app/src/main/java/moe/berd/pocket_server/fragment/ConsoleFragment.java b/app/src/main/java/moe/berd/pocket_server/fragment/ConsoleFragment.java index 05a2bea..1bc4489 100644 --- a/app/src/main/java/moe/berd/pocket_server/fragment/ConsoleFragment.java +++ b/app/src/main/java/moe/berd/pocket_server/fragment/ConsoleFragment.java @@ -4,7 +4,6 @@ import android.content.*; import android.os.*; import android.text.*; -import android.util.*; import android.view.*; import android.widget.*; @@ -94,11 +93,19 @@ public void onClick(View arg0) label_log.setTextSize(ConfigProvider.getInt("ConsoleFontSize",16)); label_current.setTextSize(ConfigProvider.getInt("ConsoleFontSize",16)); - postAppend(currentLog); + label_log.setText(currentLog); + label_current.setText(currentLine); super.onStart(); } + @Override + public void onResume() + { + super.onResume(); + scrollToBottom(); + } + @Override public void onStop() { @@ -142,7 +149,14 @@ public boolean handleMessage(Message msg) { case MESSAGE_APPEND: label_log.append((CharSequence)msg.obj); - scrollToBottom(); + label_log.post(new Runnable() + { + @Override + public void run() + { + scrollToBottom(); + } + }); break; case MESSAGE_UPDATE_LINE: label_current.setText(currentLine); @@ -153,13 +167,12 @@ public boolean handleMessage(Message msg) public void scrollToBottom() { - scroll_log.smoothScrollBy(0,scroll_log.getChildAt(scroll_log.getChildCount() - 1) - .getBottom() + scroll_log.getPaddingBottom() - scroll_log.getScrollY() - scroll_log.getHeight()); + scroll_log.smoothScrollBy(0,scroll_log.getChildAt(scroll_log.getChildCount() - 1).getBottom()); } private void sendCommand() { - log("> " + edit_command.getText()); + logLine("> " + edit_command.getText()); ServerUtils.writeCommand(edit_command.getText().toString()); edit_command.setText(""); } @@ -189,7 +202,7 @@ public static boolean postNewLine() return false; } - public static void log(String line) + public static void logLine(String line) { if(!currentLine.equals("")) { @@ -204,14 +217,12 @@ public static void log(String line) { line=line.substring(index + 4); } - long timeSpan=System.currentTimeMillis(); line=TerminalColorConverter.control2html(line.replace("&","&") .replace("<","<") .replace(">",">") .replace(" "," ") .replace("\u001b[1G","") .replace("\u001b[K","")); - Log.d("Parse Time",(System.currentTimeMillis() - timeSpan) + "ms"); } currentLine=ansiMode ? Html.fromHtml(line) : line; postNewLine(); diff --git a/app/src/main/java/moe/berd/pocket_server/fragment/MainFragment.java b/app/src/main/java/moe/berd/pocket_server/fragment/MainFragment.java index 912bb9d..2cb3d1d 100644 --- a/app/src/main/java/moe/berd/pocket_server/fragment/MainFragment.java +++ b/app/src/main/java/moe/berd/pocket_server/fragment/MainFragment.java @@ -23,6 +23,7 @@ public class MainFragment extends Fragment implements View.OnClickListener public String[] jenkins_nukkit, jenkins_pocketmine; + public TextView label_path_tip=null; public Button button_start=null, button_stop=null, button_mount=null; public RadioButton radio_pocketmine=null, radio_nukkit=null; @@ -58,6 +59,8 @@ public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle save @Override public void onStart() { + label_path_tip=(TextView)main.findViewById(R.id.label_path_tip); + button_stop=(Button)main.findViewById(R.id.button_stop); button_stop.setOnClickListener(this); button_start=(Button)main.findViewById(R.id.button_start); @@ -73,7 +76,7 @@ public void onStart() radio_pocketmine.setOnClickListener(this); reloadUrls(); - refreshEnabled(); + refreshElements(); super.onStart(); } @@ -198,7 +201,7 @@ public void onClick(View v) default: return; } - refreshEnabled(); + refreshElements(); } public void reloadUrls() @@ -247,25 +250,39 @@ public void reloadUrls() } } - public void refreshEnabled() + public void refreshElements() { boolean running=ServerUtils.isRunning(); button_stop.setEnabled(running); button_mount.setEnabled(!running); radio_nukkit.setEnabled(!running); radio_pocketmine.setEnabled(!running); + label_path_tip.setText(""); - // Fake running state to prevent user starting server without Java/PHP installed if(nukkitMode) { + button_mount.setVisibility(View.VISIBLE); + if(!new File(ServerUtils.getDataDirectory(),"Nukkit.jar").exists()) + { + label_path_tip.setText(R.string.label_nukkit_to); + } if(!ServerUtils.installedJava()) { running=true; } } - else if(!ServerUtils.installedPHP()) + else { - running=true; + button_mount.setVisibility(View.GONE); + if(!new File(ServerUtils.getDataDirectory(),"PocketMine-MP.phar").exists() && !new File(ServerUtils + .getDataDirectory(),"src").exists()) + { + label_path_tip.setText(R.string.label_pocketMine_to); + } + if(!ServerUtils.installedPHP()) + { + running=true; + } } button_start.setEnabled(!running); } diff --git a/app/src/main/java/moe/berd/pocket_server/utils/ServerUtils.java b/app/src/main/java/moe/berd/pocket_server/utils/ServerUtils.java index 78a2f17..43698bc 100644 --- a/app/src/main/java/moe/berd/pocket_server/utils/ServerUtils.java +++ b/app/src/main/java/moe/berd/pocket_server/utils/ServerUtils.java @@ -154,15 +154,7 @@ public void run() case '\r': continue; case '\n': - String line=s.toString(); - /*if(line.startsWith("\u001b]0;")) - { - ConsoleFragment.postTitle(line.substring(8)); - } - else*/ - { - ConsoleFragment.log(line); - } + ConsoleFragment.logLine(s.toString()); case '\u0007': s.setLength(0); break; @@ -193,7 +185,7 @@ public void run() } } } - ConsoleFragment.log("[PE Server] Server was stopped."); + ConsoleFragment.logLine("[PE Server] Server was stopped."); MainActivity.postStopService(); } }; @@ -201,8 +193,8 @@ public void run() } catch(Exception e) { - ConsoleFragment.log("[PE Server] Unable to start " + (MainActivity.nukkitMode ? "Java" : "PHP") + "."); - ConsoleFragment.log(e.toString()); + ConsoleFragment.logLine("[PE Server] Unable to start " + (MainActivity.nukkitMode ? "Java" : "PHP") + "."); + ConsoleFragment.logLine(e.toString()); MainActivity.postStopService(); killServer(); } @@ -222,13 +214,33 @@ public static boolean writeCommand(String cmd) return true; } + public static void walkSetPermission(File folder) + { + folder.setReadable(true,true); + folder.setExecutable(true,true); + File[] files=folder.listFiles(); + if(files==null) + { + return; + } + for(File file : files) + { + file.setReadable(true,true); + file.setExecutable(true,true); + if(file.isDirectory()) + { + walkSetPermission(file); + } + } + } + public static void setPermission() { try { if(MainActivity.nukkitMode) { - Runtime.getRuntime().exec("./busybox chmod -R 755 java",new String[0],appDirectory).waitFor(); + walkSetPermission(new File(appDirectory,"java")); } else { diff --git a/app/src/main/res/drawable-hdpi/content_clear.png b/app/src/main/res/drawable-hdpi/content_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..1791cd7062ac9d1d0520c1b105024c5c8d95173a GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtot`d^Ar-gY&M@RUWFX?uz4F$< z&o4x+D!P=a#Mv`1?&b(G-(I!+OL>8yx6rIVR(sgf;~eXHU$}F=fhQY;KDZejsQt=V7?g`IuJ5>#35FizNe8 zEdH}HvIsaZAQLUOGue6if4LuN*uCSzJs%lmwvghrVSbN_4?S305%B+ayrOsi)L%0! fqsy28# literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/content_copy.png b/app/src/main/res/drawable-hdpi/content_copy.png index 72c6bc6e213c1f730a0939be123f4f97d9aa0cfb..d6bd2ecec59b727c422cccb34fa58e39065f89f4 100644 GIT binary patch delta 293 zcmV+=0owlR3cmu7BYyz~NklZZd>4Q<$iUtJnSbgF#0Bsif~(LCRriKs z0{HBLqu>==s(x2WU;v)lZ+U$!8X(s?A7CUUFl@Z7$k36E8ogr*P=Epypa2CZKmiI+ zfC8-v%)vr2?VP}eg(yG)3Q(Y30T0}?g$hF>_d@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o+kE~|fyMEXv~zE~tUok2pFX$m{F&eB_X0gM zn?KtedN8No$wBc!y?8*8ML5g5M#c$qHYA*W5G=>))4*D=@@(6ugT z1GX1zi+Vr4x@n^EypUZ;Y9I46$2FWQn6S< zt9D%C>|Ix=e#lI3+AhDD)=ORFnzSOA&L3>|%%>3`{oP$bstt}e(f~YY53RoV9rdrXH4v&H=~_{ub%sV zt+S;#w3h2e`GndpfzRh0-FhnXxIWtkZE>qdbMCRI^f8CcnwRIxDq~^ex177^L9oM8 z=ExO~f*W2q*l^8fdS&x{$F0WL%Ug1^7F;YTOx0E}vyHmVQ83p{I&#N^ZYPPfhfXhd zuPamd6x+%CZDZ0llYelb#{Ni?uWQ|IJ&xn-(=TK<5f7DoCcXLWylc+4*#kb# k{{>7-3j`*-{Gok-LH)?F>j~0pmV=6SPgg&ebxsLQ0FuvZE&u=k diff --git a/app/src/main/res/drawable-mdpi/content_clear.png b/app/src/main/res/drawable-mdpi/content_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..c02ac5263718b5ede721ab8235e76ee027cefc22 GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ>7Fi*Ar-fh6C_v{CulVN|Nnn8 zqanLg+T!U?^Bih~I?gY6DD3dYiJLo}>7$-X4OjP5gBmX1w#e(Ux_%xIbGqPSO zX;2V2uXI7mDNpn)LsDIo$@v=_P24UT{?6E3E5f76z>qw_T5p-^mWMzmGI+ZBxvX#Ar-fh6C_xhMgRQ&A1~N( z_QZinS2pYs=3qkT*xM% z&+^OCv1{M4WM5r^I?tgDumdKI;Vst E0P;3rBme*a literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/content_clear.png b/app/src/main/res/drawable-xhdpi/content_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..27db3187de704d6bf3cced0182dddc541092156b GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=pFLe1Ln>~)owbp-$$`PO{}hXk z%mGdv9iJQ>oi&_&i4VDs9kT3UwrFS#?R%#0`BwCwRfwyH5oicQ zgI4EbiwS$@{Q7TJr=kC8>gCBYTS{wQ?GzL&Il1&s{fBRde_Y8vc9UD2DTj+k=T#R2 z%L@AgG3&C8o-iNY$Uk?VDziAVi`f0Y9SkfA42&EO3`_zIIGDPe0=pyrILffk zCQ71yg6w0ZT{nE}v}OKJ2!3pI^08+5r?^KSo~&6bGgECrch#ofNBbv6s-;(ge9gdc Z>Je{GyL5X|k){ZU>*?y}vd$@?2>^N`Yy$uQ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/content_copy.png b/app/src/main/res/drawable-xhdpi/content_copy.png new file mode 100644 index 0000000000000000000000000000000000000000..7258bf0d433fd265baaf78469179f32bc9771a27 GIT binary patch literal 400 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEU<~(kaSW-r_4bybH?yI{v5z4a zk19QSvEad@cVTy|uDZsE?piU~SKZ#NIu@_xYYMvZzQnFk_z6dm>m>7n z|LpUgT6lbVyyKbI9OV`PCy%)zt`~#0U)fhRYlZtxow~riLH1YHx740uePHwP&}YUA zDq&Z@t1*`_30DWIb5_k~b}(nyaBs(G{yzlr(dl- z=>K#}OGYGfjPzU4x?9G~ANm&_G~0R0y7U}Zf_cID#lHkLK0Z}ZxBb>OrW@RMF8BS( zyT#wLlL=@bc5uL+Jxc5U_y2cWk1<@C!vj-vA*LZN!RY)%{=j`<$Ev$~|A`-PV^eo= z3-s$a(_ml{^Jn@0w8Ckc`z7;Eom>*L$6l)VMNvmR%hlYkF1Fn<^V660XaSW-r_4baTK69eX@sIA= z3q91Qc7-b$dPw-@-0MD~u=ln6VVAEvTI{R-y z4}Dvpi-jm5pR{D+F}C}&{)XFJ#;*D+|4v9OsEE1cHJ34J;KuZfhJX3o6*sp`hLv!Z?;jkz=Ln^r}@_a(2V+Hal;52=v%b&UG8%AFTB3A_Qh N-qY33Wt~$(69CyZs7wF= literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/content_copy.png b/app/src/main/res/drawable-xxhdpi/content_copy.png new file mode 100644 index 0000000000000000000000000000000000000000..a5b19ba1bd882532e969141fa59c80233b65790e GIT binary patch literal 554 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>VEpLm;uunK>+Rk1+AfJA$3AAy z65;ioaU;=q=^s`NZfi|3vt`Fl9Xb{_ah82z&W*?kZz4P*C3>dFf41*^zV>?2I@X!r z=j`*hm6n=YZMSk~`Nw-Y$}Iv;9Ew2Vg#P8XW$Z!gj<x{HxU4#NP8ITz~MXmf?kx+f^}!zswO~_KYv&9dw^Fy}x?9W%nb-1a - - + android:layout_height="wrap_content"/> diff --git a/app/src/main/res/menu/console.xml b/app/src/main/res/menu/console.xml index 6a8bd48..9711789 100644 --- a/app/src/main/res/menu/console.xml +++ b/app/src/main/res/menu/console.xml @@ -3,7 +3,7 @@