Skip to content

Commit 0da1616

Browse files
feat: remove legacy targeting method
1 parent 1c3944f commit 0da1616

5 files changed

Lines changed: 11 additions & 64 deletions

File tree

DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/IdentifyFragment.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import android.view.View;
66
import android.view.ViewGroup;
77
import android.widget.EditText;
8-
import android.widget.Switch;
98
import android.widget.TextView;
109
import androidx.annotation.NonNull;
1110
import androidx.fragment.app.Fragment;
11+
import co.optable.android_sdk.OptableIdentifiers;
1212
import co.optable.android_sdk.OptableResult;
1313
import co.optable.android_sdk.OptableSDK;
1414
import co.optable.demoappjava.R;
@@ -19,7 +19,6 @@ public class IdentifyFragment extends Fragment {
1919

2020
private TextView identifyView;
2121
private EditText emailText;
22-
private Switch gaidSwitch;
2322

2423
private OptableSDK optable;
2524

@@ -34,15 +33,17 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
3433
private void initUi(View root) {
3534
identifyView = root.findViewById(R.id.identifyView);
3635
emailText = root.findViewById(R.id.editTextTextEmailAddress);
37-
gaidSwitch = root.findViewById(R.id.gaidSwitch);
3836

3937
root.findViewById(R.id.identifyButton).setOnClickListener(view -> onClickIdentify());
4038
}
4139

4240
private void onClickIdentify() {
4341
identifyView.setText("");
4442

45-
optable.identify(emailText.getText().toString(), gaidSwitch.isChecked(), result -> {
43+
OptableIdentifiers ids = new OptableIdentifiers.Builder()
44+
.email(emailText.getText().toString())
45+
.build();
46+
optable.identify(ids, result -> {
4647
if (result instanceof OptableResult.Success) {
4748
identifyView.setText("Identify success");
4849
} else if (result instanceof OptableResult.Error<Unit> error) {

DemoApp/DemoAppJava/app/src/main/res/layout/fragment_identify.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@
2828
android:layout_marginTop="8dp"
2929
android:text="Identify"
3030
app:layout_constraintStart_toStartOf="parent"
31-
app:layout_constraintTop_toBottomOf="@+id/gaidSwitch" />
32-
33-
<Switch
34-
android:id="@+id/gaidSwitch"
35-
android:layout_width="84dp"
36-
android:layout_height="40dp"
37-
android:layout_marginStart="32dp"
38-
android:layout_marginLeft="32dp"
39-
android:layout_marginTop="8dp"
40-
android:text="GAID"
41-
app:layout_constraintStart_toStartOf="parent"
4231
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
4332

4433
<TextView
@@ -49,4 +38,5 @@
4938
app:layout_constraintEnd_toEndOf="parent"
5039
app:layout_constraintStart_toStartOf="parent"
5140
app:layout_constraintTop_toBottomOf="@+id/identifyButton" />
41+
5242
</androidx.constraintlayout.widget.ConstraintLayout>

DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/IdentifyFragment.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import android.view.View
66
import android.view.ViewGroup
77
import android.widget.Button
88
import android.widget.EditText
9-
import android.widget.Switch
109
import android.widget.TextView
1110
import androidx.fragment.app.Fragment
11+
import co.optable.android_sdk.OptableIdentifiers
1212
import co.optable.android_sdk.OptableResult
1313
import co.optable.android_sdk.OptableSDK
1414
import co.optable.androidsdkdemo.R
@@ -18,7 +18,6 @@ class IdentifyFragment : Fragment() {
1818

1919
private lateinit var identifyView: TextView
2020
private lateinit var emailText: EditText
21-
private lateinit var gaidSwitch: Switch
2221

2322
private lateinit var optable: OptableSDK
2423

@@ -36,7 +35,6 @@ class IdentifyFragment : Fragment() {
3635
private fun initUi(root: View) {
3736
identifyView = root.findViewById(R.id.identifyView)
3837
emailText = root.findViewById(R.id.editTextTextEmailAddress)
39-
gaidSwitch = root.findViewById(R.id.gaidSwitch)
4038

4139
root.findViewById<Button>(R.id.identifyButton).setOnClickListener {
4240
onClickIdentify()
@@ -46,10 +44,10 @@ class IdentifyFragment : Fragment() {
4644
private fun onClickIdentify() {
4745
identifyView.text = ""
4846

49-
val email = emailText.text.toString()
50-
val gaidStatus = gaidSwitch.isChecked
51-
52-
optable.identify(email, gaidStatus) { result ->
47+
val ids = OptableIdentifiers.Builder()
48+
.email(emailText.getText().toString())
49+
.build()
50+
optable.identify(ids) { result ->
5351
val msg = when (result) {
5452
is OptableResult.Success -> "Identify success"
5553
is OptableResult.Error -> "Identify error: ${result.message}"

DemoApp/DemoAppKotlin/app/src/main/res/layout/fragment_identify.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@
2828
android:layout_marginTop="8dp"
2929
android:text="Identify"
3030
app:layout_constraintStart_toStartOf="parent"
31-
app:layout_constraintTop_toBottomOf="@+id/gaidSwitch" />
32-
33-
<Switch
34-
android:id="@+id/gaidSwitch"
35-
android:layout_width="84dp"
36-
android:layout_height="40dp"
37-
android:layout_marginStart="32dp"
38-
android:layout_marginLeft="32dp"
39-
android:layout_marginTop="8dp"
40-
android:text="GAID"
41-
app:layout_constraintStart_toStartOf="parent"
4231
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
4332

4433
<TextView

android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,6 @@ class OptableSDK(
5757
}
5858
}
5959

60-
61-
/**
62-
* Calls the Optable Sandbox "identify" API, passing only email, GAID and PPID.
63-
*
64-
* @param email email address to identify (encrypted with SHA256)
65-
* @param gaid Should receive Google Advertising ID of the device
66-
* @param ppid Should receive PPID of the device
67-
*/
68-
@JvmOverloads
69-
fun identify(email: String, gaid: Boolean = false, ppid: String? = null, listener: OptableResultListener<Unit>) {
70-
val emailValue = if (email.isNotBlank() && android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
71-
email
72-
} else null
73-
74-
val gaid = if (gaid) {
75-
adIdManager.getId()
76-
} else null
77-
78-
val ppid = if (ppid != null) {
79-
listOf("c:$ppid")
80-
} else null
81-
82-
val ids = OptableIdentifiers(
83-
email = emailValue,
84-
googleGaid = gaid,
85-
raw = ppid
86-
)
87-
88-
return identify(ids, listener)
89-
}
90-
9160
/**
9261
* tryIdentifyFromURI(uri) is a helper that attempts to find a valid-looking "oeid"
9362
* parameter in the specified uri's query string parameters and, if found, calls

0 commit comments

Comments
 (0)