Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global navigation implementation for all details pages. #7

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app_main/src/main/java/com/hover/runner/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.hover.runner.enums.GlobalNav;
import com.hover.sdk.api.Hover;
import com.hover.sdk.permissions.PermissionActivity;
import com.hover.runner.api.Apis;
Expand Down Expand Up @@ -54,6 +55,17 @@ protected void onCreate(Bundle savedInstanceState) {
initialActionFilter = getIntent().getExtras().getString("navigate");
navController.navigate(R.id.navigation_transactions);
}
GlobalNav globalNavPos = (GlobalNav) getIntent().getExtras().get(Apis.GLOBAL_NAV);
if(globalNavPos !=null) {
switch (globalNavPos) {
case NAV_ACTION: navController.navigate(R.id.navigation_actions);
break;
case NAV_TRANSACTION: navController.navigate(R.id.navigation_transactions);
break;
case NAV_SETTINGS: navController.navigate(R.id.navigation_settings);
break;
}
}
}

}
Expand Down
1 change: 1 addition & 0 deletions app_main/src/main/java/com/hover/runner/api/Apis.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class Apis {
public static final String TRANS_ID = "trans_id";
public static final String TRANS_DATE = "trans_date";
public static final String TRANS_STATUS = "trans_status";
public static final String GLOBAL_NAV = "globalNav";


public LoginModel doLoginWorkManager(String email, String password) {
Expand Down
5 changes: 5 additions & 0 deletions app_main/src/main/java/com/hover/runner/enums/GlobalNav.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.hover.runner.enums;

public enum GlobalNav {
NAV_ACTION, NAV_TRANSACTION, NAV_SETTINGS
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.recyclerview.widget.RecyclerView;

import com.hover.runner.ApplicationInstance;
import com.hover.runner.enums.GlobalNav;
import com.hover.runner.models.TransactionModels;
import com.hover.runner.states.TransactionState;
import com.hover.sdk.api.HoverParameters;
Expand Down Expand Up @@ -91,6 +92,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
});
mostRecentStatus = ActionDetailsActivity.statusEnums;
setupTopDetailsInfo(mostRecentStatus);
setupGlobalNav(view);

RecyclerView variablesRecyclerView = view.findViewById(R.id.action_variables_recyclerView);
actionDetailsViewModel = new ViewModelProvider(this).get(ActionDetailsViewModel.class);
Expand Down Expand Up @@ -271,6 +273,12 @@ public void onResume() {
actionDetailsViewModel.getActionTrans(ActionDetailsActivity.actionId);

}
private void setupGlobalNav(View view) {
view.findViewById(R.id.global_nav_Actions).setOnClickListener(v ->UIHelper.doGlobalNavigation(GlobalNav.NAV_ACTION, getActivity()));
view.findViewById(R.id.global_nav_Transactions).setOnClickListener(v -> UIHelper.doGlobalNavigation(GlobalNav.NAV_TRANSACTION, getActivity()));
view.findViewById(R.id.global_nav_Settings).setOnClickListener(v->UIHelper.doGlobalNavigation(GlobalNav.NAV_SETTINGS, getActivity()));
}


@Override
public void customClickListener(Object... data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.hover.runner.enums.GlobalNav;
import com.hover.sdk.actions.HoverAction;
import com.hover.sdk.api.Hover;
import com.hover.sdk.api.HoverParameters;
Expand Down Expand Up @@ -77,6 +78,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

UIHelper.setTextUnderline(filterText, getResources().getString(R.string.filter_text));


//CALL THE FILTER FUNCTION
filterText.setOnClickListener(v -> {
Intent i = new Intent(getActivity(), ActionFilterActivity.class);
Expand Down Expand Up @@ -248,6 +250,7 @@ else if(actionRunCounter == withCompletedVariableActionList.size()) {
}



@Override
public void customClickListener(Object... data) {
assert data!=null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.hover.runner.R;
import com.hover.runner.adapters.TransactionRecyclerAdapter;
import com.hover.runner.api.Apis;
import com.hover.runner.enums.GlobalNav;
import com.hover.runner.enums.StatusEnums;
import com.hover.runner.interfaces.CustomOnClickListener;
import com.hover.runner.ui.action_details.ActionDetailsActivity;
Expand Down Expand Up @@ -111,10 +112,15 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

parsersViewModel.getParsersInfo(ParsersActivity.parserId);
parsersViewModel.getParserTransactions(ParsersActivity.parserId);

setupGlobalNav(view);

return view;
}
private void setupGlobalNav(View view) {
view.findViewById(R.id.global_nav_Actions).setOnClickListener(v ->UIHelper.doGlobalNavigation(GlobalNav.NAV_ACTION, getActivity()));
view.findViewById(R.id.global_nav_Transactions).setOnClickListener(v -> UIHelper.doGlobalNavigation(GlobalNav.NAV_TRANSACTION, getActivity()));
view.findViewById(R.id.global_nav_Settings).setOnClickListener(v->UIHelper.doGlobalNavigation(GlobalNav.NAV_SETTINGS, getActivity()));
}

private void startActionActivity(String actionId, String actionTitle, StatusEnums statusEnums) {
Intent i = new Intent(getActivity(), ActionDetailsActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.hover.runner.adapters.TransactionMessagesRecyclerAdapter;
import com.hover.runner.api.Apis;
import com.hover.runner.enums.ClickTypeEnum;
import com.hover.runner.enums.GlobalNav;
import com.hover.runner.interfaces.CustomOnClickListener;
import com.hover.runner.ui.action_details.ActionDetailsActivity;
import com.hover.runner.ui.parsers.ParsersActivity;
Expand Down Expand Up @@ -138,9 +139,15 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
transactionDetailsViewModel.getDeviceModels(TransactionDetailsActivity.transactionId);
transactionDetailsViewModel.getMessagesModels(TransactionDetailsActivity.transactionId);

setupGlobalNav(view);
return view;
}

private void setupGlobalNav(View view) {
view.findViewById(R.id.global_nav_Actions).setOnClickListener(v ->UIHelper.doGlobalNavigation(GlobalNav.NAV_ACTION, getActivity()));
view.findViewById(R.id.global_nav_Transactions).setOnClickListener(v -> UIHelper.doGlobalNavigation(GlobalNav.NAV_TRANSACTION, getActivity()));
view.findViewById(R.id.global_nav_Settings).setOnClickListener(v->UIHelper.doGlobalNavigation(GlobalNav.NAV_SETTINGS, getActivity()));
}
@Override
public void customClickListener(Object... data) {
if (data[0] == ClickTypeEnum.CLICK_ACTION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.hover.runner.R;
import com.hover.runner.adapters.TransactionRecyclerAdapter;
import com.hover.runner.api.Apis;
import com.hover.runner.enums.GlobalNav;
import com.hover.runner.enums.StatusEnums;
import com.hover.runner.interfaces.CustomOnClickListener;
import com.hover.runner.ui.transactionDetails.TransactionDetailsActivity;
Expand Down
13 changes: 13 additions & 0 deletions app_main/src/main/java/com/hover/runner/utils/UIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
Expand All @@ -22,13 +23,23 @@
import com.google.android.material.snackbar.Snackbar;

import com.hover.runner.ApplicationInstance;
import com.hover.runner.MainActivity;
import com.hover.runner.R;
import com.hover.runner.api.Apis;
import com.hover.runner.enums.GlobalNav;
import com.hover.runner.enums.StatusEnums;
import com.hover.runner.interfaces.ParserClickListener;

public class UIHelper {
private static final int INITIAL_ITEMS_FETCH = 30;

public static void doGlobalNavigation(GlobalNav nav, Activity activity) {
Intent intent = new Intent(activity, MainActivity.class);
intent.putExtra(Apis.GLOBAL_NAV, nav);
activity.startActivity(intent);
activity.finishAffinity();
}

public static LinearLayoutManager setMainLinearManagers(Context context) {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
linearLayoutManager.setInitialPrefetchItemCount(INITIAL_ITEMS_FETCH);
Expand Down Expand Up @@ -136,4 +147,6 @@ private static String getPackage(Context c) {





}
4 changes: 4 additions & 0 deletions app_main/src/main/res/layout/action_details_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,8 @@
android:textColor="@color/runActionTextColor"
android:id="@+id/testSingle_id"
android:text="@string/test_single_action"/>

<include layout="@layout/global_nav"/>


</LinearLayout>
1 change: 0 additions & 1 deletion app_main/src/main/res/layout/fragment_transactions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:layout_marginBottom="55dp"
tools:context=".ui.transactions.TransactionFragment">

<LinearLayout
Expand Down
49 changes: 49 additions & 0 deletions app_main/src/main/res/layout/global_nav.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Actions"
android:layout_gravity="center"
android:gravity="center"
android:textSize="12sp"
android:id="@+id/global_nav_Actions"
android:drawablePadding="4dp"
android:textColor="@color/colorMainGrey"
android:drawableTop="@drawable/ic_device_hub_grey_24dp"/>

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transactions"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="12sp"
android:id="@+id/global_nav_Transactions"
android:layout_marginHorizontal="16dp"
android:drawablePadding="4dp"
android:textColor="@color/colorMainGrey"
android:drawableTop="@drawable/ic_list_grey_24dp"/>

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Settings"
android:textSize="12sp"
android:id="@+id/global_nav_Settings"
android:drawablePadding="4dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="@color/colorMainGrey"
android:drawableTop="@drawable/ic_settings_grey_24dp"/>

</LinearLayout>
23 changes: 16 additions & 7 deletions app_main/src/main/res/layout/parsers_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>

<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimaryDark"
>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="@dimen/activity_vertical_margin"
android:layout_height="0dp"
android:paddingTop="@dimen/activity_vertical_margin"
android:layout_weight="1"
android:orientation="vertical">

<TextView
Expand Down Expand Up @@ -249,6 +256,8 @@
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/parser_transac_recyclerView"/>

</LinearLayout>
</androidx.core.widget.NestedScrollView>

</androidx.core.widget.NestedScrollView>
<include layout="@layout/global_nav"/>
</LinearLayout>
14 changes: 12 additions & 2 deletions app_main/src/main/res/layout/transaction_details_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
>


<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
tools:context=".ui.transactionDetails.TransactionDetailsFragment"
android:layout_weight="1"
android:layout_height="wrap_content">

<LinearLayout
Expand Down Expand Up @@ -184,4 +192,6 @@

</LinearLayout>

</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
<include layout="@layout/global_nav"/>
</LinearLayout>