androidabe

git clone git://git.codymlewis.com/androidabe.git
Log | Files | Refs | Submodules | README

commit c174ad14a2870b49248bfb44f50a07d6e8acec21
parent f1f225aa7fafa6e37d101690a3d334e1a4988122
Author: Cody Lewis <cody@codymlewis.com>
Date:   Wed, 20 May 2020 12:19:14 +1000

Added wear OS app

Diffstat:
M.idea/gradle.xml | 1+
M.idea/vcs.xml | 3+++
A::wearapp/src/main/AndroidManifest.xml | 5+++++
Msettings.gradle | 1+
Awearapp/.gitignore | 1+
Awearapp/build.gradle | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awearapp/proguard-rules.pro | 21+++++++++++++++++++++
Awearapp/src/main/AndroidManifest.xml | 39+++++++++++++++++++++++++++++++++++++++
Awearapp/src/main/java/com/codymlewis/wearapp/MainActivity.java | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Awearapp/src/main/res/layout/activity_main.xml | 27+++++++++++++++++++++++++++
Awearapp/src/main/res/mipmap-hdpi/ic_launcher.png | 0
Awearapp/src/main/res/mipmap-mdpi/ic_launcher.png | 0
Awearapp/src/main/res/mipmap-xhdpi/ic_launcher.png | 0
Awearapp/src/main/res/mipmap-xxhdpi/ic_launcher.png | 0
Awearapp/src/main/res/values-round/strings.xml | 3+++
Awearapp/src/main/res/values/dimens.xml | 15+++++++++++++++
Awearapp/src/main/res/values/strings.xml | 9+++++++++
17 files changed, 231 insertions(+), 0 deletions(-)

