import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
-import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerAccount;
+import net.ktnx.mobileledger.utils.Colors;
import java.util.List;
}
if (position % 2 == 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
- .setBackgroundColor(rm.getColor(R.color.table_row_dark_bg, ctx.getTheme()));
- else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_dark_bg));
+ holder.row.setBackgroundColor(Colors.tableRowDarkBG);
}
else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
- .setBackgroundColor(rm.getColor(R.color.drawer_background, ctx.getTheme()));
- else holder.row.setBackgroundColor(rm.getColor(R.color.drawer_background));
+ holder.row.setBackgroundColor(Colors.tableRowLightBG);
}
holder.selectionCb.setVisibility(selectionActive ? View.VISIBLE : View.GONE);
import net.ktnx.mobileledger.ui.MobileLedgerListFragment;
import net.ktnx.mobileledger.ui.RecyclerItemListener;
import net.ktnx.mobileledger.ui.activity.MainActivity;
+import net.ktnx.mobileledger.utils.Colors;
import java.util.List;
import java.util.Observer;
}
});
swiper = mActivity.findViewById(R.id.account_swiper);
- swiper.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent);
+ Colors.themeWatch.addObserver(
+ (o, arg) -> swiper.setColorSchemeColors(Colors.primary));
+ swiper.setColorSchemeColors(Colors.primary);
swiper.setOnRefreshListener(() -> {
Log.d("ui", "refreshing accounts via swipe");
mActivity.scheduleTransactionListRetrieval();
Data.accounts.addObserver(
(o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));
- Data.profile.addObserver(
- (o, arg) -> mActivity.runOnUiThread(() -> AccountSummaryViewModel.scheduleAccountListReload()));
+ Data.profile.addObserver((o, arg) -> mActivity.runOnUiThread(
+ AccountSummaryViewModel::scheduleAccountListReload));
update_account_table();
}
private void update_account_table() {
import android.view.View;
import android.view.ViewGroup;
+import net.ktnx.mobileledger.utils.Colors;
+
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
+ Colors.setupTheme(this);
}
@Override
import android.util.Log;
import net.ktnx.mobileledger.ui.CrashReportDialogFragment;
+import net.ktnx.mobileledger.utils.Colors;
import java.io.PrintWriter;
import java.io.StringWriter;
-public class CrashReportingActivity extends 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 android.content.Intent;
import android.content.pm.PackageInfo;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.ColorInt;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
import net.ktnx.mobileledger.ui.transaction_list.TransactionListFragment;
+import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.MLDB;
import java.lang.ref.WeakReference;
}
public void markDrawerItemCurrent(int id) {
TextView item = drawer.findViewById(id);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg, getTheme()));
- }
- else {
- item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg));
- }
-
- @ColorInt int transparent = getResources().getColor(android.R.color.transparent);
+ item.setBackgroundColor(Colors.tableRowDarkBG);
LinearLayout actions = drawer.findViewById(R.id.nav_actions);
for (int i = 0; i < actions.getChildCount(); i++) {
View view = actions.getChildAt(i);
if (view.getId() != id) {
- view.setBackgroundColor(transparent);
+ view.setBackgroundColor(Color.TRANSPARENT);
}
}
}
else Toast.makeText(this, error, Toast.LENGTH_LONG).show();
}
public void onRetrieveStart() {
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary));
+ progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary));
progressBar.setIndeterminate(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false);
else progressBar.setProgress(0);
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.model.TransactionListItem;
+import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.Globals;
import net.ktnx.mobileledger.utils.MLDB;
case HEAD:
holder.tvDescription.setText(step.getTransaction().getDescription());
- if (step.isOdd()) holder.row.setBackgroundColor(Globals.tableRowDarkBG);
- else holder.row.setBackgroundColor(Globals.tableRowLightBG);
+ if (step.isOdd()) holder.row.setBackgroundColor(Colors.tableRowDarkBG);
+ else holder.row.setBackgroundColor(Colors.tableRowLightBG);
break;
case ACCOUNTS:
if ((boldAccountName != null) &&
acc.getAccountName().startsWith(boldAccountName))
{
- accName.setTextColor(Globals.primaryDark);
- accAmount.setTextColor(Globals.primaryDark);
+ accName.setTextColor(Colors.accent);
+ accAmount.setTextColor(Colors.accent);
SpannableString ss = new SpannableString(acc.getAccountName());
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, boldAccountName.length(),
accName.setText(ss);
}
else {
- accName.setTextColor(Globals.defaultTextColor);
- accAmount.setTextColor(Globals.defaultTextColor);
+ accName.setTextColor(Colors.defaultTextColor);
+ accAmount.setTextColor(Colors.defaultTextColor);
accName.setText(acc.getAccountName());
}
accAmount.setText(acc.toString());
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.ui.MobileLedgerListFragment;
import net.ktnx.mobileledger.ui.activity.MainActivity;
+import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.Globals;
import net.ktnx.mobileledger.utils.MLDB;
import net.ktnx.mobileledger.utils.ObservableValue;
mActivity.scheduleTransactionListRetrieval();
});
- swiper.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent);
+ Colors.themeWatch.addObserver(
+ (o, arg) -> swiper.setColorSchemeColors(Colors.primary));
+ swiper.setColorSchemeColors(Colors.primary);
vAccountFilter = mActivity.findViewById(R.id.transaction_list_account_name_filter);
accNameFilter = mActivity.findViewById(R.id.transaction_filter_account_name);
import android.app.Activity;
import android.content.Context;
-import android.support.annotation.ColorInt;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import java.util.regex.Pattern;
public final class Globals {
- @ColorInt
- public static int tableRowLightBG;
- @ColorInt
- public static int tableRowDarkBG;
- @ColorInt
- public static int primaryDark, defaultTextColor;
public static String[] monthNames;
public static String developerEmail = "dam+mole-crash@ktnx.net";
private static SimpleDateFormat ledgerDateFormatter =