Skip to content

Commit 8b51e0b

Browse files
authored
Merge pull request #350 from Countly/transparent_activity_example
feat: transparent activity example
2 parents 78c34df + 52eb0a2 commit 8b51e0b

File tree

7 files changed

+344
-160
lines changed

7 files changed

+344
-160
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="ly.count.android.demo">
3+
package="ly.count.android.demo">
44

5-
<uses-permission android:name="android.permission.INTERNET" />
6-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7-
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
88

9-
<uses-permission android:name="${applicationId}.CountlyPush.BROADCAST_PERMISSION" />
9+
<uses-permission android:name="${applicationId}.CountlyPush.BROADCAST_PERMISSION"/>
1010
<uses-permission
1111
android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
12-
android:maxSdkVersion="30" />
12+
android:maxSdkVersion="30"/>
1313

1414

1515
<application
@@ -24,17 +24,17 @@
2424
android:configChanges="orientation|screenSize"
2525
android:exported="true">
2626
<intent-filter>
27-
<action android:name="android.intent.action.MAIN" />
27+
<action android:name="android.intent.action.MAIN"/>
2828

29-
<category android:name="android.intent.category.LAUNCHER" />
29+
<category android:name="android.intent.category.LAUNCHER"/>
3030
</intent-filter>
3131
</activity>
3232

3333
<service
3434
android:name=".DemoFirebaseMessagingService"
3535
android:exported="false">
3636
<intent-filter>
37-
<action android:name="com.google.firebase.MESSAGING_EVENT" />
37+
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
3838
</intent-filter>
3939
</service>
4040

@@ -50,60 +50,65 @@
5050
<activity
5151
android:name=".ActivityExampleAPM"
5252
android:label="@string/activity_name_apm"
53-
android:configChanges="orientation|screenSize"></activity>
53+
android:configChanges="orientation|screenSize"/>
5454

5555
<activity
5656
android:name=".ActivityExampleCrashReporting"
5757
android:label="@string/activity_name_crash_reporting"
58-
android:configChanges="orientation|screenSize"></activity>
58+
android:configChanges="orientation|screenSize"/>
5959

6060
<activity
6161
android:name=".ActivityExampleCustomEvents"
6262
android:label="@string/activity_name_custom_events"
63-
android:configChanges="orientation|screenSize"></activity>
63+
android:configChanges="orientation|screenSize"/>
6464

6565
<activity
6666
android:name=".ActivityExampleMultiThreading"
6767
android:label="@string/activity_name_multithreading"
68-
android:configChanges="orientation|screenSize"></activity>
68+
android:configChanges="orientation|screenSize"/>
6969

7070
<activity
7171
android:name=".ActivityExampleOthers"
7272
android:label="@string/activity_name_others"
73-
android:configChanges="orientation|screenSize"></activity>
73+
android:configChanges="orientation|screenSize"/>
7474

7575
<activity
7676
android:name=".ActivityExampleUserDetails"
7777
android:label="@string/activity_name_user_detail"
78-
android:configChanges="orientation|screenSize"></activity>
78+
android:configChanges="orientation|screenSize"/>
7979

8080
<activity
8181
android:name=".ActivityExampleViewTracking"
8282
android:label="@string/activity_name_view_tracking"
83-
android:configChanges="orientation|screenSize"></activity>
83+
android:configChanges="orientation|screenSize"/>
8484

8585
<activity
8686
android:name=".ActivityExampleAutoViewTracking"
8787
android:label="Multiple view tracking options"
88-
android:configChanges="orientation|screenSize"></activity>
88+
android:configChanges="orientation|screenSize"/>
8989

9090
<activity
9191
android:name=".ActivityExampleRemoteConfig"
9292
android:label="@string/activity_name_remote_config"
93-
android:configChanges="orientation|screenSize"></activity>
93+
android:configChanges="orientation|screenSize"/>
9494
<activity
9595
android:name=".ActivityExampleDeviceId"
9696
android:label="@string/activity_name_device_id"
97-
android:configChanges="orientation|screenSize"></activity>
97+
android:configChanges="orientation|screenSize"/>
9898

9999
<activity
100100
android:name=".ActivityExampleFeedback"
101101
android:label="@string/activity_name_feedback"
102-
android:configChanges="orientation|screenSize"></activity>
102+
android:configChanges="orientation|screenSize"/>
103+
104+
<activity
105+
android:name=".ActivityExampleTransparentActivity"
106+
android:label="@string/activity_name_feedback"
107+
android:configChanges="orientation|screenSize"/>
103108

104109
<activity
105110
android:name=".ActivityExampleTests"
106-
android:exported="false" />
111+
android:exported="false"/>
107112

108113
<activity
109114
android:name=".ActivityExampleDeepLinkA"
@@ -112,16 +117,16 @@
112117
android:exported="true">
113118

114119
<intent-filter android:label="@string/deep_link">
115-
<action android:name="android.intent.action.VIEW" />
120+
<action android:name="android.intent.action.VIEW"/>
116121

117-
<category android:name="android.intent.category.DEFAULT" />
118-
<category android:name="android.intent.category.BROWSABLE" />
122+
<category android:name="android.intent.category.DEFAULT"/>
123+
<category android:name="android.intent.category.BROWSABLE"/>
119124

120125
<!-- Accepts URIs that begin with "countly://sample_a” -->
121126
<!-- test with adb shell am start -a android.intent.action.VIEW -d "countly://test" ly.count.android.demo -->
122127
<data
123128
android:scheme="countly"
124-
android:host="sample_a" />
129+
android:host="sample_a"/>
125130
</intent-filter>
126131
</activity>
127132

