diff --git a/.gitignore b/.gitignore index d0b369a4963f736198af33137747cc363a4bd6d8..30f29f0e733db9a0ae86702d463517e7be394e29 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ localdev_* *.dex *.class *.aar +*.jar diff --git a/README.md b/README.md index a2b2c7ba5e31205125bd47b68148148e7d7805cc..9b1d0a48d90da4d48c49f20cf6d49880094516d4 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,22 @@ In either case you will need to run $ gomobile init. Building == -To build the .aar for the client, run +To build the .aar for the client, cd to privategrity/client/android/client and +run this command: -$ gomobile bind +$ gomobile bind -target=android gitlab.com/privategrity/client + +Adding the .aar to the Android Studio project +== + +In case you need to add another .aar to the Android Studio project, follow +these steps: + +1. Go to File-\>New-\>New Module. +1. Scroll to and click on Import .JAR/.AAR Package. +1. Pick the .aar in the file chooser. +1. Click through the rest of the wizard. + +In any case, this isn't a recommended course of action because there might be +some weirdness about gomobile generating more than one .aar. -Then import the .aar in Android Studio. For future builds, you'll need to copy -the new bindings .aar over the .aar that's been imported to Android Studio. diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml index 7ac24c777f8adde6bd57c01c1bfa1cf0143f3d77..875fe877d9f64c2149c828fa537a740fc5ee30ba 100644 --- a/android/.idea/gradle.xml +++ b/android/.idea/gradle.xml @@ -9,6 +9,7 @@ <set> <option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$/app" /> + <option value="$PROJECT_DIR$/client" /> </set> </option> <option name="resolveModulePerSourceSet" value="false" /> diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml index 37a750962da6f2b31810e85c8acae1081de7f58c..39638799269d0193201b39e5276d8236659f97fe 100644 --- a/android/.idea/misc.xml +++ b/android/.idea/misc.xml @@ -1,5 +1,29 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="NullableNotNullManager"> + <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> + <option name="myNullables"> + <value> + <list size="4"> + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> + </list> + </value> + </option> + <option name="myNotNulls"> + <value> + <list size="4"> + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> + </list> + </value> + </option> + </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> diff --git a/android/.idea/modules.xml b/android/.idea/modules.xml index abc31fc679bb491e423c03e7bd677ff03ed00d98..4987fb25c3a7c6a3cfeb2dce555c6659b05377fa 100644 --- a/android/.idea/modules.xml +++ b/android/.idea/modules.xml @@ -4,6 +4,7 @@ <modules> <module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/android.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> + <module fileurl="file://$PROJECT_DIR$/client/client.iml" filepath="$PROJECT_DIR$/client/client.iml" /> </modules> </component> </project> \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index bb62dc6c2a6dfca2052bf3303688c8b3cab1d3a2..00c8d3e3cab8aaf1b0ef2cc96337277c6e44cf00 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,10 +19,11 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation project(':client') } diff --git a/android/app/src/main/java/com/privategrity/messagingclient/MainActivity.java b/android/app/src/main/java/com/privategrity/messagingclient/MainActivity.java index 144abb2f373dc3cd2d66711e0c7a44a499834826..d278844e9e7a4c171ddd84de6a6687c9c0ddc8e1 100644 --- a/android/app/src/main/java/com/privategrity/messagingclient/MainActivity.java +++ b/android/app/src/main/java/com/privategrity/messagingclient/MainActivity.java @@ -2,12 +2,21 @@ package com.privategrity.messagingclient; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.widget.TextView; + +import client.Client; public class MainActivity extends AppCompatActivity { + private TextView textView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + textView = (TextView) findViewById(R.id.mytextview); + + String greetings = Client.greetings("Android and Gopher"); + textView.setText(greetings); } } diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index b27ecbcb0ddec112bf67228d5b9870d740b931f9..b4175c8ee2a8c25e93d67948f715f82a3a4bf28e 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -7,12 +7,11 @@ tools:context="com.privategrity.messagingclient.MainActivity"> <TextView + android:id="@+id/mytextview" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Hello World!" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + android:text="TextView" + tools:layout_editor_absoluteX="16dp" + tools:layout_editor_absoluteY="16dp" /> </android.support.constraint.ConstraintLayout> diff --git a/android/client/build.gradle b/android/client/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..2d28884b3d6f88ceea99da4269a7886189890ae4 --- /dev/null +++ b/android/client/build.gradle @@ -0,0 +1,2 @@ +configurations.maybeCreate("default") +artifacts.add("default", file('client.aar')) \ No newline at end of file diff --git a/android/settings.gradle b/android/settings.gradle index e7b4def49cb53d9aa04228dd3edb14c9e635e003..48a8eb7a46974807b4a9a72dab779616a58e2bab 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1 +1 @@ -include ':app' +include ':app', ':client' diff --git a/hello.go b/hello.go new file mode 100644 index 0000000000000000000000000000000000000000..65ca75a1aefba6d98780c5a828adec2200b3cfae --- /dev/null +++ b/hello.go @@ -0,0 +1,7 @@ +package client + +import "fmt" + +func Greetings(name string) string { + return fmt.Sprintf("Hello, %s!", name) +}