download mit Links funktionieren jetzt auch

This commit is contained in:
Joshua
2018-10-15 13:47:09 +02:00
parent f97e293ef3
commit b244778c4a
3 changed files with 21 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.KVV.KVV; import de.sebse.fuplanner.services.KVV.KVV;
import de.sebse.fuplanner.services.KVV.types.Modules; import de.sebse.fuplanner.services.KVV.types.Modules;
import de.sebse.fuplanner.services.KVV.types.Resource; import de.sebse.fuplanner.services.KVV.types.Resource;
import de.sebse.fuplanner.tools.Regex;
import de.sebse.fuplanner.tools.UtilsDate; import de.sebse.fuplanner.tools.UtilsDate;
import de.sebse.fuplanner.tools.logging.Logger; import de.sebse.fuplanner.tools.logging.Logger;
import de.sebse.fuplanner.tools.ui.treeview.DirectoryNodeBinder; import de.sebse.fuplanner.tools.ui.treeview.DirectoryNodeBinder;
@@ -181,7 +182,14 @@ public class ModDetailResourceFragment extends Fragment {
AlertDialog alertDialog = alertDialogBuilder.create(); AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show(); alertDialog.show();
}else { }else {
fileOpen(new File(success1)); if (Regex.has("^http", success1)){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(success1));
startActivity(intent);
}
else {
fileOpen(new File(success1));
}
} }
}, error -> { }, error -> {

View File

@@ -544,10 +544,18 @@ class KVVModuleList extends HTTPService {
errorCallback.onError(new NetworkError(101701, 500, "Currently running in offline mode!")); errorCallback.onError(new NetworkError(101701, 500, "Currently running in offline mode!"));
return; return;
} }
get(url, token.getCookies(), response ->{ get(url, token.getCookies(), response ->{
final String[] pfad = {""}; final String[] pfad = {""};
if (response.getBytes()==null){ if (Regex.has("\\.[Uu][Rr][Ll]$", url)){//für Links
if (response.getHeaders().get("Location") != null){
pfad[0] = response.getHeaders().get("Location");
}
callback.onResponse(pfad[0]);
}
else if (response.getBytes()==null){
log.d("ResourceFile neu einlogen"); log.d("ResourceFile neu einlogen");
testLogin(token, token -> { testLogin(token, token -> {
if (isExternalStorageWritable()) { if (isExternalStorageWritable()) {

View File

@@ -8,10 +8,12 @@ import java.util.regex.MatchResult;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.sebse.fuplanner.tools.logging.Logger;
public class Regex { public class Regex {
public static boolean has(@Language("Regexp") String regex, String match) { public static boolean has(@Language("Regexp") String regex, String match) {
try { try {
regex(regex, match, 1); regex(regex, match, 0);
return true; return true;
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
return false; return false;