This Android application boilerplate allows users (at compile time) to sandbox a website, either from the web or locally, in the android.webkit.WebView.

vaeringjar 7278604faf added licences 9 年之前
.idea 5c1b05e608 first commit yay 9 年之前
app 761490bcd6 updated the icon 9 年之前
gradle 5c1b05e608 first commit yay 9 年之前
.gitignore 4646f068d2 added readme and updated ignore 9 年之前
Hundreds.iml 5c1b05e608 first commit yay 9 年之前
LICENSE.md 7278604faf added licences 9 年之前
LICENSE_Apache-2.0.txt 7278604faf added licences 9 年之前
LICENSE_gpl-3.0.txt 7278604faf added licences 9 年之前
README.md 41d4f5de5f updated configuration docs and added license info 9 年之前
build.gradle 5c1b05e608 first commit yay 9 年之前
gradle.properties 5c1b05e608 first commit yay 9 年之前
gradlew 5c1b05e608 first commit yay 9 年之前
gradlew.bat 5c1b05e608 first commit yay 9 年之前
settings.gradle 5c1b05e608 first commit yay 9 年之前

README.md

Hunreds

About

This Android application boilerplate allows users (at compile time) to sandbox a website, either from the web or locally, in the android.webkit.WebView.

License

Copyright 2015 vaeringjar
Multi-licensed as GLPv3+ and Apache 2.0:
https://www.gnu.org/licenses/gpl-3.0.html
https://www.apache.org/licenses/LICENSE-2.0.html

Configuration

You have the option to either sandbox a website with files on the local file system or to sandbox an internet website. You can also change the name of the program and its icons.

The source should have the following:

Hundreds/app/src/main/assets/root/  
Hundreds/app/src/main/res/drawable-%  
Hundreds/app/src/main/java/community/peers/hundreds/MainActivity.java  
Hundreds/app/src/main/java/community/peers/hundreds/HundredsSandbox.java  
Hundreds/app/src/main/AndroidManifest.xml  
Hundreds/app/src/main/res/values/strings.xml  
Hundreds/app/build.gradle

Fork Hundreds

If you would like to fork Hundreds to install many instances with different configurations, and if you use Gradle, make sure to update your Hundreds/app/build.gradle file with a distinct applicationId. Most of these use descending (reverse) domain names, but you can really use anything you like.

If you do not fork Hundreds, each time you install a "new" application configuration build, Android will recognize the apk as an update rather than a separate app.

Customize the Name

To change the name, open AndroidManifest.xml and change either the references for any of these:

android:label="@string/app_name"

Or update the values in strings.xml:

<resources>  
    <string name="app_name">Hundreds</string>  
    ...  
</resources>  

Customize the App Icon

To add a customized icon, update the reference in the AndroidManifest.xml:

android:icon="@drawable/ic_launcher"

Then update the files in the res/drawable folders. Each of the folders holds a different icon for a different screen density. Other projects might have higher or lower density folders, in addtion to these.

drawable-mdpi/ic_launcher.png //48px x 48px
drawable-hdpi/ic_launcher.png //72px x 72px
drawable-xhdpi/ic_launcher.png //96px x 96px
drawable-xxhdpi/ic_launcher.png //144px x 144px

For the reference in the AndroidManifest.xml to match, each density variation needs the same file name.

Optionally, you can put one large icon, for example 512px x 512px, in Hundreds/app/src/main/res/drawable-xxhdpi and your device will render it at run time. This makes it easier to maintain, but it might produce a lower quality icon when displaying the file.

Local File System

In the assets/root directory, place the complete website. At the very least, place an index.html file.

In the MainActivity.java, set the flag loadLocal to true. This will tell Hundreds to look at the file system instead of an internet website.

private boolean loadLocal = true;

Internet Website

In the MainActivity.java, set the flag loadLocal to false. This will tell Hundreds to look at a website domain name instead of in the local assets/root directory.

private boolean loadLocal = false;

In HundredsSandbox.java, set the desired protocol and domain name for the internet website. For example:

public final static String PROTOCOL_HTTP = "http://";
public final static String DOMAIN_INTERNET = "peers.community";

Ignore files

Note the project has multiple ignore files:

Hundreds/.gitignore
Hundreds/app/.gitignore

Security Considerations

The Android Developer Reference warns about vulnerabilities for Android systems earlier than 4.2.
https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface%28java.lang.Object,%20java.lang.String%29 https://developer.android.com/reference/android/webkit/JavascriptInterface.html

Roadmap

  • Migrate to the Replicant SDK.
  • Add a config file that defines the domain and the protocol for run time preferences.