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;
private LinearLayout progressLayout;
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
+ private FloatingActionButton fab;
@Override
protected void onStart() {
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();
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();
+ }
});
});
});
findViewById(R.id.btn_no_profiles_add).setOnClickListener(v -> startAddProfileActivity());
+
+ findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked);
}
@Override
protected void onResume() {
return 2;
}
}
-
+ public void fabShouldShow() {
+ MobileLedgerProfile profile = Data.profile.get();
+ if (profile.isPostingPermitted()) fab.show();
+ }
}