@@ -132,19 +137,19 @@
132137
android:exported="true">
133138

134139
<intent-filter android:label="@string/deep_link">
135-
<action android:name="android.intent.action.VIEW" />
140+
<action android:name="android.intent.action.VIEW"/>
136141

137-
<category android:name="android.intent.category.DEFAULT" />
138-
<category android:name="android.intent.category.BROWSABLE" />
142+
<category android:name="android.intent.category.DEFAULT"/>
143+
<category android:name="android.intent.category.BROWSABLE"/>
139144

140145
<!-- Accepts URIs that begin with "countly://sample_b” -->
141146
<!-- test with adb shell am start -a android.intent.action.VIEW -d "countly://test" ly.count.android.demo -->
142147
<data
143148
android:scheme="countly"
144-
android:host="sample_b" />
149+
android:host="sample_b"/>
145150
</intent-filter>
146151
</activity>
147-
<activity android:name=".ActivityExampleKotlin" />
152+
<activity android:name=".ActivityExampleKotlin"/>
148153
</application>
149154

150155
</manifest>

app/src/main/java/ly/count/android/demo/ActivityExampleOthers.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ly.count.android.demo;
22

33
import android.app.Activity;
4+
import android.content.Intent;
45
import android.os.Bundle;
56
import android.util.Log;
67
import android.view.View;
@@ -137,4 +138,8 @@ public void onClickUpdateSession(View v) {
137138
public void onClickEndSession(View v) {
138139
Countly.sharedInstance().sessions().endSession();
139140
}
141+
142+
public void onClickTransparentActivity(View v) {
143+
startActivity(new Intent(this, ActivityExampleTransparentActivity.class));
144+
}
140145
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package ly.count.android.demo;
2+
3+
import android.os.Bundle;
4+
import android.util.Log;
5+
import android.view.View;
6+
import android.widget.EditText;
7+
import androidx.appcompat.app.AppCompatActivity;
8+
import ly.count.android.sdk.TransparentActivity;
9+
import ly.count.android.sdk.TransparentActivityConfig;
10+
11+
public class ActivityExampleTransparentActivity extends AppCompatActivity {
12+
13+
@Override
14+
public void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_example_transparent_activity);
17+
}
18+
19+
public void onClickShowTransparentActivity(View v) {
20+
EditText editText1, editText2, editText3, editText4, editText5, editText6, editText7, editText8, editText9;
21+
22+
editText1 = findViewById(R.id.buttonShowTransparent_text1);
23+
editText2 = findViewById(R.id.buttonShowTransparent_text2);
24+
editText3 = findViewById(R.id.buttonShowTransparent_text3);
25+
editText4 = findViewById(R.id.buttonShowTransparent_text4);
26+
editText5 = findViewById(R.id.buttonShowTransparent_text5);
27+
editText6 = findViewById(R.id.buttonShowTransparent_text6);
28+
editText7 = findViewById(R.id.buttonShowTransparent_text7);
29+
editText8 = findViewById(R.id.buttonShowTransparent_text8);
30+
editText9 = findViewById(R.id.buttonShowTransparent_text9);
31+
32+
Integer xCoordinate = getOptionalNullInt(editText1.getText().toString());
33+
Integer yCoordinate = getOptionalNullInt(editText2.getText().toString());
34+
Double xPercentage = getOptionalNullDouble(editText3.getText().toString());
35+
Double yPercentage = getOptionalNullDouble(editText4.getText().toString());
36+
Integer widthPx = getOptionalNullInt(editText5.getText().toString());
37+
Integer heightPx = getOptionalNullInt(editText6.getText().toString());
38+
Double widthPercentage = getOptionalNullDouble(editText7.getText().toString());
39+
Double heightPercentage = getOptionalNullDouble(editText8.getText().toString());
40+
String webviewURL = editText9.getText().toString();
41+
if (webviewURL.isEmpty()) {
42+
webviewURL = "https://countly.com/";
43+
}
44+
45+
Log.d("Countly", "ActivityExampleTransparentActivity, xCoordinate: " + xCoordinate);
46+
Log.d("Countly", "ActivityExampleTransparentActivity, yCoordinate: " + yCoordinate);
47+
Log.d("Countly", "ActivityExampleTransparentActivity, xPercentage: " + xPercentage);
48+
Log.d("Countly", "ActivityExampleTransparentActivity, yPercentage: " + yPercentage);
49+
Log.d("Countly", "ActivityExampleTransparentActivity, widthPx: " + widthPx);
50+
Log.d("Countly", "ActivityExampleTransparentActivity, heightPx: " + heightPx);
51+
Log.d("Countly", "ActivityExampleTransparentActivity, widthPercentage: " + widthPercentage);
52+
Log.d("Countly", "ActivityExampleTransparentActivity, heightPercentage: " + heightPercentage);
53+
Log.d("Countly", "ActivityExampleTransparentActivity, webviewURL: " + webviewURL);
54+
55+
TransparentActivityConfig config = new TransparentActivityConfig(xCoordinate, yCoordinate, widthPx, heightPx);
56+
config.setUrl(webviewURL);
57+
config.setPercents(xPercentage, yPercentage, widthPercentage, heightPercentage);
58+
59+
TransparentActivity.showActivity(this, config);
60+
}
61+
62+
private Integer getOptionalNullInt(String value) {
63+
try {
64+
return Integer.parseInt(value);
65+
} catch (Exception e) {
66+
return null;
67+
}
68+
}
69+
70+
private Double getOptionalNullDouble(String value) {
71+
try {
72+
return Double.parseDouble(value);
73+
} catch (Exception e) {
74+
return null;
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)