added popups and services

This commit is contained in:
IvanaE 2018-10-28 19:31:34 -04:00
parent 60c0da3558
commit 7790edac33
15 changed files with 474 additions and 46 deletions

View file

@ -25,7 +25,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -30,13 +30,18 @@
<activity <activity
android:name=".SignUp" android:name=".SignUp"
android:screenOrientation="portrait"/> android:screenOrientation="portrait" />
<activity android:name=".LogIn" <activity
android:screenOrientation="portrait"/> android:name=".LogIn"
<activity android:name=".Welcome" android:screenOrientation="portrait" />
android:screenOrientation="portrait"/> <activity
<activity android:name=".AdminWelcome" android:name=".Welcome"
android:screenOrientation="portrait"/> android:screenOrientation="portrait" />
<activity
android:name=".AdminWelcome"
android:screenOrientation="portrait" />
<activity android:name=".UsersList" />
<activity android:name=".ServicesList"></activity>
</application> </application>
</manifest> </manifest>

View file

@ -4,13 +4,6 @@ import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.Iterator;
import java.util.List;
public class AdminWelcome extends AppCompatActivity { public class AdminWelcome extends AppCompatActivity {
@ -19,21 +12,6 @@ public class AdminWelcome extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_welcome); setContentView(R.layout.activity_admin_welcome);
DBHelper dbHelper = new DBHelper(this);
List<String[]> users = dbHelper.getAllUsers();
String[] usernames = new String[(users.size()+1)*2];
usernames[0] = "Username";
usernames[1] = "User Type";
Iterator iter = users.iterator();
for (int i=0; i<users.size();i++){
String[] current = (String[])iter.next();
usernames[(i+1)*2] = current[0];
usernames[(i+1)*2+1] = current[3];
}
ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames);
GridView gridView = (GridView) findViewById(R.id.Users);
gridView.setAdapter(adapter);
} }
@Override @Override
public void onBackPressed(){ public void onBackPressed(){
@ -44,4 +22,12 @@ public class AdminWelcome extends AppCompatActivity {
startActivity(intent); startActivity(intent);
finish(); finish();
} }
public void goToUsers(View view){
Intent intent = new Intent(getApplicationContext(), UsersList.class);
startActivity(intent);
}
public void goToServices(View view){
Intent intent = new Intent(getApplicationContext(), ServicesList.class);
startActivity(intent);
}
} }

View file

@ -0,0 +1,67 @@
package com.uottawa.olympus.olympusservices;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
public class EditServiceDialogFragment extends DialogFragment{
public interface NoticeDialogListener {
public void onDialogEdit(DialogFragment dialog);
public void onDialogDelete(DialogFragment dialog);
}
EditServiceDialogFragment.NoticeDialogListener mListener;
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
@Override
public void onAttach(Context context) {
super.onAttach(context);
// Verify that the host activity implements the callback interface
try {
// Instantiate the NoticeDialogListener so we can send events to the host
mListener = (EditServiceDialogFragment.NoticeDialogListener) context;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(this.toString()
+ " must implement NoticeDialogListener");
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialog_service_edit, null))
// Add action buttons
.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
args.putString("name", "hey");
args.putDouble("rate", 2.5);
//
EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogEdit(EditServiceDialogFragment.this);
}
})
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
args.putString("name", "hey");
//
EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogDelete(EditServiceDialogFragment.this);
}
});
return builder.create();
}
}

View file

@ -0,0 +1,63 @@
package com.uottawa.olympus.olympusservices;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
public class NewServiceDialogFragment extends DialogFragment {
public interface NoticeDialogListener {
public void onDialogNew(DialogFragment dialog);
public void onDialogNevermind(DialogFragment dialog);
}
NoticeDialogListener mListener;
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
@Override
public void onAttach(Context context) {
super.onAttach(context);
// Verify that the host activity implements the callback interface
try {
// Instantiate the NoticeDialogListener so we can send events to the host
mListener = (NoticeDialogListener) context;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(this.toString()
+ " must implement NoticeDialogListener");
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialog_service_new, null))
// Add action buttons
.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
args.putString("name", "hey");
args.putDouble("rate", 2.5);
///
NewServiceDialogFragment.this.setArguments(args);
mListener.onDialogNew(NewServiceDialogFragment.this);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
NewServiceDialogFragment.this.getDialog().cancel();
}
});
return builder.create();
}
}

View file

