From: Damyan Ivanov Date: Sun, 5 Jul 2020 16:40:57 +0000 (+0300) Subject: add splash on startup X-Git-Tag: v0.15.0~108 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=bc308eb5e470d3f51e91bebad2f368d618593907 add splash on startup use the small delay to prepare as much as possible there's still a bit of a flicker, so this needs more work to make it smooth --- diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 85a211ef..6a0c6709 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,18 +32,20 @@ android:networkSecurityConfig="@xml/network_security_config" tools:ignore="GoogleAppIndexingWarning"> + - + android:parentActivityName=".ui.activity.MainActivity"> list = new ArrayList<>(); SQLiteDatabase db = App.getDatabase(); 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 cad02177..3cf5aa24 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 @@ -69,6 +69,7 @@ import net.ktnx.mobileledger.ui.transaction_list.TransactionListViewModel; import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.GetOptCallback; import net.ktnx.mobileledger.utils.LockHolder; +import net.ktnx.mobileledger.utils.Logger; import net.ktnx.mobileledger.utils.MLDB; import org.jetbrains.annotations.NotNull; @@ -109,6 +110,8 @@ public class MainActivity extends ProfileThemedActivity { protected void onStart() { super.onStart(); + Logger.debug("MainActivity", "onStart()"); + mViewPager.setCurrentItem(mCurrentPage, false); } @Override @@ -152,8 +155,9 @@ public class MainActivity extends ProfileThemedActivity { } @Override protected void onCreate(Bundle savedInstanceState) { + debug("MainActivity", "onCreate()/entry"); super.onCreate(savedInstanceState); - debug("flow", "MainActivity.onCreate()"); + debug("MainActivity", "onCreate()/after super"); setContentView(R.layout.activity_main); fab = findViewById(R.id.btn_add_transaction); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/SplashActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/SplashActivity.java new file mode 100644 index 00000000..32b71d65 --- /dev/null +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/SplashActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright © 2020 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your opinion), any later version. + * + * 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 MoLe. If not, see . + */ + +package net.ktnx.mobileledger.ui.activity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; + +import androidx.annotation.Nullable; + +import net.ktnx.mobileledger.R; +import net.ktnx.mobileledger.model.Data; +import net.ktnx.mobileledger.model.MobileLedgerProfile; +import net.ktnx.mobileledger.utils.MLDB; + +public class SplashActivity extends Activity { + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTheme(R.style.AppTheme_default); + setContentView(R.layout.splash_activity_layout); + } + @Override + protected void onStart() { + super.onStart(); + + MobileLedgerProfile.loadAllFromDB(null); + + String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null); + MobileLedgerProfile startupProfile = Data.getProfile(profileUUID); + if (startupProfile != null) + Data.setCurrentProfile(startupProfile); + + new Handler().postDelayed(() -> { + Intent intent = new Intent(this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION | + Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + overridePendingTransition(R.anim.fade_in, R.anim.dummy); + }, 250); + } +} diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java index 96de4b64..6179174f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java @@ -93,6 +93,7 @@ public class TransactionListAdapter extends RecyclerView.Adapter + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 715486a9..b12fff86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -163,4 +163,5 @@ Show comment fields by default Filter Go to date + Main app icon