Skip to content

Commit 1ee611b

Browse files
committed
drawer link clickable
1 parent 8a562b3 commit 1ee611b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

app/src/main/java/ru/aleksandr/dccppthrottle/MainActivity.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ package ru.aleksandr.dccppthrottle
99

1010
import android.content.Intent
1111
import android.content.res.Configuration
12+
import android.net.Uri
1213
import android.os.Bundle
1314
import android.os.Handler
1415
import android.os.Looper
1516
import android.os.PersistableBundle
17+
import android.util.Log
1618
import android.view.Menu
1719
import android.view.MenuItem
1820
import android.widget.Switch
21+
import android.widget.TextView
1922
import android.widget.Toast
2023
import androidx.appcompat.app.ActionBarDrawerToggle
2124
import com.google.android.material.navigation.NavigationView
@@ -33,6 +36,8 @@ import java.io.File
3336

3437
class MainActivity : AwakeActivity(), NavigationView.OnNavigationItemSelectedListener {
3538

39+
private val TAG = javaClass.simpleName
40+
3641
private lateinit var binding: ActivityMainBinding
3742
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
3843
private lateinit var viewPager: ViewPager2
@@ -61,6 +66,13 @@ class MainActivity : AwakeActivity(), NavigationView.OnNavigationItemSelectedLis
6166
val navigationView = findViewById<NavigationView>(R.id.nav_view)
6267
navigationView.setNavigationItemSelectedListener(this)
6368

69+
val subtitle = navigationView.getHeaderView(0).findViewById<TextView>(R.id.textDrawerSubtitle)
70+
subtitle.setOnClickListener {
71+
val uri = Uri.parse(String.format("http://%s", subtitle.text))
72+
val intent = Intent(Intent.ACTION_VIEW, uri)
73+
startActivity(intent)
74+
}
75+
6476
val menuItem = navigationView.menu.findItem(R.id.power_switch_item)
6577
val powerSwitch = menuItem.actionView.findViewById<Switch>(R.id.power_switch)
6678
powerSwitch.setOnClickListener {
@@ -194,7 +206,7 @@ class MainActivity : AwakeActivity(), NavigationView.OnNavigationItemSelectedLis
194206
val prefKeyConnectStartup = getString(R.string.pref_key_connect_startup)
195207
val prefsEditor = PreferenceManager.getDefaultSharedPreferences(this).edit()
196208
prefsEditor.putBoolean(prefKeyConnectStartup, false)
197-
prefsEditor.commit()
209+
prefsEditor.apply()
198210

199211
super.onBackPressed()
200212
}
@@ -212,18 +224,21 @@ class MainActivity : AwakeActivity(), NavigationView.OnNavigationItemSelectedLis
212224

213225
try {
214226
saveStoreToFile(LocomotivesStore)
227+
if (BuildConfig.DEBUG) Log.i(TAG, "Locomotives store saved")
215228
}
216229
catch (e: Exception) {
217230
Toast.makeText(this, R.string.message_failed_save_locos, Toast.LENGTH_SHORT).show()
218231
}
219232
try {
220233
saveStoreToFile(AccessoriesStore)
234+
if (BuildConfig.DEBUG) Log.i(TAG, "Accessories store saved")
221235
}
222236
catch (e: Exception) {
223237
Toast.makeText(this, R.string.message_failed_save_acc, Toast.LENGTH_SHORT).show()
224238
}
225239
try {
226240
saveStoreToFile(RoutesStore)
241+
if (BuildConfig.DEBUG) Log.i(TAG, "Routes store saved")
227242
}
228243
catch (e: Exception) {
229244
Toast.makeText(this, R.string.message_failed_save_routes, Toast.LENGTH_SHORT).show()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
2626

2727
<TextView
28-
android:id="@+id/textView"
28+
android:id="@+id/textDrawerSubtitle"
2929
android:layout_width="wrap_content"
3030
android:layout_height="wrap_content"
3131
android:text="@string/app_subtitle" />

app/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#Sat May 06 17:09:07 MSK 2023
2-
VERSION_CODE=877
1+
#Sun May 07 00:42:20 MSK 2023
2+
VERSION_CODE=886

0 commit comments

Comments
 (0)