Create empty SettingsActivity and an Intent to open it from the Settings icon in the MainActivity bottom status bar.
This commit is contained in:
parent
79a0a5fc79
commit
30ae9c36bf
6 changed files with 64 additions and 41 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools" package="cy.agorise.bitsybitshareswallet">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="cy.agorise.bitsybitshareswallet">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -15,10 +16,15 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".activities.SettingsActivity"
|
||||||
|
android:label="@string/title_settings">
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -1,13 +1,12 @@
|
||||||
package cy.agorise.bitsybitshareswallet.activities
|
package cy.agorise.bitsybitshareswallet.activities
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v4.app.FragmentPagerAdapter
|
import android.support.v4.app.FragmentPagerAdapter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuItem
|
|
||||||
import cy.agorise.bitsybitshareswallet.BuildConfig
|
import cy.agorise.bitsybitshareswallet.BuildConfig
|
||||||
import cy.agorise.bitsybitshareswallet.R
|
import cy.agorise.bitsybitshareswallet.R
|
||||||
import cy.agorise.bitsybitshareswallet.fragments.BalancesFragment
|
import cy.agorise.bitsybitshareswallet.fragments.BalancesFragment
|
||||||
|
@ -32,7 +31,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
//setSupportActionBar(toolbar)
|
|
||||||
// Create the adapter that will return a fragment for each of the three
|
// Create the adapter that will return a fragment for each of the three
|
||||||
// primary sections of the activity.
|
// primary sections of the activity.
|
||||||
mSectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager)
|
mSectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager)
|
||||||
|
@ -44,29 +42,23 @@ class MainActivity : AppCompatActivity() {
|
||||||
// Force first tab to show BTS icon
|
// Force first tab to show BTS icon
|
||||||
tabLayout.getTabAt(0)?.setIcon(R.drawable.tab_home_selector)
|
tabLayout.getTabAt(0)?.setIcon(R.drawable.tab_home_selector)
|
||||||
|
|
||||||
tvBuildVersion.text = String.format("v%s", BuildConfig.VERSION_NAME)
|
initBottomBar()
|
||||||
}
|
|
||||||
|
|
||||||
|
ivSettings.setOnClickListener {
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
val intent = Intent(this, SettingsActivity::class.java)
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
startActivity(intent)
|
||||||
menuInflater.inflate(R.menu.menu_main, menu)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
// Handle action bar item clicks here. The action bar will
|
|
||||||
// automatically handle clicks on the Home/Up button, so long
|
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
|
||||||
val id = item.itemId
|
|
||||||
|
|
||||||
if (id == R.id.action_settings) {
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initBottomBar() {
|
||||||
|
// Show app version number in bottom bar
|
||||||
|
tvBuildVersion.text = String.format("v%s", BuildConfig.VERSION_NAME)
|
||||||
|
|
||||||
|
// Show block number in bottom bar
|
||||||
|
tvBlockNumber.text = getString(R.string.block_number_bottom_bar, "-----")
|
||||||
|
|
||||||
|
// TODO add listener to update block number
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [FragmentPagerAdapter] that returns a fragment corresponding to
|
* A [FragmentPagerAdapter] that returns a fragment corresponding to
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.activities
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple activity for the user to select his preferences
|
||||||
|
*/
|
||||||
|
class SettingsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setupActionBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the [android.app.ActionBar], if the API is available.
|
||||||
|
*/
|
||||||
|
private fun setupActionBar() {
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == android.R.id.home) {
|
||||||
|
onBackPressed()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -66,7 +66,7 @@
|
||||||
android:id="@+id/tvBlockNumber"
|
android:id="@+id/tvBlockNumber"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Block: ----"
|
tools:text="Block: ----"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -92,7 +92,8 @@
|
||||||
android:src="@drawable/ic_settings"
|
android:src="@drawable/ic_settings"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:contentDescription="@string/title_settings"/>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context="cy.agorise.bitsybitshareswallet.activities.MainActivity">
|
|
||||||
<item android:id="@+id/action_settings"
|
|
||||||
android:title="@string/action_settings"
|
|
||||||
android:orderInCategory="100"
|
|
||||||
app:showAsAction="never"/>
|
|
||||||
</menu>
|
|
|
@ -1,10 +1,11 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">BiTSy</string>
|
<string name="app_name">BiTSy</string>
|
||||||
<string name="tab_text_1">Tab 1</string>
|
|
||||||
<string name="tab_text_2">Tab 2</string>
|
<!-- Main Activity -->
|
||||||
<string name="tab_text_3">Tab 3</string>
|
|
||||||
<string name="action_settings">Settings</string>
|
|
||||||
<string name="section_format">Hello World from section: %1$d</string>
|
|
||||||
<string name="title_transactions">Transactions</string>
|
<string name="title_transactions">Transactions</string>
|
||||||
<string name="title_merchants">Merchants</string>
|
<string name="title_merchants">Merchants</string>
|
||||||
|
<string name="block_number_bottom_bar">Block: %1$s</string>
|
||||||
|
|
||||||
|
<!-- Settings -->
|
||||||
|
<string name="title_settings">Settings</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue