package net.ktnx.mobileledger.ui.activity;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import net.ktnx.mobileledger.ui.CrashReportDialogFragment;
-import net.ktnx.mobileledger.utils.Colors;
import java.io.PrintWriter;
import java.io.StringWriter;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
public abstract class CrashReportingActivity extends AppCompatActivity {
- protected void setupProfileColors() {
- Colors.setupTheme(this);
- }
- @Override
- protected void onStart() {
- super.onStart();
- Colors.refreshColors(getTheme());
- }
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Colors.setupTheme(this);
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
-public class MainActivity extends CrashReportingActivity {
+public class MainActivity extends ProfileThemedActivity {
private static final String STATE_CURRENT_PAGE = "current_page";
private static final String BUNDLE_SAVED_STATE = "bundle_savedState";
DrawerLayout drawer;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
-import com.google.android.material.snackbar.BaseTransientBottomBar;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import com.google.android.material.snackbar.Snackbar;
-import androidx.fragment.app.DialogFragment;
-import androidx.appcompat.widget.Toolbar;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.widget.TextView;
import android.widget.Toast;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.BaseTransientBottomBar;
+import com.google.android.material.snackbar.Snackbar;
+
import net.ktnx.mobileledger.BuildConfig;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.async.DescriptionSelectedCallback;
import java.util.Locale;
import java.util.Objects;
+import androidx.appcompat.widget.Toolbar;
+import androidx.fragment.app.DialogFragment;
+
/*
* TODO: nicer progress while transaction is submitted
* TODO: reports
* TODO: nicer swiping removal with visual feedback
* */
-public class NewTransactionActivity extends CrashReportingActivity
+public class NewTransactionActivity extends ProfileThemedActivity
implements TaskCallback, DescriptionSelectedCallback {
private static SaveTransactionTask saver;
private TableLayout table;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
+import net.ktnx.mobileledger.utils.Colors;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
* in a {@link ProfileListActivity}.
*/
public class ProfileDetailActivity extends CrashReportingActivity {
- private MobileLedgerProfile profile;
+ private MobileLedgerProfile profile = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
+
+ if (index != -1) {
+ profile = Data.profiles.get(index);
+ if (profile == null) throw new AssertionError(
+ String.format("Can't get profile " + "(index:%d) from the global list", index));
+
+ Log.d("profiles", String.format("Editing profile %s (%s); hue=%d", profile.getName(),
+ profile.getUuid(), profile.getThemeId()));
+ }
+
super.onCreate(savedInstanceState);
+ Colors.setupTheme(this, profile);
setContentView(R.layout.activity_profile_detail);
Toolbar toolbar = findViewById(R.id.detail_toolbar);
setSupportActionBar(toolbar);
// http://developer.android.com/guide/components/fragments.html
//
if (savedInstanceState == null) {
- final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
-
- if (index != -1) {
- profile = Data.profiles.get(index);
- if (profile == null) throw new AssertionError(
- String.format("Can't get profile " + "(index:%d) from the global list",
- index));
- }
-
// Create the detail fragment and add it to the activity
// using a fragment transaction.
Bundle arguments = new Bundle();
--- /dev/null
+/*
+ * Copyright © 2019 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 Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.ui.activity;
+
+import android.os.Bundle;
+
+import net.ktnx.mobileledger.utils.Colors;
+
+import androidx.annotation.Nullable;
+
+public class ProfileThemedActivity extends CrashReportingActivity {
+ protected void setupProfileColors() {
+ Colors.setupTheme(this);
+ }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ Colors.refreshColors(getTheme());
+ }
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Colors.setupTheme(this);
+ }
+}