Skip to content

Commit

Permalink
project crm
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteglobe committed Feb 17, 2020
1 parent 03c37a6 commit 1900ae7
Show file tree
Hide file tree
Showing 17 changed files with 448 additions and 41 deletions.
57 changes: 52 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,30 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".MarketingDetails"></activity>
<activity android:name=".Marketing" />
<activity android:name=".AddReminder" />

<activity android:name=".MarketingDetails"
android:configChanges="orientation"
android:screenOrientation="portrait" />

<activity android:name=".Marketing"
android:configChanges="orientation"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >

<meta-data
android:name="android.app.searchable"
android:resource="@xml/marketingsearch" />

<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>

</activity>

<activity android:name=".AddReminder"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name=".QuotationDetails"
android:screenOrientation="landscape" />
Expand Down Expand Up @@ -131,7 +152,19 @@
<activity
android:name=".Customers"
android:configChanges="orientation"
android:screenOrientation="portrait" />
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >

<meta-data
android:name="android.app.searchable"
android:resource="@xml/customersearch" />

<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>

</activity>
<activity
android:name=".ProductDetails"
android:configChanges="orientation"
Expand Down Expand Up @@ -192,10 +225,24 @@
android:name=".LeadDetails"
android:configChanges="orientation"
android:screenOrientation="portrait" />

<activity
android:name=".Leads"
android:label="@string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" >

<meta-data
android:name="android.app.searchable"
android:resource="@xml/leadsearch" />

<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>

</activity>

<activity
android:name=".UpdateUser"
android:configChanges="orientation"
Expand Down
53 changes: 49 additions & 4 deletions app/src/main/java/com/whiteglobe/crm/Customers.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.whiteglobe.crm;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.ProgressDialog;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

Expand All @@ -32,18 +38,27 @@ public class Customers extends AppCompatActivity {

RecyclerView recyclerView;
RecyclerView.LayoutManager recyclerViewlayoutManager;
RecyclerView.Adapter recyclerViewadapter;
CustomersAdapter customersAdapter;

private ProgressDialog pDialog;
private static String TAG = Customers.class.getSimpleName();

List<CustomersGS> allCustomers;

private SearchView searchView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customers);
getSupportActionBar().hide();

Toolbar toolbar = findViewById(R.id.toolbarCustomers);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Customers");

// toolbar fancy stuff
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

recyclerView = findViewById(R.id.recyclerViewCustomers);
recyclerView.setHasFixedSize(true);
Expand All @@ -70,6 +85,35 @@ public void onLongClick(View view, int position) {
getAllCustomerDataOfUser();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_customer, menu);

// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.action_search_customer).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setMaxWidth(Integer.MAX_VALUE);

// listening to search query text change
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// filter recycler view when query submitted
customersAdapter.getFilter().filter(query);
return false;
}

@Override
public boolean onQueryTextChange(String query) {
// filter recycler view when text is changed
customersAdapter.getFilter().filter(query);
return false;
}
});
return super.onCreateOptionsMenu(menu);
}