diff --git a/.idea/gradle.xml b/.idea/gradle.xml @@ -12,6 +12,7 @@ <option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$/abe" /> <option value="$PROJECT_DIR$/app" /> + <option value="$PROJECT_DIR$/wearapp" /> </set> </option> <option name="resolveModulePerSourceSet" value="false" /> diff --git a/.idea/vcs.xml b/.idea/vcs.xml @@ -2,6 +2,9 @@ <project version="4"> <component name="VcsDirectoryMappings"> <mapping directory="$PROJECT_DIR$" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/abe/src/main/cpp/gmp" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/abe/src/main/cpp/openssl" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/abe/src/main/cpp/pbc" vcs="Git" /> <mapping directory="$PROJECT_DIR$/app/src/main/cpp/gmp" vcs="Git" /> <mapping directory="$PROJECT_DIR$/app/src/main/cpp/openssl" vcs="Git" /> <mapping directory="$PROJECT_DIR$/app/src/main/cpp/pbc" vcs="Git" /> diff --git a/::wearapp/src/main/AndroidManifest.xml b/::wearapp/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <uses-permission android:name="android.permission.WAKE_LOCK" /> + +</manifest> diff --git a/settings.gradle b/settings.gradle @@ -1,3 +1,4 @@ rootProject.name='Android ABE' include ':app' include ':abe' +include ':wearapp' diff --git a/wearapp/.gitignore b/wearapp/.gitignore @@ -0,0 +1 @@ +/build diff --git a/wearapp/build.gradle b/wearapp/build.gradle @@ -0,0 +1,56 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + ndkVersion "21.1.6352462" + + defaultConfig { + applicationId "com.codymlewis.wearapp" + minSdkVersion 28 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + externalNativeBuild { + cmake { + arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared" + cFlags "-D__STDC_FORMAT_MACROS" + cppFlags "-fexceptions", "-frtti" + } + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + externalNativeBuild { + cmake { + path "../abe/src/main/cpp/CMakeLists.txt" + version "3.10.2" + } + } + + sourceSets { + main { + jniLibs.srcDirs '../abe/src/main/cpp/gmp/', '../abe/src/main/cpp/pbc/', '../abe/src/main/cpp/openssl' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.google.android.support:wearable:2.7.0' + implementation 'com.google.android.gms:play-services-wearable:17.0.0' + implementation 'androidx.percentlayout:percentlayout:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.wear:wear:1.0.0' + compileOnly 'com.google.android.wearable:wearable:2.6.0' + + implementation project(':abe') +} diff --git a/wearapp/proguard-rules.pro b/wearapp/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/wearapp/src/main/AndroidManifest.xml b/wearapp/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.codymlewis.wearapp"> + + <uses-permission android:name="android.permission.WAKE_LOCK" /> + + <uses-feature android:name="android.hardware.type.watch" /> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@android:style/Theme.DeviceDefault"> + <uses-library + android:name="com.google.android.wearable" + android:required="true" /> + + <!-- + Set to true if your app is Standalone, that is, it does not require the handheld + app to run. + --> + <meta-data + android:name="com.google.android.wearable.standalone" + android:value="true" /> + + <activity + android:name=".MainActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest>+ \ No newline at end of file diff --git a/wearapp/src/main/java/com/codymlewis/wearapp/MainActivity.java b/wearapp/src/main/java/com/codymlewis/wearapp/MainActivity.java @@ -0,0 +1,50 @@ +package com.codymlewis.wearapp; + +import android.os.Bundle; +import android.support.wearable.activity.WearableActivity; +import android.widget.TextView; + +import com.codymlewis.abe.Functions; +import com.codymlewis.abe.Keychain; +import com.codymlewis.abe.Token; + +import java.io.IOException; +import java.util.Base64; + +public class MainActivity extends WearableActivity { + + private TextView tv; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + tv = (TextView) findViewById(R.id.text); + String groupParams = ""; + try { + groupParams = Functions.readParams(this); + } catch (IOException ioe) { + tv.setText(getString(R.string.asset_io_error_message, ioe.getMessage())); + } + System.out.println("Loaded param file"); + Keychain kc = new Keychain(groupParams, 5); + Functions.setup(kc); + String text = String.format("x = %s\n", Base64.getEncoder().encodeToString(kc.getSecretX())); +// for (int i = 0; i < kc.lenSecretY(); ++i) { +// text += String.format("y_%d = %s\n", i, Base64.getEncoder().encodeToString(kc.getSecretY(i))); +// } +// text += String.format("X = %s\n", Base64.getEncoder().encodeToString(kc.getPublicX())); +// for (int i = 0; i < kc.lenPublicY(); ++i) { +// text += String.format("Y_%d = %s\n", i, Base64.getEncoder().encodeToString(kc.getPublicY(i))); +// } + + Token token = new Token("Alice", 5); + Functions.issueToken(kc, token); + text += String.format("sigma1 = %s\n", Base64.getEncoder().encodeToString(token.getSigma1())); + text += String.format("sigmabar1 = %s\n", Base64.getEncoder().encodeToString(token.getSigmabar1())); + tv.setText(text); + + setAmbientEnabled(); + } +} diff --git a/wearapp/src/main/res/layout/activity_main.xml b/wearapp/src/main/res/layout/activity_main.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/dark_grey" + android:padding="@dimen/box_inset_layout_padding" + tools:context=".MainActivity" + tools:deviceIds="wear"> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="@dimen/inner_frame_layout_padding" + app:boxedEdges="all"> + + <TextView + android:id="@+id/text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/hello_world" + android:textSize="10sp" /> + + </FrameLayout> +</androidx.wear.widget.BoxInsetLayout>+ \ No newline at end of file diff --git a/wearapp/src/main/res/mipmap-hdpi/ic_launcher.png b/wearapp/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ. diff --git a/wearapp/src/main/res/mipmap-mdpi/ic_launcher.png b/wearapp/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ. diff --git a/wearapp/src/main/res/mipmap-xhdpi/ic_launcher.png b/wearapp/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ. diff --git a/wearapp/src/main/res/mipmap-xxhdpi/ic_launcher.png b/wearapp/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ. diff --git a/wearapp/src/main/res/values-round/strings.xml b/wearapp/src/main/res/values-round/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="hello_world">Hello Round World!</string> +</resources> diff --git a/wearapp/src/main/res/values/dimens.xml b/wearapp/src/main/res/values/dimens.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- + Because the window insets on round devices are larger than 15dp, this padding only applies + to square screens. + --> + <dimen name="box_inset_layout_padding">0dp</dimen> + + <!-- + This padding applies to both square and round screens. The total padding between the buttons + and the window insets is box_inset_layout_padding (above variable) on square screens and + inner_frame_layout_padding (below variable) on round screens. + --> + <dimen name="inner_frame_layout_padding">5dp</dimen> +</resources> diff --git a/wearapp/src/main/res/values/strings.xml b/wearapp/src/main/res/values/strings.xml @@ -0,0 +1,9 @@ +<resources> + <string name="app_name">wearapp</string> + <!-- + This string is used for square devices and overridden by hello_world in + values-round/strings.xml for round devices. + --> + <string name="hello_world">Hello Square World!</string> + <string name="asset_io_error_message">Asset File IO Error: %1$s</string> +</resources>