-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 38ce06f
Showing
40 changed files
with
1,168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
.DS_Store | ||
/local.properties | ||
/.idea | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Futurae Adaptive SDK | ||
|
||
This is the Futurae adaptive SDK for Android. The Adaptive SDK is a data collection SDK that can be used stand-alone or together with Futurae SDK. | ||
|
||
### Installation | ||
In your application `build.gradle` file add: | ||
``` | ||
repositories { | ||
maven { | ||
url "https://artifactory.futurae.com/artifactory/futurae-mobile" | ||
credentials { | ||
username = "anonymous" | ||
password = "" | ||
} | ||
} | ||
} | ||
... | ||
dependencies { | ||
implementation 'com.futurae.sdk:adaptive:x.x.x' | ||
} | ||
``` | ||
### User guide | ||
|
||
For usage instructions together with [Futurae SDK](https://github.com/Futurae-Technologies/android-sdk) please refer to the [Futurae adaptive SDK guide](https://www.futurae.com/docs/guide/futurae-sdks/mobile-sdk/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'org.jetbrains.kotlin.kapt' | ||
} | ||
|
||
android { | ||
namespace 'com.futurae.adaptivedemo' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.futurae.adaptivedemo" | ||
minSdk 23 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0.0-alpha" | ||
} | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
minifyEnabled false | ||
} | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.futurae.sdk:adaptive:1.0.0-alpha' | ||
implementation 'androidx.core:core-ktx:1.10.1' | ||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' | ||
implementation 'androidx.activity:activity-compose:1.7.2' | ||
implementation "androidx.appcompat:appcompat:1.6.1" | ||
implementation "androidx.activity:activity-ktx:1.7.2" | ||
implementation "androidx.fragment:fragment-ktx:1.6.0" | ||
implementation "androidx.constraintlayout:constraintlayout:2.1.4" | ||
implementation "com.google.android.material:material:1.9.0" | ||
implementation "com.jakewharton.timber:timber:5.0.1" | ||
implementation "com.google.code.gson:gson:2.9.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<!-- START - Adaptive Permissions --> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> | ||
<!-- Backwards compatibility permissions for bluetooth. Uncomment when bump targetSdk to 31 --> | ||
<uses-permission | ||
android:name="android.permission.BLUETOOTH" | ||
android:maxSdkVersion="30" /> | ||
<uses-permission | ||
android:name="android.permission.BLUETOOTH_ADMIN" | ||
android:maxSdkVersion="30" /> | ||
<!-- END - Adaptive Permissions --> | ||
|
||
<application | ||
android:name=".AdaptiveApp" | ||
android:allowBackup="false" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Futurae" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:theme="@style/Theme.Futurae"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".CollectionsActivity" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.futurae.adaptivedemo | ||
|
||
import android.app.Application | ||
import com.futurae.sdk.adaptive.AdaptiveSDK | ||
import timber.log.Timber | ||
|
||
class AdaptiveApp : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
AdaptiveSDK.INSTANCE.init(this) | ||
Timber.plant(Timber.DebugTree()) | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/futurae/adaptivedemo/CollectionsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.futurae.adaptivedemo | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.futurae.adaptivedemo.databinding.ActivityCollectionsBinding | ||
import com.futurae.adaptivedemo.databinding.ItemCollectionBinding | ||
import com.futurae.sdk.adaptive.AdaptiveDbHelper | ||
import com.futurae.sdk.adaptive.model.AdaptiveCollection | ||
import com.google.gson.GsonBuilder | ||
import kotlinx.coroutines.launch | ||
import java.text.DateFormat | ||
import java.util.Calendar | ||
|
||
class CollectionsActivity : AppCompatActivity() { | ||
|
||
private val collectionsAdapter = CollectionsAdapter() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val binding = ActivityCollectionsBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
binding.recyclerView.apply { | ||
layoutManager = LinearLayoutManager(this@CollectionsActivity) | ||
adapter = collectionsAdapter | ||
} | ||
|
||
lifecycleScope.launch { | ||
AdaptiveDbHelper.INSTANCE.allCollections.collect { | ||
collectionsAdapter.submitList(it.toList()) | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
class CollectionsAdapter : ListAdapter<AdaptiveCollection, CollectionViewHolder>( | ||
object : DiffUtil.ItemCallback<AdaptiveCollection>() { | ||
override fun areItemsTheSame(oldItem: AdaptiveCollection, newItem: AdaptiveCollection): Boolean { | ||
return oldItem.timestamp == newItem.timestamp | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: AdaptiveCollection, newItem: AdaptiveCollection): Boolean { | ||
return oldItem == newItem | ||
} | ||
} | ||
) { | ||
|
||
private val dateFormat = DateFormat.getDateInstance() | ||
private val gson = GsonBuilder().setLenient().create() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CollectionViewHolder { | ||
return CollectionViewHolder( | ||
ItemCollectionBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: CollectionViewHolder, position: Int) { | ||
val collection = getItem(position) | ||
val calendar = Calendar.getInstance().apply { | ||
timeInMillis = collection.timestamp * 1000 | ||
} | ||
holder.binding.titleTextView.text = dateFormat.format(calendar.time) | ||
holder.binding.subtitleTextView.text = gson.toJson(collection) | ||
} | ||
|
||
} | ||
|
||
class CollectionViewHolder(val binding: ItemCollectionBinding) : RecyclerView.ViewHolder(binding.root) |
Oops, something went wrong.