-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use correct direct Identity data store name * Override toString in IdentityMap and IdentityItem * Add Kotlin test app for IdentityEdge * Add fragment for starting an Assurance session * Remove unused test files from sample app. * Add implementations for send event and reset identities buttons. * Add Application class to initialize SDK and extensions * Add network security config to AndroidManifest * Comment out call to resetIdentities as API in Core is not yet released * Remove Java app * Rename 'appkt' to 'app' and move files to 'code/app' * Remove launch environment ID * Rename test app package from 'appkt' to 'app' * fix IdentityMap.toString to handle case where map is empty. * Use correct AuthenticatedState.loggedOut string * Save custom identifier UI entries and update UI with saved values when page is viewed. * Remove copyright from non-source files (Manifest, layouts, drawables, etc). * Make StringBuilder final in IdentityMap.toString()
- Loading branch information
Showing
44 changed files
with
1,433 additions
and
207 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
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 |
---|---|---|
@@ -1,37 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.adobe.marketing.mobile.testApp"> | ||
package="com.adobe.marketing.edge.identity.app"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:name="com.adobe.marketing.edge.identity.app.EdgeIdentityApplication" | ||
android:label="@string/app_name" | ||
android:name=".TestApplication" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
android:networkSecurityConfig="@xml/network_security_config"> | ||
<activity android:name=".MainActivity"> | ||
android:networkSecurityConfig="@xml/network_security_config" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name="com.adobe.marketing.edge.identity.app.MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<!-- Accepts URIs that begin with "testapp://main”--> | ||
<data | ||
android:scheme="testapp" | ||
android:host="main" /> | ||
|
||
</intent-filter> | ||
|
||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
40 changes: 40 additions & 0 deletions
40
code/app/src/main/java/com/adobe/marketing/edge/identity/app/EdgeIdentityApplication.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,40 @@ | ||
/* | ||
Copyright 2021 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.edge.identity.app | ||
|
||
import android.app.Application | ||
import com.adobe.marketing.mobile.Assurance | ||
import com.adobe.marketing.mobile.Edge | ||
import com.adobe.marketing.mobile.LoggingMode | ||
import com.adobe.marketing.mobile.MobileCore | ||
import com.adobe.marketing.mobile.edge.identity.Identity | ||
|
||
class EdgeIdentityApplication : Application() { | ||
// Add your Launch Environment ID to configure the SDK from your Launch property | ||
private var LAUNCH_ENVIRONMENT_ID: String = "" | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
// register AEP SDK extensions | ||
MobileCore.setApplication(this) | ||
MobileCore.setLogLevel(LoggingMode.VERBOSE) | ||
|
||
Identity.registerExtension() | ||
Edge.registerExtension() | ||
Assurance.registerExtension() | ||
|
||
MobileCore.start { | ||
MobileCore.configureWithAppID(LAUNCH_ENVIRONMENT_ID) | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
code/app/src/main/java/com/adobe/marketing/edge/identity/app/MainActivity.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,57 @@ | ||
/* | ||
Copyright 2021 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.edge.identity.app | ||
|
||
import android.os.Bundle | ||
import android.view.Menu | ||
import com.google.android.material.navigation.NavigationView | ||
import androidx.navigation.findNavController | ||
import androidx.navigation.ui.AppBarConfiguration | ||
import androidx.navigation.ui.navigateUp | ||
import androidx.navigation.ui.setupActionBarWithNavController | ||
import androidx.navigation.ui.setupWithNavController | ||
import androidx.drawerlayout.widget.DrawerLayout | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.appcompat.widget.Toolbar | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private lateinit var appBarConfiguration: AppBarConfiguration | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
val toolbar: Toolbar = findViewById(R.id.toolbar) | ||
setSupportActionBar(toolbar) | ||
|
||
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) | ||
val navView: NavigationView = findViewById(R.id.nav_view) | ||
val navController = findNavController(R.id.nav_host_fragment) | ||
// Passing each menu ID as a set of Ids because each | ||
// menu should be considered as top level destinations. | ||
appBarConfiguration = AppBarConfiguration(setOf( | ||
R.id.nav_get_identity, R.id.nav_custom_identity, R.id.nav_multiple_identity, R.id.nav_assurance), drawerLayout) | ||
setupActionBarWithNavController(navController, appBarConfiguration) | ||
navView.setupWithNavController(navController) | ||
} | ||
|
||
override fun onCreateOptionsMenu(menu: Menu): Boolean { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
menuInflater.inflate(R.menu.main, menu) | ||
return true | ||
} | ||
|
||
override fun onSupportNavigateUp(): Boolean { | ||
val navController = findNavController(R.id.nav_host_fragment) | ||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() | ||
} | ||
} |
148 changes: 148 additions & 0 deletions
148
code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.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,148 @@ | ||
/* | ||
Copyright 2021 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.edge.identity.app.model | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.adobe.marketing.mobile.edge.identity.AuthenticatedState | ||
|
||
class SharedViewModel : ViewModel() { | ||
companion object { | ||
const val REGISTER_IDENTITY_STRING = "Register Identity" | ||
const val REGISTER_EDGE_IDENTITY_STRING = "Register Edge Identity" | ||
const val IDENTITY_IS_REGISTERED_STRING = "Identity is registered" | ||
const val EDGE_IDENTITY_IS_REGISTERED_STRING = "Edge Identity is registered" | ||
} | ||
|
||
// Models for Get Identities View | ||
|
||
private val _ecidText = MutableLiveData<String>("") | ||
val ecidText: LiveData<String> = _ecidText | ||
|
||
private val _ecidLegacyText = MutableLiveData<String>("") | ||
val ecidLegacyText: LiveData<String> = _ecidLegacyText | ||
|
||
private val _identitiesText = MutableLiveData<String>("") | ||
val identitiesText: LiveData<String> = _identitiesText | ||
|
||
fun setEcidValue(value: String) { | ||
_ecidText.value = value | ||
} | ||
|
||
fun setEcidLegacyValue(value: String) { | ||
_ecidLegacyText.value = value | ||
} | ||
|
||
fun setIdentitiesValue(value: String) { | ||
_identitiesText.value = value | ||
} | ||
|
||
// Models for Update Identities View | ||
|
||
private val _identifier = MutableLiveData<String>("") | ||
val identifier: LiveData<String> = _identifier | ||
|
||
private val _namespace = MutableLiveData<String>("") | ||
val namespace: LiveData<String> = _namespace | ||
|
||
private val _isPrimary = MutableLiveData<Boolean>(false) | ||
val isPrimary: LiveData<Boolean> = _isPrimary | ||
|
||
private val _authenticatedState = MutableLiveData<AuthenticatedState>(AuthenticatedState.AMBIGUOUS) | ||
val authenticatedState: LiveData<AuthenticatedState> = _authenticatedState | ||
|
||
private val _authenticatedStateId = MutableLiveData<Int>(null) | ||
val authenticatedStateId: LiveData<Int> = _authenticatedStateId | ||
|
||
fun setIdentifier(value: String) { | ||
if (_identifier.value == value) { | ||
return | ||
} | ||
_identifier.value = value | ||
} | ||
|
||
fun setNamespace(value: String) { | ||
if (_namespace.value == value) { | ||
return | ||
} | ||
_namespace.value = value | ||
} | ||
|
||
fun setIsPrimary(value: Boolean) { | ||
if (_isPrimary.value == value) { | ||
return | ||
} | ||
_isPrimary.value = value | ||
} | ||
|
||
fun setAuthenticatedState(value: AuthenticatedState) { | ||
if (_authenticatedState.value == value) { | ||
return | ||
} | ||
_authenticatedState.value = value | ||
} | ||
|
||
fun setAuthenticatedStateId(value: Int) { | ||
if (_authenticatedStateId.value == value) { | ||
return | ||
} | ||
_authenticatedStateId.value = value | ||
} | ||
|
||
// Models for Multiple Identities View | ||
|
||
private val _isEdgeIdentityRegistered = MutableLiveData<Boolean>(true) | ||
val isEdgeIdentityRegistered: LiveData<Boolean> = _isEdgeIdentityRegistered | ||
|
||
private val _edgeIdentityRegisteredText = MutableLiveData<String>().apply { | ||
value = if (_isEdgeIdentityRegistered.value == true) { | ||
EDGE_IDENTITY_IS_REGISTERED_STRING | ||
} else { | ||
REGISTER_EDGE_IDENTITY_STRING | ||
} | ||
} | ||
val edgeIdentityRegisteredText: LiveData<String> = _edgeIdentityRegisteredText | ||
|
||
private val _isDirectIdentityRegistered = MutableLiveData<Boolean>(false) | ||
val isDirectIdentityRegistered: LiveData<Boolean> = _isDirectIdentityRegistered | ||
|
||
private val _directIdentityRegisteredText = MutableLiveData<String>().apply { | ||
value = if (_isDirectIdentityRegistered.value == true) { | ||
IDENTITY_IS_REGISTERED_STRING | ||
} else { | ||
REGISTER_IDENTITY_STRING | ||
} | ||
} | ||
val directIdentityRegisteredText: LiveData<String> = _directIdentityRegisteredText | ||
|
||
|
||
fun toggleEdgeIdentityRegistration() { | ||
if (_isEdgeIdentityRegistered.value == true) { | ||
_isEdgeIdentityRegistered.value = false | ||
_edgeIdentityRegisteredText.value = REGISTER_EDGE_IDENTITY_STRING | ||
} else { | ||
_isEdgeIdentityRegistered.value = true | ||
_edgeIdentityRegisteredText.value = EDGE_IDENTITY_IS_REGISTERED_STRING | ||
} | ||
} | ||
|
||
fun toggleDirectIdentityRegistration() { | ||
if (_isDirectIdentityRegistered.value == true) { | ||
_isDirectIdentityRegistered.value = false | ||
_directIdentityRegisteredText.value = REGISTER_IDENTITY_STRING | ||
} else { | ||
_isDirectIdentityRegistered.value = true | ||
_directIdentityRegisteredText.value = IDENTITY_IS_REGISTERED_STRING | ||
} | ||
} | ||
} |
Oops, something went wrong.