From bde37d0aa472d31606b53491240c79af3374f09b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 12 Jan 2019 07:47:28 +0000 Subject: [PATCH] toCamelCase --- .../mobileledger/MobileLedgerApplication.java | 8 +- .../async/RetrieveTransactionsTask.java | 32 ++-- .../async/SaveTransactionTask.java | 40 ++--- .../net/ktnx/mobileledger/model/Data.java | 2 +- .../mobileledger/model/LedgerAccount.java | 6 +- .../ui/activity/MainActivity.java | 10 +- .../ui/activity/NewTransactionActivity.java | 144 ++++++++---------- .../TransactionListAdapter.java | 4 +- .../TransactionListFragment.java | 2 +- .../net/ktnx/mobileledger/utils/Globals.java | 6 +- .../net/ktnx/mobileledger/utils/MLDB.java | 35 ++--- .../ktnx/mobileledger/utils/NetworkUtil.java | 2 +- .../utils/UrlEncodedFormData.java | 6 +- app/src/main/res/layout/activity_main.xml | 8 +- 14 files changed, 147 insertions(+), 158 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java index ea4a3d66..7f0dfeb6 100644 --- a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java +++ b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerApplication.java @@ -59,14 +59,14 @@ public class MobileLedgerApplication extends Application { Resources rm = getResources(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Resources.Theme theme = getTheme(); - Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg, theme); - Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg, theme); + Globals.tableRowOddBG = rm.getColor(R.color.table_row_odd_bg, theme); + Globals.tableRowEvenBG = rm.getColor(R.color.table_row_even_bg, theme); Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark, theme); Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text, theme); } else { - Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg); - Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg); + Globals.tableRowOddBG = rm.getColor(R.color.table_row_odd_bg); + Globals.tableRowEvenBG = rm.getColor(R.color.table_row_even_bg); Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark); Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text); } diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 91ea8ffc..b13b9050 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -54,20 +54,20 @@ import java.util.regex.Pattern; public class RetrieveTransactionsTask extends AsyncTask { private static final int MATCHING_TRANSACTIONS_LIMIT = 50; - private static final Pattern commentPattern = Pattern.compile("^\\s*;"); - private static final Pattern transactionStartPattern = Pattern.compile("([\\d.-]+)"); - private static final Pattern transactionDescriptionPattern = + private static final Pattern reComment = Pattern.compile("^\\s*;"); + private static final Pattern reTransactionStart = Pattern.compile("([\\d.-]+)"); + private static final Pattern reTransactionDescription = Pattern.compile(" contextRef; private int error; // %3A is '=' private boolean success; - private Pattern account_name_re = Pattern.compile("/register\\?q=inacct%3A([a-zA-Z0-9%]+)\""); - private Pattern account_value_re = Pattern.compile( + private Pattern reAccountName = Pattern.compile("/register\\?q=inacct%3A([a-zA-Z0-9%]+)\""); + private Pattern reAccountValue = Pattern.compile( "\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?"); public RetrieveTransactionsTask(WeakReference contextRef) { this.contextRef = contextRef; @@ -117,7 +117,7 @@ public class RetrieveTransactionsTask boolean onlyStarred = Data.optShowOnlyStarred.get(); Data.backgroundTaskCount.incrementAndGet(); try { - HttpURLConnection http = NetworkUtil.prepare_connection("journal"); + HttpURLConnection http = NetworkUtil.prepareConnection("journal"); http.setAllowUserInteraction(false); publishProgress(progress); MainActivity ctx = getContext(); @@ -145,7 +145,7 @@ public class RetrieveTransactionsTask while ((line = buf.readLine()) != null) { throwIfCancelled(); Matcher m; - m = commentPattern.matcher(line); + m = reComment.matcher(line); if (m.find()) { // TODO: comments are ignored for now Log.v("transaction-parser", "Ignoring comment"); @@ -160,7 +160,7 @@ public class RetrieveTransactionsTask Data.accounts.set(accountList); continue; } - m = account_name_re.matcher(line); + m = reAccountName.matcher(line); if (m.find()) { String acct_encoded = m.group(1); String acct_name = URLDecoder.decode(acct_encoded, "UTF-8"); @@ -206,7 +206,7 @@ public class RetrieveTransactionsTask break; case EXPECTING_ACCOUNT_AMOUNT: - m = account_value_re.matcher(line); + m = reAccountValue.matcher(line); boolean match_found = false; while (m.find()) { throwIfCancelled(); @@ -231,7 +231,7 @@ public class RetrieveTransactionsTask case EXPECTING_TRANSACTION: if (!line.isEmpty() && (line.charAt(0) == ' ')) continue; - m = transactionStartPattern.matcher(line); + m = reTransactionStart.matcher(line); if (m.find()) { transactionId = Integer.valueOf(m.group(1)); state = ParserState.EXPECTING_TRANSACTION_DESCRIPTION; @@ -246,7 +246,7 @@ public class RetrieveTransactionsTask progress.setTotal(transactionId); publishProgress(progress); } - m = endPattern.matcher(line); + m = reEnd.matcher(line); if (m.find()) { L("--- transaction value complete ---"); success = true; @@ -256,7 +256,7 @@ public class RetrieveTransactionsTask case EXPECTING_TRANSACTION_DESCRIPTION: if (!line.isEmpty() && (line.charAt(0) == ' ')) continue; - m = transactionDescriptionPattern.matcher(line); + m = reTransactionDescription.matcher(line); if (m.find()) { if (transactionId == 0) throw new TransactionParserException( @@ -320,7 +320,7 @@ public class RetrieveTransactionsTask // } } else { - m = transactionDetailsPattern.matcher(line); + m = reTransactionDetails.matcher(line); if (m.find()) { String acc_name = m.group(1); String amount = m.group(2); diff --git a/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java b/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java index 913fddc5..c4cc9a3e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java @@ -41,18 +41,18 @@ import java.util.regex.Pattern; import static java.lang.Thread.sleep; public class SaveTransactionTask extends AsyncTask { - private final TaskCallback task_callback; + private final TaskCallback taskCallback; private String token; private String session; - private String backend_url; + private String backendUrl; private LedgerTransaction ltr; protected String error; public SaveTransactionTask(TaskCallback callback) { - task_callback = callback; + taskCallback = callback; } - private boolean send_ok() throws IOException { - HttpURLConnection http = NetworkUtil.prepare_connection("add"); + private boolean sendOK() throws IOException { + HttpURLConnection http = NetworkUtil.prepareConnection("add"); http.setRequestMethod("POST"); http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); http.setRequestProperty("Accept", "*/*"); @@ -63,15 +63,15 @@ public class SaveTransactionTask extends AsyncTask> header = http.getHeaderFields(); - List cookie_header = header.get("Set-Cookie"); - if (cookie_header != null) { - String cookie = cookie_header.get(0); - Matcher m = sess_cookie_re.matcher(cookie); + List cookieHeader = header.get("Set-Cookie"); + if (cookieHeader != null) { + String cookie = cookieHeader.get(0); + Matcher m = reSessionCookie.matcher(cookie); if (m.matches()) { session = m.group(1); Log.d("network", "new session is " + session); @@ -135,11 +135,11 @@ public class SaveTransactionTask extends AsyncTask= 2) @@ -162,6 +162,6 @@ public class SaveTransactionTask extends AsyncTask(new ArrayList<>()); public static ObservableValue optShowOnlyStarred = new ObservableValue<>(); public static void setCurrentProfile(MobileLedgerProfile newProfile) { - MLDB.set_option_value(MLDB.OPT_PROFILE_UUID, newProfile.getUuid()); + MLDB.setOption(MLDB.OPT_PROFILE_UUID, newProfile.getUuid()); profile.set(newProfile); } } diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java index 4cf08f9e..532642ac 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Damyan Ivanov. + * Copyright © 2019 Damyan Ivanov. * This file is part of Mobile-Ledger. * Mobile-Ledger is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -32,7 +32,7 @@ public class LedgerAccount { private boolean hidden; private boolean hiddenToBe; private List amounts; - static Pattern higher_account = Pattern.compile("^[^:]+:"); + static Pattern reHigherAccount = Pattern.compile("^[^:]+:"); public LedgerAccount(String name) { this.setName(name); @@ -64,7 +64,7 @@ public class LedgerAccount { shortName = name; StringBuilder parentBuilder = new StringBuilder(); while (true) { - Matcher m = higher_account.matcher(shortName); + Matcher m = reHigherAccount.matcher(shortName); if (m.find()) { level++; parentBuilder.append(m.group(0)); 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 a59ec036..20460186 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 @@ -172,7 +172,7 @@ public class MainActivity extends AppCompatActivity { Data.profiles.setList(MobileLedgerProfile.loadAllFromDB()); MobileLedgerProfile profile = null; - String profileUUID = MLDB.get_option_value(MLDB.OPT_PROFILE_UUID, null); + String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null); if (profileUUID == null) { if (Data.profiles.isEmpty()) { Data.profiles.setList(MobileLedgerProfile.createInitialProfileList()); @@ -215,18 +215,18 @@ public class MainActivity extends AppCompatActivity { startActivity(intent, args); } } - public void fab_new_transaction_clicked(View view) { + public void fabNewTransactionClicked(View view) { Intent intent = new Intent(this, NewTransactionActivity.class); startActivity(intent); overridePendingTransition(R.anim.slide_in_right, R.anim.dummy); } - public void nav_exit_clicked(View view) { + public void navExitClicked(View view) { Log.w("app", "exiting"); finish(); } - public void nav_settings_clicked(View view) { + public void navSettingsClicked(View view) { Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); drawer.closeDrawers(); @@ -363,7 +363,7 @@ public class MainActivity extends AppCompatActivity { progressBar.setIndeterminate(false); } } - public void nav_profiles_clicked(View view) { + public void navProfilesClicked(View view) { drawer.closeDrawers(); Intent intent = new Intent(this, ProfileListActivity.class); startActivity(intent); 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 c2ca87b9..0856bb54 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 @@ -69,10 +69,12 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal private static SaveTransactionTask saver; private TableLayout table; private ProgressBar progress; - private TextView text_date; - private AutoCompleteTextView text_descr; + private TextView tvDate; + private AutoCompleteTextView tvDescription; private MenuItem mSave; - + private static boolean isZero(float f) { + return (f < 0.005) && (f > -0.005); + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -80,14 +82,14 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - text_date = findViewById(R.id.new_transaction_date); - text_date.setOnFocusChangeListener((v, hasFocus) -> { + tvDate = findViewById(R.id.new_transaction_date); + tvDate.setOnFocusChangeListener((v, hasFocus) -> { if (hasFocus) pickTransactionDate(v); }); - text_descr = findViewById(R.id.new_transaction_description); - MLDB.hook_autocompletion_adapter(this, text_descr, MLDB.DESCRIPTION_HISTORY_TABLE, + tvDescription = findViewById(R.id.new_transaction_description); + MLDB.hookAutocompletionAdapter(this, tvDescription, MLDB.DESCRIPTION_HISTORY_TABLE, "description", false, findViewById(R.id.new_transaction_acc_1)); - hook_text_change_listener(text_descr); + hookTextChangeListener(tvDescription); progress = findViewById(R.id.save_transaction_progress); @@ -95,23 +97,17 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal table = findViewById(R.id.new_transaction_accounts_table); for (int i = 0; i < table.getChildCount(); i++) { TableRow row = (TableRow) table.getChildAt(i); - AutoCompleteTextView acc_name_view = (AutoCompleteTextView) row.getChildAt(0); - TextView amount_view = (TextView) row.getChildAt(1); - hook_swipe_listener(row); - MLDB.hook_autocompletion_adapter(this, acc_name_view, MLDB.ACCOUNTS_TABLE, "name", true, - amount_view); - hook_text_change_listener(acc_name_view); - hook_text_change_listener(amount_view); + AutoCompleteTextView tvAccountName = (AutoCompleteTextView) row.getChildAt(0); + TextView tvAmount = (TextView) row.getChildAt(1); + hookSwipeListener(row); + MLDB.hookAutocompletionAdapter(this, tvAccountName, MLDB.ACCOUNTS_TABLE, "name", true, + tvAmount); + hookTextChangeListener(tvAccountName); + hookTextChangeListener(tvAmount); // Log.d("swipe", "hooked to row "+i); } } - @Override - protected void onStart() { - super.onStart(); - if (text_descr.getText().toString().isEmpty()) text_descr.requestFocus(); - } - @Override public void finish() { super.finish(); @@ -127,17 +123,21 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal } return super.onOptionsItemSelected(item); } - - public void save_transaction() { + @Override + protected void onStart() { + super.onStart(); + if (tvDescription.getText().toString().isEmpty()) tvDescription.requestFocus(); + } + public void saveTransaction() { if (mSave != null) mSave.setVisible(false); - toggle_all_editing(false); + toggleAllEditing(false); progress.setVisibility(View.VISIBLE); saver = new SaveTransactionTask(this); - String date = text_date.getText().toString(); + String date = tvDate.getText().toString(); if (date.isEmpty()) date = String.valueOf(new Date().getDate()); - LedgerTransaction tr = new LedgerTransaction(date, text_descr.getText().toString()); + LedgerTransaction tr = new LedgerTransaction(date, tvDescription.getText().toString()); TableLayout table = findViewById(R.id.new_transaction_accounts_table); for (int i = 0; i < table.getChildCount(); i++) { @@ -152,10 +152,9 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal } saver.execute(tr); } - - private void toggle_all_editing(boolean enabled) { - text_date.setEnabled(enabled); - text_descr.setEnabled(enabled); + private void toggleAllEditing(boolean enabled) { + tvDate.setEnabled(enabled); + tvDescription.setEnabled(enabled); TableLayout table = findViewById(R.id.new_transaction_accounts_table); for (int i = 0; i < table.getChildCount(); i++) { TableRow row = (TableRow) table.getChildAt(i); @@ -164,8 +163,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal } } } - - private void hook_swipe_listener(final TableRow row) { + private void hookSwipeListener(final TableRow row) { row.getChildAt(0).setOnTouchListener(new OnSwipeTouchListener(this) { public void onSwipeLeft() { // Log.d("swipe", "LEFT" + row.getId()); @@ -173,7 +171,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal TableRow prev_row = (TableRow) table.getChildAt(table.indexOfChild(row) - 1); TableRow next_row = (TableRow) table.getChildAt(table.indexOfChild(row) + 1); TextView prev_amt = - (prev_row != null) ? (TextView) prev_row.getChildAt(1) : text_descr; + (prev_row != null) ? (TextView) prev_row.getChildAt(1) : tvDescription; TextView next_acc = (next_row != null) ? (TextView) next_row.getChildAt(0) : null; @@ -212,27 +210,6 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal }); } - private void hook_text_change_listener(final TextView view) { - view.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { -// Log.d("input", "text changed"); - check_transaction_submittable(); - } - }); - - } - public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.new_transaction, menu); @@ -253,8 +230,27 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics())); } + private void hookTextChangeListener(final TextView view) { + view.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } - private void do_add_account_row(boolean focus) { + @Override + public void afterTextChanged(Editable s) { +// Log.d("input", "text changed"); + check_transaction_submittable(); + } + }); + + } + private void doAddAccountRow(boolean focus) { final AutoCompleteTextView acc = new AutoCompleteTextView(this); acc.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 9f)); @@ -294,28 +290,20 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal if (focus) acc.requestFocus(); - hook_swipe_listener(row); - MLDB.hook_autocompletion_adapter(this, acc, MLDB.ACCOUNTS_TABLE, "name", true, amt); - hook_text_change_listener(acc); - hook_text_change_listener(amt); + hookSwipeListener(row); + MLDB.hookAutocompletionAdapter(this, acc, MLDB.ACCOUNTS_TABLE, "name", true, amt); + hookTextChangeListener(acc); + hookTextChangeListener(amt); } - public void addTransactionAccountFromMenu(MenuItem item) { - do_add_account_row(true); + doAddAccountRow(true); } - public void resetTransactionFromMenu(MenuItem item) { - reset_form(); + resetForm(); } - public void saveTransactionFromMenu(MenuItem item) { - save_transaction(); + saveTransaction(); } - - private boolean is_zero(float f) { - return (f < 0.005) && (f > -0.005); - } - // rules: // 1) at least two account names // 2) each amount must have account name @@ -377,7 +365,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal if ((empty_rows == 0) && ((table.getChildCount() == accounts) || (table.getChildCount() == amounts))) { - do_add_account_row(false); + doAddAccountRow(false); } Log.d("submittable", String.format("accounts=%d, accounts_with_values=%s, " + @@ -388,7 +376,7 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal if (have_description && (accounts >= 2) && (accounts_with_values >= (accounts - 1)) && (amounts_with_accounts == amounts) && - (single_empty_amount && single_empty_amount_has_account || is_zero(running_total))) + (single_empty_amount && single_empty_amount_has_account || isZero(running_total))) { if (mSave != null) mSave.setVisible(true); } @@ -414,19 +402,19 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal progress.setVisibility(View.INVISIBLE); Log.d("visuals", "hiding progress"); - if (error == null) reset_form(); + if (error == null) resetForm(); else Snackbar.make(findViewById(R.id.new_transaction_accounts_table), error, BaseTransientBottomBar.LENGTH_LONG).show(); - toggle_all_editing(true); + toggleAllEditing(true); check_transaction_submittable(); } - private void reset_form() { - text_date.setText(""); - text_descr.setText(""); + private void resetForm() { + tvDate.setText(""); + tvDescription.setText(""); - text_descr.requestFocus(); + tvDescription.requestFocus(); while (table.getChildCount() > 2) { table.removeViewAt(2); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java index 96933eeb..7004dd7d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java @@ -112,10 +112,10 @@ public class TransactionListAdapter extends RecyclerView.Adapter { // Log.d("tmp", "direct onItemClick"); TransactionListViewModel.scheduleTransactionListReload(); diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java index e32a4321..4cf2b755 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Damyan Ivanov. + * Copyright © 2019 Damyan Ivanov. * This file is part of Mobile-Ledger. * Mobile-Ledger is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -25,9 +25,9 @@ import android.view.inputmethod.InputMethodManager; public final class Globals { @ColorInt - public static int table_row_even_bg; + public static int tableRowEvenBG; @ColorInt - public static int table_row_odd_bg; + public static int tableRowOddBG; @ColorInt public static int primaryDark, defaultTextColor; public static void hideSoftKeyboard(Activity act) { diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java index b3557936..76763d01 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java @@ -78,8 +78,8 @@ public final class MLDB { public static SQLiteDatabase getWritableDatabase() { return getDatabase(WRITE); } - static public int get_option_value(String name, int default_value) { - String s = get_option_value(name, String.valueOf(default_value)); + static public int getIntOption(String name, int default_value) { + String s = getOption(name, String.valueOf(default_value)); try { return Integer.parseInt(s); } @@ -88,8 +88,8 @@ public final class MLDB { return default_value; } } - static public long get_option_value(String name, long default_value) { - String s = get_option_value(name, String.valueOf(default_value)); + static public long getLongOption(String name, long default_value) { + String s = getOption(name, String.valueOf(default_value)); try { return Long.parseLong(s); } @@ -98,7 +98,7 @@ public final class MLDB { return default_value; } } - static public String get_option_value(String name, String default_value) { + static public String getOption(String name, String default_value) { Log.d("db", "about to fetch option " + name); SQLiteDatabase db = getReadableDatabase(); try (Cursor cursor = db.rawQuery("select value from options where profile = ? and name=?", @@ -119,27 +119,28 @@ public final class MLDB { return default_value; } } - static public void set_option_value(String name, String value) { + static public void setOption(String name, String value) { Log.d("option", String.format("%s := %s", name, value)); SQLiteDatabase db = MLDB.getWritableDatabase(); db.execSQL("insert or replace into options(profile, name, value) values(?, ?, ?);", new String[]{NO_PROFILE, name, value}); } - static public void set_option_value(String name, long value) { - set_option_value(name, String.valueOf(value)); + static public void setLongOption(String name, long value) { + setOption(name, String.valueOf(value)); } @TargetApi(Build.VERSION_CODES.N) - public static void hook_autocompletion_adapter(final Context context, - final AutoCompleteTextView view, - final String table, final String field, - final boolean profileSpecific) { - hook_autocompletion_adapter(context, view, table, field, profileSpecific, null); + public static void hookAutocompletionAdapter(final Context context, + final AutoCompleteTextView view, + final String table, final String field, + final boolean profileSpecific) { + hookAutocompletionAdapter(context, view, table, field, profileSpecific, null); } @TargetApi(Build.VERSION_CODES.N) - public static void hook_autocompletion_adapter(final Context context, - final AutoCompleteTextView view, final String table, final String field, - final boolean profileSpecific, - final View nextView) { + public static void hookAutocompletionAdapter(final Context context, + final AutoCompleteTextView view, + final String table, final String field, + final boolean profileSpecific, + final View nextView) { String[] from = {field}; int[] to = {android.R.id.text1}; SimpleCursorAdapter adapter = diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java index efb1ac97..e6cc9acb 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java @@ -29,7 +29,7 @@ import java.net.URL; public final class NetworkUtil { private static final int thirtySeconds = 30000; - public static HttpURLConnection prepare_connection(String path) throws IOException { + public static HttpURLConnection prepareConnection(String path) throws IOException { MobileLedgerProfile profile = Data.profile.get(); final String backend_url = profile.getUrl(); final boolean use_auth = profile.isAuthEnabled(); diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java b/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java index 5d69da21..73d26ee1 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Damyan Ivanov. + * Copyright © 2019 Damyan Ivanov. * This file is part of Mobile-Ledger. * Mobile-Ledger is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -32,8 +32,8 @@ public class UrlEncodedFormData { pairs = new ArrayList<>(); } - public void add_pair(String name, String value) { - pairs.add(new AbstractMap.SimpleEntry(name, value)); + public void addPair(String name, String value) { + pairs.add(new AbstractMap.SimpleEntry<>(name, value)); } @NonNull diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e29e6739..01e4bb2a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -46,7 +46,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" - android:onClick="fab_new_transaction_clicked" + android:onClick="fabNewTransactionClicked" app:backgroundTint="@color/colorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -201,7 +201,7 @@ android:layout_width="match_parent" android:layout_weight="1" android:drawableStart="@drawable/ic_view_list_black_24dp" - android:onClick="nav_profiles_clicked" + android:onClick="navProfilesClicked" android:text="@string/profiles" /> -- 2.39.5