import com.google.android.material.snackbar.Snackbar;
+import net.ktnx.mobileledger.BackupsActivity;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.async.RetrieveTransactionsTask;
import net.ktnx.mobileledger.async.TransactionAccumulator;
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();
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();
}
b.btnNoProfilesAdd.setOnClickListener(v -> ProfileDetailActivity.start(this, null));
+ b.btnRestore.setOnClickListener(v -> BackupsActivity.start(this));
b.btnAddTransaction.setOnClickListener(this::fabNewTransactionClicked);
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
b.navAccountSummary.setOnClickListener(this::onAccountSummaryClicked);
b.navLatestTransactions.setOnClickListener(this::onLatestTransactionsClicked);
b.navPatterns.setOnClickListener(this::onPatternsClick);
+ b.navBackupRestore.setOnClickListener(this::onBackupRestoreClick);
+ }
+ private void onBackupRestoreClick(View view) {
+ Intent intent = new Intent(this, BackupsActivity.class);
+ startActivity(intent);
}
private void onPatternsClick(View view) {
Intent intent = new Intent(this, TemplatesActivity.class);
createShortcuts(newList);
- Profile currentProfile = Data.getProfile();
- boolean currentProfilePresent = false;
+ final Profile currentProfile = Data.getProfile();
+ Profile replacementProfile = null;
if (currentProfile != null) {
for (Profile p : newList) {
if (p.getId() == currentProfile.getId()) {
- currentProfilePresent = true;
+ replacementProfile = p;
break;
}
}
}
- if (!currentProfilePresent) {
+
+ if (replacementProfile == null) {
Logger.debug(TAG, "Switching profile because the current is no longer available");
Data.setCurrentProfile(newList.get(0));
}
+ else {
+ Data.setCurrentProfile(replacementProfile);
+ }
}
/**
* called when the current profile has changed
*/
private void onProfileChanged(@Nullable Profile newProfile) {
- if (this.profile == null) {
- if (newProfile == null)
- return;
- }
- else {
+ if (this.profile != null) {
if (this.profile.equals(newProfile))
return;
}
else
setTitle(R.string.app_name);
- int newProfileTheme = haveProfile ? newProfile.getTheme() : -1;
+ int newProfileTheme = haveProfile ? newProfile.getTheme() : Colors.DEFAULT_HUE_DEG;
if (newProfileTheme != Colors.profileThemeId) {
Logger.debug("profiles",
String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
Logger.debug(TAG, "account filter changed, reloading transactions");
// mainModel.scheduleTransactionListReload();
LiveData<List<TransactionWithAccounts>> transactions =
- new MutableLiveData<>(new ArrayList<TransactionWithAccounts>());
+ new MutableLiveData<>(new ArrayList<>());
if (profile != null) {
if (accFilter == null || accFilter.isEmpty()) {
transactions = DB.get()
}
@Override
public void run() {
- TransactionAccumulator accumulator = new TransactionAccumulator(accFilter);
+ TransactionAccumulator accumulator = new TransactionAccumulator(accFilter, accFilter);
for (TransactionWithAccounts tr : list) {
if (isInterrupted()) {