Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
/.idea/misc.xml
40 changes: 0 additions & 40 deletions .idea/misc.xml

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

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ public User retrieveUserByName(User user) {
public List<User> retirveAll() {
return dao.retrieveUsers();
}

/*@Override
public void setNewPrefferedTaxiService(String newservice) {dao.setNewPrefferedTaxiService(newservice);}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public class User extends SugarRecord
private Sex sex;
private int sexDB;
private String prefferedTaxiService;
private int prefferedTaxiServicePosition;
private String emergencyNumber;

public User() {
}

public User(long id, String name, int age, double weight, Sex sex, String prefferedTaxiService, String emergencyNumber) {
public User(long id, String name, int age, double weight, Sex sex, String prefferedTaxiService, int prefferedTaxiServicePosition, String emergencyNumber) {
setId(id);
this.name = name;
this.age = age;
Expand All @@ -29,6 +30,7 @@ public User(long id, String name, int age, double weight, Sex sex, String preffe
else if (sex == Sex.MALE) sexDB = 0;
this.sex = sex;
this.prefferedTaxiService = prefferedTaxiService;
this.prefferedTaxiServicePosition = 0;
this.emergencyNumber = emergencyNumber;
}

Expand Down Expand Up @@ -94,6 +96,12 @@ public void setPrefferedTaxiService(String prefferedTaxiService) {
this.prefferedTaxiService = prefferedTaxiService;
}

public int getPrefferedTaxiServicePosition() { return prefferedTaxiServicePosition;}

public void setPrefferedTaxiServicePosition(int _position) {
this.prefferedTaxiServicePosition = _position;
}

public String getEmergencyNumber() {
return emergencyNumber;
}
Expand Down Expand Up @@ -142,6 +150,7 @@ public int hashCode() {
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + sex.hashCode();
result = 31 * result + (prefferedTaxiService != null ? prefferedTaxiService.hashCode() : 0);
result = 31 * result + prefferedTaxiServicePosition;
result = 31 * result + (emergencyNumber != null ? emergencyNumber.hashCode() : 0);
return result;
}
Expand All @@ -155,6 +164,7 @@ public String toString() {
", weight=" + weight +
", sex=" + sex +
", prefferedTaxiService='" + prefferedTaxiService + '\'' +
", prefferedTaxiServicePosition='" + prefferedTaxiServicePosition + '\'' +
", emergencyNumber='" + emergencyNumber + '\'' +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ public User retrieveUserByName(User user) {
public List<User> retrieveUsers() {
return User.listAll(User.class);
}

/*@Override
public void setNewPrefferedTaxiService(String newservice) {}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public interface UserDAOInterface {
void deleteUser(User user);
User retrieveUserById(User user);
User retrieveUserByName(User user);
//void setNewPrefferedTaxiService(String newservice);
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ else if (id == R.id.btn_contactsOpen)
else {
getSupportFragmentManager().beginTransaction().replace(R.id.fragmentFrame, contactSettingsFragment, "ContactSettingsFragment").addToBackStack(null).commit();
}
drawerLayout.closeDrawer(GravityCompat.START);
//drawerLayout.closeDrawer(GravityCompat.START);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.content.pm.PackageManager;
import android.content.pm.ApplicationInfo;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.os.Handler;

import com.cognitioco.drunkster.R;
import com.cognitioco.drunkster.com.cognitioco.drunkster.com.cognitioco.drunkster.controller.RegistryController;
import com.cognitioco.drunkster.com.cognitioco.drunkster.com.cognitioco.drunkster.controller.UserController;
import com.cognitioco.drunkster.com.cognitioco.drunkster.model.Registry;
import com.cognitioco.drunkster.com.cognitioco.drunkster.model.User;

import java.util.List;
import java.util.Locale;
Expand All @@ -34,6 +46,41 @@ public void onClick(View v) {
onAddDrinkPressed();
}
};
private View.OnClickListener uberListener = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = getContext().getPackageManager().getLaunchIntentForPackage("com.ubercab");
if (intent == null)
return;
List<ResolveInfo> list = getContext().getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if(list.size() > 0)
{
Intent LaunchApp = getContext().getPackageManager().getLaunchIntentForPackage("com.ubercab");
startActivity( LaunchApp );
}

}
};
private View.OnClickListener lyftListener = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = getContext().getPackageManager().getLaunchIntentForPackage("me.lyft.android");
if (intent == null)
return;
List<ResolveInfo> list = getContext().getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if(list.size() > 0)
{
Intent LaunchApp = getContext().getPackageManager().getLaunchIntentForPackage("me.lyft.android");
startActivity( LaunchApp );
}
}
};
private FragmentManager.OnBackStackChangedListener backStackListener = new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
Expand Down Expand Up @@ -78,6 +125,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
FloatingActionButton addDrinkFAB = (FloatingActionButton) v.findViewById(R.id.addDrinkButton);
addDrinkFAB.setOnClickListener(clickReact);



ProgressBar pb = (ProgressBar) v.findViewById(R.id.circle_progress_bar);
List<Registry> list = regcontroller.retrieveAllRegistries();

Expand All @@ -98,6 +147,41 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

th.start();

//Check User for selected taxi service and set to visible
UserController userc = new UserController();
User user = userc.retirveAll().get(0);

FloatingActionButton uberFAB = (FloatingActionButton) v.findViewById(R.id.btn_openUber);
uberFAB.setOnClickListener(uberListener);
FloatingActionButton lyftFAB = (FloatingActionButton) v.findViewById(R.id.btn_openLyft);
lyftFAB.setOnClickListener(lyftListener);

if (user.getPrefferedTaxiServicePosition() == 1 && bac > 0.04)
{
//make uber button visible
uberFAB.show();
lyftFAB.hide();

forceRippleAnimation(uberFAB);
}
else if (user.getPrefferedTaxiServicePosition() == 2 && bac > 0.04)
{
//make lyft button visible
uberFAB.hide();
lyftFAB.show();

forceRippleAnimation(lyftFAB);

//RippleDrawable rippledraw = new RippleDrawable();
//RippleDrawable.setState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled });
}
else
{
//make all taxi buttons invisible
uberFAB.hide();
lyftFAB.hide();
}


return v;
}
Expand All @@ -107,6 +191,13 @@ public void onAddDrinkPressed() {
mListener.onAddDrinkPressed();
}
}
/*public void onUberPressed()
{
if (mListener != null)
{
mListener.onUberPressed();
}
}*/



Expand Down Expand Up @@ -195,4 +286,26 @@ private int getPercentage(double number) {
return (int) percentage;
}
}
protected void forceRippleAnimation(View view)
{
Drawable background = view.getBackground();

if(Build.VERSION.SDK_INT >= 21 && background instanceof RippleDrawable)
{
final RippleDrawable rippleDrawable = (RippleDrawable) background;

rippleDrawable.setState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled});

