Skip to content

Commit

Permalink
Merged kiwix-android code into main repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Apr 4, 2013
1 parent 32b74dc commit 637c65b
Show file tree
Hide file tree
Showing 43 changed files with 1,176 additions and 10 deletions.
59 changes: 59 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="org.kiwix.kiwixmobile">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="17"/>
<application android:icon="@drawable/kiwix_icon" android:label="@string/app_name" android:allowBackup="true">
<activity android:name=".KiwixMobileActivity"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.zim.*" />
<data android:pathPattern=".*\\..*\\.zim.*"/>
<data android:pathPattern=".*\\..*\\..*\\.zim.*"/>
<data android:pathPattern=".*\\..*\\..*\\..*\\.zim.*"/>
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<provider
android:name=".ZimContentProvider"
android:authorities="org.kiwix.zim"
android:exported="false"/>

<activity
android:name=".ZimFileSelectActivity"
android:icon="@drawable/kiwix_icon"
android:label="@string/choose_file" >
<!-- TODO -->
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />

<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file added Kiwix_icon_transparent_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Kiwix_icon_transparent_600x600.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions create_libkiwix.so.py → build-android-with-native.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
COMPILE_LIBZIM = True
COMPILE_LIBKIWIX = True
STRIP_LIBKIWIX = True
COMPILE_APK = False
COMPILE_APK = True

# store the OS's environment PATH as we'll mess with it
# ORIGINAL_ENVIRON_PATH = os.environ.get('PATH')
Expand All @@ -45,6 +45,7 @@
# store host machine name
UNAME = check_output(['uname', '-s']).strip()
UARCH = check_output(['uname', '-m']).strip()
SYSTEMS = {'Linux': 'linux', 'Darwin': 'mac'}

# compiler version to use
# list of available toolchains in <NDK_PATH>/toolchains
Expand All @@ -56,6 +57,10 @@
os.path.join(os.path.dirname(CURRENT_PATH),
'src', 'dependencies',
'android-ndk-r8e'))
SDK_PATH = os.environ.get('ANDROID_HOME',
os.path.join(os.path.dirname(CURRENT_PATH),
'src', 'dependencies',
'android-sdk', 'sdk'))

# Target Android EABI/version to compile for.
# list of available platforms in <NDK_PATH>/platforms
Expand Down Expand Up @@ -184,8 +189,8 @@ def change_env(values):
'orig': ORIGINAL_ENVIRON['PATH'],
'arch_full': arch_full,
'gccver': COMPILER_VERSION}),
'CFLAGS': ' -fPIC '
}
'CFLAGS': ' -fPIC ',
'ANDROID_HOME': SDK_PATH}
change_env(new_environ)
change_env(OPTIMIZATION_ENV)

Expand Down Expand Up @@ -264,9 +269,9 @@ def change_env(values):
os.remove(src.replace('.cpp', '.o'))

# compile JNI header
os.chdir(os.path.join(curdir, 'org', 'kiwix', 'kiwixmobile'))
os.chdir(os.path.join(curdir, 'src', 'org', 'kiwix', 'kiwixmobile'))
syscall('javac JNIKiwix.java')
os.chdir(curdir)
os.chdir(os.path.join(curdir, 'src'))
syscall('javah -jni org.kiwix.kiwixmobile.JNIKiwix')

# create libkiwix.so
Expand All @@ -284,7 +289,9 @@ def change_env(values):
+ platform_includes
+ [LIBKIWIX_SRC,
os.path.join(LIBZIM_SRC,
'include')])
'include'),
os.path.join(curdir,
'src')])
})

link_cmd = ('g++ -fPIC -shared -B%(platform)s/sysroot '
Expand All @@ -297,10 +304,12 @@ def change_env(values):
'/libs/%(arch_short)s/libgnustl_static.a '
'-llog -landroid -lstdc++ -lc '
'%(platform)s/lib/gcc/%(arch_full)s/%(gccver)s/libgcc.a '
'-o %(platform)s/lib/libkiwix.so'
'-o %(curdir)s/libs/%(arch_short)s/libkiwix.so'
% {'kwsrc': LIBKIWIX_SRC,
'platform': platform,
'arch_full': arch_full,
'arch_short': arch_short,
'curdir': curdir,
'gccver': COMPILER_VERSION,
'NDK_PATH': NDK_PATH,
'arch_short': arch_short})
Expand All @@ -309,14 +318,17 @@ def change_env(values):
syscall(compile_cmd)
syscall(link_cmd)

for obj in ('kiwix.o', 'reader.o', 'stringTools.o'):
for obj in ('kiwix.o', 'reader.o', 'stringTools.o',
'src/org_kiwix_kiwixmobile_JNIKiwix.h'):
os.remove(obj)

if STRIP_LIBKIWIX:
syscall('%(platform)s/%(arch_full)s/bin/strip '
'%(platform)s/lib/libkiwix.so'
'%(curdir)s/libs/%(arch_short)s/libkiwix.so'
% {'platform': platform,
'arch_full': arch_full})
'arch_full': arch_full,
'arch_short': arch_short,
'curdir': curdir})

os.chdir(curdir)
change_env(ORIGINAL_ENVIRON)
Expand Down
92 changes: 92 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Kiwix" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />

<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>

<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>

<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />

<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />

</project>
26 changes: 26 additions & 0 deletions create-signed-android-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

if [ -f "$1" ];
then
CERTIFICATE=$1
else
echo "Usage: $0 Kiwix-android.keystore"
echo "You must specify the path of the certificate keystore."
exit 1
fi

function die {
echo -n "[ERROR] "
echo -n $1
echo -n " Aborting.
"
exit 1
}

ant release || die "ant release error."
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore $CERTIFICATE bin/Kiwix-release-unsigned.apk kiwix || die "Error signing the package."
jarsigner -verify bin/Kiwix-release-unsigned.apk || die "The package is not properly signed."
zipalign -f -v 4 bin/Kiwix-release-unsigned.apk bin/kiwix-android.apk || die "Could not zipalign the signed package. Please check."

echo "[SUCCESS] Your signed release package is ready:"
ls -lh bin/kiwix-android.apk
36 changes: 36 additions & 0 deletions proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
14 changes: 14 additions & 0 deletions project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-14
Binary file added res/drawable-hdpi/action_help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/device_access_sd_storage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/kiwix_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/navigation_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/navigation_forward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/kiwix_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/action_help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/device_access_sd_storage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/kiwix_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/navigation_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/navigation_forward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/action_help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/device_access_sd_storage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/kiwix_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/navigation_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/navigation_forward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<AutoCompleteTextView
android:id="@+id/articleSearchTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:ellipsize="end"
android:maxLines="1"
android:inputType="text|textCapWords"
android:imeOptions="actionGo"
android:text=""
android:hint="@string/articlesearch_hint"
android:completionThreshold="1" >
</AutoCompleteTextView>

<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<requestFocus />
</WebView>

</LinearLayout>
8 changes: 8 additions & 0 deletions res/layout/zimfilelist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/zimfilelist"
android:layout_width="match_parent"
android:layout_height="match_parent" >


</ListView>
17 changes: 17 additions & 0 deletions res/layout/zimfilelistentry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/zim_file_list_entry_path"
style="@android:style/TextAppearance.Large"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Loading

0 comments on commit 637c65b

Please sign in to comment.