1 package net.ktnx.mobileledger;
3 import android.content.Intent;
4 import android.content.pm.PackageInfo;
5 import android.os.Bundle;
6 import android.preference.PreferenceManager;
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;
17 import java.util.Date;
19 import static net.ktnx.mobileledger.MobileLedgerDB.db;
21 public class LatestTransactions extends AppCompatActivity {
24 private static Date account_list_last_updated;
25 private static boolean account_list_needs_update = true;
26 public static void preferences_changed() {
27 account_list_needs_update = true;
31 protected void onCreate(Bundle savedInstanceState) {
32 super.onCreate(savedInstanceState);
33 setContentView(R.layout.activity_latest_transactions);
34 Toolbar toolbar = findViewById(R.id.toolbar);
35 setSupportActionBar(toolbar);
37 drawer = findViewById(R.id.drawer_layout);
38 ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
39 this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
40 drawer.addDrawerListener(toggle);
43 android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text);
46 PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
47 ver.setText(pi.versionName);
48 } catch (Exception e) {
54 public void fab_new_transaction_clicked(View view) {
55 Intent intent = new Intent(this, NewTransactionActivity.class);
56 startActivity(intent);
59 public void nav_exit_clicked(View view) {
60 Log.w("mobileledger", "exiting");
64 public void nav_settings_clicked(View view) {
65 Intent intent = new Intent(this, SettingsActivity.class);
66 startActivity(intent);
70 public void onBackPressed() {
71 DrawerLayout drawer = findViewById(R.id.drawer_layout);
72 if (drawer.isDrawerOpen(GravityCompat.START)) {
73 drawer.closeDrawer(GravityCompat.START);
75 super.onBackPressed();
80 public boolean onCreateOptionsMenu(Menu menu) {
81 // Inflate the menu; this adds items to the action bar if it is present.
82 //getMenuInflater().inflate(R.menu.latest_transactions, menu);
87 public boolean onOptionsItemSelected(MenuItem item) {
88 // Handle action bar item clicks here. The action bar will
89 // automatically handle clicks on the Home/Up button, so long
90 // as you specify a parent activity in AndroidManifest.xml.
91 int id = item.getItemId();
93 //noinspection SimplifiableIfStatement
94 //if (id == R.id.action_settings) {
98 return super.onOptionsItemSelected(item);
101 private void prepare_db() {
102 MobileLedgerDB.setDb_filename(this.getApplicationInfo().deviceProtectedDataDir + "/" + MobileLedgerDB.DATABASE_NAME);
103 MobileLedgerDB.initDB();
105 private void update_accounts() {
108 RetrieveAccountsTask task = new RetrieveAccountsTask();
110 task.setPref(PreferenceManager.getDefaultSharedPreferences(this));