diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser
index 46974ea..004dcba 100644
Binary files a/OlympusServices/.idea/caches/build_file_checksums.ser and b/OlympusServices/.idea/caches/build_file_checksums.ser differ
diff --git a/OlympusServices/app/src/main/AndroidManifest.xml b/OlympusServices/app/src/main/AndroidManifest.xml
index d2c0e60..fe68bbe 100644
--- a/OlympusServices/app/src/main/AndroidManifest.xml
+++ b/OlympusServices/app/src/main/AndroidManifest.xml
@@ -59,7 +59,8 @@
+ android:screenOrientation="portrait"
+ android:windowSoftInputMode="stateHidden"/>
0) {
if(dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(),
address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), licensed.isChecked())){
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java
index d2b8184..81a56e0 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java
@@ -13,7 +13,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
@@ -188,7 +187,7 @@ public class ServiceProviderServicesList extends AppCompatActivity implements De
@Override
public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.list_item, parent, false);
+ .inflate(R.layout.service_list_item, parent, false);
ServicesHolder vh = new ServicesHolder(v);
return vh;
}
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java
index 9d9300d..299c5ee 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java
@@ -54,7 +54,8 @@ public class SignUp extends AppCompatActivity {
String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString();
MaterialSpinner spinner = findViewById(R.id.RoleInput);
- if(username.length()>=5 && password.length()>=5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
+ if(username.length()>=5 && password.length()>=5 && firstname.length()>0 && lastname.length()>0
+ && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
DBHelper dbHelper = new DBHelper(this);
Intent intent = new Intent(getApplicationContext(),LogIn.class);
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java
index d3b4672..48ab789 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java
@@ -35,7 +35,9 @@ public class SignUpPart2 extends AppCompatActivity {
if(companyname.length()>0 && address.length()>0 && phonenumber.length()>0
&& companyname.matches("^[a-zA-Z0-9_ ]*$") && address.matches("^[a-zA-Z0-9_ ]*$")
- && phonenumber.matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")) {
+ && phonenumber.matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")
+ && companyname.replaceAll("\\s+","").length()>0
+ && address.replaceAll("\\s+","").length()>0) {
ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname,
address, phonenumber, companyname, licensed);
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java
index b1f34d7..f407880 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java
@@ -1,9 +1,17 @@
package com.uottawa.olympus.olympusservices;
+import android.content.Context;
+import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
+import android.widget.TextView;
import java.util.Iterator;
import java.util.List;
@@ -24,22 +32,98 @@ public class UsersList extends AppCompatActivity {
*
* @param savedInstanceState bundle to transfer data
*/
+
+ //field for RecyclerView
+ private RecyclerView mRecyclerView;
+ //field for adapter of Recycler view
+ private RecyclerView.Adapter mAdapter;
+ //field for layout manager of Recyler view.
+ private RecyclerView.LayoutManager mLayoutManager;
+
+ private DBHelper dbHelper;
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users_list);
- DBHelper dbHelper = new DBHelper(this);
+ dbHelper = new DBHelper(this);
List users = dbHelper.getAllUsers();
- String[] usernames = new String[(users.size())*2];
+ String[] usernames = new String[(users.size())];
Iterator iter = users.iterator();
for (int i=0; i(this, R.layout.simple_list_item_1_customized, usernames);
- GridView gridView = findViewById(R.id.Users);
- gridView.setAdapter(adapter);
+
+
+ mRecyclerView = (RecyclerView) findViewById(R.id.Users);
+
+
+ mLayoutManager = new LinearLayoutManager(this);
+ mRecyclerView.setLayoutManager(mLayoutManager);
+
+ mAdapter = new UsersList.MyAdapter(usernames, this);
+ mRecyclerView.setAdapter(mAdapter);
}
+
+
+ public class MyAdapter extends RecyclerView.Adapter {
+
+ private String[] users;
+ private Context context;
+
+ // Provide a reference to the views for each data item
+ // Complex data items may need more than one view per item, and
+ // you provide access to all the views for a data item in a view holder
+
+ // Provide a suitable constructor (depends on the kind of dataset)
+ public MyAdapter(String[] users, Context context) {
+ this.users = users;
+ }
+
+ // Create new views (invoked by the layout manager)
+ @NonNull
+ @Override
+ public UsersHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View v = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.user_list_item, parent, false);
+ return new UsersHolder(v);
+ }
+
+ // Replace the contents of a view (invoked by the layout manager)
+ @Override
+ public void onBindViewHolder(UsersHolder holder, int position) {
+ UserType user = dbHelper.findUserByUsername(users[position]);
+ holder.name.setText(user.getUsername());
+ holder.rate.setText(user.getRole());
+
+
+
+ }
+
+ // Return the size of your dataset (invoked by the layout manager)
+ @Override
+ public int getItemCount() {
+ return users.length;
+ }
+
+ class UsersHolder extends RecyclerView.ViewHolder{
+
+ TextView name;
+ TextView rate;
+
+ public UsersHolder(View row){
+ super(row);
+ name = row.findViewById(R.id.Name);
+ rate = row.findViewById(R.id.Role);
+ }
+
+ }
+
+
+ }
+
+
}
diff --git a/OlympusServices/app/src/main/res/layout/activity_users_list.xml b/OlympusServices/app/src/main/res/layout/activity_users_list.xml
index 02964ab..6b05bc9 100644
--- a/OlympusServices/app/src/main/res/layout/activity_users_list.xml
+++ b/OlympusServices/app/src/main/res/layout/activity_users_list.xml
@@ -34,7 +34,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="15sp"
- android:gravity="center"/>
+ android:paddingLeft="10dp"/>
+ android:gravity="end"
+ android:paddingRight="10dp"/>
-
- />
+
+
+
diff --git a/OlympusServices/app/src/main/res/layout/list_item.xml b/OlympusServices/app/src/main/res/layout/service_list_item.xml
similarity index 100%
rename from OlympusServices/app/src/main/res/layout/list_item.xml
rename to OlympusServices/app/src/main/res/layout/service_list_item.xml
diff --git a/OlympusServices/app/src/main/res/layout/user_list_item.xml b/OlympusServices/app/src/main/res/layout/user_list_item.xml
new file mode 100644
index 0000000..e2eefee
--- /dev/null
+++ b/OlympusServices/app/src/main/res/layout/user_list_item.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+