Disabled 'import github' button on Android because Android is garbage and can't even do something as simple as an HTTP request without 5 workaround for different versions

This commit is contained in:
Anuken
2019-10-27 10:51:35 -04:00
parent 4e946ae52b
commit 34db321577
3 changed files with 33 additions and 32 deletions

View File

@@ -14,7 +14,6 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:isGame="true" android:isGame="true"
android:appCategory="game" android:appCategory="game"
android:usesCleartextTraffic="true"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules"> android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
<meta-data android:name="android.max_aspect" android:value="2.1"/> <meta-data android:name="android.max_aspect" android:value="2.1"/>

View File

@@ -29,39 +29,41 @@ public class ModsDialog extends FloatingDialog{
buttons.addImageTextButton("$mods.guide", Icon.wiki, buttons.addImageTextButton("$mods.guide", Icon.wiki,
() -> Core.net.openURI(modGuideURL)) () -> Core.net.openURI(modGuideURL))
.size(210f, 64f); .size(android ? 210f + 250f + 10f : 210, 64f).colspan(android ? 2 : 1);
buttons.addImageTextButton("$mod.import.github", Icon.github, () -> { if(!android){
ui.showTextInput("$mod.import.github", "", 64, "Anuken/ExampleMod", text -> { buttons.addImageTextButton("$mod.import.github", Icon.github, () -> {
ui.loadfrag.show(); ui.showTextInput("$mod.import.github", "", 64, "Anuken/ExampleMod", text -> {
Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> { ui.loadfrag.show();
Core.net.httpGet(loc.getHeader("Location"), result -> { Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> {
if(result.getStatus() != HttpStatus.OK){ Core.net.httpGet(loc.getHeader("Location"), result -> {
ui.showErrorMessage(Core.bundle.format("connectfail", result.getStatus())); if(result.getStatus() != HttpStatus.OK){
ui.loadfrag.hide(); ui.showErrorMessage(Core.bundle.format("connectfail", result.getStatus()));
}else{ ui.loadfrag.hide();
try{ }else{
FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip"); try{
Streams.copyStream(result.getResultAsStream(), file.write(false)); FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip");
mods.importMod(file); Streams.copyStream(result.getResultAsStream(), file.write(false));
file.delete(); mods.importMod(file);
Core.app.post(() -> { file.delete();
try{ Core.app.post(() -> {
mods.reloadContent(); try{
setup(); mods.reloadContent();
ui.loadfrag.hide(); setup();
}catch(Throwable e){ ui.loadfrag.hide();
ui.showException(e); }catch(Throwable e){
} ui.showException(e);
}); }
}catch(Throwable e){ });
ui.showException(e); }catch(Throwable e){
ui.showException(e);
}
} }
} }, t -> Core.app.post(() -> ui.showException(t)));
}, t -> Core.app.post(() -> ui.showException(t))); }, t -> Core.app.post(() -> ui.showException(t)));
}, t -> Core.app.post(() -> ui.showException(t))); });
}); }).size(250f, 64f);
}).size(250f, 64f); }
shown(this::setup); shown(this::setup);

View File

@@ -241,7 +241,7 @@ public class Block extends BlockStorage{
} }
public void drawCracks(Tile tile){ public void drawCracks(Tile tile){
if(!tile.entity.damaged()) return; if(!tile.entity.damaged() || size > maxCrackSize) return;
int id = tile.pos(); int id = tile.pos();
TextureRegion region = cracks[size - 1][Mathf.clamp((int)((1f - tile.entity.healthf()) * crackRegions), 0, crackRegions-1)]; TextureRegion region = cracks[size - 1][Mathf.clamp((int)((1f - tile.entity.healthf()) * crackRegions), 0, crackRegions-1)];
Draw.colorl(0.2f, 0.1f + (1f - tile.entity.healthf())* 0.6f); Draw.colorl(0.2f, 0.1f + (1f - tile.entity.healthf())* 0.6f);