From 06ee93b396c2089719cb610c0c324e10ff62be2e Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Fri, 7 Jan 2022 00:06:46 +0400 Subject: [PATCH] Update README.md --- README.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8966041..423551a 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,14 @@ Testing playground to support the peernet protocol on android phones. The implem There is currently no modifications done to the peernet core to get it running on android phones. As a brief the entire project is done using Kotlin with Go mobile. +### Screenshots: +![image](https://user-images.githubusercontent.com/31743758/148444431-3cb045a3-4950-4f57-9148-84756f6cfcf6.png) + + ## Disclaimer: It is important to note that there could be scenarios where the phone could potencially freeze. The current commits are currently unstable. + ## Current Features: - Upload file to peernet 1. Add files to warehouse @@ -13,9 +18,78 @@ It is important to note that there could be scenarios where the phone could pote - Download file from peernet - View latest files uploaded -## Build steps/ Installation +## Build from gomobile: The following steps below demonstrate how to build the application: +- Create go project with the package called mobile +``` +## The following applies for linux +- mkdir mobile +- cd mobile/ +- go mod init +- touch mobile.go +``` +- add to ```mobile.go``` +```go +package mobile + +import ( + "fmt" + "github.com/PeernetOfficial/core" + "github.com/PeernetOfficial/core/webapi" + "github.com/google/uuid" + "net/http" + "time" +) + +// MobileMain The following function is called as a bind function +// from the Kotlin implementation +func MobileMain(path string) { + + var config core.Config + + // Load the config file + core.LoadConfig(path+"Config.yaml", &config) + + //Setting modified paths in the config file + config.SearchIndex = path + "data/search_Index/" + config.BlockchainGlobal = path + "data/blockchain/" + config.BlockchainMain = path + "data/blockchain_main/" + config.WarehouseMain = path + "data/warehouse/" + config.GeoIPDatabase = path + "data/GeoLite2-City.mmdb" + config.LogFile = path + "data/log.txt" + + // save modified config changes + core.SaveConfig(path+"Config.yaml", &config) + + backendInit, status, err := core.Init("Your application/1.0", path+"Config.yaml", nil) + if status != core.ExitSuccess { + fmt.Printf("Error %d initializing config: %s\n", status, err.Error()) + return + } + + // start config api server + webapi.Start(backendInit, []string{"127.0.0.1:5125"}, false, "", "", 10*time.Second, 10*time.Second, uuid.Nil) + + backendInit.Connect() + + // Checks if the go code can access the internet + if !connected() { + fmt.Print("Not connected to the internet ") + } else { + fmt.Print("Connected") + } + +} + +func connected() (ok bool) { + _, err := http.Get("http://clients3.google.com/generate_204") + if err != nil { + return false + } + return true +} +``` - Install go mobile ``` go install golang.org/x/mobile/cmd/gomobile@latest @@ -24,7 +98,27 @@ go install golang.org/x/mobile/cmd/gomobile@latest ``` gomobile init ``` -// Todo +- Add path for Android NDK +``` +export ANDROID_HOME=$HOME/Android/Sdk +``` +- Generate .aar and .jar file +``` +gomobile bind -target android . + +Output: +mobile.aar mobile-sources.jar +``` +- clone the following repo +``` +git clone https://github.com/PeernetOfficial/core-android +``` +- add the following files(i.e mobile.aar,mobile-sources.jar) to the following path. Overwrite it if the file already exists +``` +//core-android/app/libs/ +``` +- Open the project in android studio and click the play button. +![image](https://user-images.githubusercontent.com/31743758/148443246-79ce16c3-d2a0-483a-9396-620deafda6ee.png) ## Implementation - // Todo