From: Damyan Ivanov Date: Sun, 3 Mar 2019 09:29:38 +0000 (+0200) Subject: make the profile details activity use the theme of the profile X-Git-Tag: v0.7~19 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=e975cffd3885678f30f69d09fbc99905c3118588 make the profile details activity use the theme of the profile --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java index 911d2cec..c8edc604 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/CrashReportingActivity.java @@ -1,29 +1,20 @@ 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 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 51ddf6e8..c2ee2c60 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 @@ -66,7 +66,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; 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; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index 79475329..b69710b3 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -21,11 +21,6 @@ import android.annotation.SuppressLint; 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; @@ -45,6 +40,10 @@ import android.widget.TableRow; 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; @@ -66,6 +65,9 @@ import java.util.List; 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 @@ -74,7 +76,7 @@ import java.util.Objects; * 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; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java index ee4707ca..a1bc5cf7 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java @@ -30,6 +30,7 @@ import net.ktnx.mobileledger.R; 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; @@ -41,10 +42,22 @@ 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); @@ -74,15 +87,6 @@ public class ProfileDetailActivity extends CrashReportingActivity { // 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(); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java new file mode 100644 index 00000000..1301a85f --- /dev/null +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +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); + } +}