forked from codinguser/gnucash-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c93d6ef
commit f78ec11
Showing
14 changed files
with
71 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.gnucash.android.app | ||
|
||
import android.os.Bundle | ||
import android.view.Menu | ||
import android.view.MenuInflater | ||
import android.view.MenuItem | ||
import androidx.activity.ComponentActivity | ||
import androidx.core.view.MenuProvider | ||
import androidx.fragment.app.Fragment | ||
|
||
open class MenuFragment : Fragment() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val activity = requireActivity() | ||
if (activity is ComponentActivity) { | ||
activity.addMenuProvider(object : MenuProvider { | ||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { | ||
menu.clear() | ||
onCreateOptionsMenu(menu, menuInflater) | ||
} | ||
|
||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean { | ||
return onOptionsItemSelected(menuItem) | ||
} | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.content.res.Resources; | ||
import android.content.res.TypedArray; | ||
import android.database.Cursor; | ||
|
@@ -51,14 +50,13 @@ | |
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.content.ContextCompat; | ||
import androidx.cursoradapter.widget.SimpleCursorAdapter; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentResultListener; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.GnuCashApplication; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.databinding.FragmentAccountFormBinding; | ||
import org.gnucash.android.app.GnuCashApplication; | ||
import org.gnucash.android.db.DatabaseSchema; | ||
import org.gnucash.android.db.adapter.AccountsDbAdapter; | ||
import org.gnucash.android.db.adapter.CommoditiesDbAdapter; | ||
|
@@ -68,7 +66,6 @@ | |
import org.gnucash.android.model.Commodity; | ||
import org.gnucash.android.ui.colorpicker.ColorPickerDialog; | ||
import org.gnucash.android.ui.common.UxArgument; | ||
import org.gnucash.android.ui.settings.PreferenceActivity; | ||
import org.gnucash.android.util.CommoditiesCursorAdapter; | ||
import org.gnucash.android.util.QualifiedAccountNameCursorAdapter; | ||
|
||
|
@@ -86,7 +83,7 @@ | |
* @author Ngewi Fet <[email protected]> | ||
* @author Yongxin Wang <[email protected]> | ||
*/ | ||
public class AccountFormFragment extends Fragment implements FragmentResultListener { | ||
public class AccountFormFragment extends MenuFragment implements FragmentResultListener { | ||
/** | ||
* Accounts database adapter | ||
*/ | ||
|
@@ -173,7 +170,6 @@ static public AccountFormFragment newInstance() { | |
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setHasOptionsMenu(true); | ||
mAccountsDbAdapter = AccountsDbAdapter.getInstance(); | ||
mUseDoubleEntry = GnuCashApplication.isDoubleEntryEnabled(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,6 @@ | |
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.appcompat.widget.PopupMenu; | ||
import androidx.appcompat.widget.SearchView; | ||
import androidx.core.view.MenuItemCompat; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentResultListener; | ||
import androidx.lifecycle.Lifecycle; | ||
|
@@ -57,7 +55,7 @@ | |
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.GnuCashApplication; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.databinding.CardviewAccountBinding; | ||
import org.gnucash.android.databinding.FragmentAccountsListBinding; | ||
import org.gnucash.android.db.DatabaseCursorLoader; | ||
|
@@ -83,7 +81,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public class AccountsListFragment extends Fragment implements | ||
public class AccountsListFragment extends MenuFragment implements | ||
Refreshable, | ||
LoaderManager.LoaderCallbacks<Cursor>, | ||
SearchView.OnQueryTextListener, | ||
|
@@ -151,6 +149,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
|
||
mBinding.list.setHasFixedSize(true); | ||
mBinding.list.setEmptyView(mBinding.emptyView); | ||
mBinding.list.setAdapter(mAccountRecyclerAdapter); | ||
|
||
switch (mDisplayMode) { | ||
|
||
|
@@ -190,20 +189,15 @@ public void onCreate(Bundle savedInstanceState) { | |
mDisplayMode = (DisplayMode) savedInstanceState.getSerializable(STATE_DISPLAY_MODE); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onActivityCreated(Bundle savedInstanceState) { | ||
super.onActivityCreated(savedInstanceState); | ||
|
||
ActionBar actionbar = ((AppCompatActivity) getActivity()).getSupportActionBar(); | ||
AppCompatActivity activity = (AppCompatActivity) requireActivity(); | ||
ActionBar actionbar = activity.getSupportActionBar(); | ||
assert actionbar != null; | ||
actionbar.setTitle(R.string.title_accounts); | ||
actionbar.setDisplayHomeAsUpEnabled(true); | ||
setHasOptionsMenu(true); | ||
|
||
// specify an adapter (see also next example) | ||
mAccountRecyclerAdapter = new AccountRecyclerAdapter(null); | ||
mBinding.list.setAdapter(mAccountRecyclerAdapter); | ||
} | ||
|
||
@Override | ||
|
@@ -281,21 +275,20 @@ private void showConfirmationDialog(String accountUID) { | |
@Override | ||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { | ||
super.onCreateOptionsMenu(menu, inflater); | ||
if (mParentAccountUID != null) | ||
if (!TextUtils.isEmpty(mParentAccountUID)) | ||
inflater.inflate(R.menu.sub_account_actions, menu); | ||
else { | ||
inflater.inflate(R.menu.account_actions, menu); | ||
// Associate searchable configuration with the SearchView | ||
|
||
SearchManager searchManager = | ||
(SearchManager) GnuCashApplication.getAppContext().getSystemService(Context.SEARCH_SERVICE); | ||
mSearchView = (SearchView) | ||
MenuItemCompat.getActionView(menu.findItem(R.id.menu_search)); | ||
mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); | ||
if (mSearchView == null) | ||
return; | ||
|
||
Activity context = requireActivity(); | ||
SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); | ||
mSearchView.setSearchableInfo( | ||
searchManager.getSearchableInfo(getActivity().getComponentName())); | ||
searchManager.getSearchableInfo(context.getComponentName())); | ||
mSearchView.setOnQueryTextListener(this); | ||
mSearchView.setOnCloseListener(this); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,15 +49,14 @@ | |
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.content.ContextCompat; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.codetroopers.betterpickers.recurrencepicker.EventRecurrence; | ||
import com.codetroopers.betterpickers.recurrencepicker.EventRecurrenceFormatter; | ||
import com.codetroopers.betterpickers.recurrencepicker.RecurrencePickerDialogFragment; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.GnuCashApplication; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.databinding.FragmentExportFormBinding; | ||
import org.gnucash.android.db.adapter.BooksDbAdapter; | ||
import org.gnucash.android.db.adapter.DatabaseAdapter; | ||
|
@@ -94,7 +93,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public class ExportFormFragment extends Fragment implements | ||
public class ExportFormFragment extends MenuFragment implements | ||
RecurrencePickerDialogFragment.OnRecurrenceSetListener, | ||
DatePickerDialog.OnDateSetListener, | ||
TimePickerDialog.OnTimeSetListener { | ||
|
@@ -321,10 +320,9 @@ public void onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | ||
|
||
AppCompatActivity activity = (AppCompatActivity) requireActivity(); | ||
ActionBar supportActionBar = activity.getSupportActionBar(); | ||
assert supportActionBar != null; | ||
supportActionBar.setTitle(R.string.title_export_dialog); | ||
setHasOptionsMenu(true); | ||
ActionBar actionBar = activity.getSupportActionBar(); | ||
assert actionBar != null; | ||
actionBar.setTitle(R.string.title_export_dialog); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ | |
import androidx.annotation.StringRes; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.github.mikephil.charting.data.ChartData; | ||
import com.github.mikephil.charting.data.Entry; | ||
|
@@ -46,6 +45,7 @@ | |
import com.github.mikephil.charting.listener.OnChartValueSelectedListener; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.db.adapter.AccountsDbAdapter; | ||
import org.gnucash.android.model.AccountType; | ||
import org.gnucash.android.model.Commodity; | ||
|
@@ -69,7 +69,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public abstract class BaseReportFragment extends Fragment implements | ||
public abstract class BaseReportFragment extends MenuFragment implements | ||
OnChartValueSelectedListener, ReportOptionsListener, Refreshable { | ||
|
||
/** | ||
|
@@ -201,8 +201,6 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |
assert actionBar != null; | ||
actionBar.setTitle(getTitle()); | ||
|
||
setHasOptionsMenu(true); | ||
|
||
ReportsActivity reportsActivity = (ReportsActivity) getActivity(); | ||
mReportPeriodStart = reportsActivity.getReportPeriodStart(); | ||
mReportPeriodEnd = reportsActivity.getReportPeriodEnd(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,14 @@ | |
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.appcompat.widget.PopupMenu; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.loader.app.LoaderManager; | ||
import androidx.loader.content.Loader; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.ActivityExtKt; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.databinding.FragmentScheduledEventsListBinding; | ||
import org.gnucash.android.databinding.ListItemScheduledTrxnBinding; | ||
import org.gnucash.android.db.adapter.ScheduledActionDbAdapter; | ||
|
@@ -60,7 +60,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public abstract class ScheduledActionsListFragment extends Fragment implements | ||
public abstract class ScheduledActionsListFragment extends MenuFragment implements | ||
Refreshable, | ||
LoaderManager.LoaderCallbacks<Cursor> { | ||
|
||
|
@@ -94,7 +94,6 @@ public void onActivityCreated(Bundle savedInstanceState) { | |
actionBar.setDisplayShowTitleEnabled(true); | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setHomeButtonEnabled(true); | ||
setHasOptionsMenu(true); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,11 @@ | |
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.cursoradapter.widget.SimpleCursorAdapter; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.google.android.material.snackbar.Snackbar; | ||
|
||
import org.gnucash.android.R; | ||
import org.gnucash.android.app.MenuFragment; | ||
import org.gnucash.android.databinding.FragmentSplitEditorBinding; | ||
import org.gnucash.android.databinding.ItemSplitEntryBinding; | ||
import org.gnucash.android.db.DatabaseSchema; | ||
|
@@ -80,7 +80,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public class SplitEditorFragment extends Fragment { | ||
public class SplitEditorFragment extends MenuFragment { | ||
private AccountsDbAdapter mAccountsDbAdapter; | ||
private Cursor mCursor; | ||
private SimpleCursorAdapter mCursorAdapter; | ||
|
@@ -136,7 +136,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat | |
ActionBar actionBar = ((AppCompatActivity) requireActivity()).getSupportActionBar(); | ||
assert actionBar != null; | ||
actionBar.setTitle(R.string.title_split_editor); | ||
setHasOptionsMenu(true); | ||
|
||
mSplitItemViewList = new ArrayList<>(); | ||
|
||
|
Oops, something went wrong.