package org.kivy.android;

import java.io.File;

import android.util.Log;


public class PythonUtil {
	private static final String TAG = "PythonUtil";

	protected static String[] getLibraries() {
        return new String[] {
            "SDL2",
            "SDL2_image",
            "SDL2_mixer",
            "SDL2_ttf",
            "python2.7",
            "main"
        };
    }

	public static void loadLibraries(File filesDir) {
		for (String lib : getLibraries()) {
			System.loadLibrary(lib);
		}

		System.load(filesDir + "/lib/python2.7/lib-dynload/_io.so");
		System.load(filesDir + "/lib/python2.7/lib-dynload/unicodedata.so");

		try {
			System.load(filesDir + "/lib/python2.7/lib-dynload/_ctypes.so");
		} catch(UnsatisfiedLinkError e) {
			Log.v(TAG, "Unsatisfied linker when loading ctypes");
		}

		Log.v(TAG, "Loaded everything!");
	}
}

@@ -319,33 +319,8 @@
 f%22,%0A
-            %22python2.7%22,%0A
     
@@ -441,19 +441,28 @@
 es()) %7B%0A
-%09%09%09
+            
 System.l
@@ -482,35 +482,422 @@
 b);%0A
-%09%09%7D%0A%0A%09%09System.load(f
+        %7D%0A%0A        try %7B%0A            System.loadLibrary(%22python2.7%22);%0A        %7D catch(UnsatisfiedLinkError e) %7B%0A            Log.v(TAG, %22Failed to load libpython2.7%22);%0A        %7D%0A        %0A        try %7B%0A            System.loadLibrary(%22python3.5m%22);%0A        %7D catch(UnsatisfiedLinkError e) %7B%0A            Log.v(TAG, %22Failed to load libpython3.5m%22);%0A        %7D%0A        %0A        try %7B%0A            System.load(getF
 ilesDir
+()
  + %22
@@ -933,18 +933,28 @@
 o.so%22);%0A
-%09%09
+            
 System.l
@@ -953,32 +953,37 @@
 System.load(
-f
+getF
 ilesDir
+()
  + %22/lib/pyt
@@ -1023,40 +1023,251 @@
 %22);%0A
-%0A%09%09try %7B%0A%09%09%09System.load(f
+        %7D catch(UnsatisfiedLinkError e) %7B%0A            Log.v(TAG, %22Failed to load _io.so or unicodedata.so...but that's okay.%22);%0A        %7D%0A        %0A        try %7B%0A            // System.loadLibrary(%22ctypes%22);%0A            System.load(getF
 ilesDir
+()
  + %22
@@ -1307,18 +1307,24 @@
 s.so%22);%0A
-%09%09
+        
 %7D catch(
@@ -1353,11 +1353,20 @@
 ) %7B%0A
-%09%09%09
+            
 Log.
@@ -1419,15 +1419,27 @@
 %22);%0A
-%09%09%7D%0A%0A%09%09
+        %7D%0A%0A        
 Log.

add py3 support to PythonUtil load