--- /dev/null
+package net.ktnx.mobileledger;
+
+import android.annotation.TargetApi;
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AppCompatDialogFragment;
+import android.widget.DatePicker;
+import android.widget.TextView;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DatePickerFragment extends AppCompatDialogFragment
+implements DatePickerDialog.OnDateSetListener
+{
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Calendar c = GregorianCalendar.getInstance();
+ int year = c.get(GregorianCalendar.YEAR);
+ int month = c.get(GregorianCalendar.MONTH);
+ int day = c.get(GregorianCalendar.DAY_OF_MONTH);
+ TextView date = getActivity().findViewById(R.id.new_transaction_date);
+
+ CharSequence present = date.getText();
+
+ Pattern re_mon_day = Pattern.compile("^\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
+ Matcher m_mon_day = re_mon_day.matcher(present);
+
+ if (m_mon_day.matches()) {
+ month = Integer.parseInt(m_mon_day.group(0));
+ day = Integer.parseInt(m_mon_day.group(1));
+ }
+ else {
+ Pattern re_day = Pattern.compile("^\\s*(\\d{1,2})\\s*$");
+ Matcher m_day = re_day.matcher(present);
+ if (m_day.matches()) {
+ day = Integer.parseInt(m_day.group(0));
+ }
+ }
+
+ return new DatePickerDialog(Objects.requireNonNull(getActivity()), this, year, month, day);
+ }
+
+ @TargetApi(Build.VERSION_CODES.O)
+ public void onDateSet(DatePicker view, int year, int month, int day) {
+ TextView date = getActivity().findViewById(R.id.new_transaction_date);
+
+ final Calendar c = GregorianCalendar.getInstance();
+ if ( c.get(GregorianCalendar.YEAR) == year && c.get(GregorianCalendar.MONTH) == month) {
+ date.setText(String.format(Locale.US, "%d", day));
+ }
+ else {
+ date.setText(String.format(Locale.US, "%d/%d", month, day));
+ }
+ }
+}
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
- FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
- .setAction("Action", null).show();
- }
- });
-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
ver.setText(pi.versionName);
} catch (Exception e) {
- ver.setText("version");
}
}
+ public void fab_new_transaction_clicked(View view) {
+ Intent intent = new Intent(this, NewTransactionActivity.class);
+ startActivity(intent);
+ }
+
public void nav_exit_clicked(View view) {
Log.w("mobileledger", "exiting");
finish();
--- /dev/null
+package net.ktnx.mobileledger;
+
+import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.DialogFragment;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+
+import java.util.Objects;
+
+public class NewTransactionActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_new_transaction);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show();
+ }
+ });
+ Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
+ }
+
+ public void pickTransactionDate(View view) {
+ DialogFragment picker = new DatePickerFragment();
+ picker.show(getSupportFragmentManager(), "datePicker");
+// Snackbar.make(view, "Date editing not yet ready", Snackbar.LENGTH_LONG)
+// .setAction("Action", null).show();
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ tools:context=".NewTransactionActivity"
+ tools:showIn="@layout/activity_new_transaction">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <EditText
+ android:id="@+id/new_transaction_date"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/new_transaction_date_hint"
+ android:importantForAutofill="no"
+ android:inputType="date"
+ android:onClick="pickTransactionDate"
+ android:textAlignment="center" />
+
+ <LinearLayout
+ android:importantForAutofill="noExcludeDescendants"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <AutoCompleteTextView
+ android:id="@+id/autoCompleteTextView2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:hint="@string/new_transaction_account_label"
+ android:text="" />
+
+ <EditText
+ android:id="@+id/editText4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:ems="10"
+ android:hint="@string/new_transaction_amount_hint"
+ android:inputType="numberSigned|numberDecimal"
+ android:textAlignment="viewEnd" />
+ </LinearLayout>
+
+ </LinearLayout>
+ </ScrollView>
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".NewTransactionActivity">
+
+ <android.support.design.widget.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/content_new_transaction" />
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/fab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|end"
+ android:layout_margin="@dimen/fab_margin"
+ app:backgroundTint="@color/colorPrimary"
+ app:srcCompat="@android:drawable/ic_menu_send" />
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/fab_add_account"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top|end"
+ android:layout_marginBottom="80dp"
+ android:clickable="true"
+ android:focusable="auto"
+ app:layout_anchor="@id/fab"
+ app:layout_anchorGravity="top"
+ app:srcCompat="@drawable/svg_thick_plus_white" />
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
+ android:onClick="fab_new_transaction_clicked"
app:backgroundTint="@color/colorPrimary"
app:srcCompat="@drawable/svg_thick_plus_white" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ tools:context=".NewTransactionActivity"
+ tools:showIn="@layout/activity_new_transaction">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <EditText
+ android:id="@+id/new_transaction_date"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/new_transaction_date_hint"
+ android:inputType="date"
+ android:onClick="pickTransactionDate"
+ android:textAlignment="center" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <AutoCompleteTextView
+ android:id="@+id/autoCompleteTextView2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:hint="@string/new_transaction_account_label"
+ android:text="" />
+
+ <EditText
+ android:id="@+id/editText4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:ems="10"
+ android:hint="@string/new_transaction_amount_hint"
+ android:inputType="numberSigned|numberDecimal"
+ android:textAlignment="viewEnd" />
+ </LinearLayout>
+
+ </LinearLayout>
+ </ScrollView>
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <style name="AppTheme.NoActionBar">
- <item name="windowActionBar">false</item>
- <item name="windowNoTitle">true</item>
- <item name="android:statusBarColor">@android:color/transparent</item>
- </style>
-</resources>
<string name="pref_title_vibrate">Vibrate</string>
<string name="pref_title_backend_auth_user">Username</string>
<string name="pref_title_backend_auth_password">Password</string>
+ <string name="title_activity_new_transaction">New Transaction</string>
+ <string name="new_transaction_account_label">Account</string>
+ <string name="new_transaction_date_hint">Transaction date</string>
+ <string name="new_transaction_amount_hint">amount</string>
</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<full-backup-content>
+<!-- Exclude specific shared preferences that contain GCM registration Id -->
+</full-backup-content>