1 package net.ktnx.mobileledger;
3 import android.content.pm.PackageInfo;
4 import android.os.Bundle;
5 import android.support.design.widget.FloatingActionButton;
6 import android.support.design.widget.NavigationView;
7 import android.support.design.widget.Snackbar;
8 import android.support.v4.view.GravityCompat;
9 import android.support.v4.widget.DrawerLayout;
10 import android.support.v7.app.ActionBarDrawerToggle;
11 import android.support.v7.app.AppCompatActivity;
12 import android.support.v7.widget.Toolbar;
13 import android.view.Menu;
14 import android.view.MenuItem;
15 import android.view.View;
17 public class LatestTransactions extends AppCompatActivity
18 implements NavigationView.OnNavigationItemSelectedListener {
21 protected void onCreate(Bundle savedInstanceState) {
22 super.onCreate(savedInstanceState);
23 setContentView(R.layout.activity_latest_transactions);
24 Toolbar toolbar = findViewById(R.id.toolbar);
25 setSupportActionBar(toolbar);
27 FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
28 fab.setOnClickListener(new View.OnClickListener() {
30 public void onClick(View view) {
31 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
32 .setAction("Action", null).show();
36 DrawerLayout drawer = findViewById(R.id.drawer_layout);
37 ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
38 this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
39 drawer.addDrawerListener(toggle);
42 NavigationView navigationView = findViewById(R.id.nav_view);
43 navigationView.setNavigationItemSelectedListener(this);
45 android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text);
48 PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
49 ver.setText(pi.versionName);
50 } catch (Exception e) {
51 ver.setText("version");
56 public void onBackPressed() {
57 DrawerLayout drawer = findViewById(R.id.drawer_layout);
58 if (drawer.isDrawerOpen(GravityCompat.START)) {
59 drawer.closeDrawer(GravityCompat.START);
61 super.onBackPressed();
66 public boolean onCreateOptionsMenu(Menu menu) {
67 // Inflate the menu; this adds items to the action bar if it is present.
68 getMenuInflater().inflate(R.menu.latest_transactions, menu);
73 public boolean onOptionsItemSelected(MenuItem item) {
74 // Handle action bar item clicks here. The action bar will
75 // automatically handle clicks on the Home/Up button, so long
76 // as you specify a parent activity in AndroidManifest.xml.
77 int id = item.getItemId();
79 //noinspection SimplifiableIfStatement
80 if (id == R.id.action_settings) {
84 return super.onOptionsItemSelected(item);
87 @SuppressWarnings("StatementWithEmptyBody")
89 public boolean onNavigationItemSelected(MenuItem item) {
90 // Handle navigation view item clicks here.
91 int id = item.getItemId();
93 if (id == R.id.nav_latest_transactions) {
94 // Handle the camera action
95 } else if (id == R.id.nav_reports) {
97 } else if (id == R.id.nav_settings) {
99 } else if (id == R.id.nav_exit) {
103 DrawerLayout drawer = findViewById(R.id.drawer_layout);
104 drawer.closeDrawer(GravityCompat.START);