Skip to content

Commit

Permalink
Merge branch 'uiux' into feature/user_mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
FolkLoreee committed Sep 7, 2021
2 parents 05424ce + 2dcecbe commit 31babbd
Show file tree
Hide file tree
Showing 87 changed files with 5,217 additions and 603 deletions.
5 changes: 3 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions .idea/runConfigurations.xml

This file was deleted.

10 changes: 8 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
applicationId "com.infosys.stocktake"
minSdkVersion 27
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand All @@ -34,7 +34,7 @@ android {

dependencies {
implementation 'com.android.support:support-annotations:28.0.0'

implementation 'org.adw.library:discrete-seekbar:1.0.1'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
Expand Down Expand Up @@ -87,6 +87,12 @@ dependencies {

implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'

implementation 'com.google.android.material:material:1.0.0-beta01'


implementation project(':navigationtabbar')


// QR Scanner
dependencies {
implementation 'com.budiyev.android:code-scanner:2.1.0'
Expand Down
48 changes: 20 additions & 28 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />



<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />

<uses-feature android:name="android.hardware.nfc" />

Expand All @@ -21,36 +20,29 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:icon">
<!-- Inventory Activities-->
<activity android:name=".inventory.InventoryActivity"/>
<activity android:name=".inventory.items.ItemDetailsActivity"></activity>
<activity android:name=".inventory.items.AddItemActivity" />

<!-- QR Activities-->
<activity android:name=".loans.ReturnHealthCheck"></activity>
<!-- Inventory Activities -->
<activity android:name=".inventory.InventoryActivity" />
<activity android:name=".inventory.items.ItemDetailsActivity" />
<activity android:name=".inventory.items.AddItemActivity" /> <!-- QR Activities -->
<activity android:name=".qr.QrScannerActivity" />
<activity android:name=".qr.QrOptionsActivity"
></activity>

<!-- Loan Activities-->
<activity android:name=".inventory.itemloanhistory.ItemLoanHistoryActivity"/>
<activity android:name=".loans.AddLoanActivity"/>
<activity android:name=".loans.LoanDetailsActivity"/>

<!-- Profile Activities-->
<activity android:name=".Profile"></activity>
<activity android:name=".auth.ProfileSetupActivity"></activity>
<activity android:name=".nfc.NfcReaderActivity"></activity>
<activity android:name=".loans.PersonalLoanHistoryActivity"/>
<activity android:name=".inventory.clubs.ViewClubActivity" />

<!-- Auth Activities-->
<activity android:name=".qr.QrOptionsActivity" /> <!-- Loan Activities -->
<activity android:name=".inventory.itemloanhistory.ItemLoanHistoryActivity" />
<activity android:name=".loans.AddLoanActivity" />
<activity android:name=".loans.LoanDetailsActivity" /> <!-- Profile Activities -->
<activity android:name=".Profile" />
<activity android:name=".auth.ProfileSetupAddClubActivity" />
<activity android:name=".auth.ProfileSetupActivity" />
<activity android:name=".nfc.NfcReaderActivity" />
<activity android:name=".loans.PersonalLoanHistoryActivity" />
<activity android:name=".HomeActivity"/>
<activity android:name=".inventory.clubs.ViewClubActivity" /> <!-- Auth Activities -->
<activity android:name=".auth.GoogleLoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />


<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- SuperAdmin Activities-->
<activity android:name=".superadmin.SuperadminClubViewActivity"/>
Expand Down
239 changes: 239 additions & 0 deletions app/src/main/java/com/infosys/stocktake/HomeActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
package com.infosys.stocktake;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.appbar.CollapsingToolbarLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.PagerAdapter;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.google.firebase.auth.FirebaseAuth;
import com.infosys.stocktake.firebase.StockTakeFirebase;
import com.infosys.stocktake.inventory.InventoryAdapter;
import com.infosys.stocktake.inventory.clubs.ClubFragment;
import com.infosys.stocktake.models.Membership;
import com.infosys.stocktake.models.User;


//import androidx.viewpager.widget.ViewPager;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import devlight.io.library.ntb.NavigationTabBar;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
* Created by GIGAMOLE on 28.03.2016.
*/
public class HomeActivity extends AppCompatActivity {

private ViewPager viewPager;
private InventoryAdapter inventoryAdapter;
private TabLayout tabLayout;
private User currentUser;
private String currentClub;
private final String userUID = FirebaseAuth.getInstance().getCurrentUser().getUid();
private final String TAG = "Inventory Activity: ";
private boolean toClub;


@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
getCurrentUser();
Intent intent = getIntent();
toClub = intent.getBooleanExtra("toClub", false);
Log.d(TAG, "toClub: " + toClub);
setContentView(R.layout.activity_home_screen);
initUI();
}

private void getCurrentUser(){
StockTakeFirebase<User> stockTakeFirebase = new StockTakeFirebase<>(User.class,"users");
Task<User> userTask = stockTakeFirebase.query(userUID);
userTask.addOnSuccessListener(new OnSuccessListener<User>() {
@Override
public void onSuccess(User user) {
currentUser = user;
Log.d(TAG, "User is: " + user.getTelegramHandle());
setUpViews();
}
});

userTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Failed to get user");
}
});

}

private void setUpViews(){
Map<String, Membership> membershipMap = currentUser.getClubMembership();
Log.d(TAG, "MembershipMap: " + membershipMap.toString());
Log.d(TAG, "setUpViews: " + membershipMap.entrySet().iterator().next().getKey().toString());
if(membershipMap.size() != 0) {
Map.Entry<String, Membership> entry = membershipMap.entrySet().iterator().next();
currentClub = entry.getKey();
}
else{
currentClub = "";
}


viewPager = findViewById(R.id.vp_horizontal_ntb);
inventoryAdapter = new InventoryAdapter(getSupportFragmentManager(), currentUser, membershipMap, toClub);
viewPager.setAdapter(inventoryAdapter);
}

private void initUI() {
final String[] colors = getResources().getStringArray(R.array.default_preview);

final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_baseline_heart_24),
Color.parseColor(colors[0]))
.title("My Club")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_baseline_search_24),
Color.parseColor(colors[1]))
.title("Other Club")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_baseline_shopping_cart_24),
Color.parseColor(colors[2]))
.title("My Loans")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_baseline_account_circle_24),
Color.parseColor(colors[3]))
.title("Profile")
.build()
);

navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);

//IMPORTANT: ENABLE SCROLL BEHAVIOUR IN COORDINATOR LAYOUT
navigationTabBar.setBehaviorEnabled(true);

navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@Override
public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
}

@Override
public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
model.hideBadge();
}
});
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {

}

@Override
public void onPageSelected(final int position) {

}

@Override
public void onPageScrollStateChanged(final int state) {

}
});

final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.parent);
// findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
// final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
// navigationTabBar.postDelayed(new Runnable() {
// @Override
// public void run() {
// final String title = String.valueOf(new Random().nextInt(15));
// if (!model.isBadgeShowed()) {
// model.setBadgeTitle(title);
// model.showBadge();
// } else model.updateBadgeTitle(title);
// }
// }, i * 100);
// }
//
////
// }
// });

final CollapsingToolbarLayout collapsingToolbarLayout =
(CollapsingToolbarLayout) findViewById(R.id.toolbar);
collapsingToolbarLayout.setExpandedTitleColor(Color.parseColor("#009F90AF"));
collapsingToolbarLayout.setCollapsedTitleTextColor(Color.parseColor("#3399FF"));
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.text_size);
}

public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.ViewHolder> {

@Override
public ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.my_club_item_list, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
holder.txt.setText(String.format("Navigation Item #%d", position));
}

@Override
public int getItemCount() {
return 20;
}

public class ViewHolder extends RecyclerView.ViewHolder {

public TextView txt;

public ViewHolder(final View itemView) {
super(itemView);
txt = (TextView) itemView.findViewById(R.id.txt_vp_item_list);
}
}
}
}
Loading

0 comments on commit 31babbd

Please sign in to comment.