Skip to content

Commit cc4543c

Browse files
committed
Rename app
1 parent 4795013 commit cc4543c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

AndroidProject/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
88
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
99

10-
<application android:name=".Bridge">
10+
<application android:name=".BridgeApplication">
1111
<service
1212
android:name=".PedometerService"
1313
android:enabled="true"

AndroidProject/app/src/main/java/com/kdg/toast/plugin/Bridge.java renamed to AndroidProject/app/src/main/java/com/kdg/toast/plugin/BridgeApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import static android.Manifest.permission.ACTIVITY_RECOGNITION;
2424

25-
public final class Bridge extends Application {
25+
public final class BridgeApplication extends Application {
2626
static int summarySteps;
2727
static int steps;
2828
static int initialSteps;
@@ -59,7 +59,7 @@ public static void ReceiveActivityInstance(Activity tempActivity) {
5959
if (ContextCompat.checkSelfPermission(myActivity, Manifest.permission.ACTIVITY_RECOGNITION)
6060
!= PackageManager.PERMISSION_GRANTED) {
6161
Log.i("PEDOMETER", "Permision isnt granted!");
62-
ActivityCompat.requestPermissions(Bridge.myActivity,
62+
ActivityCompat.requestPermissions(BridgeApplication.myActivity,
6363
perms,
6464
1);
6565
}
@@ -138,7 +138,7 @@ public static String SyncData() {
138138
@Override
139139
public void onCreate() {
140140
super.onCreate();
141-
Bridge.appContext = getApplicationContext();
141+
BridgeApplication.appContext = getApplicationContext();
142142

143143
}
144144
}

AndroidProject/app/src/main/java/com/kdg/toast/plugin/PedometerService.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PedometerService : Service(), SensorEventListener {
4242

4343
private fun startNotification() {
4444
val input = "Counting your steps..."
45-
val notificationIntent = Intent(this, Bridge.myActivity.javaClass)
45+
val notificationIntent = Intent(this, BridgeApplication.myActivity.javaClass)
4646
val pendingIntent = PendingIntent.getActivity(
4747
this,
4848
0, notificationIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
@@ -57,15 +57,15 @@ class PedometerService : Service(), SensorEventListener {
5757
}
5858

5959
override fun onCreate() {
60-
Log.i(TAG, "onCreate: CREATED" + Bridge.steps)
60+
Log.i(TAG, "onCreate: CREATED" + BridgeApplication.steps)
6161
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
6262
loadData()
63-
saveSummarySteps(Bridge.summarySteps + Bridge.steps)
63+
saveSummarySteps(BridgeApplication.summarySteps + BridgeApplication.steps)
6464
}
6565

6666
override fun onTaskRemoved(rootIntent: Intent) {
6767
super.onTaskRemoved(rootIntent)
68-
Log.i(TAG, "onTaskRemoved: REMOVED" + Bridge.steps)
68+
Log.i(TAG, "onTaskRemoved: REMOVED" + BridgeApplication.steps)
6969
initSensorManager()
7070
}
7171

@@ -74,11 +74,11 @@ class PedometerService : Service(), SensorEventListener {
7474
createNotificationChannel()
7575
startNotification()
7676
super.onCreate()
77-
Bridge.initialSteps = 0
77+
BridgeApplication.initialSteps = 0
7878
initSensorManager()
7979
val editor = sharedPreferences!!.edit()
8080
initialDate = Calendar.getInstance().time
81-
editor.putString(Bridge.INIT_DATE, currentDate.toString())
81+
editor.putString(BridgeApplication.INIT_DATE, currentDate.toString())
8282
editor.apply()
8383
return START_NOT_STICKY
8484
}
@@ -88,19 +88,19 @@ class PedometerService : Service(), SensorEventListener {
8888
Log.i(TAG, "onDestroy: DESTROYED")
8989
disposeSensorManager()
9090
loadData()
91-
saveSummarySteps(Bridge.summarySteps + Bridge.steps)
91+
saveSummarySteps(BridgeApplication.summarySteps + BridgeApplication.steps)
9292
}
9393

9494
override fun onSensorChanged(sensorEvent: SensorEvent) {
9595
Log.i(TAG, "onSensorChanged!!!!!!: " + sensorEvent.values[0])
96-
if (Bridge.initialSteps == 0) {
96+
if (BridgeApplication.initialSteps == 0) {
9797
Log.i(TAG, "onSensorChanged: AWAKE")
98-
Bridge.initialSteps = sensorEvent.values[0].toInt()
98+
BridgeApplication.initialSteps = sensorEvent.values[0].toInt()
9999
}
100100
if (running) {
101-
Bridge.steps = sensorEvent.values[0].toInt() - Bridge.initialSteps
102-
Log.i(TAG, "onSensorChanged: current steps: " + Bridge.steps)
103-
saveData(Bridge.steps)
101+
BridgeApplication.steps = sensorEvent.values[0].toInt() - BridgeApplication.initialSteps
102+
Log.i(TAG, "onSensorChanged: current steps: " + BridgeApplication.steps)
103+
saveData(BridgeApplication.steps)
104104
}
105105
}
106106

@@ -113,7 +113,7 @@ class PedometerService : Service(), SensorEventListener {
113113
if (countSensor != null) {
114114
sensorManager!!.registerListener(this, countSensor, SensorManager.SENSOR_DELAY_UI)
115115
} else {
116-
Toast.makeText(Bridge.myActivity, "Sensor Not Found (", Toast.LENGTH_LONG).show()
116+
Toast.makeText(BridgeApplication.myActivity, "Sensor Not Found (", Toast.LENGTH_LONG).show()
117117
}
118118
}
119119

@@ -125,25 +125,25 @@ class PedometerService : Service(), SensorEventListener {
125125
fun saveData(currentSteps: Int) {
126126
val editor = sharedPreferences!!.edit()
127127
currentDate = Calendar.getInstance().time
128-
editor.putString(Bridge.DATE, currentDate.toString())
128+
editor.putString(BridgeApplication.DATE, currentDate.toString())
129129
Log.i(TAG, "saveData: saved! $currentSteps")
130-
editor.putInt(Bridge.STEPS, currentSteps)
130+
editor.putInt(BridgeApplication.STEPS, currentSteps)
131131
editor.apply()
132132
}
133133

134134
fun saveSummarySteps(stepsToSave: Int) {
135135
val editor = sharedPreferences!!.edit()
136136
currentDate = Calendar.getInstance().time
137-
editor.putString(Bridge.DATE, currentDate.toString())
137+
editor.putString(BridgeApplication.DATE, currentDate.toString())
138138
Log.i(TAG, "saveSummarySteps: saved! $stepsToSave")
139139
editor.putInt("summarySteps", stepsToSave)
140140
editor.apply()
141141
}
142142

143143
fun loadData() {
144-
Bridge.steps = sharedPreferences!!.getInt(Bridge.STEPS, 0)
145-
Bridge.summarySteps = sharedPreferences!!.getInt("summarySteps", 0)
146-
Log.i(TAG, "loadData: steps" + Bridge.steps)
147-
Log.i(TAG, "loadData: summarySteps " + Bridge.summarySteps)
144+
BridgeApplication.steps = sharedPreferences!!.getInt(BridgeApplication.STEPS, 0)
145+
BridgeApplication.summarySteps = sharedPreferences!!.getInt("summarySteps", 0)
146+
Log.i(TAG, "loadData: steps" + BridgeApplication.steps)
147+
Log.i(TAG, "loadData: summarySteps " + BridgeApplication.summarySteps)
148148
}
149149
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void SyncData()
4848

4949
---
5050
### [Android](https://github.com/nintendaii/unity-background-service/tree/master/AndroidProject)
51-
The entry point of the Android application is the [`Bridge`](https://github.com/nintendaii/unity-background-service/blob/master/AndroidProject/app/src/main/java/com/kdg/toast/plugin/Bridge.java) class. Explanation of the methods:
51+
The entry point of the Android application is the [`BridgeApplication`](https://github.com/nintendaii/unity-background-service/blob/master/AndroidProject/app/src/main/java/com/kdg/toast/plugin/BridgeApplication.java) class. Explanation of the methods:
5252
1. The `receiveActivityInstance` method is called when the `SendActivityReference` from Unity executes. It takes the Unity activity to know where to start the background service in the future. Also it checks if the permission for activity recognition is granted and asks for the permission if it is not (this logic is implemented for Android API 28 and above).
5353
```java
5454
public static void receiveActivityInstance(Activity tempActivity) {

0 commit comments

Comments
 (0)