@ -0,0 +1,86 @@
package com.uottawa.olympus.olympusservices;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import java.util.Iterator;
import java.util.List;
public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_services_list);
DBHelper dbHelper = new DBHelper(this);
List<String[]> users = dbHelper.getAllServices();
String[] services = new String[(users.size()+1)*2];
services[0] = "Name";
services[1] = "Rate";
Iterator iter = users.iterator();
for (int i=0; i<users.size();i++){
String[] current = (String[])iter.next();
services[(i+1)*2] = current[0];
services[(i+1)*2+1] = current[1];
}
ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, services);
GridView gridView = findViewById(R.id.Services);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
editService(view);
}
});
}
public void addService(View view) {
DialogFragment newFragment = new NewServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "addService");
}
public void editService(View view) {
DialogFragment newFragment = new EditServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "editService");
}
//add new service
@Override
public void onDialogNew(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name");
Double rate = (Double)dialog.getArguments().get("rate");
dbHelper.addService(new Service(name,rate));
dialog.dismiss();
this.recreate();
}
//user clicked cancel
@Override
public void onDialogNevermind(DialogFragment dialog) {
}
//edits service with info from dialog
@Override
public void onDialogEdit(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name");
Double rate = (Double)dialog.getArguments().get("rate");
dbHelper.updateService(new Service(name,rate));
dialog.dismiss();
this.recreate();
}
//deletes service with info from dialog
@Override
public void onDialogDelete(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name");
dbHelper.deleteService(name);
dialog.dismiss();
this.recreate();
}
}

View file

@ -0,0 +1,33 @@
package com.uottawa.olympus.olympusservices;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import java.util.Iterator;
import java.util.List;
public class UsersList extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users_list);
DBHelper dbHelper = new DBHelper(this);
List<String[]> users = dbHelper.getAllUsers();
String[] usernames = new String[(users.size()+1)*2];
usernames[0] = "Username";
usernames[1] = "User Type";
Iterator iter = users.iterator();
for (int i=0; i<users.size();i++){
String[] current = (String[])iter.next();
usernames[(i+1)*2] = current[0];
usernames[(i+1)*2+1] = current[3];
}
ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames);
GridView gridView = findViewById(R.id.Users);
gridView.setAdapter(adapter);
}
}

View file

@ -24,28 +24,31 @@
android:textSize="20sp" android:textSize="20sp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
app:fontFamily="@font/julius_sans_one" /> app:fontFamily="@font/julius_sans_one" />
<LinearLayout
<Button
android:id="@+id/Users"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_marginTop="20dp"
android:onClick="goToUsers"
<GridView android:text="List of Users"
android:id="@+id/Users" android:theme="@style/AppTheme.Button" />
android:layout_width="fill_parent" <Button
android:layout_weight="1" android:id="@+id/Services"
android:layout_height="250dp" android:layout_width="match_parent"
android:numColumns="2" android:layout_height="wrap_content"
android:textColor="@android:color/white" android:layout_marginTop="20dp"
android:textSize="15sp" /> android:onClick="goToServices"
android:text="List of Services"
</LinearLayout> android:theme="@style/AppTheme.Button" />
<Button <Button
android:id="@+id/LogOut" android:id="@+id/LogOut"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="50dp"
android:onClick="LogOut" android:onClick="LogOut"
android:text="Logout" android:text="Logout"
android:theme="@style/AppTheme.Button" /> android:theme="@style/AppTheme.Button" />
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".ServicesList">
<TextView
android:id="@+id/Welcome"
android:layout_width="300dp"
android:layout_height="80dp"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="List of Services"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="20sp"
android:layout_marginTop="10dp"
app:fontFamily="@font/julius_sans_one" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<GridView
android:id="@+id/Services"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="250dp"
android:numColumns="2"
android:textColor="@android:color/white"
android:textSize="15sp" />
</LinearLayout>
<Button
android:id="@+id/newService"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Add New Service"
android:onClick="addService"
android:theme="@style/AppTheme.Button" />
</LinearLayout>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".Welcome">
<TextView
android:id="@+id/Welcome"
android:layout_width="300dp"
android:layout_height="80dp"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="List of Users"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="20sp"
android:layout_marginTop="10dp"
app:fontFamily="@font/julius_sans_one" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<GridView
android:id="@+id/Users"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:numColumns="2"
android:textColor="@android:color/white"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/NameInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:hint="@string/servicename"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
app:met_singleLineEllipsis="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/RateInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:hint="@string/servicerate"
android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
app:met_singleLineEllipsis="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
</LinearLayout>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/NameInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:hint="@string/servicename"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
app:met_singleLineEllipsis="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/RateInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:hint="@string/servicerate"
android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
app:met_singleLineEllipsis="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
</LinearLayout>

View file

@ -2,7 +2,7 @@
<resources> <resources>
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#303F9F</color>
<color name="colorWhite">#FFFFFF</color> <color name="colorWhite">#FFFFFF</color>
<color name="colorBlack">#000000</color> <color name="colorBlack">#000000</color>
</resources> </resources>

View file

@ -21,6 +21,13 @@
<string name="newpassword">Enter Password</string> <string name="newpassword">Enter Password</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="username">Username</string> <string name="username">Username</string>
<string name="servicename">Service Name</string>
<string name="servicerate">Service Rate</string>
<string name="save">Save</string>
<string name="cancel">Cancel</string>
<string name="update">Update</string>
<string name="delete">Delete</string>
<string name="add">Add</string>
<string-array name="roles"> <string-array name="roles">
<item>Admin</item> <item>Admin</item>
<item>User</item> <item>User</item>