adds help page

This commit is contained in:
Raphael Maenle 2022-03-11 13:59:52 +01:00
parent d5ceace59f
commit d102004e6b
4 changed files with 36 additions and 4 deletions

View File

@ -1,19 +1,24 @@
package com.maenle.bump.ui
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.util.Log
import com.google.android.material.snackbar.Snackbar
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import android.view.Menu
import android.view.MenuItem
import com.maenle.bump.R
import com.maenle.bump.databinding.ActivityMainBinding
import com.maenle.bump.util.BumpProcessor
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
@ -38,8 +43,24 @@ class MainActivity : AppCompatActivity() {
}
fun showHelp() {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://raphael.maenle.net/post/projects/bump/"));
startActivity(browserIntent);
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
for (i in 0 until menu.size()) {
val item = menu.getItem(i)
val spanString = SpannableString(menu.getItem(i).title.toString())
spanString.setSpan(
ForegroundColorSpan(Color.WHITE),
0,
spanString.length,
0
) //fix the color to white
item.title = spanString
}
return true
}
@ -53,6 +74,10 @@ class MainActivity : AppCompatActivity() {
BumpProcessor.clearLog(applicationContext)
true
}
R.id.action_info -> {
showHelp()
true
}
else -> super.onOptionsItemSelected(item)
}

View File

@ -7,9 +7,14 @@
android:orderInCategory="100"
android:title="@string/action_clear_log"
app:showAsAction="never" />
<item
android:id="@+id/action_info"
android:orderInCategory="101"
android:title="@string/action_info"
app:showAsAction="never" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:orderInCategory="102"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>

View File

@ -1,6 +1,7 @@
<resources>
<string name="app_name">Bump</string>
<string name="action_settings">Settings</string>
<string name="action_info">Help</string>
<string name="action_clear_log">Clear Log</string>
<!-- Strings used for fragments for navigation -->
<string name="main_fragment_label">Bump</string>

View File

@ -12,6 +12,7 @@
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="actionMenuTextColor">@color/white</item>
</style>
<style name="Theme.BumpForAndroid.NoActionBar">