X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=02eb8096c7b2b0799515e45f95c2f72ed6292345;hb=0974c053bfa714958b1ce911865907085232a6d9;hp=1afc155d39e8e7d0bc6cd4dd7038406352e59476;hpb=dc38d4a30e643611ce9374448ce142610dba7b87;p=mobile-ledger-staging.git
diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
index 1afc155d..02eb8096 100644
--- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
+++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
@@ -1,18 +1,18 @@
/*
* Copyright © 2019 Damyan Ivanov.
- * This file is part of Mobile-Ledger.
- * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * 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
* the Free Software Foundation, either version 3 of the License, or
* (at your opinion), any later version.
*
- * Mobile-Ledger is distributed in the hope that it will be useful,
+ * MoLe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License terms for details.
*
* You should have received a copy of the GNU General Public License
- * along with Mobile-Ledger. If not, see .
+ * along with MoLe. If not, see .
*/
package net.ktnx.mobileledger.ui.activity;
@@ -22,6 +22,7 @@ import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
+import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
@@ -29,7 +30,6 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
-import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
@@ -52,7 +52,7 @@ import java.lang.ref.WeakReference;
import java.text.DateFormat;
import java.util.Date;
-public class MainActivity extends AppCompatActivity {
+public class MainActivity extends CrashReportingActivity {
DrawerLayout drawer;
private FragmentManager fragmentManager;
private TextView tvLastUpdate;
@@ -62,6 +62,7 @@ public class MainActivity extends AppCompatActivity {
private LinearLayout progressLayout;
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
+ private FloatingActionButton fab;
@Override
protected void onStart() {
@@ -87,6 +88,7 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
+ fab = findViewById(R.id.btn_add_transaction);
Data.profile.addObserver((o, arg) -> {
MobileLedgerProfile profile = Data.profile.get();
@@ -94,6 +96,14 @@ public class MainActivity extends AppCompatActivity {
if (profile == null) setTitle(R.string.app_name);
else setTitle(profile.getName());
updateLastUpdateTextFromDB();
+ if (profile.isPostingPermitted()) {
+ toolbar.setSubtitle(null);
+ fab.show();
+ }
+ else {
+ toolbar.setSubtitle(R.string.profile_subitlte_read_only);
+ fab.hide();
+ }
});
});
@@ -166,6 +176,8 @@ public class MainActivity extends AppCompatActivity {
});
findViewById(R.id.btn_no_profiles_add).setOnClickListener(v -> startAddProfileActivity());
+
+ findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked);
}
@Override
protected void onResume() {
@@ -381,5 +393,8 @@ public class MainActivity extends AppCompatActivity {
return 2;
}
}
-
+ public void fabShouldShow() {
+ MobileLedgerProfile profile = Data.profile.get();
+ if (profile.isPostingPermitted()) fab.show();
+ }
}