diff --git a/app/build.gradle b/app/build.gradle --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,6 @@ dependencies { //new libraries - } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + @@ -13,18 +12,18 @@ - - + + - - + + - + - + @@ -36,7 +35,6 @@ android:networkSecurityConfig="@xml/networks_security_config" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/AppTheme.NoActionBar"> - + android:windowSoftInputMode="adjustResize"> @@ -105,7 +103,6 @@ android:enabled="true" android:exported="false"> - { + private static final String OPTION_SHOW_LEGEND = "show_legend"; private final static String KEY_STOP_ID = "stopid"; private final static String KEY_STOP_NAME = "stopname"; private final static String DEBUG_TAG_ALL = "BUSTOArrivalsFragment"; @@ -92,6 +95,9 @@ protected RecyclerView arrivalsRecyclerView; private PalinaAdapter mListAdapter = null; + private TextView howDoesItWorkTextView; + private Button hideHintButton; + //private NestedScrollView theScrollView; protected RecyclerView noArrivalsRecyclerView; @@ -181,6 +187,11 @@ View root = inflater.inflate(R.layout.fragment_arrivals, container, false); messageTextView = root.findViewById(R.id.messageTextView); addToFavorites = root.findViewById(R.id.addToFavorites); + // "How does it work part" + howDoesItWorkTextView = root.findViewById(R.id.howDoesItWorkTextView); + hideHintButton = root.findViewById(R.id.hideHintButton); + hideHintButton.setOnClickListener(this::onHideHint); + //theScrollView = root.findViewById(R.id.arrivalsScrollView); // recyclerview holding the arrival times arrivalsRecyclerView = root.findViewById(R.id.arrivalsRecyclerView); @@ -288,6 +299,10 @@ updateMessage(); } + if (ScreenBaseFragment.getOption(requireContext(),OPTION_SHOW_LEGEND, true)) { + showHints(); + } + } @@ -333,6 +348,23 @@ this.reloadOnResume = reloadOnResume; } + // HINT "HOW TO USE" + private void showHints() { + howDoesItWorkTextView.setVisibility(View.VISIBLE); + hideHintButton.setVisibility(View.VISIBLE); + //actionHelpMenuItem.setVisible(false); + } + + private void hideHints() { + howDoesItWorkTextView.setVisibility(View.GONE); + hideHintButton.setVisibility(View.GONE); + //actionHelpMenuItem.setVisible(true); + } + + public void onHideHint(View v) { + hideHints(); + setOption(requireContext(),OPTION_SHOW_LEGEND, false); + } /** * Give the fetchers * @return the list of the fetchers diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java --- a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java +++ b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java @@ -68,7 +68,6 @@ public class MainScreenFragment extends ScreenBaseFragment implements FragmentListenerMain{ - private static final String OPTION_SHOW_LEGEND = "show_legend"; private static final String SAVED_FRAGMENT="saved_fragment"; private static final String DEBUG_TAG = "BusTO - MainFragment"; @@ -82,8 +81,7 @@ private EditText busStopSearchByIDEditText; private EditText busStopSearchByNameEditText; private ProgressBar progressBar; - private TextView howDoesItWorkTextView; - private Button hideHintButton; + private MenuItem actionHelpMenuItem; private FloatingActionButton floatingActionButton; private FrameLayout resultFrameLayout; @@ -279,8 +277,7 @@ busStopSearchByIDEditText = root.findViewById(R.id.busStopSearchByIDEditText); busStopSearchByNameEditText = root.findViewById(R.id.busStopSearchByNameEditText); progressBar = root.findViewById(R.id.progressBar); - howDoesItWorkTextView = root.findViewById(R.id.howDoesItWorkTextView); - hideHintButton = root.findViewById(R.id.hideHintButton); + swipeRefreshLayout = root.findViewById(R.id.listRefreshLayout); floatingActionButton = root.findViewById(R.id.floatingActionButton); resultFrameLayout = root.findViewById(R.id.resultFrame); @@ -311,7 +308,6 @@ coordLayout = root.findViewById(R.id.coord_layout); floatingActionButton.setOnClickListener((this::onToggleKeyboardLayout)); - hideHintButton.setOnClickListener(this::onHideHint); AppCompatImageButton qrButton = root.findViewById(R.id.QRButton); qrButton.setOnClickListener(this::onQRButtonClick); @@ -527,11 +523,7 @@ barcodeLauncher.launch(scanOptions); } } - public void onHideHint(View v) { - hideHints(); - setOption(OPTION_SHOW_LEGEND, false); - } /** * OK this is pure shit * @@ -618,18 +610,6 @@ busStopSearchByIDEditText.setSelection(busStopID.length()); } - private void showHints() { - howDoesItWorkTextView.setVisibility(View.VISIBLE); - hideHintButton.setVisibility(View.VISIBLE); - //actionHelpMenuItem.setVisible(false); - } - - private void hideHints() { - howDoesItWorkTextView.setVisibility(View.GONE); - hideHintButton.setVisibility(View.GONE); - //actionHelpMenuItem.setVisible(true); - } - @Nullable @org.jetbrains.annotations.Nullable @Override @@ -711,9 +691,6 @@ switch (fragmentType) { case ARRIVALS: prepareGUIForBusLines(); - if (getOption(OPTION_SHOW_LEGEND, true)) { - showHints(); - } break; case STOPS: prepareGUIForBusStops(); diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/ScreenBaseFragment.java b/app/src/main/java/it/reyboz/bustorino/fragments/ScreenBaseFragment.java --- a/app/src/main/java/it/reyboz/bustorino/fragments/ScreenBaseFragment.java +++ b/app/src/main/java/it/reyboz/bustorino/fragments/ScreenBaseFragment.java @@ -16,7 +16,7 @@ public abstract class ScreenBaseFragment extends Fragment { - protected final String PREF_FILE= BuildConfig.APPLICATION_ID+".fragment_prefs"; + protected final static String PREF_FILE= BuildConfig.APPLICATION_ID+".fragment_prefs"; protected void setOption(String optionName, boolean value) { Context mContext = getContext(); @@ -27,8 +27,8 @@ protected boolean getOption(String optionName, boolean optDefault) { Context mContext = getContext(); - SharedPreferences preferences = mContext.getSharedPreferences(PREF_FILE, MODE_PRIVATE); - return preferences.getBoolean(optionName, optDefault); + assert mContext != null; + return getOption(mContext, optionName, optDefault); } protected void showToastMessage(int messageID, boolean short_lenght) { @@ -52,4 +52,14 @@ */ @Nullable public abstract View getBaseViewForSnackBar(); + + public static boolean getOption(Context context, String optionName, boolean optDefault){ + SharedPreferences preferences = context.getSharedPreferences(PREF_FILE, MODE_PRIVATE); + return preferences.getBoolean(optionName, optDefault); + } + public static void setOption(Context context,String optionName, boolean value) { + SharedPreferences.Editor editor = context.getSharedPreferences(PREF_FILE, MODE_PRIVATE).edit(); + editor.putBoolean(optionName, value); + editor.apply(); + } } diff --git a/app/src/main/res/drawable/top_bottom_border_radius.xml b/app/src/main/res/drawable/top_bottom_border_radius.xml new file mode 100644 --- /dev/null +++ b/app/src/main/res/drawable/top_bottom_border_radius.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/top_bottom_border_radius_with_border.xml b/app/src/main/res/drawable/top_bottom_border_radius_with_border.xml new file mode 100644 --- /dev/null +++ b/app/src/main/res/drawable/top_bottom_border_radius_with_border.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_arrivals.xml b/app/src/main/res/layout/fragment_arrivals.xml --- a/app/src/main/res/layout/fragment_arrivals.xml +++ b/app/src/main/res/layout/fragment_arrivals.xml @@ -5,7 +5,41 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:paddingTop="8dp"> + android:paddingTop="8dp" + android:animateLayoutChanges="true"> + + +