android:theme="@style/AppTheme"
android:fullBackupContent="@xml/backup_descriptor">
<activity
- android:name=".LatestTransactions"
- android:label="@string/app_name"
+ android:name=".AccountSummary"
+ android:label="@string/account_summary_title"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"
- android:parentActivityName=".LatestTransactions">
+ android:parentActivityName=".AccountSummary">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
- android:value="net.ktnx.mobileledger.LatestTransactions" />
+ android:value="net.ktnx.mobileledger.AccountSummary" />
</activity>
<activity
android:name=".NewTransactionActivity"
android:label="@string/title_activity_new_transaction"
- android:parentActivityName=".LatestTransactions"
+ android:parentActivityName=".AccountSummary"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
- android:value="net.ktnx.mobileledger.LatestTransactions" />
+ android:value="net.ktnx.mobileledger.AccountSummary" />
</activity>
</application>
--- /dev/null
+package net.ktnx.mobileledger;
+
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.res.Resources;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.design.widget.Snackbar;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import java.util.Date;
+
+import static android.view.View.GONE;
+import static net.ktnx.mobileledger.MobileLedgerDB.db;
+import static net.ktnx.mobileledger.MobileLedgerDB.set_option_value;
+
+public class AccountSummary extends AppCompatActivity {
+ DrawerLayout drawer;
+
+ private static long account_list_last_updated;
+ private static boolean account_list_needs_update = true;
+ public static void preferences_changed() {
+ account_list_needs_update = true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_latest_transactions);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ drawer = findViewById(R.id.drawer_layout);
+ ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
+ this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
+ drawer.addDrawerListener(toggle);
+ toggle.syncState();
+
+ android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text);
+
+ try {
+ PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
+ ver.setText(pi.versionName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ prepare_db();
+ update_accounts(false);
+ }
+
+ 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();
+ }
+
+ public void nav_settings_clicked(View view) {
+ Intent intent = new Intent(this, SettingsActivity.class);
+ startActivity(intent);
+ }
+
+ @Override
+ public void onBackPressed() {
+ DrawerLayout drawer = findViewById(R.id.drawer_layout);
+ if (drawer.isDrawerOpen(GravityCompat.START)) {
+ drawer.closeDrawer(GravityCompat.START);
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ //getMenuInflater().inflate(R.menu.latest_transactions, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ //if (id == R.id.action_settings) {
+ // return true;
+ // }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void prepare_db() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ MobileLedgerDB.setDb_filename(this.getApplicationInfo().deviceProtectedDataDir + "/" + MobileLedgerDB.DATABASE_NAME);
+ }
+ else {
+ MobileLedgerDB.setDb_filename(MobileLedgerDB.DATABASE_NAME);
+ }
+ MobileLedgerDB.initDB();
+
+ account_list_last_updated = MobileLedgerDB.get_option_value("last_refresh", (long) 0);
+
+ }
+
+ private void update_accounts(boolean force) {
+ long now = new Date().getTime();
+ if ((now > (account_list_last_updated + (24 * 3600*1000))) || force) {
+ Log.d("db", "accounts last updated at " + account_list_last_updated+" and now is " + now+". re-fetching");
+ update_accounts();
+ }
+ }
+
+ private void update_accounts() {
+ Resources rm = getResources();
+
+ ProgressBar pb = findViewById(R.id.progressBar);
+ pb.setVisibility(View.VISIBLE);
+ TextView pt = findViewById(R.id.textProgress);
+ pt.setVisibility(View.VISIBLE);
+ pb.setIndeterminate(true);
+
+ RetrieveAccountsTask task = new RetrieveAccountsTask() {
+ @Override
+ protected void onProgressUpdate(Integer... values) {
+ if ( values[0] == 0 )
+ pt.setText(R.string.progress_connecting);
+ else
+ pt.setText(String.format(getResources().getString(R.string.progress_N_accounts_loaded), values[0]));
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ pb.setVisibility(GONE);
+ pt.setVisibility(GONE);
+ if (this.error != 0)
+ Snackbar.make(drawer, rm.getString(this.error), Snackbar.LENGTH_LONG );
+ else
+ set_option_value("last_refresh", new Date().getTime() );
+ }
+ };
+
+ task.setPref(PreferenceManager.getDefaultSharedPreferences(this));
+ task.execute(db);
+
+ }
+}
+++ /dev/null
-package net.ktnx.mobileledger;
-
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.res.Resources;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.design.widget.Snackbar;
-import android.support.v4.view.GravityCompat;
-import android.support.v4.widget.DrawerLayout;
-import android.support.v7.app.ActionBarDrawerToggle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import java.util.Date;
-
-import static android.view.View.GONE;
-import static net.ktnx.mobileledger.MobileLedgerDB.db;
-import static net.ktnx.mobileledger.MobileLedgerDB.set_option_value;
-
-public class LatestTransactions extends AppCompatActivity {
- DrawerLayout drawer;
-
- private static long account_list_last_updated;
- private static boolean account_list_needs_update = true;
- public static void preferences_changed() {
- account_list_needs_update = true;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_latest_transactions);
- Toolbar toolbar = findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- drawer = findViewById(R.id.drawer_layout);
- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
- this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
- drawer.addDrawerListener(toggle);
- toggle.syncState();
-
- android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text);
-
- try {
- PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
- ver.setText(pi.versionName);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- prepare_db();
- update_accounts(false);
- }
-
- 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();
- }
-
- public void nav_settings_clicked(View view) {
- Intent intent = new Intent(this, SettingsActivity.class);
- startActivity(intent);
- }
-
- @Override
- public void onBackPressed() {
- DrawerLayout drawer = findViewById(R.id.drawer_layout);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
- } else {
- super.onBackPressed();
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- //getMenuInflater().inflate(R.menu.latest_transactions, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
-
- //noinspection SimplifiableIfStatement
- //if (id == R.id.action_settings) {
- // return true;
- // }
-
- return super.onOptionsItemSelected(item);
- }
-
- private void prepare_db() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- MobileLedgerDB.setDb_filename(this.getApplicationInfo().deviceProtectedDataDir + "/" + MobileLedgerDB.DATABASE_NAME);
- }
- else {
- MobileLedgerDB.setDb_filename(MobileLedgerDB.DATABASE_NAME);
- }
- MobileLedgerDB.initDB();
-
- account_list_last_updated = MobileLedgerDB.get_option_value("last_refresh", (long) 0);
-
- }
-
- private void update_accounts(boolean force) {
- long now = new Date().getTime();
- if ((now > (account_list_last_updated + (24 * 3600*1000))) || force) {
- Log.d("db", "accounts last updated at " + account_list_last_updated+" and now is " + now+". re-fetching");
- update_accounts();
- }
- }
-
- private void update_accounts() {
- Resources rm = getResources();
-
- ProgressBar pb = findViewById(R.id.progressBar);
- pb.setVisibility(View.VISIBLE);
- TextView pt = findViewById(R.id.textProgress);
- pt.setVisibility(View.VISIBLE);
- pb.setIndeterminate(true);
-
- RetrieveAccountsTask task = new RetrieveAccountsTask() {
- @Override
- protected void onProgressUpdate(Integer... values) {
- if ( values[0] == 0 )
- pt.setText(R.string.progress_connecting);
- else
- pt.setText(String.format(getResources().getString(R.string.progress_N_accounts_loaded), values[0]));
- }
-
- @Override
- protected void onPostExecute(Void result) {
- pb.setVisibility(GONE);
- pt.setVisibility(GONE);
- if (this.error != 0)
- Snackbar.make(drawer, rm.getString(this.error), Snackbar.LENGTH_LONG );
- else
- set_option_value("last_refresh", new Date().getTime() );
- }
- };
-
- task.setPref(PreferenceManager.getDefaultSharedPreferences(this));
- task.execute(db);
-
- }
-}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_new_transaction);
+ setContentView(R.layout.activity_account_summary);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = (preference, value) -> {
String stringValue = value.toString();
- LatestTransactions.preferences_changed();
+ AccountSummary.preferences_changed();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="#313131"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17,10L7,10v2h10v-2zM19,3h-1L18,1h-2v2L8,3L8,1L6,1v2L5,3c-1.11,0 -1.99,0.9 -1.99,2L3,19c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19L5,19L5,8h14v11zM14,14L7,14v2h7v-2z" />
+</vector>
--- /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.constraint.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+
+ <ProgressBar
+ android:id="@+id/save_transaction_progress"
+ android:layout_width="80dp"
+ android:layout_height="80dp"
+ android:layout_margin="4dp"
+ android:indeterminate="true"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </android.support.constraint.ConstraintLayout>
+
+</android.support.design.widget.CoordinatorLayout>
\ 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.constraint.ConstraintLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
-
- <ProgressBar
- android:id="@+id/save_transaction_progress"
- android:layout_width="80dp"
- android:layout_height="80dp"
- android:layout_margin="4dp"
- android:indeterminate="true"
- android:visibility="invisible"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent" />
-
- </android.support.constraint.ConstraintLayout>
-
-</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".LatestTransactions">
+ tools:context=".AccountSummary">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
</android.support.design.widget.AppBarLayout>
- <include layout="@layout/content_latest_transactions" />
+ <include layout="@layout/content_account_summary" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/btn_add_transaction"
--- /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=".AccountSummary"
+ tools:showIn="@layout/app_bar_latest_transactions">
+
+ <TextView
+ android:id="@+id/textProgress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="TextView"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginBottom="16dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toTopOf="@+id/textProgress"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="325dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="40dp"
+ app:layout_constraintBottom_toTopOf="@+id/textProgress"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" />
+ </ScrollView>
+ </LinearLayout>
+ </ScrollView>
+
+ </LinearLayout>
+ </ScrollView>
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+++ /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=".LatestTransactions"
- tools:showIn="@layout/app_bar_latest_transactions">
-
- <TextView
- android:id="@+id/textProgress"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="TextView"
- android:visibility="gone"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent" />
-
- <ProgressBar
- android:id="@+id/progressBar"
- style="?android:attr/progressBarStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="8dp"
- android:layout_marginBottom="16dp"
- android:visibility="gone"
- app:layout_constraintBottom_toTopOf="@+id/textProgress"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent" />
-
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".NewTransactionActivity"
- tools:showIn="@layout/activity_new_transaction">
+ tools:showIn="@layout/activity_account_summary">
<ScrollView
android:id="@+id/transaction_details"
android:paddingEnd="16dp">
<TextView
- android:id="@+id/textView4"
+ android:id="@+id/nav_account_summary"
style="@style/nav_button"
android:drawableStart="@drawable/ic_home_black_24dp"
+ android:text="@string/account_summary_title" />
+
+ <TextView
+ android:id="@+id/nav_latest_transactions"
+ style="@style/nav_button"
+ android:drawableStart="@drawable/ic_event_note_black_24dp"
android:text="@string/nav_latest_transactions_title" />
<TextView
style="@style/nav_button"
android:drawableStart="@drawable/ic_assignment_black_24dp"
android:text="@string/nav_reports_title" />
+
</LinearLayout>
</LinearLayout>
<string name="new_transaction_description_hint">Описание</string>
<string name="progress_N_accounts_loaded">Заредени са %d сметки</string>
<string name="action_submit_transaction_title">Запазване</string>
+ <string name="account_summary_title">Сметките накратко</string>
</resources>
\ No newline at end of file
<string name="progress_N_accounts_loaded">%d accounts loaded</string>
<string name="new_transaction_description_hint">Description</string>
<string name="action_submit_transaction_title">Save</string>
+ <string name="account_summary_title">Account Summary</string>
</resources>