android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="GoogleAppIndexingWarning">
<activity
- android:name=".ui.activity.MainActivity"
+ android:name=".ui.activity.SplashActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".ui.activity.MainActivity"
+ android:label="@string/app_name"></activity>
<activity
android:name=".ui.activity.NewTransactionActivity"
android:label="@string/title_activity_new_transaction"
- android:parentActivityName=".ui.activity.MainActivity">
- </activity>
+ android:parentActivityName=".ui.activity.MainActivity"></activity>
<activity
android:name=".ui.activity.ProfileDetailActivity"
android:label="@string/title_profile_details"
/*
- * Copyright © 2019 Damyan Ivanov.
+ * 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
public class App extends Application {
public static App instance;
private MobileLedgerDatabase dbHelper;
+ private boolean monthNamesPrepared = false;
public static SQLiteDatabase getDatabase() {
if (instance == null) throw new RuntimeException("Application not created yet");
Logger.debug("flow", "App onCreate()");
instance = this;
super.onCreate();
- updateMonthNames();
Data.refreshCurrencyData(Locale.getDefault());
Authenticator.setDefault(new Authenticator() {
@Override
}
});
}
- private void updateMonthNames() {
+ public static void prepareMonthNames() {
+ instance.prepareMonthNames(false);
+ }
+ private void prepareMonthNames(boolean force) {
+ if (force || monthNamesPrepared)
+ return;
Resources rm = getResources();
Globals.monthNames = rm.getStringArray(R.array.month_names);
+ monthNamesPrepared = true;
}
@Override
public void onTerminate() {
Logger.debug("flow", "App onTerminate()");
- if (dbHelper != null) dbHelper.close();
+ if (dbHelper != null)
+ dbHelper.close();
super.onTerminate();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- updateMonthNames();
+ prepareMonthNames(true);
Data.refreshCurrencyData(Locale.getDefault());
Data.locale.setValue(Locale.getDefault());
}
}
// loads all profiles into Data.profiles
// returns the profile with the given UUID
- public static MobileLedgerProfile loadAllFromDB(String currentProfileUUID) {
+ public static MobileLedgerProfile loadAllFromDB(@Nullable String currentProfileUUID) {
MobileLedgerProfile result = null;
ArrayList<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = App.getDatabase();
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;
protected void onStart() {
super.onStart();
+ Logger.debug("MainActivity", "onStart()");
+
mViewPager.setCurrentItem(mCurrentPage, false);
}
@Override
}
@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);
--- /dev/null
+/*
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+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);
+ }
+}
if (item.isMonthShown()) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault());
cal.setTime(date.toDate());
+ App.prepareMonthNames();
holder.tvDelimiterMonth.setText(
Globals.monthNames[cal.get(GregorianCalendar.MONTH)]);
holder.tvDelimiterMonth.setVisibility(View.VISIBLE);
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ 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 <https://www.gnu.org/licenses/>.
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?colorPrimary"
+ >
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="@android:dimen/thumbnail_width"
+ android:layout_height="@android:dimen/thumbnail_height"
+ android:contentDescription="@string/splash_icon_description"
+ android:src="@drawable/app_icon_transparent_bg"
+ android:tint="@android:color/white"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:srcCompat="@drawable/app_icon_transparent_bg"
+ />
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<string name="show_comment_input_by_default">Show comment fields by default</string>
<string name="filter_menu_title">Filter</string>
<string name="go_to_date_menu_title">Go to date</string>
+ <string name="splash_icon_description">Main app icon</string>
</resources>