]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
shuffle some classes under proper packages
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 2fc09379873faa8d030c094c709a9451270f568e..3ed892913f5ffd85b14bda661c14fa031ea227b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2020 Damyan Ivanov.
+ * Copyright © 2021 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -54,6 +54,8 @@ import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.ui.MainModel;
 import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
+import net.ktnx.mobileledger.ui.new_transaction.NewTransactionActivity;
+import net.ktnx.mobileledger.ui.patterns.PatternsActivity;
 import net.ktnx.mobileledger.ui.profiles.ProfilesRecyclerViewAdapter;
 import net.ktnx.mobileledger.ui.transaction_list.TransactionListFragment;
 import net.ktnx.mobileledger.utils.Colors;
@@ -146,8 +148,7 @@ public class MainActivity extends ProfileThemedActivity {
         Data.backgroundTasksRunning.observe(this, this::onRetrieveRunningChanged);
 
         if (barDrawerToggle == null) {
-            barDrawerToggle = new ActionBarDrawerToggle(this, b.drawerLayout, b.toolbar,
-                    R.string.navigation_drawer_open, R.string.navigation_drawer_close);
+            barDrawerToggle = new ActionBarDrawerToggle(this, b.drawerLayout, b.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
             b.drawerLayout.addDrawerListener(barDrawerToggle);
         }
         barDrawerToggle.syncState();
@@ -156,8 +157,7 @@ public class MainActivity extends ProfileThemedActivity {
             PackageInfo pi = getApplicationContext().getPackageManager()
                                                     .getPackageInfo(getPackageName(), 0);
             ((TextView) b.navUpper.findViewById(R.id.drawer_version_text)).setText(pi.versionName);
-            ((TextView) b.noProfilesLayout.findViewById(R.id.drawer_version_text)).setText(
-                    pi.versionName);
+            ((TextView) b.noProfilesLayout.findViewById(R.id.drawer_version_text)).setText(pi.versionName);
         }
         catch (Exception e) {
             e.printStackTrace();
@@ -200,13 +200,11 @@ public class MainActivity extends ProfileThemedActivity {
                      .setValue(savedInstanceState.getString(STATE_ACC_FILTER, null));
         }
 
-        b.btnNoProfilesAdd.setOnClickListener(
-                v -> MobileLedgerProfile.startEditProfileActivity(this, null));
+        b.btnNoProfilesAdd.setOnClickListener(v -> MobileLedgerProfile.startEditProfileActivity(this, null));
 
         b.btnAddTransaction.setOnClickListener(this::fabNewTransactionClicked);
 
-        b.navNewProfileButton.setOnClickListener(
-                v -> MobileLedgerProfile.startEditProfileActivity(this, null));
+        b.navNewProfileButton.setOnClickListener(v -> MobileLedgerProfile.startEditProfileActivity(this, null));
 
         b.transactionListCancelDownload.setOnClickListener(this::onStopTransactionRefreshClick);
 
@@ -251,10 +249,8 @@ public class MainActivity extends ProfileThemedActivity {
         b.navProfileList.setLayoutManager(llm);
 
         b.navProfilesStartEdit.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
-        b.navProfilesCancelEdit.setOnClickListener(
-                (v) -> mProfileListAdapter.flipEditingProfiles());
-        b.navProfileListHeadButtons.setOnClickListener(
-                (v) -> mProfileListAdapter.flipEditingProfiles());
+        b.navProfilesCancelEdit.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
+        b.navProfileListHeadButtons.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
         if (drawerListener == null) {
             drawerListener = new DrawerLayout.SimpleDrawerListener() {
                 @Override
@@ -293,7 +289,7 @@ public class MainActivity extends ProfileThemedActivity {
                      if (error == null)
                          return;
 
-                     Snackbar.make(b.mainPager, error, Snackbar.LENGTH_LONG)
+                     Snackbar.make(b.mainPager, error, Snackbar.LENGTH_INDEFINITE)
                              .show();
                      mainModel.clearUpdateError();
                  });
@@ -301,6 +297,13 @@ public class MainActivity extends ProfileThemedActivity {
         Data.lastUpdateDate.observe(this, date -> refreshLastUpdateInfo());
         Data.lastUpdateTransactionCount.observe(this, date -> refreshLastUpdateInfo());
         Data.lastUpdateAccountCount.observe(this, date -> refreshLastUpdateInfo());
+        b.navAccountSummary.setOnClickListener(this::onAccountSummaryClicked);
+        b.navLatestTransactions.setOnClickListener(this::onLatestTransactionsClicked);
+        b.navPatterns.setOnClickListener(this::onPatternsClick);
+    }
+    private void onPatternsClick(View view) {
+        Intent intent = new Intent(this, PatternsActivity.class);
+        startActivity(intent);
     }
     private void scheduleDataRetrievalIfStale(long lastUpdate) {
         long now = new Date().getTime();