Handler handler = new Handler();

handler.postDelayed(new Runnable()
{
@Override public void run()
{
rippleDrawable.setState(new int[]{});
}
}, 900000000);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Spinner;
import android.widget.ArrayAdapter;

import com.cognitioco.drunkster.R;
import com.cognitioco.drunkster.com.cognitioco.drunkster.com.cognitioco.drunkster.controller.UserController;
Expand Down Expand Up @@ -101,7 +103,7 @@ public void onClick(View v)
{
// TODO: Correct fragment_contacts_display loading. Crashes on each attempt.
/*ContactsDisplaySettings CDS = new ContactsDisplaySettings() ;
getFragmentManager().beginTransaction().add(R.id.fragmentContactsDisplay, CDS).addToBackStack(null).commit();*/
getFragmentManager().beginTransaction().add(R.id.fragmentContactsDisplay, CDS, null).addToBackStack(null).commit();*/

/*ContactsDisplaySettings CDS= new ContactsDisplaySettings();
getActivity().getFragmentManager().beginTransaction()
Expand Down Expand Up @@ -170,6 +172,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
RadioButton maleButton = (RadioButton) v.findViewById(R.id.radio_male);
RadioButton femaleButton = (RadioButton) v.findViewById(R.id.radio_female);

//fill spinner values
Spinner taxi = (Spinner) v.findViewById((R.id.spin_taxiservice));
ArrayAdapter<CharSequence> taxiadapter = ArrayAdapter.createFromResource(getContext(),
R.array.taxi_spinner_list, android.R.layout.simple_spinner_item);
taxiadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
taxi.setAdapter(taxiadapter);

if (user.getSexDB() == 1) {
femaleButton.setSelected(true);
} else {
Expand All @@ -181,6 +190,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
age.setProgress(user.getAge());
weight.setOnSeekBarChangeListener(seekbarWeightListener);
age.setOnSeekBarChangeListener(seekbarAgeListener);
//set spinner place to previously entered value
taxi.setSelection(user.getPrefferedTaxiServicePosition());

return v;
}
Expand Down Expand Up @@ -247,6 +258,16 @@ private boolean saveUserSettings()
newSettings.setSex(User.Sex.FEMALE);
}


//save spinner position and text
Spinner spinner = (Spinner)getView().findViewById(R.id.spin_taxiservice);
String selectedItemAsText = spinner.getSelectedItem().toString();
int selectedItemAsInt = spinner.getSelectedItemPosition();

newSettings.setPrefferedTaxiService(selectedItemAsText);
//newSettings.setPrefferedTaxiServicePosition(spinner.getSelectedItemPosition());
newSettings.setPrefferedTaxiServicePosition(selectedItemAsInt);

usercontroller.updateUser(newSettings);

return true;
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/specialripple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffff0000">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>

</selector>
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_contacts_display.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<FrameLayout 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:id="@+id/fragmentContactsDisplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".com.cognitioco.drunkster.view.ContactsDisplaySettings">


Expand Down
Loading