private void getAllCustomerDataOfUser() {

pDialog = new ProgressDialog(this);
Expand Down Expand Up @@ -102,8 +146,9 @@ public void onResponse(JSONObject response) {
jsonObject = jsonArray.getJSONObject(i);
allCustomers.add(new CustomersGS(jsonObject.getInt("CustomerID"),jsonObject.getString("CustomerName"),jsonObject.getString("CustomerEmail"),jsonObject.getString("CustomerOfficePhone")));
}
recyclerViewadapter = new CustomersAdapter(allCustomers, getApplicationContext());
recyclerView.setAdapter(recyclerViewadapter);
customersAdapter = new CustomersAdapter(allCustomers, getApplicationContext());
recyclerView.setAdapter(customersAdapter);
customersAdapter.notifyDataSetChanged();
}
else if(response.getInt("success") == 0)
{
Expand Down
46 changes: 43 additions & 3 deletions app/src/main/java/com/whiteglobe/crm/CustomersAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class CustomersAdapter extends RecyclerView.Adapter<CustomersAdapter.ViewHolder> {
public class CustomersAdapter extends RecyclerView.Adapter<CustomersAdapter.ViewHolder> implements Filterable {
Context context;
List<CustomersGS> allCustomerData;
List<CustomersGS> allCustomerDataFiltered;

public CustomersAdapter(List<CustomersGS> getDataAdapter, Context context){

super();

this.allCustomerData = getDataAdapter;
this.allCustomerDataFiltered = getDataAdapter;

this.context = context;
}
Expand All @@ -36,7 +41,7 @@ public CustomersAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int view
@Override
public void onBindViewHolder(CustomersAdapter.ViewHolder holder, int position) {

CustomersGS customersGS = allCustomerData.get(position);
CustomersGS customersGS = allCustomerDataFiltered.get(position);

holder.txtCustomerName.setText(customersGS.getCustName());
holder.txtCardCustomerEmail.setText(customersGS.getCustEmail());
Expand All @@ -47,7 +52,7 @@ public void onBindViewHolder(CustomersAdapter.ViewHolder holder, int position) {
@Override
public int getItemCount() {

return allCustomerData.size();
return allCustomerDataFiltered.size();
}

class ViewHolder extends RecyclerView.ViewHolder{
Expand All @@ -65,4 +70,39 @@ public ViewHolder(View itemView) {
txtCardCustomerPhone = itemView.findViewById(R.id.txtCardCustomerPhone) ;
}
}

@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence charSequence) {
String charString = charSequence.toString();
if (charString.isEmpty()) {
allCustomerDataFiltered = allCustomerData;
} else {
List<CustomersGS> filteredList = new ArrayList<>();
for (CustomersGS row : allCustomerData) {

// name match condition. this might differ depending on your requirement
// here we are looking for name or phone number match
if (row.getCustName().toLowerCase().contains(charString.toLowerCase()) || row.getCustPhone().contains(charString)) {
filteredList.add(row);
}
}

allCustomerDataFiltered = filteredList;
}

FilterResults filterResults = new FilterResults();
filterResults.values = allCustomerDataFiltered;
return filterResults;
}

@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
allCustomerDataFiltered = (ArrayList<CustomersGS>) filterResults.values;
notifyDataSetChanged();
}
};
}
}
52 changes: 48 additions & 4 deletions app/src/main/java/com/whiteglobe/crm/Leads.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.whiteglobe.crm;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.ProgressDialog;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;
Expand All @@ -36,7 +41,7 @@ public class Leads extends AppCompatActivity {

RecyclerView recyclerView;
RecyclerView.LayoutManager recyclerViewlayoutManager;
RecyclerView.Adapter recyclerViewadapter;
LeadsAdapter leadsAdapter;
List<LeadGS> allLeads;

SharedPreferences sessionUserAccount;
Expand All @@ -45,11 +50,20 @@ public class Leads extends AppCompatActivity {

FloatingActionButton btnAddNewLead;

private SearchView searchView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_leads);
getSupportActionBar().hide();

Toolbar toolbar = findViewById(R.id.toolbarLeads);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Leads");

// toolbar fancy stuff
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

recyclerView = findViewById(R.id.recyclerViewLeads);
recyclerView.setHasFixedSize(true);
Expand Down Expand Up @@ -86,6 +100,35 @@ public void onClick(View view) {
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_leads, menu);

// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.action_search_leads).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setMaxWidth(Integer.MAX_VALUE);

// listening to search query text change
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// filter recycler view when query submitted
leadsAdapter.getFilter().filter(query);
return false;
}

@Override
public boolean onQueryTextChange(String query) {
// filter recycler view when text is changed
leadsAdapter.getFilter().filter(query);
return false;
}
});
return super.onCreateOptionsMenu(menu);
}

private void getAllLeadsDataOfUser(String u_name) {

pDialog = new ProgressDialog(this);
Expand Down Expand Up @@ -118,8 +161,9 @@ public void onResponse(JSONObject response) {
jsonObject = jsonArray.getJSONObject(i);
allLeads.add(new LeadGS(jsonObject.getInt("RL_Id"),jsonObject.getString("RL_Title"),jsonObject.getString("RL_Company_Name"),jsonObject.getString("RL_Phone")));
}
recyclerViewadapter = new LeadsAdapter(allLeads, getApplicationContext());
recyclerView.setAdapter(recyclerViewadapter);
leadsAdapter = new LeadsAdapter(allLeads, getApplicationContext());
recyclerView.setAdapter(leadsAdapter);
leadsAdapter.notifyDataSetChanged();
}
} catch (JSONException e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit 1900ae7

Please sign in to comment.