I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit f9fce317 authored by meeh's avatar meeh
Browse files

Added support for ndk building in osx. (Hope i did't breake it.. worked on osx 10.8 / ubuntu 12.04)

Also did some changes in AddressbookSettingsActivity; changed the way subscriptions.txt is readed and removed tabs. also changed some handlings in save function.
parent f87a3eb0
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,12 @@ ...@@ -15,8 +15,12 @@
# #
#THISDIR=$(realpath $(dirname $(which $0))) #THISDIR=$(realpath $(dirname $(which $0)))
## Making it work on osx too. ## works on linux and other unixes, but not osx.
THISDIR=$(dirname $(readlink -ne $0)) if [ "`uname -s`" != "Darwin" ]; then
THISDIR=$(dirname $(readlink -ne $0))
else
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
cd $THISDIR cd $THISDIR
LIBFILE=$PWD/libjbigi.so LIBFILE=$PWD/libjbigi.so
...@@ -49,7 +53,11 @@ LEVEL=8 ...@@ -49,7 +53,11 @@ LEVEL=8
ARCH=arm ARCH=arm
export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/ export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/
export AABI=arm-linux-androideabi-4.4.3 export AABI=arm-linux-androideabi-4.4.3
export SYSTEM=linux-x86 if [ "`uname -s`" == "Darwin" ]; then
export SYSTEM=darwin-x86
else
export SYSTEM=linux-x86
fi
export BINPREFIX=arm-linux-androideabi- export BINPREFIX=arm-linux-androideabi-
export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT" export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT"
# worked without this on 4.3.2, but 5.0.2 couldn't find it # worked without this on 4.3.2, but 5.0.2 couldn't find it
...@@ -88,14 +96,20 @@ cd build ...@@ -88,14 +96,20 @@ cd build
if [ ! -f config.status ] if [ ! -f config.status ]
then then
echo "Configuring GMP..." echo "Configuring GMP..."
$GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1 if [ "`uname -s`" == "Darwin" ]; then
$GMP/configure --with-pic --build=x86-darwin --host=armv5-eabi-linux || exit 1
else
$GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1
fi
fi fi
echo "Building GMP..." echo "Building GMP..."
make || exit 1 make || exit 1
if [ "`uname -s`" == "Darwin" ]; then if [ "`uname -s`" == "Darwin" ]; then
export JAVA_HOME="/Library/Java/Home" # Depends on version
# TODO: Fix something for finding the newest jdk and set it as home.
export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/"
else else
export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac)))) export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac))))
fi fi
......
package net.i2p.android.router.activity; package net.i2p.android.router.activity;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStreamReader; import java.io.IOException;
import java.io.OutputStreamWriter;
import net.i2p.util.FileUtil;
import net.i2p.android.router.R; import net.i2p.android.router.R;
import android.os.Bundle; import android.os.Bundle;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
...@@ -21,11 +18,11 @@ import android.widget.Toast; ...@@ -21,11 +18,11 @@ import android.widget.Toast;
public class AddressbookSettingsActivity extends Activity { public class AddressbookSettingsActivity extends Activity {
protected EditText text_content_subscriptions; protected EditText text_content_subscriptions;
protected Button btn_save_subscriptions; protected Button btn_save_subscriptions;
private String filename = "/addressbook/subscriptions.txt"; private String filename = "/addressbook/subscriptions.txt";
private String i2pDir; private File i2pDir;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -33,7 +30,7 @@ public class AddressbookSettingsActivity extends Activity { ...@@ -33,7 +30,7 @@ public class AddressbookSettingsActivity extends Activity {
text_content_subscriptions = (EditText) findViewById(R.id.subscriptions_content); text_content_subscriptions = (EditText) findViewById(R.id.subscriptions_content);
btn_save_subscriptions = (Button) findViewById(R.id.button_save_subscriptions); btn_save_subscriptions = (Button) findViewById(R.id.button_save_subscriptions);
init_actions(); init_actions();
i2pDir = getFilesDir().getAbsolutePath(); i2pDir = new File(getFilesDir(), filename);
load(); load();
} }
...@@ -42,61 +39,49 @@ public class AddressbookSettingsActivity extends Activity { ...@@ -42,61 +39,49 @@ public class AddressbookSettingsActivity extends Activity {
getMenuInflater().inflate(R.menu.activity_addressbook_settings, menu); getMenuInflater().inflate(R.menu.activity_addressbook_settings, menu);
return true; return true;
} }
private void init_actions() { private void init_actions() {
btn_save_subscriptions.setOnClickListener(new View.OnClickListener() { btn_save_subscriptions.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
Context context = getApplicationContext(); Context context = getApplicationContext();
CharSequence text = ""; CharSequence text = "";
if (save()) { if (save()) {
text = "subscriptions.txt successfully saved!"; text = "subscriptions.txt successfully saved!";
} else { } else {
text = "there was a problem saving subscriptions.txt! Try fix permissions or reinstall i2p."; text = "there was a problem saving subscriptions.txt! Try fix permissions or reinstall i2p.";
} }
Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
} }
}); });
} }
private boolean load() { private boolean load() {
String res = null; String res = FileUtil.readTextFile(i2pDir.getAbsolutePath(), -1, true);
FileInputStream in; if (res.length() > 0) {
try { text_content_subscriptions.setText(res);
in = new FileInputStream(new File(i2pDir+filename)); return true;
if (in != null) { }
InputStreamReader input = new InputStreamReader(in); Context context = getApplicationContext();
BufferedReader buffreader = new BufferedReader(input); CharSequence text = "Sorry, could not load subscriptions.txt!";
res=""; Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
String line = null; return false;
while (( line = buffreader.readLine()) != null) {
res += line+"\n";
}
in.close();
text_content_subscriptions.setText(res);
return true;
}
} catch (Exception e) {
Log.e("I2P-AddressbookSettings", "Can't read subscriptions.txt");
//TODO: Add error reporting support
e.printStackTrace();
return false;
}
return false;
} }
private boolean save() { private boolean save() {
// //
String content = text_content_subscriptions.getText().toString(); String content = text_content_subscriptions.getText().toString();
try { FileOutputStream out = null;
FileOutputStream out = new FileOutputStream(new File(i2pDir+filename)); try {
byte[] contentInBytes = content.getBytes(); out = new FileOutputStream(i2pDir);
out.write(contentInBytes); byte[] contentInBytes = content.getBytes();
out.flush(); out.write(contentInBytes);
out.close(); out.close();
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} } finally {
if (out != null) try {out.close(); } catch (IOException ioe) {}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment