]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/LatestTransactions.java
remove unused navigationView implementation
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / LatestTransactions.java
1 package net.ktnx.mobileledger;
2
3 import android.content.pm.PackageInfo;
4 import android.os.Bundle;
5 import android.support.design.widget.FloatingActionButton;
6 import android.support.design.widget.Snackbar;
7 import android.support.v4.view.GravityCompat;
8 import android.support.v4.widget.DrawerLayout;
9 import android.support.v7.app.ActionBarDrawerToggle;
10 import android.support.v7.app.AppCompatActivity;
11 import android.support.v7.widget.Toolbar;
12 import android.util.Log;
13 import android.view.Menu;
14 import android.view.MenuItem;
15 import android.view.View;
16
17 public class LatestTransactions extends AppCompatActivity {
18
19     @Override
20     protected void onCreate(Bundle savedInstanceState) {
21         super.onCreate(savedInstanceState);
22         setContentView(R.layout.activity_latest_transactions);
23         Toolbar toolbar = findViewById(R.id.toolbar);
24         setSupportActionBar(toolbar);
25
26         FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
27         fab.setOnClickListener(new View.OnClickListener() {
28             @Override
29             public void onClick(View view) {
30                 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
31                         .setAction("Action", null).show();
32             }
33         });
34
35         DrawerLayout drawer = findViewById(R.id.drawer_layout);
36         ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
37                 this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
38         drawer.addDrawerListener(toggle);
39         toggle.syncState();
40
41         android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text);
42
43         try {
44             PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
45             ver.setText(pi.versionName);
46         } catch (Exception e) {
47             ver.setText("version");
48         }
49     }
50
51     public void nav_exit_clicked(View view) {
52         Log.w("mobileledger", "exiting");
53         finish();
54     }
55
56     @Override
57     public void onBackPressed() {
58         DrawerLayout drawer = findViewById(R.id.drawer_layout);
59         if (drawer.isDrawerOpen(GravityCompat.START)) {
60             drawer.closeDrawer(GravityCompat.START);
61         } else {
62             super.onBackPressed();
63         }
64     }
65
66     @Override
67     public boolean onCreateOptionsMenu(Menu menu) {
68         // Inflate the menu; this adds items to the action bar if it is present.
69         getMenuInflater().inflate(R.menu.latest_transactions, menu);
70         return true;
71     }
72
73     @Override
74     public boolean onOptionsItemSelected(MenuItem item) {
75         // Handle action bar item clicks here. The action bar will
76         // automatically handle clicks on the Home/Up button, so long
77         // as you specify a parent activity in AndroidManifest.xml.
78         int id = item.getItemId();
79
80         //noinspection SimplifiableIfStatement
81         if (id == R.id.action_settings) {
82             return true;
83         }
84
85         return super.onOptionsItemSelected(item);
86     }
87
88 }