fixed small errors

This commit is contained in:
IvanaE 2018-11-14 14:14:22 -05:00
parent 3155b66a7e
commit 6b72b3162c
11 changed files with 150 additions and 25 deletions

View file

@ -59,7 +59,8 @@
<activity
android:name=".EditProfile"
android:label="Edit Profile"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ServiceProviderServicesList"
android:label="List of Services"

View file

@ -163,7 +163,7 @@ public class AdminServicesList extends AppCompatActivity implements NewServiceDi
@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;
}

View file

@ -71,7 +71,7 @@ public class EditProfile extends AppCompatActivity {
&& companyname.getText().toString().matches("^[a-zA-Z0-9_ ]*$")
&& address.getText().toString().matches("^[a-zA-Z0-9_ ]*$")
&& phonenumber.getText().toString().matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")
) {
&& address.getText().toString().replaceAll("\\s+","").length()>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())){

View file

@ -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;
}

View file

@ -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);

View file

@ -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);

View file

@ -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<String[]> 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<users.size();i++){
String[] current = (String[])iter.next();
usernames[(i)*2] = current[0];
usernames[(i)*2+1] = current[3];
usernames[(i)] = current[0];
}
ArrayAdapter adapter = new ArrayAdapter<String>(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<MyAdapter.UsersHolder> {
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);
}
}
}
}

View file

@ -34,7 +34,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="15sp"
android:gravity="center"/>
android:paddingLeft="10dp"/>
<TextView
android:id="@+id/Title2"
@ -47,19 +47,21 @@
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="15sp"
android:gravity="center"/>
android:gravity="end"
android:paddingRight="10dp"/>
</LinearLayout>
<GridView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/Users"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="450dp"
android:numColumns="2"
android:textColor="@android:color/white"
android:textSize="15sp"
/>
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="400dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@color/colorWhite"
android:layout_marginBottom="5dp">
<TextView
android:paddingLeft="10dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:id="@+id/Name"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text=""
android:textColor="@color/colorBlack"
android:textSize="15sp"
/>
<TextView
android:id="@+id/Role"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:textColor="@color/colorBlack"
android:textSize="15sp"
android:gravity="end"/>
</LinearLayout>