Skip to content

Commit

Permalink
Add simple demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
slambang committed May 12, 2022
1 parent 2f06739 commit e146652
Show file tree
Hide file tree
Showing 37 changed files with 438 additions and 17 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
ext.hilt_version = '2.38.1'

ext.minimum_supported_android_version = 16
ext.maximum_supported_android_version = 32

repositories {
google()
Expand Down
8 changes: 4 additions & 4 deletions jarvis-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ plugins {
}

android {
compileSdkVersion 32
compileSdkVersion maximum_supported_android_version
buildToolsVersion "32.0.0"

defaultConfig {
applicationId "com.jarvis.app"
minSdkVersion minimum_supported_android_version
targetSdkVersion 32
targetSdkVersion maximum_supported_android_version
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -50,10 +50,10 @@ dependencies {
implementation project(':jarvis-client')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"

implementation "com.google.android.material:material:1.5.0"
implementation "com.google.android.material:material:1.6.0"
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.0-beta01"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.0-rc01"
implementation "androidx.fragment:fragment-ktx:1.4.1"

implementation "com.google.dagger:hilt-android:$hilt_version"
Expand Down
2 changes: 1 addition & 1 deletion jarvis-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<string name="app_name">Jarvis</string>

<!-- Main View -->
<string name="no_config_message">No config.\n\nEnsure the Jarvis App is installed and unlocked.\n\nEnsure the Jarvis config is pushed from your app to the Jarvis App.</string>
<string name="no_config_message">No config.\n\nEnsure the Jarvis App is unlocked and a Jarvis config is pushed from your app to the Jarvis App.</string>

<!-- Menu -->
<string name="menu_item_active">Active</string>
Expand Down
4 changes: 2 additions & 2 deletions jarvis-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
}

android {
compileSdkVersion 32
compileSdkVersion maximum_supported_android_version
buildToolsVersion "32.0.0"

defaultConfig {
minSdkVersion minimum_supported_android_version
targetSdkVersion 32
targetSdkVersion maximum_supported_android_version
}

compileOptions {
Expand Down
7 changes: 4 additions & 3 deletions jarvis-demo-advanced/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ plugins {
}

android {
compileSdkVersion 32
compileSdkVersion maximum_supported_android_version
buildToolsVersion "32.0.0"

defaultConfig {
applicationId "com.jarvis.demo.advanced"
minSdkVersion minimum_supported_android_version
targetSdkVersion 32
targetSdkVersion maximum_supported_android_version
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -41,5 +42,5 @@ dependencies {
// debugImplementation "com.github.slambang:jarvis:v1.0.0" // latest published

implementation "io.insert-koin:koin-android:3.1.6"
implementation "com.google.android.material:material:1.5.0"
implementation "com.google.android.material:material:1.6.0"
}
1 change: 1 addition & 0 deletions jarvis-demo-advanced/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<application tools:ignore="MissingApplicationIcon">

<!-- This is needed so the Jarvis Client can send your app's config to the Jarvis App. -->
<!-- Copy/Paste this into your own app's manifest. -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.jarvis_config_provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DebugConfigRepository(

companion object {

private const val SOME_STRING_NAME = "Some string"
private const val SOME_STRING_NAME = "Some string (advanced demo)"

private val JARVIS_CONFIG = jarvisConfig {

Expand Down
2 changes: 0 additions & 2 deletions jarvis-demo-advanced/src/main/res/values/dimens.xml

This file was deleted.

2 changes: 1 addition & 1 deletion jarvis-demo-advanced/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="app_name">Jarvis Demo Advanced</string>
<string name="app_name">Jarvis Demo: Advanced</string>
<string name="read_value">Read value</string>
</resources>
1 change: 1 addition & 0 deletions jarvis-demo-simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions jarvis-demo-simple/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdkVersion maximum_supported_android_version
buildToolsVersion "32.0.0"

defaultConfig {
minSdkVersion minimum_supported_android_version
targetSdkVersion maximum_supported_android_version
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}
}

dependencies {
debugImplementation project(":jarvis-client") // local
// debugImplementation "com.github.slambang:jarvis:v1.0.0" // latest published

implementation "io.insert-koin:koin-android:3.1.6"
implementation "com.google.android.material:material:1.6.0"
}
21 changes: 21 additions & 0 deletions jarvis-demo-simple/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions jarvis-demo-simple/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.slambang.jarvis.demo.simple">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Jarvis">

<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Jarvis.NoActionBar">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- This is needed so the Jarvis Client can send your app's config to the Jarvis App. -->
<!-- Copy/Paste this into your own app's manifest. -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.jarvis_config_provider"
android:exported="false"
android:grantUriPermissions="true">

<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/jarvis_client_file_paths" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.slambang.jarvis.demo.simple

import com.jarvis.client.data.jarvisConfig

const val SOME_STRING_NAME = "Some string (simple demo)"

val jarvisConfig = jarvisConfig {

withLockAfterPush = false

withStringField {
name = SOME_STRING_NAME
value = "Jarvis value"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.slambang.jarvis.demo.simple

import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.jarvis.client.JarvisClient

/**
* Absolute minimal code setup, instantiating an instance of [JarvisClient] to read a string.
* See the FileProvider that is declared in the manifest.
*/
class MainActivity : AppCompatActivity() {

private lateinit var jarvis: JarvisClient

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

/**
* Instantiate the [JarvisClient] and push your app's config.
* This can be done wherever you like, but the config must be pushed before your
* app tries to read any config values.
*/
jarvis = JarvisClient.newInstance(this)
jarvis.pushConfigToJarvisApp(jarvisConfig)

findViewById<View>(R.id.get_value_button).setOnClickListener {
findViewById<TextView>(R.id.value_at_runtime).text =
jarvis.getString(SOME_STRING_NAME, "Default value")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
Loading

0 comments on commit e146652

Please sign in to comment.