add menu items for settings and About

This commit is contained in:
tibbi 2016-12-09 20:40:11 +01:00
parent 3f9a44ef42
commit 48aed0cc44
6 changed files with 77 additions and 0 deletions

View File

@ -15,5 +15,21 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activities.AboutActivity"
android:label="@string/about"
android:parentActivityName=".activities.MainActivity"/>
<activity
android:name=".activities.LicenseActivity"
android:label="@string/third_party_licences"
android:parentActivityName=".activities.AboutActivity"/>
<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings"
android:parentActivityName=".activities.MainActivity"/>
</application>
</manifest>

View File

@ -0,0 +1,9 @@
package com.simplemobiletools.thankyou.activities
import android.os.Bundle
class AboutActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}

View File

@ -0,0 +1,9 @@
package com.simplemobiletools.thankyou.activities
import android.os.Bundle
class LicenseActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}

View File

@ -1,6 +1,9 @@
package com.simplemobiletools.thankyou.activities
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.thankyou.R
class MainActivity : SimpleActivity() {
@ -14,4 +17,23 @@ class MainActivity : SimpleActivity() {
super.onDestroy()
mConfig.isFirstRun = false
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.settings -> {
startActivity(Intent(applicationContext, SettingsActivity::class.java))
true
}
R.id.about -> {
startActivity(Intent(applicationContext, AboutActivity::class.java))
true
}
else -> super.onOptionsItemSelected(item)
}
}
}

View File

@ -0,0 +1,9 @@
package com.simplemobiletools.thankyou.activities
import android.os.Bundle
class SettingsActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/settings"
android:title="@string/settings"
app:showAsAction="never"/>
<item
android:id="@+id/about"
android:title="@string/about"
app:showAsAction="never"/>
</menu>