diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/android/.gradle/5.6.4/fileHashes/fileHashes.lock b/android/.gradle/5.6.4/fileHashes/fileHashes.lock new file mode 100644 index 0000000..c3bd737 Binary files /dev/null and b/android/.gradle/5.6.4/fileHashes/fileHashes.lock differ diff --git a/android/.idea/.name b/android/.idea/.name new file mode 100644 index 0000000..696dada --- /dev/null +++ b/android/.idea/.name @@ -0,0 +1 @@ +Backup \ No newline at end of file diff --git a/android/.idea/codeStyles/Project.xml b/android/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/android/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/android/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/android/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/android/.idea/runConfigurations.xml b/android/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/android/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/android/.idea/vcs.xml b/android/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/android/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/README.md b/android/README.md new file mode 100644 index 0000000..0e788dd --- /dev/null +++ b/android/README.md @@ -0,0 +1,40 @@ +## Gomobile instalation +``` +$ go get golang.org/x/mobile/cmd/gomobile +$ gomobile init +``` +## Install Android Studio (on Ubuntu 20.04): +``` +$ sudo apt install openjdk-11-jdk +$ sudo snap install android-studio --classic +``` +## Install Android NDK: + +https://developer.android.com/ndk + +You may need to configure these enviroment variables: +``` +export GOPATH=~/go +export PATH=$PATH:$GOPATH/bin +export ANDROID_NDK_HOME= {PATH to Android NDK} +export ANDROID_HOME= {PATH to Android SDK} +``` +## aar generation +``` +$ gomobile bind -o app/backup.aar -target=android ../wrapper/ +``` +## Use of .aar in Android project + +Edit android\app\build.gradle adding: +``` ++ repositories { ++ flatDir { ++ dirs '.' ++ } ++ } + +dependencies { +... ++ implementation (name:'backup', ext:'aar') +} +``` diff --git a/android/app/.gitignore b/android/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/android/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/app/backup-sources.jar b/android/app/backup-sources.jar new file mode 100644 index 0000000..e84ca8e Binary files /dev/null and b/android/app/backup-sources.jar differ diff --git a/android/app/backup.aar b/android/app/backup.aar new file mode 100644 index 0000000..1bb3c14 Binary files /dev/null and b/android/app/backup.aar differ diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..062692b --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,45 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "io.iden3.backup" + minSdkVersion 16 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +repositories { + flatDir { + dirs '.' + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'com.google.android.material:material:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.navigation:navigation-fragment:2.2.2' + implementation 'androidx.navigation:navigation-ui:2.2.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation (name:'backup', ext:'aar') + +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android/app/src/androidTest/java/io/iden3/backup/ExampleInstrumentedTest.java b/android/app/src/androidTest/java/io/iden3/backup/ExampleInstrumentedTest.java new file mode 100644 index 0000000..904b2d7 --- /dev/null +++ b/android/app/src/androidTest/java/io/iden3/backup/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package io.iden3.backup; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + assertEquals("io.iden3.backup", appContext.getPackageName()); + } +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..211b947 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/java/io/iden3/backup/FirstFragment.java b/android/app/src/main/java/io/iden3/backup/FirstFragment.java new file mode 100644 index 0000000..8677cec --- /dev/null +++ b/android/app/src/main/java/io/iden3/backup/FirstFragment.java @@ -0,0 +1,34 @@ +package io.iden3.backup; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class FirstFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_first, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(FirstFragment.this) + .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + }); + } +} diff --git a/android/app/src/main/java/io/iden3/backup/MainActivity.java b/android/app/src/main/java/io/iden3/backup/MainActivity.java new file mode 100644 index 0000000..1a7d0cd --- /dev/null +++ b/android/app/src/main/java/io/iden3/backup/MainActivity.java @@ -0,0 +1,61 @@ +package io.iden3.backup; + +import android.os.Bundle; + +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + +import android.view.View; +import android.view.Menu; +import android.view.MenuItem; +import wrapper.*; +import android.util.Log; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + String kOp = new String(Wrapper.keyOperational()); + + Log.d("KOP", kOp); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/android/app/src/main/java/io/iden3/backup/SecondFragment.java b/android/app/src/main/java/io/iden3/backup/SecondFragment.java new file mode 100644 index 0000000..b1a79eb --- /dev/null +++ b/android/app/src/main/java/io/iden3/backup/SecondFragment.java @@ -0,0 +1,34 @@ +package io.iden3.backup; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class SecondFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_second, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(SecondFragment.this) + .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + }); + } +} diff --git a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..e9fa907 --- /dev/null +++ b/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/content_main.xml b/android/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..d825cbb --- /dev/null +++ b/android/app/src/main/res/layout/content_main.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/android/app/src/main/res/layout/fragment_first.xml b/android/app/src/main/res/layout/fragment_first.xml new file mode 100644 index 0000000..fb44a3d --- /dev/null +++ b/android/app/src/main/res/layout/fragment_first.xml @@ -0,0 +1,28 @@ + + + + + +