├── .circleci └── config.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── io │ │ └── textile │ │ └── textileexample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── io │ │ │ └── textile │ │ │ └── textileexample │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── io │ └── textile │ └── textileexample │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ipfslite ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ ├── assets │ │ ├── TEST0.JPG │ │ ├── TEST1.JPG │ │ ├── TEST2.JPG │ │ ├── TEST3.JPG │ │ ├── TEST4.JPG │ │ ├── TEST5.JPG │ │ ├── TEST6.JPG │ │ └── TEST7.JPG │ └── java │ │ └── io │ │ └── textile │ │ └── ipfslite │ │ └── PeerTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── io │ │ │ └── textile │ │ │ └── ipfslite │ │ │ └── Peer.java │ ├── proto │ │ └── ipfs_lite.proto │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ ├── java │ └── io │ │ └── textile │ │ └── ipfslite │ │ └── ExampleUnitTest.java │ └── proto │ └── ipfs_lite.proto ├── manifest.gradle └── settings.gradle /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | jobs: 4 | build: 5 | docker: 6 | - image: circleci/android:api-28-ndk 7 | steps: 8 | - checkout 9 | - restore_cache: 10 | key: jars-{{ checksum "manifest.gradle" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "ipfslite/build.gradle" }} 11 | - run: 12 | name: Download Dependencies 13 | command: ./gradlew androidDependencies 14 | - save_cache: 15 | paths: 16 | - ~/.gradle 17 | key: jars-{{ checksum "manifest.gradle" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "ipfslite/build.gradle" }} 18 | - run: 19 | name: install 20 | command: | 21 | ./gradlew ipfslite:install 22 | 23 | publish: 24 | docker: 25 | - image: circleci/android:api-28-ndk 26 | steps: 27 | - checkout 28 | - restore_cache: 29 | key: jars-{{ checksum "manifest.gradle" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "ipfslite/build.gradle" }} 30 | - run: 31 | name: Download Dependencies 32 | command: ./gradlew androidDependencies 33 | - save_cache: 34 | paths: 35 | - ~/.gradle 36 | key: jars-{{ checksum "manifest.gradle" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "ipfslite/build.gradle" }} 37 | - run: 38 | name: update version 39 | command: | 40 | sed -i.bak "s/0.0.1-dev/${CIRCLE_TAG}/g" manifest.gradle 41 | - run: 42 | name: install 43 | command: | 44 | ./gradlew ipfslite:install 45 | - run: 46 | name: publish 47 | command: | 48 | ./gradlew ipfslite:bintrayUpload 49 | workflows: 50 | android-ipfs-lite: 51 | jobs: 52 | - build 53 | - publish: 54 | filters: 55 | tags: 56 | only: /.*/ 57 | branches: 58 | ignore: /.*/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # IntelliJ 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/gradle.xml 41 | .idea/assetWizardSettings.xml 42 | .idea/dictionaries 43 | .idea/libraries 44 | .idea/caches 45 | # Android Studio 3 in .gitignore file. 46 | .idea/caches/build_file_checksums.ser 47 | .idea/modules.xml 48 | 49 | # Keystore files 50 | # Uncomment the following lines if you do not want to check your keystore files in. 51 | #*.jks 52 | #*.keystore 53 | 54 | # External native build folder generated in Android Studio 2.2 and later 55 | .externalNativeBuild 56 | 57 | # Google Services (e.g. APIs or Firebase) 58 | # google-services.json 59 | 60 | # Freeline 61 | freeline.py 62 | freeline/ 63 | freeline_project_description.json 64 | 65 | # fastlane 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | fastlane/readme.md 71 | 72 | # Version control 73 | vcs.xml 74 | 75 | # lint 76 | lint/intermediates/ 77 | lint/generated/ 78 | lint/outputs/ 79 | lint/tmp/ 80 | # lint/reports/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | The following is a set of guidelines for contributing to Textile-related projects, which are hosted in the [Textile organization](https://github.com/textileio). These are just guidelines, not rules. Use your best judgment, and 4 | feel free to propose changes to this document in a pull request. 5 | 6 | Note that Textile is an evolving project, so expect things to change over time as the team learns, listens and refines how we work with the community. 7 | 8 | #### Table Of Contents 9 | 10 | [What should I know before I get started?](#what-should-i-know-before-i-get-started) 11 | * [Code of Conduct](#code-of-conduct) 12 | 13 | [How Can I Contribute?](#how-can-i-contribute) 14 | * [Reporting Bugs](#reporting-bugs) 15 | * [Suggesting Enhancements](#suggesting-enhancements) 16 | 17 | [Additional Notes](#additional-notes) 18 | 19 | ## What should I know before I get started? 20 | 21 | ### Code of Conduct 22 | 23 | This project adheres to the Contributor Covenant [code of conduct](./CODE_OF_CONDUCT.md). 24 | By participating, you are expected to uphold this code. 25 | Please report unacceptable behavior to [contact@textile.io](mailto:contact@textile.io). 26 | 27 | ## How Can I Contribute? 28 | 29 | ### Developing locally 30 | 31 | #### How to Setup 32 | 33 | Generally, Textile projects can be initialized with something like: 34 | 35 | **Step 1:** git clone this repo: 36 | 37 | **Step 2:** cd to the cloned repo: 38 | 39 | **Step 3:** Install the Application with `yarn` or `npm i` 40 | 41 | See each indiviual project's `README` for details. 42 | 43 | ### Reporting Bugs 44 | 45 | This section guides you through submitting a bug report for any Textile repo. 46 | Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports. 47 | 48 | Before creating bug reports, please check [this list](../../labels/bug) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). 49 | 50 | #### Before Submitting A Bug Report 51 | 52 | **Perform a [cursory search](../../labels/bug)** to see if the problem has already been reported. If it does exist, add a :thumbsup: to the issue to indicate this is also an issue for you, and add a comment to the existing issue if there is extra information you can contribute. 53 | 54 | #### How Do I Submit A (Good) Bug Report? 55 | 56 | Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). 57 | 58 | Simply create an issue on the [Textile issue tracker](../../issues). 59 | 60 | The information we are interested in includes: 61 | 62 | - details about your environment - which build, which operating system 63 | - details about reproducing the issue - what steps to take, what happens, how 64 | often it happens 65 | - other relevant information - log files, screenshots, etc. 66 | 67 | ### Suggesting Enhancements 68 | 69 | This section guides you through submitting an enhancement suggestion for this project, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:. 70 | 71 | Before creating enhancement suggestions, please check [this list](../..//labels/bug) 72 | as you might find out that you don't need to create one. When you are creating 73 | an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Include the steps 74 | that you imagine you would take if the feature you're requesting existed. 75 | 76 | #### Before Submitting An Enhancement Suggestion 77 | 78 | **Perform a [cursory search](../../labels/enhancement)** 79 | to see if the enhancement has already been suggested. If it has, add a 80 | :thumbsup: to indicate your interest in it, or comment if there is additional 81 | information you would like to add. 82 | 83 | #### How Do I Submit A (Good) Enhancement Suggestion? 84 | 85 | Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). 86 | 87 | Simply create an issue on the [Textile issue tracker](../..//issues) 88 | and provide the following information: 89 | 90 | * **Use a clear and descriptive title** for the issue to identify the 91 | suggestion. 92 | * **Provide a step-by-step description of the suggested enhancement** in as 93 | much detail as possible. This additional context helps the maintainers to 94 | understand the enhancement from your perspective 95 | * **Explain why this enhancement would be useful** to Textile users. 96 | * **Include screenshots and animated GIFs** if relevant to help you demonstrate 97 | the steps or point out the part of Textile which the suggestion is 98 | related to. 99 | * **List some other applications where this enhancement exists, if applicable.** 100 | 101 | ## Additional Notes 102 | 103 | More to be added 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 textile.io 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-ipfs-lite 2 | 3 | [![Made by Textile](https://img.shields.io/badge/made%20by-Textile-informational.svg?style=flat-square)](https://textile.io) 4 | [![Chat on Slack](https://img.shields.io/badge/slack-slack.textile.io-informational.svg?style=flat-square)](https://slack.textile.io) 5 | [![GitHub license](https://img.shields.io/github/license/textileio/android-ipfs-lite.svg?style=flat-square)](./LICENSE) 6 | [![Release](https://img.shields.io/github/release/textileio/android-ipfs-lite.svg?style=flat-square)](https://github.com/textileio/android-ipfs-lite/releases/latest) 7 | [![CircleCI branch](https://img.shields.io/circleci/project/github/textileio/android-ipfs-lite/master.svg?style=flat-square)](https://circleci.com/gh/textileio/android-ipfs-lite) 8 | [![docs](https://img.shields.io/badge/docs-master-success.svg?style=popout-square)](https://textileio.github.io/android-ipfs-lite/) 9 | [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) 10 | 11 | > A lightweight, extensible IPFS peer for Android. 12 | 13 | IPFS Lite runs the minimal setup required to get and put IPLD DAGs on the IPFS network. It is a port of the [Go IPFS Lite](https://github.com/hsanjuan/ipfs-lite) library. 14 | 15 | ## Table of Contents 16 | 17 | - [android-ipfs-lite](#android-ipfs-lite) 18 | - [Table of Contents](#table-of-contents) 19 | - [Background](#background) 20 | - [IPFS-lite Libraries](#ipfs-lite-libraries) 21 | - [Roadmap](#roadmap) 22 | - [Install](#install) 23 | - [Usage](#usage) 24 | - [Initialize and start a Peer](#initialize-and-start-a-peer) 25 | - [Add data](#add-data) 26 | - [Add a file](#add-a-file) 27 | - [Fetch a file by CID](#fetch-a-file-by-cid) 28 | - [Maintainers](#maintainers) 29 | - [Contributing](#contributing) 30 | - [License](#license) 31 | 32 | ## Background 33 | 34 | IPFS Lite runs the minimal setup required to provide a DAG service. It is a port of the [Go IPFS Lite](https://github.com/hsanjuan/ipfs-lite) library, and as such, has the same requirements. The goal of IPFS Lite is to run the bare minimal functionality for any IPLD-based application to interact with the IPFS network (by getting and putting blocks). This saves having to deal with the complexities of using a full IPFS daemon, while maintaining the ability to share the underlying libp2p host and DHT with other components. 35 | 36 | ### IPFS-lite Libraries 37 | 38 | > The following includes information about support for ipfs-lite. 39 | 40 | | Name | Build | Language | Description | 41 | |:---------|:---------|:---------|:---------| 42 | | [`ipfs-lite`](https://github.com/hsanjuan/ipfs-lite) | [![Build Status](https://img.shields.io/travis/hsanjuan/ipfs-lite.svg?branch=master&style=flat-square)](https://travis-ci.org/hsanjuan/ipfs-lite) | [![golang](https://img.shields.io/badge/golang-blueviolet.svg?style=popout-square)](https://github.com/hsanjuan/ipfs-lite) | The reference implementaiton of ipfs-lite, written in Go. | 43 | | [`js-ipfs-lite`](//github.com/textileio/js-ipfs-lite) | [![Build status](https://img.shields.io/github/workflow/status/textileio/js-ipfs-lite/Test/master.svg?style=popout-square)](https://github.com/textileio/js-ipfs-lite/actions?query=branch%3Amaster) | [![javascript](https://img.shields.io/badge/javascript-blueviolet.svg?style=popout-square)](https://github.com/textileio/js-ipfs-lite)| The Javascript version of ipfs-lite available for web, nodejs, and React Native applications. | 44 | | [`ios-ipfs-lite`](//github.com/textileio/ios-ipfs-lite) | [![Build status](https://img.shields.io/circleci/project/github/textileio/ios-ipfs-lite/master.svg?style=flat-square)](https://github.com/textileio/ios-ipfs-lite/actions?query=branch%3Amaster) | [![objc](https://img.shields.io/badge/objc-blueviolet.svg?style=popout-square)](https://github.com/textileio/ios-ipfs-lite)| The iOS ipfs-lite library for use in Objc and Swift apps | 45 | | [`android-ipfs-lite`](//github.com/textileio/android-ipfs-lite) | [![Build status](https://img.shields.io/circleci/project/github/textileio/android-ipfs-lite/master.svg?style=flat-square)](https://github.com/textileio/android-ipfs-lite/actions?query=branch%3Amaster) | [![java](https://img.shields.io/badge/java-blueviolet.svg?style=popout-square)](https://github.com/textileio/android-ipfs-lite)| The Java ipfs-lite library for us in Android apps | 46 | | [`grpc-ipfs-lite`](//github.com/textileio/grpc-ipfs-lite) | [![Build status](https://img.shields.io/circleci/project/github/textileio/grpc-ipfs-lite/master.svg?style=flat-square)](https://github.com/textileio/grpc-ipfs-lite/actions?query=branch%3Amaster) | [![java](https://img.shields.io/badge/grpc--api-blueviolet.svg?style=popout-square)](https://github.com/textileio/grpc-ipfs-lite)| A common gRPC API interface that runs on the Go ipfs-lite node. | 47 | 48 | ## Roadmap 49 | 50 | - [x] Start IPFS Lite 51 | - [x] Stop IPFS Lite 52 | - [x] `getFile(String cid)` Get file by Content Address. 53 | - [x] `getFileSync(String cid)` Synchronously get file by Content Address. 54 | - [x] `addFile(byte[] data)` Add file to IPFS. 55 | - [x] `addFileSync(byte[] data)` Synchronously Add file to IPFS. 56 | - [x] `getNode(String cid)` Get IPLD node. 57 | - [x] `removeNode(String cid)` Remove IPLD node. 58 | - [ ] Add IPLD node. 59 | - [x] `resolveLink(String link)` 60 | 61 | ## Install 62 | 63 | The IPFS Lite library is published in [Textile's Bintray Maven repository](https://dl.bintray.com/textile/maven). 64 | You can install it using Gradle. 65 | 66 | First, you'll need to add Textile's Bintray Maven repository to you project's top level `build.gradle` in the `allProjects.repositories` section: 67 | 68 | ```cmd 69 | allprojects { 70 | repositories { 71 | ... 72 | maven { url 'https://dl.bintray.com/textile/maven' } 73 | maven { url 'https://jitpack.io' } 74 | ... 75 | } 76 | } 77 | ``` 78 | 79 | Next, add the IPFS Lite dependency to your app module's `build.gradle` `dependencies` section, specifying the [latest version available](https://bintray.com/textile/maven/ipfs-lite/_latestVersion): 80 | 81 | ```cmd 82 | dependencies { 83 | ... 84 | implementation 'io.textile:ipfslite:0.1.4' 85 | ... 86 | } 87 | ``` 88 | 89 | ## Usage 90 | 91 | ### Initialize and start a Peer 92 | 93 | ```java 94 | Boolean debug = false; 95 | Peer litePeer = new Peer('/path/', debug, true); 96 | litePeer.start(); 97 | ``` 98 | 99 | * To learn see how a path is choosen, see the [test suite example](https://github.com/textileio/android-ipfs-lite/blob/master/ipfslite/src/androidTest/java/io/textile/ipfslite/PeerTest.java#L38). 100 | 101 | ### Add data 102 | 103 | ```java 104 | String message = "Hello World"; 105 | String cid = litePeer.addFileSync(message.getBytes()); 106 | ``` 107 | 108 | ### Add a file 109 | 110 | ```java 111 | File file = openFile("secret_plans"); 112 | byte[] bytes = Files.readAllBytes(file.toPath()); 113 | String cid = litePeer.addFileSync(bytes); 114 | 115 | // OR Asynchronously 116 | litePeer.addFile(bytes, resultHandler); 117 | ``` 118 | 119 | ### Fetch a file by CID 120 | 121 | ```java 122 | byte[] data = litePeer.getFileSync("bafybeic35nent64fowmiohupnwnkfm2uxh6vpnyjlt3selcodjipfrokgi"); 123 | // OR Asynchronously 124 | litePeer.getFile("bafybeic35nent64fowmiohupnwnkfm2uxh6vpnyjlt3selcodjipfrokgi", resultHandler); 125 | ``` 126 | 127 | ## Maintainers 128 | 129 | [Andrew Hill](https://github.com/andrewxhill) 130 | 131 | ## Contributing 132 | 133 | See [the contributing file](CONTRIBUTING.md)! 134 | 135 | PRs accepted. 136 | 137 | Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. 138 | 139 | ## License 140 | 141 | [MIT](LICENSE) (c) 2019 Textile 142 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | repositories { 4 | maven { 5 | url 'https://dl.bintray.com/textile/maven' 6 | } 7 | } 8 | 9 | android { 10 | compileSdkVersion targetSdk 11 | 12 | defaultConfig { 13 | applicationId demoAppId 14 | minSdkVersion minSdk 15 | targetSdkVersion targetSdk 16 | versionCode 1 17 | versionName '1.0' 18 | 19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation fileTree(dir: 'libs', include: ['*.jar']) 37 | 38 | // UI 39 | implementation "com.android.support.constraint:constraint-layout:$constraintLayoutVersion" 40 | 41 | // Support 42 | implementation "com.android.support:appcompat-v7:$appcompatVersion" 43 | implementation "com.android.support:support-v4:$appcompatVersion" 44 | 45 | // gRPC IPFS Lite 46 | implementation project(':ipfslite') 47 | 48 | // Testing 49 | testImplementation "junit:junit:$junitVersion" 50 | 51 | androidTestImplementation "com.android.support.test:runner:$testRunnerVersion" 52 | } 53 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/io/textile/textileexample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package io.textile.textileexample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("io.textile.textile.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/io/textile/textileexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.textile.textileexample; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | 8 | import java.io.File; 9 | 10 | import io.textile.ipfslite.Peer; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | Peer litePeer; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | 21 | initIPFS(); 22 | } 23 | 24 | public void onButtonClick(View v) { 25 | try { 26 | String cid = litePeer.addFileSync("Hello World".getBytes()); 27 | System.out.println("Success: " + cid); 28 | } catch (Exception e) { 29 | System.out.println(e.getMessage()); 30 | } 31 | try { 32 | byte[] file = litePeer.getFileSync("bafybeic35nent64fowmiohupnwnkfm2uxh6vpnyjlt3selcodjipfrokgi"); 33 | System.out.println("Success: " + new String(file, "UTF-8")); 34 | } catch (Exception e) { 35 | System.out.println(e.getMessage()); 36 | } 37 | } 38 | 39 | private void initIPFS() { 40 | try { 41 | Context ctx = getApplicationContext(); 42 | final File filesDir = ctx.getFilesDir(); 43 | final String path = new File(filesDir, "ipfslite").getAbsolutePath(); 44 | litePeer = new Peer(path, BuildConfig.DEBUG, true); 45 | litePeer.start(); 46 | } catch (Exception e) { 47 | System.out.println(e.getMessage()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 |