Skip to content

Commit cd2aaee

Browse files
author
ars
committed
first dev release
1 parent 16cbbae commit cd2aaee

File tree

6 files changed

+21
-96
lines changed

6 files changed

+21
-96
lines changed

app/build.gradle.kts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
plugins {
22
alias(libs.plugins.android.application)
3+
// Removed Kotlin plugin from here since it causes 'extension already registered' errors
34
}
45

56
android {
67
namespace = "com.andrerinas.wirelesshelper"
7-
compileSdk {
8-
version = release(36)
9-
}
8+
compileSdk = 36
109

1110
buildFeatures {
1211
buildConfig = true
@@ -15,6 +14,7 @@ android {
1514
defaultConfig {
1615
applicationId = "com.andrerinas.wirelesshelper"
1716
minSdk = 16
17+
// minSdk = 21 // 21 only for google play console. App should work in minSDK 16
1818
targetSdk = 36
1919
versionCode = 1
2020
versionName = "0.1.0"
@@ -23,20 +23,26 @@ android {
2323
}
2424

2525
buildTypes {
26-
release {
26+
getByName("release") {
2727
isMinifyEnabled = false
2828
proguardFiles(
2929
getDefaultProguardFile("proguard-android-optimize.txt"),
3030
"proguard-rules.pro"
3131
)
3232
}
3333
}
34+
3435
compileOptions {
3536
sourceCompatibility = JavaVersion.VERSION_11
3637
targetCompatibility = JavaVersion.VERSION_11
3738
}
3839
}
3940

41+
// Radical simple way to set APK name that works in all AGP versions
42+
base {
43+
archivesName.set("com.andrerinas.wirelesshelper_${android.defaultConfig.versionName}")
44+
}
45+
4046
dependencies {
4147
implementation(libs.androidx.core.ktx)
4248
implementation(libs.androidx.appcompat)

app/src/main/java/com/andrerinas/wirelesshelper/MainActivity.kt

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class MainActivity : AppCompatActivity() {
2222

2323
private lateinit var btnToggleService: Button
2424

25-
// Connection Mode
26-
private lateinit var layoutConnectionMode: View
27-
private lateinit var tvConnectionModeValue: TextView
28-
2925
// Auto Start
3026
private lateinit var layoutAutoStart: View
3127
private lateinit var tvAutoStartValue: TextView
@@ -48,15 +44,6 @@ class MainActivity : AppCompatActivity() {
4844
}
4945
}
5046

51-
private val connectionModes by lazy {
52-
arrayOf(
53-
getString(R.string.mode_network_discovery),
54-
getString(R.string.mode_wifi_direct),
55-
getString(R.string.mode_hotspot_phone),
56-
getString(R.string.mode_hotspot_headunit)
57-
)
58-
}
59-
6047
private val autoStartModes by lazy {
6148
arrayOf(
6249
getString(R.string.auto_start_no),
@@ -78,9 +65,6 @@ class MainActivity : AppCompatActivity() {
7865
private fun initializeViews() {
7966
btnToggleService = findViewById(R.id.btnToggleService)
8067

81-
layoutConnectionMode = findViewById(R.id.layoutConnectionMode)
82-
tvConnectionModeValue = findViewById(R.id.tvConnectionModeValue)
83-
8468
layoutAutoStart = findViewById(R.id.layoutAutoStart)
8569
tvAutoStartValue = findViewById(R.id.tvAutoStartValue)
8670

@@ -97,7 +81,7 @@ class MainActivity : AppCompatActivity() {
9781
layoutAbout.setOnClickListener {
9882
MaterialAlertDialogBuilder(this, R.style.DarkAlertDialog)
9983
.setTitle(R.string.about)
100-
.setMessage("Wireless Helper is a trigger app for Headunit Revived.\n\nDeveloped by André Rinas\n© 2026")
84+
.setMessage("Wireless Helper is a trigger app for Headunit Revived.\n\nYou need to set 'Wireless Helper' in 'Wireless Mode'-Setting at Headunit Revived for this to work.\n\nDeveloped by André Rinas\n© 2026")
10185
.setPositiveButton(android.R.string.ok, null)
10286
.show()
10387
}
@@ -106,21 +90,6 @@ class MainActivity : AppCompatActivity() {
10690
if (isServiceRunning) stopLauncherService() else checkPermissionsAndStart()
10791
}
10892

109-
layoutConnectionMode.setOnClickListener {
110-
val prefs = getSharedPreferences("WirelessHelperPrefs", Context.MODE_PRIVATE)
111-
val currentMode = prefs.getInt("connection_mode", 0)
112-
113-
MaterialAlertDialogBuilder(this, R.style.DarkAlertDialog)
114-
.setTitle(R.string.connection_mode_label)
115-
.setSingleChoiceItems(connectionModes, currentMode) { dialog, which ->
116-
prefs.edit { putInt("connection_mode", which) }
117-
tvConnectionModeValue.text = connectionModes[which]
118-
dialog.dismiss()
119-
}
120-
.setNegativeButton(android.R.string.cancel, null)
121-
.show()
122-
}
123-
12493
layoutAutoStart.setOnClickListener {
12594
val prefs = getSharedPreferences("WirelessHelperPrefs", Context.MODE_PRIVATE)
12695
val currentMode = prefs.getInt("auto_start_mode", 0)
@@ -177,9 +146,6 @@ class MainActivity : AppCompatActivity() {
177146
private fun restoreState() {
178147
val prefs = getSharedPreferences("WirelessHelperPrefs", Context.MODE_PRIVATE)
179148

180-
val connMode = prefs.getInt("connection_mode", 0)
181-
tvConnectionModeValue.text = connectionModes.getOrElse(connMode) { connectionModes[0] }
182-
183149
val autoMode = prefs.getInt("auto_start_mode", 0)
184150
updateAutoStartUI(autoMode)
185151

@@ -194,11 +160,11 @@ class MainActivity : AppCompatActivity() {
194160
when (mode) {
195161
0 -> { // No
196162
layoutBluetoothDevice.visibility = View.GONE
197-
layoutAutoStart.setBackgroundResource(R.drawable.bg_item_bottom)
163+
layoutAutoStart.setBackgroundResource(R.drawable.bg_item_single)
198164
}
199165
1 -> { // Bluetooth
200166
layoutBluetoothDevice.visibility = View.VISIBLE
201-
layoutAutoStart.setBackgroundResource(R.drawable.bg_item_middle)
167+
layoutAutoStart.setBackgroundResource(R.drawable.bg_item_top)
202168
layoutBluetoothDevice.setBackgroundResource(R.drawable.bg_item_bottom)
203169
}
204170
}
@@ -266,4 +232,4 @@ class MainActivity : AppCompatActivity() {
266232
if (requestCode == 101) showBluetoothDeviceSelector()
267233
}
268234
}
269-
}
235+
}

app/src/main/java/com/andrerinas/wirelesshelper/WirelessHelperService.kt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,11 @@ class WirelessHelperService : Service() {
140140
}
141141

142142
updateNotification("Searching for Headunit...")
143-
Log.i(TAG, "Service started")
143+
Log.i(TAG, "Service started (Auto-Discovery Mode)")
144144

145-
val prefs = getSharedPreferences("WirelessHelperPrefs", Context.MODE_PRIVATE)
146-
val mode = prefs.getInt("connection_mode", 0)
147-
148-
when (mode) {
149-
3 -> { // Hotspot on Headunit
150-
Log.i(TAG, "Mode: Hotspot on Headunit (Passive Wait)")
151-
Log.i(TAG, "Listening on TCP port $PORT_AA_WIFI_DISCOVERY")
152-
startTcpServer()
153-
}
154-
else -> { // Network Discovery / Active Scan / Phone Hotspot
155-
Log.i(TAG, "Mode: Active Discovery (Scanning)")
156-
startNsdDiscovery()
157-
}
158-
}
145+
// Always start both mechanisms: NSD (Client) and TCP 5289 (Server)
146+
startNsdDiscovery()
147+
startTcpServer()
159148
}
160149
}
161150

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,6 @@
6060
android:orientation="vertical"
6161
android:paddingHorizontal="16dp">
6262

63-
<!-- 1. Connection Mode -->
64-
<LinearLayout
65-
android:id="@+id/layoutConnectionMode"
66-
android:layout_width="match_parent"
67-
android:layout_height="wrap_content"
68-
android:orientation="vertical"
69-
android:paddingHorizontal="16dp"
70-
android:paddingVertical="14dp"
71-
android:layout_marginBottom="2dp"
72-
android:background="@drawable/bg_item_top"
73-
android:clickable="true"
74-
android:focusable="true">
75-
76-
<TextView
77-
android:layout_width="match_parent"
78-
android:layout_height="wrap_content"
79-
android:text="@string/connection_mode_label"
80-
android:textColor="@color/text_title"
81-
android:textSize="16sp"
82-
android:textStyle="normal"
83-
android:layout_marginBottom="2dp"/>
84-
85-
<TextView
86-
android:id="@+id/tvConnectionModeValue"
87-
android:layout_width="match_parent"
88-
android:layout_height="wrap_content"
89-
android:text="Network Discovery"
90-
android:textColor="@color/text_subtitle"
91-
android:textSize="14sp"/>
92-
</LinearLayout>
93-
9463
<!-- 2. Auto Start -->
9564
<LinearLayout
9665
android:id="@+id/layoutAutoStart"
@@ -100,7 +69,7 @@
10069
android:paddingHorizontal="16dp"
10170
android:paddingVertical="14dp"
10271
android:layout_marginBottom="2dp"
103-
android:background="@drawable/bg_item_bottom"
72+
android:background="@drawable/bg_item_top"
10473
android:clickable="true"
10574
android:focusable="true">
10675

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
<resources>
22
<string name="app_name">Wireless Helper</string>
33
<string name="start_service">Start Wireless Mode</string>
4-
<string name="stop_service">Stop</string>
5-
6-
<string name="connection_mode_label">Connection Mode</string>
7-
<string name="mode_network_discovery">Network Discovery (Same WiFi)</string>
8-
<string name="mode_wifi_direct">Wifi Direct</string>
9-
<string name="mode_hotspot_phone">Hotspot on this device</string>
10-
<string name="mode_hotspot_headunit">Hotspot on Headunit</string>
4+
<string name="stop_service">Stop Searching</string>
115

126
<string name="auto_start_label">Auto Start Service</string>
137
<string name="auto_start_no">No (Manual)</string>

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
33
alias(libs.plugins.android.application) apply false
4+
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
45
}

0 commit comments

Comments
 (0)