Skip to content

Commit fb5bc6e

Browse files
author
Robert Henigan
authored
Merge pull request #1522 from smartdevicelink/feature/reformat_hello_sdl_code
Reformat hello sdl code
2 parents 3f91db4 + d4f285d commit fb5bc6e

13 files changed

Lines changed: 559 additions & 554 deletions

File tree

android/hello_sdl_android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ android {
1717
}
1818
}
1919
flavorDimensions "default"
20-
productFlavors{
20+
productFlavors {
2121
multi_sec_high {
2222
buildConfigField 'String', 'TRANSPORT', '"MULTI"'
2323
buildConfigField 'String', 'SECURITY', '"HIGH"'

android/hello_sdl_android/src/main/AndroidManifest.xml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.sdl.hellosdlandroid">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.sdl.hellosdlandroid">
55

66
<uses-permission android:name="android.permission.BLUETOOTH" />
77
<uses-permission android:name="android.permission.INTERNET" />
@@ -20,16 +20,17 @@
2020
tools:ignore="DeepLinks">
2121
<activity
2222
android:name=".MainActivity"
23-
android:label="@string/app_name" >
23+
android:label="@string/app_name">
2424
<intent-filter>
2525
<action android:name="android.intent.action.MAIN" />
2626

2727
<category android:name="android.intent.category.LAUNCHER" />
2828
</intent-filter>
2929
</activity>
3030

31-
<activity android:name="com.smartdevicelink.transport.USBAccessoryAttachmentActivity"
32-
android:launchMode="singleTop">
31+
<activity
32+
android:name="com.smartdevicelink.transport.USBAccessoryAttachmentActivity"
33+
android:launchMode="singleTop">
3334
<intent-filter>
3435
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
3536
</intent-filter>
@@ -49,23 +50,27 @@
4950
android:process="com.smartdevicelink.router"
5051
android:foregroundServiceType="connectedDevice">
5152
<intent-filter>
52-
<action android:name="com.smartdevicelink.router.service"/>
53+
<action android:name="com.smartdevicelink.router.service" />
5354
</intent-filter>
54-
<meta-data android:name="@string/sdl_router_service_version_name" android:value="@integer/sdl_router_service_version_value" />
55+
<meta-data
56+
android:name="@string/sdl_router_service_version_name"
57+
android:value="@integer/sdl_router_service_version_value" />
5558
</service>
59+
5660
<receiver
5761
android:name=".SdlReceiver"
5862
android:enabled="true"
5963
android:exported="true"
6064
tools:ignore="ExportedReceiver">
6165
<intent-filter>
62-
<action android:name="com.smartdevicelink.USB_ACCESSORY_ATTACHED"/> <!--For AOA -->
66+
<action android:name="com.smartdevicelink.USB_ACCESSORY_ATTACHED" /> <!--For AOA -->
6367
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
6468
<action android:name="sdl.router.startservice" />
6569
</intent-filter>
6670
</receiver>
67-
<activity android:name="com.smartdevicelink.managers.lockscreen.SDLLockScreenActivity"
68-
android:launchMode="singleTop"/>
71+
<activity
72+
android:name="com.smartdevicelink.managers.lockscreen.SDLLockScreenActivity"
73+
android:launchMode="singleTop" />
6974
</application>
7075

7176
</manifest>

android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/MainActivity.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@
99

1010
public class MainActivity extends AppCompatActivity {
1111

12-
@Override
13-
protected void onCreate(Bundle savedInstanceState) {
14-
super.onCreate(savedInstanceState);
15-
setContentView(R.layout.activity_main);
16-
//If we are connected to a module we want to start our SdlService
17-
if(BuildConfig.TRANSPORT.equals("MULTI") || BuildConfig.TRANSPORT.equals("MULTI_HB")) {
18-
SdlReceiver.queryForConnectedService(this);
19-
}else if(BuildConfig.TRANSPORT.equals("TCP")) {
20-
Intent proxyIntent = new Intent(this, SdlService.class);
21-
startService(proxyIntent);
22-
}
23-
}
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
setContentView(R.layout.activity_main);
16+
//If we are connected to a module we want to start our SdlService
17+
if (BuildConfig.TRANSPORT.equals("MULTI") || BuildConfig.TRANSPORT.equals("MULTI_HB")) {
18+
SdlReceiver.queryForConnectedService(this);
19+
} else if (BuildConfig.TRANSPORT.equals("TCP")) {
20+
Intent proxyIntent = new Intent(this, SdlService.class);
21+
startService(proxyIntent);
22+
}
23+
}
2424

25-
@Override
26-
public boolean onCreateOptionsMenu(Menu menu) {
27-
// Inflate the menu; this adds items to the action bar if it is present.
28-
getMenuInflater().inflate(R.menu.main, menu);
29-
return true;
30-
}
25+
@Override
26+
public boolean onCreateOptionsMenu(Menu menu) {
27+
// Inflate the menu; this adds items to the action bar if it is present.
28+
getMenuInflater().inflate(R.menu.main, menu);
29+
return true;
30+
}
3131

32-
@Override
33-
public boolean onOptionsItemSelected(MenuItem item) {
34-
// Handle action bar item clicks here. The action bar will
35-
// automatically handle clicks on the Home/Up button, so long
36-
// as you specify a parent activity in AndroidManifest.xml.
37-
int id = item.getItemId();
38-
if (id == R.id.action_settings) {
39-
return true;
40-
}
41-
return super.onOptionsItemSelected(item);
42-
}
32+
@Override
33+
public boolean onOptionsItemSelected(MenuItem item) {
34+
// Handle action bar item clicks here. The action bar will
35+
// automatically handle clicks on the Home/Up button, so long
36+
// as you specify a parent activity in AndroidManifest.xml.
37+
int id = item.getItemId();
38+
if (id == R.id.action_settings) {
39+
return true;
40+
}
41+
return super.onOptionsItemSelected(item);
42+
}
4343
}

android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88
import com.smartdevicelink.transport.SdlRouterService;
99
import com.smartdevicelink.util.DebugTool;
1010

11-
public class SdlReceiver extends SdlBroadcastReceiver {
12-
private static final String TAG = "SdlBroadcastReceiver";
11+
public class SdlReceiver extends SdlBroadcastReceiver {
12+
private static final String TAG = "SdlBroadcastReceiver";
1313

14-
@Override
15-
public void onSdlEnabled(Context context, Intent intent) {
16-
DebugTool.logInfo(TAG, "SDL Enabled");
17-
intent.setClass(context, SdlService.class);
14+
@Override
15+
public void onSdlEnabled(Context context, Intent intent) {
16+
DebugTool.logInfo(TAG, "SDL Enabled");
17+
intent.setClass(context, SdlService.class);
1818

19-
// SdlService needs to be foregrounded in Android O and above
20-
// This will prevent apps in the background from crashing when they try to start SdlService
21-
// Because Android O doesn't allow background apps to start background services
22-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
23-
context.startForegroundService(intent);
24-
} else {
25-
context.startService(intent);
26-
}
27-
}
19+
// SdlService needs to be foregrounded in Android O and above
20+
// This will prevent apps in the background from crashing when they try to start SdlService
21+
// Because Android O doesn't allow background apps to start background services
22+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
23+
context.startForegroundService(intent);
24+
} else {
25+
context.startService(intent);
26+
}
27+
}
2828

29-
@Override
30-
public Class<? extends SdlRouterService> defineLocalSdlRouterClass() {
31-
return com.sdl.hellosdlandroid.SdlRouterService.class;
32-
}
29+
@Override
30+
public Class<? extends SdlRouterService> defineLocalSdlRouterClass() {
31+
return com.sdl.hellosdlandroid.SdlRouterService.class;
32+
}
3333

34-
@Override
35-
public void onReceive(Context context, Intent intent) {
36-
super.onReceive(context, intent); // Required if overriding this method
37-
}
34+
@Override
35+
public void onReceive(Context context, Intent intent) {
36+
super.onReceive(context, intent); // Required if overriding this method
37+
}
3838
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.sdl.hellosdlandroid;
22

33

4-
public class SdlRouterService extends com.smartdevicelink.transport.SdlRouterService {
5-
4+
public class SdlRouterService extends com.smartdevicelink.transport.SdlRouterService {
65

76

87
}

0 commit comments

Comments
 (0)