diff --git a/CHANGELOG.md b/CHANGELOG.md index e56f5f1b..8730b1b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ###Version: 0.11.0 - ```fix``` Up button is working. -- ```new``` Supporting Ice Cream Sandwich and up. +- ```new``` Supporting Jelly Bean and up. ###Version: 0.10.0 - ```new``` Completely new UI. Material design. @@ -9,4 +9,4 @@ - ```new``` Export backup file to device or Google Drive. - ```new``` Export CSV to phone to device or Google Drive. - ```new``` Improved CSV format. -- ```change``` No more sub-categories. Use tags instead. +- ```new``` No more sub-categories. Use tags instead. diff --git a/financius/build.gradle b/financius/build.gradle index fc1fa662..5f75c34f 100644 --- a/financius/build.gradle +++ b/financius/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { applicationId 'com.code44.finance' targetSdkVersion 21 - minSdkVersion 14 + minSdkVersion 16 versionCode 47 versionName '0.11.0' buildConfigField "boolean", "USE_LOCAL_SERVER", "true" @@ -66,7 +66,6 @@ dependencies { compile 'me.grantland:autofittextview:0.1.1' compile 'com.squareup:otto:1.3.5' compile 'se.emilsjolander:stickylistheaders:2.5.0' - compile 'com.github.citux:datetimepicker:0.1.0' compile 'com.nononsenseapps:filepicker:1.1.3' testCompile 'junit:junit:4.11' testCompile 'org.robolectric:robolectric:2.3' diff --git a/financius/src/main/java/com/code44/finance/adapters/AccountsAdapter.java b/financius/src/main/java/com/code44/finance/adapters/AccountsAdapter.java index e05e25c9..95c12852 100644 --- a/financius/src/main/java/com/code44/finance/adapters/AccountsAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/AccountsAdapter.java @@ -53,7 +53,7 @@ private static class ViewHolder { public static ViewHolder setAsTag(View view) { final ViewHolder holder = new ViewHolder(); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); holder.balance_TV = (TextView) view.findViewById(R.id.balance_TV); holder.mainCurrencyBalance_TV = (TextView) view.findViewById(R.id.mainCurrencyBalance_TV); view.setTag(holder); diff --git a/financius/src/main/java/com/code44/finance/adapters/CategoriesAdapter.java b/financius/src/main/java/com/code44/finance/adapters/CategoriesAdapter.java index f9fb0ba0..057187b4 100644 --- a/financius/src/main/java/com/code44/finance/adapters/CategoriesAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/CategoriesAdapter.java @@ -38,7 +38,7 @@ private static class ViewHolder { public static ViewHolder setAsTag(View view) { final ViewHolder holder = new ViewHolder(); holder.color_IV = (ImageView) view.findViewById(R.id.color_IV); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); view.setTag(holder); return holder; diff --git a/financius/src/main/java/com/code44/finance/adapters/CategoriesPagerAdapter.java b/financius/src/main/java/com/code44/finance/adapters/CategoriesPagerAdapter.java index 26d2cf62..65370729 100644 --- a/financius/src/main/java/com/code44/finance/adapters/CategoriesPagerAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/CategoriesPagerAdapter.java @@ -1,9 +1,9 @@ package com.code44.finance.adapters; -import android.app.Fragment; -import android.app.FragmentManager; import android.content.Context; -import android.support.v13.app.FragmentPagerAdapter; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; import com.code44.finance.R; import com.code44.finance.common.model.TransactionType; diff --git a/financius/src/main/java/com/code44/finance/adapters/CategoriesReportAdapter.java b/financius/src/main/java/com/code44/finance/adapters/CategoriesReportAdapter.java index bd65f873..1f8e47fc 100644 --- a/financius/src/main/java/com/code44/finance/adapters/CategoriesReportAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/CategoriesReportAdapter.java @@ -73,15 +73,15 @@ private int getPercent(long amount) { } private static final class ViewHolder { - public ImageView color_IV; - public TextView percent_TV; - public TextView title_TV; - public TextView amount_TV; + public final ImageView color_IV; + public final TextView percent_TV; + public final TextView title_TV; + public final TextView amount_TV; public ViewHolder(View view) { color_IV = (ImageView) view.findViewById(R.id.color_IV); percent_TV = (TextView) view.findViewById(R.id.percent_TV); - title_TV = (TextView) view.findViewById(R.id.title_TV); + title_TV = (TextView) view.findViewById(R.id.title); amount_TV = (TextView) view.findViewById(R.id.amount_TV); view.setTag(this); } diff --git a/financius/src/main/java/com/code44/finance/adapters/CurrenciesAdapterV2.java b/financius/src/main/java/com/code44/finance/adapters/CurrenciesAdapterV2.java deleted file mode 100644 index 1390a66c..00000000 --- a/financius/src/main/java/com/code44/finance/adapters/CurrenciesAdapterV2.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.code44.finance.adapters; - -import android.database.Cursor; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import com.code44.finance.R; -import com.code44.finance.data.model.Currency; -import com.code44.finance.utils.MoneyFormatter; - -public class CurrenciesAdapterV2 extends RecyclerView.Adapter { - private Cursor cursor; - - @Override - public ViewHolder onCreateViewHolder(ViewGroup parent, int position) { - final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.li_currency, parent, false); - return new ViewHolder(view); - } - - @Override - public void onBindViewHolder(ViewHolder viewHolder, int position) { - cursor.moveToPosition(position); - viewHolder.setCurrency(Currency.from(cursor)); - } - - @Override - public int getItemCount() { - return cursor == null ? 0 : cursor.getCount(); - } - - public Cursor swapCursor(Cursor cursor) { - final Cursor oldCursor = this.cursor; - this.cursor = cursor; - notifyDataSetChanged(); - - return oldCursor; - } - - protected static final class ViewHolder extends RecyclerView.ViewHolder { - private final TextView code_TV; - private final TextView format_TV; - private final TextView exchangeRate_TV; - - private final int textPrimaryColor; - private final int textAccentColor; - - public ViewHolder(View itemView) { - super(itemView); - - code_TV = (TextView) itemView.findViewById(R.id.code_TV); - format_TV = (TextView) itemView.findViewById(R.id.format_TV); - exchangeRate_TV = (TextView) itemView.findViewById(R.id.exchangeRate_TV); - - textPrimaryColor = code_TV.getCurrentTextColor(); - textAccentColor = itemView.getResources().getColor(R.color.text_accent); - - itemView.setBackgroundResource(R.color.bg_window); - } - - public void setCurrency(Currency currency) { - code_TV.setText(currency.getCode()); - format_TV.setText(MoneyFormatter.format(currency, 100000)); - if (currency.isDefault()) { - code_TV.setTextColor(textAccentColor); - exchangeRate_TV.setText(null); - itemView.setElevation(itemView.getContext().getResources().getDimension(R.dimen.elevation_sub_header)); - } else { - code_TV.setTextColor(textPrimaryColor); - exchangeRate_TV.setText(String.valueOf(currency.getExchangeRate())); - itemView.setElevation(0); - } - } - } -} diff --git a/financius/src/main/java/com/code44/finance/adapters/CurrencyAccountsAdapter.java b/financius/src/main/java/com/code44/finance/adapters/CurrencyAccountsAdapter.java index 59b73f07..f9c1b665 100644 --- a/financius/src/main/java/com/code44/finance/adapters/CurrencyAccountsAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/CurrencyAccountsAdapter.java @@ -82,7 +82,7 @@ private static class ViewHolder { public static ViewHolder setAsTag(View view) { final ViewHolder holder = new ViewHolder(); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); holder.currency_B = (Button) view.findViewById(R.id.currency_B); holder.currency_B.setAllCaps(false); view.setTag(holder); diff --git a/financius/src/main/java/com/code44/finance/adapters/ListDialogAdapter.java b/financius/src/main/java/com/code44/finance/adapters/ListDialogAdapter.java index 8dc9b8cc..63b6a85b 100644 --- a/financius/src/main/java/com/code44/finance/adapters/ListDialogAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/ListDialogAdapter.java @@ -118,7 +118,7 @@ protected static class ViewHolder { public final TextView title_TV; public ViewHolder(View view) { - title_TV = (TextView) view.findViewById(R.id.title_TV); + title_TV = (TextView) view.findViewById(R.id.title); } } } diff --git a/financius/src/main/java/com/code44/finance/adapters/NavigationAdapter.java b/financius/src/main/java/com/code44/finance/adapters/NavigationAdapter.java index f4966479..cee9732b 100644 --- a/financius/src/main/java/com/code44/finance/adapters/NavigationAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/NavigationAdapter.java @@ -110,7 +110,7 @@ private static class ViewHolder { public static ViewHolder setAsTag(View view) { final ViewHolder holder = new ViewHolder(); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); view.setTag(holder); return holder; diff --git a/financius/src/main/java/com/code44/finance/adapters/SettingsAdapter.java b/financius/src/main/java/com/code44/finance/adapters/SettingsAdapter.java index 7ad961c1..69d3210d 100644 --- a/financius/src/main/java/com/code44/finance/adapters/SettingsAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/SettingsAdapter.java @@ -44,10 +44,6 @@ public SettingsAdapter(Context context) { return ViewType.values().length; } - @Override public int getItemViewType(int position) { - return super.getItemViewType(position); - } - @Override public Object getItem(int position) { return settingsItems.get(position); } @@ -149,7 +145,7 @@ private static class SettingsItemViewHolder { private final TextView title_TV; private SettingsItemViewHolder(View itemView) { - title_TV = (TextView) itemView.findViewById(R.id.title_TV); + title_TV = (TextView) itemView.findViewById(R.id.title); } protected void bind(SettingsItem settingsItem) { diff --git a/financius/src/main/java/com/code44/finance/adapters/TagsAdapter.java b/financius/src/main/java/com/code44/finance/adapters/TagsAdapter.java index 1c48bcae..b19c9ee6 100644 --- a/financius/src/main/java/com/code44/finance/adapters/TagsAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/TagsAdapter.java @@ -44,7 +44,7 @@ private static class ViewHolder { public static ViewHolder setAsTag(View view) { final ViewHolder holder = new ViewHolder(); holder.select_CB = (CheckBox) view.findViewById(R.id.select_CB); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); view.setTag(holder); return holder; diff --git a/financius/src/main/java/com/code44/finance/adapters/TransactionsAdapter.java b/financius/src/main/java/com/code44/finance/adapters/TransactionsAdapter.java index 41e1fad6..cf191a41 100644 --- a/financius/src/main/java/com/code44/finance/adapters/TransactionsAdapter.java +++ b/financius/src/main/java/com/code44/finance/adapters/TransactionsAdapter.java @@ -302,7 +302,7 @@ public static ViewHolder setAsTag(View view) { holder.color_IV = (ImageView) view.findViewById(R.id.color_IV); holder.weekday_TV = (TextView) view.findViewById(R.id.weekday_TV); holder.day_TV = (TextView) view.findViewById(R.id.day_TV); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); holder.subtitle_TV = (TextView) view.findViewById(R.id.subtitle_TV); holder.amount_TV = (TextView) view.findViewById(R.id.amount_TV); holder.account_TV = (TextView) view.findViewById(R.id.account_TV); @@ -320,7 +320,7 @@ private static class HeaderViewHolder { public static HeaderViewHolder setAsTag(View view) { final HeaderViewHolder holder = new HeaderViewHolder(); holder.arrow_IV = (ImageView) view.findViewById(R.id.arrow_IV); - holder.title_TV = (TextView) view.findViewById(R.id.title_TV); + holder.title_TV = (TextView) view.findViewById(R.id.title); holder.amount_TV = (TextView) view.findViewById(R.id.amount_TV); view.setTag(holder); diff --git a/financius/src/main/java/com/code44/finance/api/currencies/ExchangeRatesRequest.java b/financius/src/main/java/com/code44/finance/api/currencies/ExchangeRatesRequest.java index 66250f39..e257f0eb 100644 --- a/financius/src/main/java/com/code44/finance/api/currencies/ExchangeRatesRequest.java +++ b/financius/src/main/java/com/code44/finance/api/currencies/ExchangeRatesRequest.java @@ -10,7 +10,6 @@ import com.code44.finance.data.providers.CurrenciesProvider; import com.code44.finance.utils.EventBus; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -48,7 +47,7 @@ public ExchangeRatesRequest(EventBus eventBus, Context context, CurrenciesReques } } - private Currency getCurrencyWithUpdatedExchangeRate(String fromCode) throws IOException { + private Currency getCurrencyWithUpdatedExchangeRate(String fromCode) { final ExchangeRateRequest request = new ExchangeRateRequest(eventBus, context, requestService, fromCode, toCode, false); request.run(); return request.getCurrency(); diff --git a/financius/src/main/java/com/code44/finance/api/requests/SyncRequest.java b/financius/src/main/java/com/code44/finance/api/requests/SyncRequest.java index abdae06b..2c4de402 100644 --- a/financius/src/main/java/com/code44/finance/api/requests/SyncRequest.java +++ b/financius/src/main/java/com/code44/finance/api/requests/SyncRequest.java @@ -90,7 +90,7 @@ public SyncRequest(EventBus eventBus, Context context, DBHelper dbHelper, User u getTransactions(); } - private void pushCurrencies(SQLiteDatabase database) throws Exception { + private void pushCurrencies(SQLiteDatabase database) { markInProgress(database, Tables.Currencies.SYNC_STATE); final Cursor cursor = Query.create() @@ -108,11 +108,11 @@ private void pushCurrencies(SQLiteDatabase database) throws Exception { new PostCurrenciesRequest(gcmRegistration, currenciesService, currencies).run(); } - private void getCurrencies() throws Exception { + private void getCurrencies() { new GetCurrenciesRequest(context, user, currenciesService).run(); } - private void pushCategories(SQLiteDatabase database) throws Exception { + private void pushCategories(SQLiteDatabase database) { markInProgress(database, Tables.Categories.SYNC_STATE); final Cursor cursor = Query.create() @@ -130,11 +130,11 @@ private void pushCategories(SQLiteDatabase database) throws Exception { new PostCategoriesRequest(gcmRegistration, categoriesService, categories).run(); } - private void getCategories() throws Exception { + private void getCategories() { new GetCategoriesRequest(context, user, categoriesService).run(); } - private void pushTags(SQLiteDatabase database) throws Exception { + private void pushTags(SQLiteDatabase database) { markInProgress(database, Tables.Tags.SYNC_STATE); final Cursor cursor = Query.create() @@ -152,11 +152,11 @@ private void pushTags(SQLiteDatabase database) throws Exception { new PostTagsRequest(gcmRegistration, tagsService, tags).run(); } - private void getTags() throws Exception { + private void getTags() { new GetTagsRequest(context, user, tagsService).run(); } - private void pushAccounts(SQLiteDatabase database) throws Exception { + private void pushAccounts(SQLiteDatabase database) { markInProgress(database, Tables.Accounts.SYNC_STATE); final Cursor cursor = Query.create() @@ -175,11 +175,11 @@ private void pushAccounts(SQLiteDatabase database) throws Exception { new PostAccountsRequest(gcmRegistration, accountsService, accounts).run(); } - private void getAccounts() throws Exception { + private void getAccounts() { new GetAccountsRequest(context, user, accountsService).run(); } - private void pushTransactions(SQLiteDatabase database) throws Exception { + private void pushTransactions(SQLiteDatabase database) { markInProgress(database, Tables.Transactions.SYNC_STATE); final Cursor cursor = Query.create() @@ -202,7 +202,7 @@ private void pushTransactions(SQLiteDatabase database) throws Exception { new PostTransactionsRequest(gcmRegistration, transactionsService, transactions).run(); } - private void getTransactions() throws Exception { + private void getTransactions() { new GetTransactionsRequest(context, user, transactionsService).run(); } diff --git a/financius/src/main/java/com/code44/finance/data/Query.java b/financius/src/main/java/com/code44/finance/data/Query.java index 817dd39c..b6da9be4 100644 --- a/financius/src/main/java/com/code44/finance/data/Query.java +++ b/financius/src/main/java/com/code44/finance/data/Query.java @@ -1,10 +1,10 @@ package com.code44.finance.data; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.net.Uri; +import android.support.v4.content.CursorLoader; import android.text.TextUtils; import com.code44.finance.common.utils.StringUtils; diff --git a/financius/src/main/java/com/code44/finance/data/backup/BackupDataImporter.java b/financius/src/main/java/com/code44/finance/data/backup/BackupDataImporter.java index a2122775..d975e630 100644 --- a/financius/src/main/java/com/code44/finance/data/backup/BackupDataImporter.java +++ b/financius/src/main/java/com/code44/finance/data/backup/BackupDataImporter.java @@ -31,7 +31,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; @@ -78,13 +77,13 @@ public BackupDataImporter(InputStream inputStream, Context context, DBHelper dbH } } - private JsonObject inputStreamToJson(InputStream inputStream) throws FileNotFoundException { + private JsonObject inputStreamToJson(InputStream inputStream) { final JsonParser parser = new JsonParser(); final JsonElement jsonElement = parser.parse(new InputStreamReader(inputStream)); return jsonElement.getAsJsonObject(); } - private void validate(JsonObject json) throws Exception { + private void validate(JsonObject json) { final int version = json.get("version").getAsInt(); if (version < MIN_VALID_VERSION) { throw new IllegalArgumentException("Backup version " + version + " is not supported anymore."); diff --git a/financius/src/main/java/com/code44/finance/data/backup/DataExporter.java b/financius/src/main/java/com/code44/finance/data/backup/DataExporter.java index a1e6e62d..76b30b41 100644 --- a/financius/src/main/java/com/code44/finance/data/backup/DataExporter.java +++ b/financius/src/main/java/com/code44/finance/data/backup/DataExporter.java @@ -11,7 +11,6 @@ public abstract class DataExporter implements Closeable { protected DataExporter(OutputStream outputStream) { this.outputStream = Preconditions.checkNotNull(outputStream, "OutputStream cannot be null."); - ; } @Override public void close() throws IOException { diff --git a/financius/src/main/java/com/code44/finance/graphs/pie/PieChartView.java b/financius/src/main/java/com/code44/finance/graphs/pie/PieChartView.java index 724a6ce2..460f65c4 100644 --- a/financius/src/main/java/com/code44/finance/graphs/pie/PieChartView.java +++ b/financius/src/main/java/com/code44/finance/graphs/pie/PieChartView.java @@ -36,12 +36,7 @@ public PieChartView(Context context, AttributeSet attrs) { } public PieChartView(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public PieChartView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - + super(context, attrs, defStyleAttr); // Init outlinePaint.setStyle(Paint.Style.STROKE); inlinePaint.setStyle(Paint.Style.STROKE); diff --git a/financius/src/main/java/com/code44/finance/modules/AccountModule.java b/financius/src/main/java/com/code44/finance/modules/AccountModule.java index cb504c01..5f50761b 100644 --- a/financius/src/main/java/com/code44/finance/modules/AccountModule.java +++ b/financius/src/main/java/com/code44/finance/modules/AccountModule.java @@ -22,7 +22,7 @@ StartupService.class } ) -public class AccountModule { +class AccountModule { @Provides @Singleton public User provideUser(@ApplicationContext Context context, DBHelper dbHelper, GcmRegistration gcmRegistration, EventBus eventBus) { return new User(context, dbHelper, gcmRegistration, eventBus); } diff --git a/financius/src/main/java/com/code44/finance/modules/UIModule.java b/financius/src/main/java/com/code44/finance/modules/UIModule.java index 477e5f30..26bdc752 100644 --- a/financius/src/main/java/com/code44/finance/modules/UIModule.java +++ b/financius/src/main/java/com/code44/finance/modules/UIModule.java @@ -23,8 +23,10 @@ import com.code44.finance.ui.currencies.CurrencyEditActivity; import com.code44.finance.ui.currencies.CurrencyEditFragment; import com.code44.finance.ui.currencies.CurrencyFragment; +import com.code44.finance.ui.dialogs.DatePickerDialog; import com.code44.finance.ui.dialogs.DeleteDialogFragment; import com.code44.finance.ui.dialogs.ListDialogFragment; +import com.code44.finance.ui.dialogs.TimePickerDialog; import com.code44.finance.ui.overview.OverviewFragment; import com.code44.finance.ui.reports.CategoriesReportFragment; import com.code44.finance.ui.reports.ReportsFragment; @@ -99,7 +101,9 @@ DataFragment.class, ReportsFragment.class, CategoriesReportFragment.class, - AboutFragment.class + AboutFragment.class, + DatePickerDialog.class, + TimePickerDialog.class } ) public class UIModule { diff --git a/financius/src/main/java/com/code44/finance/ui/BaseActivity.java b/financius/src/main/java/com/code44/finance/ui/BaseActivity.java index 1439d31c..abfac4bc 100644 --- a/financius/src/main/java/com/code44/finance/ui/BaseActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/BaseActivity.java @@ -1,9 +1,9 @@ package com.code44.finance.ui; -import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; @@ -20,7 +20,7 @@ import javax.inject.Inject; -public class BaseActivity extends ActionBarActivity { +public abstract class BaseActivity extends ActionBarActivity { private final Object eventHandler = new Object() { @Subscribe public void onAppError(AppError error) { onHandleError(error); diff --git a/financius/src/main/java/com/code44/finance/ui/BaseFragment.java b/financius/src/main/java/com/code44/finance/ui/BaseFragment.java index 1211b2a4..0fcc780c 100644 --- a/financius/src/main/java/com/code44/finance/ui/BaseFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/BaseFragment.java @@ -2,7 +2,7 @@ import android.app.Activity; -import android.app.Fragment; +import android.support.v4.app.Fragment; import com.code44.finance.App; import com.code44.finance.utils.EventBus; diff --git a/financius/src/main/java/com/code44/finance/ui/CalculatorActivity.java b/financius/src/main/java/com/code44/finance/ui/CalculatorActivity.java index 67d9aa2c..9222e186 100644 --- a/financius/src/main/java/com/code44/finance/ui/CalculatorActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/CalculatorActivity.java @@ -1,8 +1,8 @@ package com.code44.finance.ui; -import android.app.Fragment; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.Fragment; public class CalculatorActivity extends BaseActivity implements CalculatorFragment.CalculatorListener { public static final String RESULT_EXTRA_RESULT = "RESULT_EXTRA_RESULT"; @@ -25,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) { // Fragment if (savedInstanceState == null) { - getFragmentManager().beginTransaction().add(android.R.id.content, CalculatorFragment.newInstance(value)).commit(); + getSupportFragmentManager().beginTransaction().add(android.R.id.content, CalculatorFragment.newInstance(value)).commit(); } } diff --git a/financius/src/main/java/com/code44/finance/ui/CalculatorFragment.java b/financius/src/main/java/com/code44/finance/ui/CalculatorFragment.java index d1957a7a..6ff29106 100644 --- a/financius/src/main/java/com/code44/finance/ui/CalculatorFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/CalculatorFragment.java @@ -244,30 +244,35 @@ private void clear() { int cy = resultClearer_V.getBottom(); float radius = Math.max(resultClearer_V.getWidth(), resultClearer_V.getHeight()) * 2.0f; - if (resultClearer_V.getVisibility() != View.VISIBLE) { - Animator reveal = ViewAnimationUtils.createCircularReveal(resultClearer_V, cx, cy, 0, radius); - reveal.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - super.onAnimationStart(animation); - resultClearer_V.setVisibility(View.VISIBLE); - } - - @Override - public void onAnimationEnd(Animator animation) { - calculator.clear(); - updateResult(); - resultClearer_V.animate().alpha(0.0f).setDuration(200).withEndAction(new Runnable() { - @Override - public void run() { - resultClearer_V.setVisibility(View.INVISIBLE); - resultClearer_V.setAlpha(1.0f); - } - }).start(); - } - }); - reveal.setDuration(600); - reveal.start(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (resultClearer_V.getVisibility() != View.VISIBLE) { + Animator reveal = ViewAnimationUtils.createCircularReveal(resultClearer_V, cx, cy, 0, radius); + reveal.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + super.onAnimationStart(animation); + resultClearer_V.setVisibility(View.VISIBLE); + } + + @Override + public void onAnimationEnd(Animator animation) { + calculator.clear(); + updateResult(); + resultClearer_V.animate().alpha(0.0f).setDuration(200).withEndAction(new Runnable() { + @Override + public void run() { + resultClearer_V.setVisibility(View.INVISIBLE); + resultClearer_V.setAlpha(1.0f); + } + }).start(); + } + }); + reveal.setDuration(600); + reveal.start(); + } + } else { + calculator.clear(); + updateResult(); } } diff --git a/financius/src/main/java/com/code44/finance/ui/GoogleApiFragment.java b/financius/src/main/java/com/code44/finance/ui/GoogleApiFragment.java index 35803fb9..2be69002 100644 --- a/financius/src/main/java/com/code44/finance/ui/GoogleApiFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/GoogleApiFragment.java @@ -2,9 +2,9 @@ import android.app.Activity; import android.app.Dialog; -import android.app.DialogFragment; import android.content.IntentSender; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; diff --git a/financius/src/main/java/com/code44/finance/ui/MainActivity.java b/financius/src/main/java/com/code44/finance/ui/MainActivity.java index b6d5e7a7..29aa8f50 100644 --- a/financius/src/main/java/com/code44/finance/ui/MainActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/MainActivity.java @@ -1,9 +1,9 @@ package com.code44.finance.ui; -import android.app.FragmentManager; -import android.app.FragmentTransaction; import android.content.res.Configuration; import android.os.Bundle; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; @@ -39,9 +39,9 @@ public class MainActivity extends BaseActivity implements NavigationFragment.Nav StartupService.start(this); } - final BaseFragment fragment = (BaseFragment) getFragmentManager().findFragmentByTag(FRAGMENT_CONTENT); + final BaseFragment fragment = (BaseFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_CONTENT); if (fragment == null) { - ((NavigationFragment) getFragmentManager().findFragmentById(R.id.navigation_F)).select(NavigationAdapter.NAV_ID_OVERVIEW); + ((NavigationFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_F)).select(NavigationAdapter.NAV_ID_OVERVIEW); } getEventBus().register(this); @@ -66,8 +66,8 @@ public void onConfigurationChanged(Configuration newConfig) { @Override public void onBackPressed() { // Select OverviewFragment before quitting the app - if (!(getFragmentManager().findFragmentByTag(FRAGMENT_CONTENT) instanceof OverviewFragment)) { - ((NavigationFragment) getFragmentManager().findFragmentById(R.id.navigation_F)).select(NavigationAdapter.NAV_ID_OVERVIEW); + if (!(getSupportFragmentManager().findFragmentByTag(FRAGMENT_CONTENT) instanceof OverviewFragment)) { + ((NavigationFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_F)).select(NavigationAdapter.NAV_ID_OVERVIEW); } else { super.onBackPressed(); } @@ -118,7 +118,7 @@ public void onConfigurationChanged(Configuration newConfig) { } private void loadFragment(BaseFragment fragment) { - final FragmentManager fm = getFragmentManager(); + final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content, fragment, FRAGMENT_CONTENT); if (fm.findFragmentByTag(FRAGMENT_CONTENT) != null) { diff --git a/financius/src/main/java/com/code44/finance/ui/ModelActivity.java b/financius/src/main/java/com/code44/finance/ui/ModelActivity.java index 92bca026..2534a49e 100644 --- a/financius/src/main/java/com/code44/finance/ui/ModelActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/ModelActivity.java @@ -39,7 +39,7 @@ public static Intent makeIntent(Context context, Class // Fragment if (savedInstanceState == null) { - getFragmentManager().beginTransaction().add(contentId, createModelFragment(modelServerId), FRAGMENT_MODEL).commit(); + getSupportFragmentManager().beginTransaction().add(contentId, createModelFragment(modelServerId), FRAGMENT_MODEL).commit(); } getEventBus().register(eventHandler); diff --git a/financius/src/main/java/com/code44/finance/ui/ModelEditFragment.java b/financius/src/main/java/com/code44/finance/ui/ModelEditFragment.java index a3a53b00..7524add6 100644 --- a/financius/src/main/java/com/code44/finance/ui/ModelEditFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/ModelEditFragment.java @@ -2,11 +2,11 @@ import android.app.Activity; import android.content.Context; -import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.content.Loader; import android.util.Pair; import android.view.View; import android.widget.Button; diff --git a/financius/src/main/java/com/code44/finance/ui/ModelFragment.java b/financius/src/main/java/com/code44/finance/ui/ModelFragment.java index 4799b958..d289c631 100644 --- a/financius/src/main/java/com/code44/finance/ui/ModelFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/ModelFragment.java @@ -1,12 +1,12 @@ package com.code44.finance.ui; -import android.app.LoaderManager; import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; import android.util.Pair; import android.view.Menu; import android.view.MenuInflater; diff --git a/financius/src/main/java/com/code44/finance/ui/ModelListActivity.java b/financius/src/main/java/com/code44/finance/ui/ModelListActivity.java index a13c916d..7fa15219 100644 --- a/financius/src/main/java/com/code44/finance/ui/ModelListActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/ModelListActivity.java @@ -61,7 +61,7 @@ public static Intent makeIntentMultiSelect(Context context, Class implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { private static final int LOADER_CURRENCIES = 1; + private final Set existingCurrencyCodes = new HashSet<>(); + @Inject CurrenciesApi currenciesApi; @Inject @Main Currency mainCurrency; @@ -67,7 +69,6 @@ public class CurrencyEditFragment extends ModelEditFragment implements private View mainCurrencyContainer_V; private View exchangeRateContainer_V; private CheckBox isDefault_CB; - private Set existingCurrencyCodes = new HashSet<>(); public CurrencyEditFragment() { } diff --git a/financius/src/main/java/com/code44/finance/ui/currencies/CurrencyFragment.java b/financius/src/main/java/com/code44/finance/ui/currencies/CurrencyFragment.java index 0ca53505..703c2283 100644 --- a/financius/src/main/java/com/code44/finance/ui/currencies/CurrencyFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/currencies/CurrencyFragment.java @@ -1,11 +1,11 @@ package com.code44.finance.ui.currencies; import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; import android.util.Pair; import android.view.LayoutInflater; import android.view.Menu; diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/AlertDialogFragment.java b/financius/src/main/java/com/code44/finance/ui/dialogs/AlertDialogFragment.java index ef5c8540..80b65594 100644 --- a/financius/src/main/java/com/code44/finance/ui/dialogs/AlertDialogFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/AlertDialogFragment.java @@ -11,15 +11,11 @@ import com.code44.finance.common.utils.StringUtils; public class AlertDialogFragment extends BaseDialogFragment implements View.OnClickListener { - protected static final String ARG_MESSAGE = "ARG_MESSAGE"; - protected static final String ARG_POSITIVE_BUTTON_TEXT = "ARG_POSITIVE_BUTTON_TEXT"; - protected static final String ARG_NEGATIVE_BUTTON_TEXT = "ARG_NEGATIVE_BUTTON_TEXT"; - protected static final String ARG_POSITIVE_BUTTON_COLOR = "ARG_POSITIVE_BUTTON_COLOR"; - protected static final String ARG_NEGATIVE_BUTTON_COLOR = "ARG_NEGATIVE_BUTTON_COLOR"; - - protected TextView message_TV; - protected Button positive_B; - protected Button negative_B; + private static final String ARG_MESSAGE = "ARG_MESSAGE"; + private static final String ARG_POSITIVE_BUTTON_TEXT = "ARG_POSITIVE_BUTTON_TEXT"; + private static final String ARG_NEGATIVE_BUTTON_TEXT = "ARG_NEGATIVE_BUTTON_TEXT"; + private static final String ARG_POSITIVE_BUTTON_COLOR = "ARG_POSITIVE_BUTTON_COLOR"; + private static final String ARG_NEGATIVE_BUTTON_COLOR = "ARG_NEGATIVE_BUTTON_COLOR"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.dialog_fragment_alert, container, false); @@ -29,9 +25,9 @@ public class AlertDialogFragment extends BaseDialogFragment implements View.OnCl super.onViewCreated(view, savedInstanceState); // Get views - message_TV = (TextView) view.findViewById(R.id.message_TV); - positive_B = (Button) view.findViewById(R.id.positive_B); - negative_B = (Button) view.findViewById(R.id.negative_B); + final TextView message_TV = (TextView) view.findViewById(R.id.message_TV); + final Button positive_B = (Button) view.findViewById(R.id.positive_B); + final Button negative_B = (Button) view.findViewById(R.id.negative_B); // Setup final String message = getArguments().getString(ARG_MESSAGE); diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/BaseDialogFragment.java b/financius/src/main/java/com/code44/finance/ui/dialogs/BaseDialogFragment.java index cdebe1f7..585cf7f8 100644 --- a/financius/src/main/java/com/code44/finance/ui/dialogs/BaseDialogFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/BaseDialogFragment.java @@ -1,7 +1,7 @@ package com.code44.finance.ui.dialogs; -import android.app.DialogFragment; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.View; import android.widget.TextView; @@ -17,7 +17,7 @@ public abstract class BaseDialogFragment extends DialogFragment { protected static final String ARG_TITLE = "ARG_TITLE"; protected static final String ARG_ARGS = "ARG_ARGS"; - protected TextView title_TV; + protected TextView titleView; protected int requestCode; @@ -33,15 +33,17 @@ public abstract class BaseDialogFragment extends DialogFragment { super.onViewCreated(view, savedInstanceState); // Get views - title_TV = (TextView) view.findViewById(R.id.title_TV); + titleView = (TextView) view.findViewById(R.id.title); // Setup requestCode = getArguments().getInt(ARG_REQUEST_CODE); - final String title = getArguments().getString(ARG_TITLE); - if (StringUtils.isEmpty(title)) { - title_TV.setVisibility(View.GONE); - } else { - title_TV.setText(title); + if (titleView != null) { + final String title = getArguments().getString(ARG_TITLE); + if (StringUtils.isEmpty(title)) { + titleView.setVisibility(View.GONE); + } else { + titleView.setText(title); + } } } @@ -50,7 +52,7 @@ protected EventBus getEventBus() { } protected abstract static class Builder { - protected Bundle args; + protected final Bundle args; public Builder(int requestCode) { args = new Bundle(); diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/DatePickerDialog.java b/financius/src/main/java/com/code44/finance/ui/dialogs/DatePickerDialog.java new file mode 100644 index 00000000..04cf4aa8 --- /dev/null +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/DatePickerDialog.java @@ -0,0 +1,76 @@ +package com.code44.finance.ui.dialogs; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.widget.DatePicker; + +import org.joda.time.DateTime; + +public class DatePickerDialog extends BaseDialogFragment implements android.app.DatePickerDialog.OnDateSetListener { + private static final String ARG_YEAR = "ARG_YEAR"; + private static final String ARG_MONTH_OF_YEAR = "ARG_MONTH_OF_YEAR"; + private static final String ARG_DAY_OF_MONTH = "ARG_DAY_OF_MONTH"; + + private static final String FRAGMENT_DATE_PICKER = DatePickerDialog.class.getName() + ".FRAGMENT_DATE_PICKER"; + + public static void show(FragmentManager fragmentManager, int requestCode, long timestamp) { + final DateTime date = new DateTime(timestamp); + show(fragmentManager, requestCode, date.getYear(), date.getMonthOfYear(), date.getDayOfMonth()); + } + + public static void show(FragmentManager fragmentManager, int requestCode, int year, int monthOfYear, int dayOfMonth) { + final Bundle args = new Bundle(); + args.putInt(ARG_REQUEST_CODE, requestCode); + args.putInt(ARG_YEAR, year); + args.putInt(ARG_MONTH_OF_YEAR, monthOfYear); + args.putInt(ARG_DAY_OF_MONTH, dayOfMonth); + + final DatePickerDialog fragment = new DatePickerDialog(); + fragment.setArguments(args); + fragment.show(fragmentManager, FRAGMENT_DATE_PICKER); + } + + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { + final int year = getArguments().getInt(ARG_YEAR); + final int monthOfYear = getArguments().getInt(ARG_MONTH_OF_YEAR); + final int dayOfMonth = getArguments().getInt(ARG_DAY_OF_MONTH); + + return new android.app.DatePickerDialog(getActivity(), this, year, monthOfYear - 1, dayOfMonth); + } + + @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { + getEventBus().post(new DateSelected(getArguments().getInt(ARG_REQUEST_CODE), year, monthOfYear + 1, dayOfMonth)); + } + + public static final class DateSelected { + private final int requestCode; + private final int year; + private final int monthOfYear; + private final int dayOfMonth; + + public DateSelected(int requestCode, int year, int monthOfYear, int dayOfMonth) { + this.requestCode = requestCode; + this.year = year; + this.monthOfYear = monthOfYear; + this.dayOfMonth = dayOfMonth; + } + + public int getRequestCode() { + return requestCode; + } + + public int getYear() { + return year; + } + + public int getMonthOfYear() { + return monthOfYear; + } + + public int getDayOfMonth() { + return dayOfMonth; + } + } +} diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/DeleteDialogFragment.java b/financius/src/main/java/com/code44/finance/ui/dialogs/DeleteDialogFragment.java index 28d267ff..0aa8720f 100644 --- a/financius/src/main/java/com/code44/finance/ui/dialogs/DeleteDialogFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/DeleteDialogFragment.java @@ -1,13 +1,13 @@ package com.code44.finance.ui.dialogs; -import android.app.LoaderManager; import android.content.Context; import android.content.DialogInterface; -import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/ListDialogFragment.java b/financius/src/main/java/com/code44/finance/ui/dialogs/ListDialogFragment.java index 715860c6..bfea8521 100644 --- a/financius/src/main/java/com/code44/finance/ui/dialogs/ListDialogFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/ListDialogFragment.java @@ -141,8 +141,8 @@ public List getSelectedPositions() { return selectedPositions; } - public boolean isListItemClicked() { - return position >= 0; + public boolean isActionButtonClicked() { + return position < 0; } public void dismiss() { diff --git a/financius/src/main/java/com/code44/finance/ui/dialogs/TimePickerDialog.java b/financius/src/main/java/com/code44/finance/ui/dialogs/TimePickerDialog.java new file mode 100644 index 00000000..2af7d6f8 --- /dev/null +++ b/financius/src/main/java/com/code44/finance/ui/dialogs/TimePickerDialog.java @@ -0,0 +1,67 @@ +package com.code44.finance.ui.dialogs; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.widget.TimePicker; + +import org.joda.time.DateTime; + +public class TimePickerDialog extends BaseDialogFragment implements android.app.TimePickerDialog.OnTimeSetListener { + private static final String ARG_HOUR_OF_DAY = "ARG_HOUR_OF_DAY"; + private static final String ARG_MINUTE = "ARG_MINUTE"; + + private static final String FRAGMENT_TIME_PICKER = TimePickerDialog.class.getName() + ".FRAGMENT_TIME_PICKER"; + + public static void show(FragmentManager fragmentManager, int requestCode, long timestamp) { + final DateTime date = new DateTime(timestamp); + show(fragmentManager, requestCode, date.getHourOfDay(), date.getMinuteOfHour()); + } + + public static void show(FragmentManager fragmentManager, int requestCode, int hourOfDay, int minute) { + final Bundle args = new Bundle(); + args.putInt(ARG_REQUEST_CODE, requestCode); + args.putInt(ARG_HOUR_OF_DAY, hourOfDay); + args.putInt(ARG_MINUTE, minute); + + final TimePickerDialog fragment = new TimePickerDialog(); + fragment.setArguments(args); + fragment.show(fragmentManager, FRAGMENT_TIME_PICKER); + } + + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { + final int hourOfDay = getArguments().getInt(ARG_HOUR_OF_DAY); + final int minute = getArguments().getInt(ARG_MINUTE); + + return new android.app.TimePickerDialog(getActivity(), this, hourOfDay, minute, true); + } + + @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { + getEventBus().post(new TimeSelected(getArguments().getInt(ARG_REQUEST_CODE), hourOfDay, minute)); + } + + public static final class TimeSelected { + private final int requestCode; + private final int hourOfDay; + private final int minute; + + public TimeSelected(int requestCode, int hourOfDay, int minute) { + this.requestCode = requestCode; + this.hourOfDay = hourOfDay; + this.minute = minute; + } + + public int getRequestCode() { + return requestCode; + } + + public int getHourOfDay() { + return hourOfDay; + } + + public int getMinute() { + return minute; + } + } +} diff --git a/financius/src/main/java/com/code44/finance/ui/overview/OverviewFragment.java b/financius/src/main/java/com/code44/finance/ui/overview/OverviewFragment.java index 823458e6..8fb0aab2 100644 --- a/financius/src/main/java/com/code44/finance/ui/overview/OverviewFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/overview/OverviewFragment.java @@ -1,10 +1,10 @@ package com.code44.finance.ui.overview; -import android.app.LoaderManager; -import android.content.Loader; import android.database.Cursor; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/financius/src/main/java/com/code44/finance/ui/reports/CategoriesReportFragment.java b/financius/src/main/java/com/code44/finance/ui/reports/CategoriesReportFragment.java index ad74a238..9aaa40ec 100644 --- a/financius/src/main/java/com/code44/finance/ui/reports/CategoriesReportFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/reports/CategoriesReportFragment.java @@ -1,9 +1,9 @@ package com.code44.finance.ui.reports; -import android.app.LoaderManager; -import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; diff --git a/financius/src/main/java/com/code44/finance/ui/reports/ReportsFragment.java b/financius/src/main/java/com/code44/finance/ui/reports/ReportsFragment.java index cf6b8c74..fdfbe288 100644 --- a/financius/src/main/java/com/code44/finance/ui/reports/ReportsFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/reports/ReportsFragment.java @@ -1,9 +1,9 @@ package com.code44.finance.ui.reports; -import android.app.LoaderManager; -import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; diff --git a/financius/src/main/java/com/code44/finance/ui/settings/GoogleDriveFragment.java b/financius/src/main/java/com/code44/finance/ui/settings/GoogleDriveFragment.java deleted file mode 100644 index b1bddf20..00000000 --- a/financius/src/main/java/com/code44/finance/ui/settings/GoogleDriveFragment.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.code44.finance.ui.settings; - -import android.os.Bundle; - -import com.code44.finance.ui.BaseFragment; - -public class GoogleDriveFragment extends BaseFragment { - private static final String ARG_GOOGLE_API_UNIQUE_ID = "ARG_GOOGLE_API_UNIQUE_ID"; - - private String googleApiUniqueId; - - public static GoogleDriveFragment newInstance(String googleApiUniqueId) { - final Bundle args = new Bundle(); - args.putString(ARG_GOOGLE_API_UNIQUE_ID, googleApiUniqueId); - - final GoogleDriveFragment fragment = new GoogleDriveFragment(); - fragment.setArguments(args); - return fragment; - } - - @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Get arguments - googleApiUniqueId = getArguments().getString(ARG_GOOGLE_API_UNIQUE_ID, ""); - } -} diff --git a/financius/src/main/java/com/code44/finance/ui/settings/SettingsActivity.java b/financius/src/main/java/com/code44/finance/ui/settings/SettingsActivity.java index 13e09de8..b071cf40 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/SettingsActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/SettingsActivity.java @@ -89,7 +89,7 @@ public static void start(Context context) { .setTitle(getString(R.string.period)) .setItems(items) .setPositiveButtonText(getString(R.string.cancel)) - .build().show(getFragmentManager(), FRAGMENT_INTERVAL); + .build().show(getSupportFragmentManager(), FRAGMENT_INTERVAL); } else if (id == SettingsAdapter.ID_DATA) { DataActivity.start(this); } else if (id == SettingsAdapter.ID_ABOUT) { @@ -102,7 +102,7 @@ public static void start(Context context) { } @Subscribe public void onNewIntervalSelected(ListDialogFragment.ListDialogEvent event) { - if (event.getRequestCode() != REQUEST_INTERVAL || !event.isListItemClicked()) { + if (event.getRequestCode() != REQUEST_INTERVAL || event.isActionButtonClicked()) { return; } diff --git a/financius/src/main/java/com/code44/finance/ui/settings/about/AboutActivity.java b/financius/src/main/java/com/code44/finance/ui/settings/about/AboutActivity.java index b8e361c4..783872ce 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/about/AboutActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/about/AboutActivity.java @@ -18,7 +18,7 @@ public static void start(Context context) { getSupportActionBar().setTitle(R.string.about); if (savedInstanceState == null) { - getFragmentManager() + getSupportFragmentManager() .beginTransaction() .add(R.id.content_V, AboutFragment.newInstance()) .commit(); diff --git a/financius/src/main/java/com/code44/finance/ui/settings/data/DataActivity.java b/financius/src/main/java/com/code44/finance/ui/settings/data/DataActivity.java index 8a15d113..b35b1e12 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/data/DataActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/data/DataActivity.java @@ -18,7 +18,7 @@ public static void start(Context context) { getSupportActionBar().setTitle(R.string.your_data); if (savedInstanceState == null) { - getFragmentManager().beginTransaction().replace(R.id.content_V, DataFragment.newInstance()).commit(); + getSupportFragmentManager().beginTransaction().replace(R.id.content_V, DataFragment.newInstance()).commit(); } } diff --git a/financius/src/main/java/com/code44/finance/ui/settings/data/DataFragment.java b/financius/src/main/java/com/code44/finance/ui/settings/data/DataFragment.java index 00e64878..c8691174 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/data/DataFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/data/DataFragment.java @@ -79,7 +79,7 @@ public static DataFragment newInstance() { if ((event.getRequestCode() != REQUEST_BACKUP_DESTINATION && event.getRequestCode() != REQUEST_RESTORE_DESTINATION && event.getRequestCode() != REQUEST_RESTORE_AND_MERGE_DESTINATION - && event.getRequestCode() != REQUEST_EXPORT_CSV_DESTINATION) || !event.isListItemClicked()) { + && event.getRequestCode() != REQUEST_EXPORT_CSV_DESTINATION) || event.isActionButtonClicked()) { return; } diff --git a/financius/src/main/java/com/code44/finance/ui/settings/data/ExportActivity.java b/financius/src/main/java/com/code44/finance/ui/settings/data/ExportActivity.java index 55d1db02..0742ef4b 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/data/ExportActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/data/ExportActivity.java @@ -1,6 +1,5 @@ package com.code44.finance.ui.settings.data; -import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.IntentSender; @@ -96,7 +95,7 @@ public static void start(Context context, ExportType exportType, Destination des break; } - final GoogleApiFragment googleApi_F = (GoogleApiFragment) getFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); + final GoogleApiFragment googleApi_F = (GoogleApiFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); if (googleApi_F != null) { googleApi_F.handleOnActivityResult(requestCode, resultCode); } @@ -207,22 +206,22 @@ public static enum ExportType { public static enum Destination { File { - @Override public void startExportProcess(Activity activity, GeneralPrefs generalPrefs) { + @Override public void startExportProcess(BaseActivity activity, GeneralPrefs generalPrefs) { FilePickerActivity.startDir(activity, REQUEST_LOCAL_DIRECTORY, generalPrefs.getLastFileExportPath()); } }, GoogleDrive { - @Override public void startExportProcess(Activity activity, GeneralPrefs generalPrefs) { - GoogleApiFragment googleApi_F = (GoogleApiFragment) activity.getFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); + @Override public void startExportProcess(BaseActivity activity, GeneralPrefs generalPrefs) { + GoogleApiFragment googleApi_F = (GoogleApiFragment) activity.getSupportFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); if (googleApi_F == null) { googleApi_F = GoogleApiFragment.with(UNIQUE_GOOGLE_API_ID).setUseDrive(true).build(); - activity.getFragmentManager().beginTransaction().add(android.R.id.content, googleApi_F, FRAGMENT_GOOGLE_API).commit(); + activity.getSupportFragmentManager().beginTransaction().add(android.R.id.content, googleApi_F, FRAGMENT_GOOGLE_API).commit(); } googleApi_F.connect(); } }; - public abstract void startExportProcess(Activity activity, GeneralPrefs generalPrefs); + public abstract void startExportProcess(BaseActivity activity, GeneralPrefs generalPrefs); } } diff --git a/financius/src/main/java/com/code44/finance/ui/settings/data/ImportActivity.java b/financius/src/main/java/com/code44/finance/ui/settings/data/ImportActivity.java index 30c2661a..be59126d 100644 --- a/financius/src/main/java/com/code44/finance/ui/settings/data/ImportActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/settings/data/ImportActivity.java @@ -1,6 +1,5 @@ package com.code44.finance.ui.settings.data; -import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.IntentSender; @@ -91,7 +90,7 @@ public static void start(Context context, ImportType importType, Source source) break; } - final GoogleApiFragment googleApi_F = (GoogleApiFragment) getFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); + final GoogleApiFragment googleApi_F = (GoogleApiFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); if (googleApi_F != null) { googleApi_F.handleOnActivityResult(requestCode, resultCode); } @@ -177,22 +176,22 @@ public static enum ImportType { public static enum Source { File { - @Override public void startImportProcess(Activity activity, GeneralPrefs generalPrefs) { + @Override public void startImportProcess(BaseActivity activity, GeneralPrefs generalPrefs) { FilePickerActivity.startFile(activity, REQUEST_LOCAL_FILE, generalPrefs.getLastFileExportPath()); } }, GoogleDrive { - @Override public void startImportProcess(Activity activity, GeneralPrefs generalPrefs) { - GoogleApiFragment googleApi_F = (GoogleApiFragment) activity.getFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); + @Override public void startImportProcess(BaseActivity activity, GeneralPrefs generalPrefs) { + GoogleApiFragment googleApi_F = (GoogleApiFragment) activity.getSupportFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); if (googleApi_F == null) { googleApi_F = GoogleApiFragment.with(UNIQUE_GOOGLE_API_ID).setUseDrive(true).build(); - activity.getFragmentManager().beginTransaction().add(android.R.id.content, googleApi_F, FRAGMENT_GOOGLE_API).commit(); + activity.getSupportFragmentManager().beginTransaction().add(android.R.id.content, googleApi_F, FRAGMENT_GOOGLE_API).commit(); } googleApi_F.connect(); } }; - public abstract void startImportProcess(Activity activity, GeneralPrefs generalPrefs); + public abstract void startImportProcess(BaseActivity activity, GeneralPrefs generalPrefs); } } diff --git a/financius/src/main/java/com/code44/finance/ui/tags/TagEditFragment.java b/financius/src/main/java/com/code44/finance/ui/tags/TagEditFragment.java index 6a986a4d..367700e5 100644 --- a/financius/src/main/java/com/code44/finance/ui/tags/TagEditFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/tags/TagEditFragment.java @@ -1,9 +1,9 @@ package com.code44.finance.ui.tags; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.os.Bundle; +import android.support.v4.content.CursorLoader; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; diff --git a/financius/src/main/java/com/code44/finance/ui/tags/TagFragment.java b/financius/src/main/java/com/code44/finance/ui/tags/TagFragment.java index 6df66591..14bb54f9 100644 --- a/financius/src/main/java/com/code44/finance/ui/tags/TagFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/tags/TagFragment.java @@ -1,10 +1,10 @@ package com.code44.finance.ui.tags; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.support.v4.content.CursorLoader; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; @@ -36,7 +36,7 @@ public static TagFragment newInstance(String tagServerId) { super.onViewCreated(view, savedInstanceState); // Get views - title_TV = (TextView) view.findViewById(R.id.title_TV); + title_TV = (TextView) view.findViewById(R.id.title); } @Override protected CursorLoader getModelCursorLoader(Context context, String modelServerId) { diff --git a/financius/src/main/java/com/code44/finance/ui/tags/TagsActivity.java b/financius/src/main/java/com/code44/finance/ui/tags/TagsActivity.java index f286d11a..dddde9c0 100644 --- a/financius/src/main/java/com/code44/finance/ui/tags/TagsActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/tags/TagsActivity.java @@ -1,8 +1,8 @@ package com.code44.finance.ui.tags; -import android.app.Fragment; import android.content.Context; import android.os.Parcelable; +import android.support.v4.app.Fragment; import android.view.Menu; import com.code44.finance.R; diff --git a/financius/src/main/java/com/code44/finance/ui/tags/TagsFragment.java b/financius/src/main/java/com/code44/finance/ui/tags/TagsFragment.java index 491cf569..b701b2a3 100644 --- a/financius/src/main/java/com/code44/finance/ui/tags/TagsFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/tags/TagsFragment.java @@ -1,10 +1,10 @@ package com.code44.finance.ui.tags; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.os.Bundle; import android.os.Parcelable; +import android.support.v4.content.CursorLoader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionEditFragment.java b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionEditFragment.java index b9893e6d..87281d49 100644 --- a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionEditFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionEditFragment.java @@ -2,11 +2,11 @@ import android.app.Activity; import android.content.Context; -import android.content.CursorLoader; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.os.Parcelable; +import android.support.v4.content.CursorLoader; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.view.LayoutInflater; @@ -19,9 +19,6 @@ import android.widget.ImageButton; import android.widget.ImageView; -import com.android.datetimepicker.date.DatePickerDialog; -import com.android.datetimepicker.time.RadialPickerLayout; -import com.android.datetimepicker.time.TimePickerDialog; import com.code44.finance.R; import com.code44.finance.common.model.TransactionState; import com.code44.finance.common.model.TransactionType; @@ -40,11 +37,14 @@ import com.code44.finance.ui.ModelListActivity; import com.code44.finance.ui.accounts.AccountsActivity; import com.code44.finance.ui.categories.CategoriesActivity; +import com.code44.finance.ui.dialogs.DatePickerDialog; +import com.code44.finance.ui.dialogs.TimePickerDialog; import com.code44.finance.ui.tags.TagsActivity; import com.code44.finance.utils.FieldValidationUtils; import com.code44.finance.utils.MoneyFormatter; import com.code44.finance.utils.TextBackgroundSpan; import com.code44.finance.utils.transaction.TransactionAutoComplete; +import com.squareup.otto.Subscribe; import net.danlew.android.joda.DateUtils; @@ -55,15 +55,14 @@ import javax.inject.Inject; -public class TransactionEditFragment extends ModelEditFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener, TransactionAutoComplete.TransactionAutoCompleteListener { +public class TransactionEditFragment extends ModelEditFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, TransactionAutoComplete.TransactionAutoCompleteListener { private static final int REQUEST_AMOUNT = 1; private static final int REQUEST_ACCOUNT_FROM = 2; private static final int REQUEST_ACCOUNT_TO = 3; private static final int REQUEST_CATEGORY = 4; private static final int REQUEST_TAGS = 5; - - private static final String FRAGMENT_DATE_DIALOG = "FRAGMENT_DATE_DIALOG"; - private static final String FRAGMENT_TIME_DIALOG = "FRAGMENT_TIME_DIALOG"; + private static final int REQUEST_DATE = 6; + private static final int REQUEST_TIME = 7; @Inject @Main Currency mainCurrency; @Inject TransactionAutoComplete transactionAutoComplete; @@ -130,33 +129,13 @@ public static TransactionEditFragment newInstance(String transactionServerId) { @Override public void onResume() { super.onResume(); - - final DatePickerDialog dateDialog_F = (DatePickerDialog) getFragmentManager().findFragmentByTag(FRAGMENT_DATE_DIALOG); - if (dateDialog_F != null) { - dateDialog_F.setOnDateSetListener(this); - } - - final TimePickerDialog timeDialog_F = (TimePickerDialog) getFragmentManager().findFragmentByTag(FRAGMENT_TIME_DIALOG); - if (timeDialog_F != null) { - timeDialog_F.setOnTimeSetListener(this); - } - + getEventBus().register(this); transactionAutoComplete.setListener(this); } @Override public void onPause() { super.onPause(); - - final DatePickerDialog dateDialog_F = (DatePickerDialog) getFragmentManager().findFragmentByTag(FRAGMENT_DATE_DIALOG); - if (dateDialog_F != null) { - dateDialog_F.setOnDateSetListener(null); - } - - final TimePickerDialog timeDialog_F = (TimePickerDialog) getFragmentManager().findFragmentByTag(FRAGMENT_TIME_DIALOG); - if (timeDialog_F != null) { - timeDialog_F.setOnTimeSetListener(null); - } - + getEventBus().unregister(this); transactionAutoComplete.setListener(null); } @@ -300,30 +279,14 @@ public static TransactionEditFragment newInstance(String transactionServerId) { TagsActivity.startMultiSelect(this, REQUEST_TAGS, model.getTags()); break; case R.id.date_B: - final DateTime date = new DateTime(model.getDate()); - DatePickerDialog.newInstance(this, date.getYear(), date.getMonthOfYear() - 1, date.getDayOfMonth()).show(getFragmentManager(), FRAGMENT_DATE_DIALOG); + DatePickerDialog.show(getChildFragmentManager(), REQUEST_DATE, model.getDate()); break; case R.id.time_B: - final DateTime time = new DateTime(model.getDate()); - TimePickerDialog.newInstance(this, time.getHourOfDay(), time.getMinuteOfHour(), true).show(getFragmentManager(), FRAGMENT_TIME_DIALOG); + TimePickerDialog.show(getChildFragmentManager(), REQUEST_TIME, model.getDate()); break; } } - @Override public void onDateSet(DatePickerDialog dialog, int year, int month, int dayOfMonth) { - final DateTime date = new DateTime(model.getDate()).withYear(year).withMonthOfYear(month + 1).withDayOfMonth(dayOfMonth); - model.setDate(date.getMillis()); - onModelLoaded(model); - transactionAutoComplete.setDate(model.getDate()); - } - - @Override public void onTimeSet(RadialPickerLayout radialPickerLayout, int hourOfDay, int minute) { - final DateTime date = new DateTime(model.getDate()).withHourOfDay(hourOfDay).withMinuteOfHour(minute); - model.setDate(date.getMillis()); - onModelLoaded(model); - transactionAutoComplete.setDate(model.getDate()); - } - @Override public void onCheckedChanged(CompoundButton view, boolean checked) { switch (view.getId()) { case R.id.confirmed_CB: @@ -361,6 +324,25 @@ public static TransactionEditFragment newInstance(String transactionServerId) { } + @Subscribe public void onDateSet(DatePickerDialog.DateSelected dateSelected) { + final DateTime date = new DateTime(model.getDate()) + .withYear(dateSelected.getYear()) + .withMonthOfYear(dateSelected.getMonthOfYear()) + .withDayOfMonth(dateSelected.getDayOfMonth()); + model.setDate(date.getMillis()); + onModelLoaded(model); + transactionAutoComplete.setDate(model.getDate()); + } + + @Subscribe public void onTimeSet(TimePickerDialog.TimeSelected timeSelected) { + final DateTime date = new DateTime(model.getDate()) + .withHourOfDay(timeSelected.getHourOfDay()) + .withMinuteOfHour(timeSelected.getMinute()); + model.setDate(date.getMillis()); + onModelLoaded(model); + transactionAutoComplete.setDate(model.getDate()); + } + private void toggleTransactionType() { switch (model.getTransactionType()) { case Expense: diff --git a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionFragment.java b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionFragment.java index 70e2f186..8d5174ab 100644 --- a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionFragment.java @@ -1,10 +1,10 @@ package com.code44.finance.ui.transactions; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.support.v4.content.CursorLoader; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; diff --git a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionsFragment.java b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionsFragment.java index 32127295..05ce5615 100644 --- a/financius/src/main/java/com/code44/finance/ui/transactions/TransactionsFragment.java +++ b/financius/src/main/java/com/code44/finance/ui/transactions/TransactionsFragment.java @@ -1,9 +1,9 @@ package com.code44.finance.ui.transactions; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.os.Bundle; +import android.support.v4.content.CursorLoader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/financius/src/main/java/com/code44/finance/ui/user/LoginActivity.java b/financius/src/main/java/com/code44/finance/ui/user/LoginActivity.java index f555e482..742aead5 100644 --- a/financius/src/main/java/com/code44/finance/ui/user/LoginActivity.java +++ b/financius/src/main/java/com/code44/finance/ui/user/LoginActivity.java @@ -37,17 +37,17 @@ protected void onCreate(Bundle savedInstanceState) { // Setup ActionBar //noinspection ConstantConditions - getActionBar().setDisplayHomeAsUpEnabled(false); + getSupportActionBar().setDisplayHomeAsUpEnabled(false); setTitle(R.string.login); // Restore state clearDefaultAccount = savedInstanceState == null || savedInstanceState.getBoolean(STATE_CLEAR_DEFAULT_ACCOUNT); - googleApi_F = (GoogleApiFragment) getFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); + googleApi_F = (GoogleApiFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_GOOGLE_API); if (googleApi_F == null) { googleApi_F = new GoogleApiFragment.Builder(UNIQUE_GOOGLE_CLIENT_ID).setUsePlus(true).build(); - getFragmentManager() + getSupportFragmentManager() .beginTransaction() .add(googleApi_F, FRAGMENT_GOOGLE_API) .commit(); diff --git a/financius/src/main/java/com/code44/finance/utils/Prefs.java b/financius/src/main/java/com/code44/finance/utils/Prefs.java index 45f130d3..753d82d8 100644 --- a/financius/src/main/java/com/code44/finance/utils/Prefs.java +++ b/financius/src/main/java/com/code44/finance/utils/Prefs.java @@ -6,7 +6,7 @@ import android.text.TextUtils; public abstract class Prefs { - private Context context; + private final Context context; protected Prefs(Context context) { this.context = context; diff --git a/financius/src/main/java/com/code44/finance/utils/ToolbarHelper.java b/financius/src/main/java/com/code44/finance/utils/ToolbarHelper.java deleted file mode 100644 index 27af90fb..00000000 --- a/financius/src/main/java/com/code44/finance/utils/ToolbarHelper.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.code44.finance.utils; - -import android.app.Activity; -import android.support.v4.app.ActionBarDrawerToggle; -import android.support.v4.widget.DrawerLayout; -import android.view.Gravity; -import android.view.MenuItem; -import android.view.View; -import android.widget.Toolbar; - -import com.code44.finance.R; - -public class ToolbarHelper { - private final Activity activity; - private final Toolbar toolbar; - private final DrawerLayout drawer; - - public ToolbarHelper(final Activity activity) { - this.activity = activity; - - // Get views - toolbar = (Toolbar) activity.findViewById(R.id.toolbar); - drawer = (DrawerLayout) activity.findViewById(R.id.drawer); - - // Setup - if (toolbar != null) { - activity.setActionBar(toolbar); - toolbar.setContentInsetsAbsolute(toolbar.getResources().getDimensionPixelSize(R.dimen.keyline_content), 0); - if (drawer != null) { - toolbar.setNavigationIcon(R.drawable.ic_drawer); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (drawer.isDrawerOpen(Gravity.START)) { - drawer.closeDrawer(Gravity.START); - } else { - drawer.openDrawer(Gravity.START); - } - } - }); - } else { - toolbar.setNavigationIcon(R.drawable.ic_up); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - activity.onBackPressed(); - } - }); - } - } - } - - public boolean onOptionsItemSelected(MenuItem item) { - if (drawer != null && item.getItemId() == android.R.id.home) { - if (drawer.isDrawerOpen(Gravity.START)) { - drawer.closeDrawer(Gravity.START); - } else { - drawer.openDrawer(Gravity.START); - } - return true; - } - return false; - } - - public void setTitle(int resId) { - toolbar.setTitle(resId); - } - - public void setTitle(String title) { - toolbar.setTitle(title); - } - - public void setElevation(float elevation) { - toolbar.setElevation(elevation); - } - - public void closeDrawer() { - if (drawer == null) { - return; - } - - drawer.closeDrawer(Gravity.START); - } - - private class CustomActionBarDrawerToggle extends ActionBarDrawerToggle { - public CustomActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes) { - super(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes); - } - } -} diff --git a/financius/src/main/java/com/code44/finance/views/AccountsView.java b/financius/src/main/java/com/code44/finance/views/AccountsView.java index 4aaa53e4..65495ba6 100644 --- a/financius/src/main/java/com/code44/finance/views/AccountsView.java +++ b/financius/src/main/java/com/code44/finance/views/AccountsView.java @@ -37,11 +37,7 @@ public AccountsView(Context context, AttributeSet attrs) { } public AccountsView(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public AccountsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + super(context, attrs, defStyleAttr); App.with(context).inject(this); setOrientation(VERTICAL); final int padding = getResources().getDimensionPixelSize(R.dimen.keyline); @@ -78,7 +74,7 @@ private void updateAccountViews(List accounts) { for (int i = TOP_STATIC_VIEWS_COUNT, size = getChildCount() - BOTTOM_STATIC_VIEWS_COUNT; i < size; i++) { final Account account = accounts.get(i - TOP_STATIC_VIEWS_COUNT); final View view = getChildAt(i); - ((TextView) view.findViewById(R.id.title_TV)).setText(account.getTitle()); + ((TextView) view.findViewById(R.id.title)).setText(account.getTitle()); ((TextView) view.findViewById(R.id.balance_TV)).setText(MoneyFormatter.format(account.getCurrency(), account.getBalance())); totalBalance += account.getBalance() * account.getCurrency().getExchangeRate(); } diff --git a/financius/src/main/java/com/code44/finance/views/ActiveIntervalView.java b/financius/src/main/java/com/code44/finance/views/ActiveIntervalView.java index 022774b3..37145dc6 100644 --- a/financius/src/main/java/com/code44/finance/views/ActiveIntervalView.java +++ b/financius/src/main/java/com/code44/finance/views/ActiveIntervalView.java @@ -30,11 +30,7 @@ public ActiveIntervalView(Context context, AttributeSet attrs) { } public ActiveIntervalView(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public ActiveIntervalView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + super(context, attrs, defStyleAttr); inflate(context, R.layout.v_interval, this); App.with(context).inject(this); diff --git a/financius/src/main/java/com/code44/finance/views/CategoriesReportView.java b/financius/src/main/java/com/code44/finance/views/CategoriesReportView.java index b85e843c..236cf344 100644 --- a/financius/src/main/java/com/code44/finance/views/CategoriesReportView.java +++ b/financius/src/main/java/com/code44/finance/views/CategoriesReportView.java @@ -31,11 +31,7 @@ public CategoriesReportView(Context context, AttributeSet attrs) { } public CategoriesReportView(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public CategoriesReportView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + super(context, attrs, defStyleAttr); App.with(context).inject(this); inflate(context, R.layout.v_categories_report, this); setBackgroundResource(R.drawable.btn_borderless); diff --git a/financius/src/main/java/com/code44/finance/views/FabImageButton.java b/financius/src/main/java/com/code44/finance/views/FabImageButton.java index 29ba01d6..c2deef80 100644 --- a/financius/src/main/java/com/code44/finance/views/FabImageButton.java +++ b/financius/src/main/java/com/code44/finance/views/FabImageButton.java @@ -1,6 +1,7 @@ package com.code44.finance.views; import android.content.Context; +import android.support.annotation.NonNull; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.ImageButton; @@ -8,8 +9,6 @@ import com.code44.finance.R; public class FabImageButton extends ImageButton { - private final android.graphics.Outline outline = new android.graphics.Outline(); - public FabImageButton(Context context) { super(context); init(); @@ -25,21 +24,12 @@ public FabImageButton(Context context, AttributeSet attrs, int defStyle) { init(); } - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - - outline.setRoundRect(0, 0, w, w, w / 2); -// setOutline(outline); - } - private void init() { setBackgroundResource(R.drawable.btn_fab); - setClipToOutline(true); } @Override - public boolean onTouchEvent(MotionEvent event) { + public boolean onTouchEvent(@NonNull MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: animate().scaleX(1.1f).scaleY(1.1f).setDuration(150).setStartDelay(0).start(); diff --git a/financius/src/main/java/com/code44/finance/views/OverviewGraphView.java b/financius/src/main/java/com/code44/finance/views/OverviewGraphView.java index 7cc84098..37f58a50 100644 --- a/financius/src/main/java/com/code44/finance/views/OverviewGraphView.java +++ b/financius/src/main/java/com/code44/finance/views/OverviewGraphView.java @@ -31,11 +31,7 @@ public OverviewGraphView(Context context, AttributeSet attrs) { } public OverviewGraphView(Context context, AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public OverviewGraphView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + super(context, attrs, defStyleAttr); App.with(context).inject(this); inflate(context, R.layout.v_overview_graph, this); setBackgroundResource(R.drawable.btn_borderless); diff --git a/financius/src/main/res/drawable-v21/btn_borderless.xml b/financius/src/main/res/drawable-v21/btn_borderless.xml new file mode 100644 index 00000000..c69b9275 --- /dev/null +++ b/financius/src/main/res/drawable-v21/btn_borderless.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/financius/src/main/res/drawable-v21/btn_calc.xml b/financius/src/main/res/drawable-v21/btn_calc.xml new file mode 100644 index 00000000..c69b9275 --- /dev/null +++ b/financius/src/main/res/drawable-v21/btn_calc.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/financius/src/main/res/drawable-v21/btn_calc_action.xml b/financius/src/main/res/drawable-v21/btn_calc_action.xml new file mode 100644 index 00000000..6eecd59f --- /dev/null +++ b/financius/src/main/res/drawable-v21/btn_calc_action.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/financius/src/main/res/drawable-v21/btn_fab.xml b/financius/src/main/res/drawable-v21/btn_fab.xml new file mode 100644 index 00000000..857f5323 --- /dev/null +++ b/financius/src/main/res/drawable-v21/btn_fab.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/financius/src/main/res/drawable-v21/btn_tab.xml b/financius/src/main/res/drawable-v21/btn_tab.xml new file mode 100644 index 00000000..6eecd59f --- /dev/null +++ b/financius/src/main/res/drawable-v21/btn_tab.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/financius/src/main/res/drawable-xxhdpi/ic_action_accept.png b/financius/src/main/res/drawable-xxhdpi/ic_action_accept.png deleted file mode 100644 index 68c41dec..00000000 Binary files a/financius/src/main/res/drawable-xxhdpi/ic_action_accept.png and /dev/null differ diff --git a/financius/src/main/res/drawable-xxhdpi/ic_action_cancel.png b/financius/src/main/res/drawable-xxhdpi/ic_action_cancel.png deleted file mode 100644 index 5dc21435..00000000 Binary files a/financius/src/main/res/drawable-xxhdpi/ic_action_cancel.png and /dev/null differ diff --git a/financius/src/main/res/drawable-xxhdpi/ic_action_device.png b/financius/src/main/res/drawable-xxhdpi/ic_action_device.png deleted file mode 100644 index a441f3f3..00000000 Binary files a/financius/src/main/res/drawable-xxhdpi/ic_action_device.png and /dev/null differ diff --git a/financius/src/main/res/drawable-xxhdpi/ic_action_drive.png b/financius/src/main/res/drawable-xxhdpi/ic_action_drive.png deleted file mode 100644 index 39cd923f..00000000 Binary files a/financius/src/main/res/drawable-xxhdpi/ic_action_drive.png and /dev/null differ diff --git a/financius/src/main/res/drawable-xxhdpi/ic_drawer.png b/financius/src/main/res/drawable-xxhdpi/ic_drawer.png deleted file mode 100644 index 19bae3ee..00000000 Binary files a/financius/src/main/res/drawable-xxhdpi/ic_drawer.png and /dev/null differ diff --git a/financius/src/main/res/drawable/btn_borderless.xml b/financius/src/main/res/drawable/btn_borderless.xml index 361472f7..98a9044b 100644 --- a/financius/src/main/res/drawable/btn_borderless.xml +++ b/financius/src/main/res/drawable/btn_borderless.xml @@ -1,3 +1,4 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/financius/src/main/res/drawable/btn_calc.xml b/financius/src/main/res/drawable/btn_calc.xml index 5d0bd361..98a9044b 100644 --- a/financius/src/main/res/drawable/btn_calc.xml +++ b/financius/src/main/res/drawable/btn_calc.xml @@ -1,3 +1,4 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/financius/src/main/res/drawable/btn_calc_action.xml b/financius/src/main/res/drawable/btn_calc_action.xml index 09cdd46b..0a22c74a 100644 --- a/financius/src/main/res/drawable/btn_calc_action.xml +++ b/financius/src/main/res/drawable/btn_calc_action.xml @@ -1,3 +1,4 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/financius/src/main/res/drawable/btn_fab.xml b/financius/src/main/res/drawable/btn_fab.xml index e0ef6ef7..26878243 100644 --- a/financius/src/main/res/drawable/btn_fab.xml +++ b/financius/src/main/res/drawable/btn_fab.xml @@ -1,9 +1,13 @@ - + + + + + + - + - + diff --git a/financius/src/main/res/drawable/btn_tab.xml b/financius/src/main/res/drawable/btn_tab.xml index 168effe8..98a9044b 100644 --- a/financius/src/main/res/drawable/btn_tab.xml +++ b/financius/src/main/res/drawable/btn_tab.xml @@ -1,3 +1,4 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/financius/src/main/res/drawable/category_gradient.xml b/financius/src/main/res/drawable/category_gradient.xml deleted file mode 100644 index 5f09b9d8..00000000 --- a/financius/src/main/res/drawable/category_gradient.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/financius/src/main/res/drawable/divider_horizontal_empty.xml b/financius/src/main/res/drawable/divider_horizontal_empty.xml deleted file mode 100644 index 84a43794..00000000 --- a/financius/src/main/res/drawable/divider_horizontal_empty.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/financius/src/main/res/drawable/divider_vertical_empty.xml b/financius/src/main/res/drawable/divider_vertical_empty.xml deleted file mode 100644 index 32517e88..00000000 --- a/financius/src/main/res/drawable/divider_vertical_empty.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/financius/src/main/res/layout-land/fragment_data.xml b/financius/src/main/res/layout-land/fragment_data.xml index 4e65bfd3..0af773eb 100644 --- a/financius/src/main/res/layout-land/fragment_data.xml +++ b/financius/src/main/res/layout-land/fragment_data.xml @@ -1,8 +1,9 @@ - @@ -31,7 +32,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/backup" - android:textColor="?android:colorPrimary" /> + android:textColor="@color/primary" />