<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
- android:duration="500" />
\ No newline at end of file
+ android:duration="250" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
- android:fromAlpha="1.0" android:toAlpha="0.5"
+ android:fromAlpha="1.0" android:toAlpha="0"
android:fillAfter="true"
- android:duration="500" />
\ No newline at end of file
+ android:duration="250" />
\ No newline at end of file
--- /dev/null
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fromDegrees="0"
+ android:toDegrees="45"
+ android:pivotX="30%"
+ android:pivotY="60%"
+ android:duration="0"
+ android:fillAfter="true" />
\ No newline at end of file
<stroke
android:width="3dp"
android:color="#a0a0a0" />
- <solid android:color="@color/background" />
+ <solid android:color="#ffffff" />
</shape>
</rotate>
</item>
<item>
<shape android:shape="rectangle" >
- <solid android:color="#f0f0f0f0" />
+ <solid android:color="#A0000000" />
</shape>
</item>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item>
+ <shape android:shape="rectangle" >
+ <solid android:color="#00a4ef" />
+ </shape>
+ </item>
+
+
+</layer-list>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+<item>
+ <shape android:shape="rectangle">
+ <solid android:color="@color/background"/>
+ </shape>
+</item>
+
+
+<item>
+ <rotate
+ android:fromDegrees="-45"
+ android:toDegrees="0"
+ android:pivotX="50%"
+ android:pivotY="-20%" >
+ <shape android:shape="rectangle" >
+ <solid android:color="#005074" />
+ </shape>
+ </rotate>
+</item>
+
+<item>
+ <rotate
+ android:fromDegrees="-45"
+ android:toDegrees="0"
+ android:pivotX="-46%"
+ android:pivotY="20%" >
+ <shape android:shape="rectangle" >
+ <solid android:color="#005074" />
+ </shape>
+ </rotate>
+</item>
+
+</layer-list>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+<item>
+ <shape android:shape="rectangle">
+ <solid android:color="#ffffff"/>
+ </shape>
+</item>
+
+
+<item>
+ <rotate
+ android:fromDegrees="-45"
+ android:toDegrees="0"
+ android:pivotX="50%"
+ android:pivotY="-20%" >
+ <shape android:shape="rectangle" >
+ <solid android:color="#bf0136" />
+ </shape>
+ </rotate>
+</item>
+
+
+<item>
+ <rotate
+ android:fromDegrees="-45"
+ android:toDegrees="0"
+ android:pivotX="-46%"
+ android:pivotY="20%" >
+ <shape android:shape="rectangle" >
+ <solid android:color="#bf0136" />
+ </shape>
+ </rotate>
+</item>
+
+<item>
+ <rotate
+ android:fromDegrees="-45"
+ android:toDegrees="0"
+ android:pivotX="0%"
+ android:pivotY="-50%" >
+ <shape android:shape="rectangle" >
+ <solid android:color="#ffffff" />
+ </shape>
+ </rotate>
+</item>
+
+
+</layer-list>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item>
+ <shape
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle" >
+ <gradient
+ android:angle="90"
+ android:startColor="#ffffff"
+ android:endColor="#c0c0c0"
+ />
+
+ <corners android:radius="0dp" />
+ </shape>
+ </item>
+
+</layer-list>
\ No newline at end of file
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <LinearLayout
+ android:id="@+id/left"
+ android:layout_width="300dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:background="@color/background"
+ android:orientation="vertical" >
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dip" >
+
+ <LinearLayout
+ android:layout_width="300dp"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/connexion"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapesred"
+ android:gravity="center"
+ android:padding="10dip"
+ android:text="@string/login_or_register"
+ android:textColor="#ffffff"
+ android:textSize="25sp" />
+
+ <LinearLayout
+ android:id="@+id/button_mon_compte"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/avatar"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:height="152dp"
+ android:scaleType="fitXY"
+ android:src="@drawable/male_user_icon" />
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapes" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="6dip" >
+
+ <TextView
+ android:id="@+id/utilisateur_name"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColor="@android:color/black"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/utilisateur_ville"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingBottom="5dip"
+ android:textColor="@android:color/black"
+ android:textSize="15sp" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/launchprofile"
+ android:layout_width="20dp"
+ android:layout_height="40dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/arrow"
+ android:contentDescription="@string/description_image_project"
+ android:gravity="right" />
+ </RelativeLayout>
+ </LinearLayout>
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="20dp" />
+
+ <Button
+ android:id="@+id/button_tout_les_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@drawable/ic_menu_home"
+ android:text="@string/all_projects" />
+
+ <Button
+ android:id="@+id/button_map_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_mapmode"
+ android:text="@string/map_projects" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_1"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_valider_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@drawable/ic_menu_mark"
+ android:text="@string/validate_projects" />
+
+ <Button
+ android:id="@+id/button_soumettre_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_add"
+ android:text="@string/add_project" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_2"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_preferences"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_preferences"
+ android:text="@string/preferences" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_3"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_changeAccount"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_directions"
+ android:text="@string/change_account" />
+
+ <Button
+ android:id="@+id/button_deconnexion"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
+ android:text="@string/logout" />
+ </LinearLayout>
+ </ScrollView>
+ </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/content_frame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="300dp" >
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/big_filter"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/filter"
+ android:visibility="gone" >
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/big_font"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center" >
+ </FrameLayout>
+
+</FrameLayout>
\ No newline at end of file
-<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/drawer_layout"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <FrameLayout
- android:id="@+id/content_frame"
+ <android.support.v4.widget.DrawerLayout
+ android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
- </FrameLayout>
- <LinearLayout
- android:id="@+id/left"
- android:layout_width="300dp"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:background="@color/background"
- android:orientation="vertical"
- android:padding="10dip" >
-
- <ScrollView
+ <FrameLayout
+ android:id="@+id/content_frame"
android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <LinearLayout
- android:layout_width="300dp"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/connexion"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/buttonshapesred"
- android:gravity="center"
- android:padding="10dip"
- android:text="@string/login_or_register"
- android:textColor="#ffffff"
- android:textSize="25sp" />
+ android:layout_height="match_parent" >
+ </FrameLayout>
+
+ <LinearLayout
+ android:id="@+id/left"
+ android:layout_width="300dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:background="@color/background"
+ android:orientation="vertical"
+ android:padding="10dip" >
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
<LinearLayout
- android:id="@+id/button_mon_compte"
- android:layout_width="fill_parent"
+ android:layout_width="300dp"
android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <ImageView
- android:id="@+id/avatar"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_marginRight="6dip"
- android:contentDescription="@string/description_image_project"
- android:height="152dp"
- android:scaleType="fitXY"
- android:src="@drawable/male_user_icon" />
-
- <RelativeLayout
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/connexion"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapesred"
+ android:gravity="center"
+ android:padding="10dip"
+ android:text="@string/login_or_register"
+ android:textColor="#ffffff"
+ android:textSize="25sp" />
+
+ <LinearLayout
+ android:id="@+id/button_mon_compte"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:background="@drawable/buttonshapes" >
+ android:orientation="horizontal" >
- <LinearLayout
- android:layout_width="wrap_content"
+ <ImageView
+ android:id="@+id/avatar"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:height="152dp"
+ android:scaleType="fitXY"
+ android:src="@drawable/male_user_icon" />
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="6dip" >
+ android:background="@drawable/buttonshapes" >
- <TextView
- android:id="@+id/utilisateur_name"
- android:layout_width="fill_parent"
+ <LinearLayout
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textColor="@android:color/black"
- android:textSize="20sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/utilisateur_ville"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingBottom="5dip"
- android:textColor="@android:color/black"
- android:textSize="15sp" />
- </LinearLayout>
-
- <ImageView
- android:id="@+id/launchprofile"
- android:layout_width="20dp"
- android:layout_height="40dp"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:background="@drawable/arrow"
- android:contentDescription="@string/description_image_project"
- android:gravity="right" />
- </RelativeLayout>
+ android:orientation="vertical"
+ android:padding="6dip" >
+
+ <TextView
+ android:id="@+id/utilisateur_name"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColor="@android:color/black"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/utilisateur_ville"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingBottom="5dip"
+ android:textColor="@android:color/black"
+ android:textSize="15sp" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/launchprofile"
+ android:layout_width="20dp"
+ android:layout_height="40dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/arrow"
+ android:contentDescription="@string/description_image_project"
+ android:gravity="right" />
+ </RelativeLayout>
+ </LinearLayout>
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="20dp" />
+
+ <Button
+ android:id="@+id/button_tout_les_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@drawable/ic_menu_home"
+ android:text="@string/all_projects" />
+
+ <Button
+ android:id="@+id/button_map_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_mapmode"
+ android:text="@string/map_projects" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_1"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_valider_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@drawable/ic_menu_mark"
+ android:text="@string/validate_projects" />
+
+ <Button
+ android:id="@+id/button_soumettre_projet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_add"
+ android:text="@string/add_project" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_2"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_preferences"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_preferences"
+ android:text="@string/preferences" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:id="@+id/separator_3"
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <Button
+ android:id="@+id/button_changeAccount"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_directions"
+ android:text="@string/change_account" />
+
+ <Button
+ android:id="@+id/button_deconnexion"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:background="@null"
+ android:contentDescription="@string/description_image_button"
+ android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
+ android:text="@string/logout" />
</LinearLayout>
+ </ScrollView>
+ </LinearLayout>
+ </android.support.v4.widget.DrawerLayout>
- <adullact.publicrowdfunding.views.SimpleLine
- android:layout_width="wrap_content"
- android:layout_height="3dp"
- android:layout_marginTop="20dp" />
+ <FrameLayout
+ android:id="@+id/big_filter"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:background="@drawable/filter" >
+ </FrameLayout>
- <Button
- android:id="@+id/button_tout_les_projet"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@drawable/ic_menu_home"
- android:text="Tout les projets" />
-
- <Button
- android:id="@+id/button_map_projet"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@android:drawable/ic_menu_mapmode"
- android:text="Carte des projets" />
-
- <adullact.publicrowdfunding.views.SimpleLine
- android:id="@+id/separator_1"
- android:layout_width="wrap_content"
- android:layout_height="3dp"
- android:layout_marginTop="10dp" />
-
- <Button
- android:id="@+id/button_valider_projet"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@drawable/ic_menu_mark"
- android:text="Valider des projets" />
-
- <Button
- android:id="@+id/button_soumettre_projet"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@android:drawable/ic_menu_add"
- android:text="Ajouter un projet" />
-
- <adullact.publicrowdfunding.views.SimpleLine
- android:id="@+id/separator_2"
- android:layout_width="wrap_content"
- android:layout_height="3dp"
- android:layout_marginTop="10dp" />
-
- <Button
- android:id="@+id/button_preferences"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@android:drawable/ic_menu_preferences"
- android:text="Préférences" />
-
- <adullact.publicrowdfunding.views.SimpleLine
- android:id="@+id/separator_3"
- android:layout_width="wrap_content"
- android:layout_height="3dp"
- android:layout_marginTop="10dp" />
-
- <Button
- android:id="@+id/button_deconnexion"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:background="@null"
- android:contentDescription="@string/description_image_button"
- android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
- android:text="Déconnexion" />
- </LinearLayout>
- </ScrollView>
- </LinearLayout>
-
-</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
+ <FrameLayout
+ android:id="@+id/big_font"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center" >
+ </FrameLayout>
+
+</FrameLayout>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map_area"
+ android:background="@color/background"
android:layout_width="match_parent"
android:layout_height="match_parent" >
-
+
<FrameLayout
android:id="@+id/mapView"
android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
+ android:layout_height="wrap_content">
</FrameLayout>
- <FrameLayout
- android:id="@+id/FlashBarLayout"
- android:layout_width="match_parent"
- android:layout_height="100dp"
- android:layout_gravity="center_horizontal|bottom"
- android:layout_marginBottom="0dp" >
- </FrameLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/wrapper"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="10dp"
+ android:background="@drawable/buttonshapes"
android:orientation="vertical"
- android:padding="5dp" >
+ android:padding="10dp" >
<LinearLayout
android:id="@+id/llinear"
<RelativeLayout
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/buttonshapes" >
+ android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@android:color/black"
- android:textSize="20sp"
+ android:textSize="15sp"
android:textStyle="bold" />
<TextView
</RelativeLayout>
</LinearLayout>
- <ImageView
- android:layout_width="40dp"
- android:layout_height="20dp"
- android:layout_marginTop="-10dp"
- android:background="@drawable/bubble"
- android:contentDescription="@string/description_image_project"
- android:gravity="right" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:padding="6dip" >
+
+ <ImageView
+ android:layout_width="40dp"
+ android:layout_height="20dp"
+ android:layout_marginTop="-10dp"
+ android:background="@drawable/bubble"
+ android:contentDescription="@string/description_image_project" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="5dp" />
+ </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dip"
- android:background="@drawable/buttonshapes"
android:orientation="vertical"
android:padding="6dip" >
android:layout_gravity="center"
android:paddingLeft="10dip"
android:textColor="@android:color/primary_text_light"
+ android:textSize="15sp"
android:textStyle="bold" />
<RatingBar
style="@style/smallRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="-30dip"
+ android:layout_marginLeft="-15dip"
android:numStars="5"
- android:scaleX="0.5"
- android:scaleY="0.5"
+ android:scaleX="0.6"
+ android:scaleY="0.6"
android:stepSize="1.0" >
</RatingBar>
</LinearLayout>
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="10dip"
- android:textColor="@android:color/primary_text_light" />
+ android:textColor="@android:color/primary_text_light"
+ android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingLeft="10dip"
- android:paddingRight="10dip"
- android:paddingTop="5dip"
- android:paddingBottom="5dip" >
+ android:orientation="vertical" >
<LinearLayout
+ android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:background="@drawable/buttonshapes"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="10dp"
android:orientation="vertical"
- android:padding="5dip" >
+ android:paddingLeft="1dp"
+ android:paddingRight="1dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal" >
+ android:layout_marginTop="20dp"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:paddingBottom="10dp"
+ android:paddingTop="40dp" >
<ImageView
- android:id="@+id/icon"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_marginRight="6dip"
+ android:layout_width="fill_parent"
+ android:layout_height="10dp"
android:contentDescription="@string/description_image_project"
- android:height="152dp"
- android:scaleType="fitXY"
- android:src="@drawable/ic_launcher" />
+ android:src="@drawable/ribbon_shadow" />
- <TextView
- android:id="@+id/titre_projet_liste"
+ <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:text="@string/project_name"
- android:textSize="18sp"
- android:textStyle="bold" />
- </LinearLayout>
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp" >
- <TextView
- android:id="@+id/description_projet_liste"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dip"
- android:gravity="center_vertical"
- android:text="@string/project_description"
- android:textSize="15sp" />
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="100dp"
+ android:layout_height="100dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/ic_launcher" />
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dip" >
+ <TextView
+ android:id="@+id/description_projet_liste"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/icon"
+ android:text="@string/project_description"
+ android:textSize="15sp" />
+ </RelativeLayout>
- <TableRow
- android:id="@+id/tableRow1"
+ <adullact.publicrowdfunding.views.SimpleLine
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="1dip" >
+ android:layout_height="3dp"
+ android:layout_marginTop="20dp" />
- <TextView
- android:id="@+id/sommeFund"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
+ <TableLayout
+ android:id="@+id/tableLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp" >
- <TextView
- android:id="@+id/sommeeDemande"
- android:layout_width="fill_parent"
+ <TableRow
+ android:id="@+id/tableRow1"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/nombre_jour_restant_detail"
- android:layout_width="fill_parent"
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/sommeFund"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/sommeeDemande"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/nombre_jour_restant_detail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+ </TableRow>
+
+ <TableRow
+ android:id="@+id/tableRow2"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
- </TableRow>
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/recolter"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/funded"
+ android:textSize="15sp" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/ask"
+ android:textSize="15sp" />
+
+ <TextView
+ android:id="@+id/restant"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/remain"
+ android:textSize="15sp" />
+ </TableRow>
+ </TableLayout>
+
+ <adullact.publicrowdfunding.views.CustomProgressBar
+ android:id="@+id/avancement_projet_liste"
+ style="@android:style/Widget.ProgressBar.Horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="10dip"
+ android:layout_marginBottom="10dip"
+ android:layout_marginTop="10dip"
+ android:max="100"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:progress="100"
+ android:progressDrawable="@drawable/progressbar" />
- <TableRow
- android:id="@+id/tableRow2"
- android:layout_width="wrap_content"
+ <TextView
+ android:id="@+id/distance"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:padding="1dip" >
-
- <TextView
- android:id="@+id/recolter"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/funded"
- android:textSize="15sp" />
+ android:layout_gravity="center"
+ android:ellipsize="marquee"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:singleLine="true"
+ android:textSize="12sp" />
+ </LinearLayout>
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/ask"
- android:textSize="15sp" />
+ </LinearLayout>
- <TextView
- android:id="@+id/restant"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/remain"
- android:textSize="15sp" />
- </TableRow>
- </TableLayout>
+ <FrameLayout
+ android:id="@+id/frame"
+ android:layout_width="fill_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="10dp"
+ android:layout_marginTop="30dp" >
- <adullact.publicrowdfunding.views.CustomProgressBar
- android:id="@+id/avancement_projet_liste"
- style="@android:style/Widget.ProgressBar.Horizontal"
+ <ImageView
android:layout_width="fill_parent"
- android:layout_height="10dip"
- android:layout_marginBottom="10dip"
- android:layout_marginTop="10dip"
- android:max="100"
- android:progress="100"
- android:progressDrawable="@drawable/progressbar" />
+ android:layout_height="30dp"
+ android:layout_marginRight="10dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/rectangle" />
+
+ <ImageView
+ android:layout_width="10dp"
+ android:layout_height="10dp"
+ android:layout_marginTop="30dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/ribbon" />
<TextView
- android:id="@+id/distance"
+ android:id="@+id/titre_projet_liste"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
+ android:layout_height="30dp"
android:ellipsize="marquee"
+ android:gravity="center"
android:singleLine="true"
- android:textSize="12sp" />
- </LinearLayout>
+ android:text="@string/project_name"
+ android:textColor="#ffffff"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+
+ </FrameLayout>
-</LinearLayout>
\ No newline at end of file
+</FrameLayout>
\ No newline at end of file
--- /dev/null
+<?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="match_parent"
+ android:background="@color/background"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/loading"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <ProgressBar
+ android:id="@+id/progressBar1"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/loading" />
+ </LinearLayout>
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <LinearLayout
+ android:id="@+id/ll"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="5dp" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip"
+ android:paddingTop="6dip" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <com.touchmenotapps.carousel.simple.HorizontalCarouselLayout
+ android:id="@+id/carousel_layout"
+ android:layout_width="100dp"
+ android:layout_height="50dp" />
+
+ <EditText
+ android:id="@+id/titre"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:gravity="center"
+ android:hint="@string/project_name"
+ android:inputType="text"
+ android:singleLine="true"
+ android:textSize="30sp"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ <ImageView
+ android:layout_width="40dp"
+ android:layout_height="20dp"
+ android:layout_marginLeft="25dp"
+ android:layout_marginTop="-25dp"
+ android:background="@drawable/bubble"
+ android:contentDescription="@string/description_image_project" />
+ </LinearLayout>
+
+ <EditText
+ android:id="@+id/description"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dip"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center_vertical"
+ android:hint="@string/project_description"
+ android:inputType="textMultiLine"
+ android:padding="3dip"
+ android:textSize="20sp" />
+
+ <TableLayout
+ android:id="@+id/tableLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip" >
+
+ <TableRow
+ android:id="@+id/tableRow1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/sommeFund"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="0€"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/sommeRequestFund"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="0€"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/pourcentage_accomplit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="0%"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/nombre_jour_restant_detail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="0 jour"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+ </TableRow>
+
+ <TableRow
+ android:id="@+id/tableRow2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/recolter"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/funded"
+ android:textSize="15sp" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/ask"
+ android:textSize="15sp" />
+
+ <TextView
+ android:id="@+id/participants"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/accomplish"
+ android:textSize="15sp" />
+
+ <TextView
+ android:id="@+id/restant"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/remain"
+ android:textSize="15sp" />
+ </TableRow>
+ </TableLayout>
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dip"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:padding="5dp" >
+
+ <ImageView
+ android:id="@+id/mailIcon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:src="@android:drawable/ic_menu_send" />
+
+ <EditText
+ android:id="@+id/mail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:layout_toRightOf="@+id/mailIcon"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/email"
+ android:inputType="textEmailAddress"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dip"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:padding="5dp" >
+
+ <ImageView
+ android:id="@+id/websiteIcon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/ic_menu_attachment" />
+
+ <EditText
+ android:id="@+id/website"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:layout_toRightOf="@+id/websiteIcon"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/site_web"
+ android:inputType="textWebEditText"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:padding="5dp" >
+
+ <ImageView
+ android:id="@+id/phoneIcon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:src="@android:drawable/ic_menu_call" />
+
+ <EditText
+ android:id="@+id/phone"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:layout_toRightOf="@+id/phoneIcon"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/telephone"
+ android:inputType="phone"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+ </RelativeLayout>
+
+ <LinearLayout
+ android:id="@+id/llinear"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:layout_marginTop="6dip"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/avatar"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:height="152dp"
+ android:scaleType="fitXY"
+ android:src="@drawable/male_user_icon" />
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapes" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="6dip" >
+
+ <TextView
+ android:id="@+id/utilisateur_soumission"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="XXX"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/ville"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingBottom="5dip"
+ android:text="XXX"
+ android:textSize="15sp" />
+ </LinearLayout>
+ </RelativeLayout>
+ </LinearLayout>
+
+ <EditText
+ android:id="@+id/edit_text_somme"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dip"
+ android:background="@drawable/buttonshapes"
+ android:ems="10"
+ android:hint="Somme à récolter"
+ android:inputType="number"
+ android:padding="5dp"
+ android:textSize="20sp" >
+ </EditText>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:padding="5dp" >
+
+ <TextView
+ android:id="@+id/textView4"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/project_end_date"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <DatePicker
+ android:id="@+id/date_de_fin"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center" />
+ </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/mapView"
+ android:layout_width="match_parent"
+ android:layout_height="300dp" >
+ </FrameLayout>
+
+ <Button
+ android:id="@+id/button_valider"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:background="@drawable/buttonshapes"
+ android:drawableLeft="@android:drawable/ic_menu_mylocation"
+ android:text="Soumettre le projet" />
+ </LinearLayout>
+ </ScrollView>
+
+</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/linearLayoutDetail"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:text="@string/loading" />
</LinearLayout>
- <FrameLayout
+ <ScrollView
android:id="@+id/showLoaded"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
- <ScrollView
- android:id="@+id/scroll"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
- <LinearLayout
- android:id="@+id/ll"
+ <FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="5dp" >
+ android:orientation="vertical" >
<LinearLayout
+ android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:paddingTop="6dip" >
-
- <ImageView
- android:id="@+id/icon"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_marginRight="6dip"
- android:contentDescription="@string/description_image_project"
- android:height="152dp"
- android:scaleType="fitXY"
- android:src="@drawable/ic_launcher" />
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="10dp"
+ android:orientation="vertical"
+ android:paddingLeft="1dp"
+ android:paddingRight="1dp" >
- <TextView
- android:id="@+id/titre_projet_detail"
+ <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:ellipsize="marquee"
- android:gravity="center"
- android:singleLine="true"
- android:text="@string/project_name"
- android:textSize="30sp"
- android:textStyle="bold" />
- </LinearLayout>
-
- <TextView
- android:id="@+id/detail_projet_detail"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="5dip"
- android:gravity="center_vertical"
- android:padding="3dip"
- android:text="@string/project_description"
- android:textSize="15sp" />
-
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dip" >
-
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="1dip" >
+ android:layout_marginTop="20dp"
+ android:background="@drawable/buttonshapes"
+ android:orientation="vertical"
+ android:paddingBottom="10dp"
+ android:paddingTop="40dp" >
- <TextView
- android:id="@+id/sommeFund"
+ <ImageView
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
+ android:layout_height="10dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/ribbon_shadow" />
<TextView
- android:id="@+id/sommeRequestFund"
- android:layout_width="fill_parent"
+ android:id="@+id/detail_projet_detail"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
+ android:drawableStart="@drawable/ic_launcher"
+ android:text="@string/project_description"
+ android:textSize="15sp" />
- <TextView
- android:id="@+id/pourcentage_accomplit"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="wrap_content"
+ android:layout_height="3dp"
+ android:layout_marginTop="20dp" />
- <TextView
- android:id="@+id/nombre_jour_restant_detail"
+ <TableLayout
+ android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="15sp"
- android:textStyle="bold" />
- </TableRow>
-
- <TableRow
- android:id="@+id/tableRow2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="1dip" >
+ android:layout_margin="5dip"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp" >
- <TextView
- android:id="@+id/recolter"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/funded"
- android:textSize="15sp" />
+ <TableRow
+ android:id="@+id/tableRow1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/sommeFund"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/pourcentage_accomplit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/sommeRequestFund"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/nombre_jour_restant_detail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textSize="15sp"
+ android:textStyle="bold" />
+ </TableRow>
+
+ <TableRow
+ android:id="@+id/tableRow2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="1dip" >
+
+ <TextView
+ android:id="@+id/recolter"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/funded"
+ android:textSize="15sp" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/accomplish"
+ android:textSize="15sp" />
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/ask"
+ android:textSize="15sp" />
+
+ <TextView
+ android:id="@+id/restant"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/remain"
+ android:textSize="15sp" />
+ </TableRow>
+ </TableLayout>
+ </LinearLayout>
+ </LinearLayout>
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/ask"
- android:textSize="15sp" />
+ <FrameLayout
+ android:id="@+id/frame"
+ android:layout_width="fill_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="10dp"
+ android:layout_marginTop="30dp" >
- <TextView
- android:id="@+id/participants"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/accomplish"
- android:textSize="15sp" />
+ <ImageView
+ android:layout_width="fill_parent"
+ android:layout_height="30dp"
+ android:layout_marginRight="10dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/rectangle" />
- <TextView
- android:id="@+id/restant"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/remain"
- android:textSize="15sp" />
- </TableRow>
- </TableLayout>
+ <ImageView
+ android:layout_width="10dp"
+ android:layout_height="10dp"
+ android:layout_marginTop="30dp"
+ android:contentDescription="@string/description_image_project"
+ android:src="@drawable/ribbon" />
+
+ <TextView
+ android:id="@+id/titre_projet_detail"
+ android:layout_width="fill_parent"
+ android:layout_height="30dp"
+ android:ellipsize="marquee"
+ android:gravity="center"
+ android:singleLine="true"
+ android:text="@string/project_name"
+ android:textColor="#ffffff"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+ </FrameLayout>
+ </FrameLayout>
+
+ <LinearLayout
+ android:id="@+id/ll"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="10dp"
+ android:orientation="vertical" >
<RelativeLayout
- android:id="@+id/layout_mail"
+ android:id="@+id/layout_website"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/buttonshapes" >
<Button
- android:id="@+id/mail"
+ android:id="@+id/website"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
- android:drawableLeft="@android:drawable/ic_menu_send"
+ android:drawableLeft="@drawable/ic_menu_attachment"
android:gravity="left|center_vertical"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
- android:id="@+id/layout_website"
+ android:id="@+id/layout_mail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/buttonshapes" >
<Button
- android:id="@+id/website"
+ android:id="@+id/mail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
- android:drawableLeft="@drawable/ic_menu_attachment"
+ android:drawableLeft="@android:drawable/ic_menu_send"
android:gravity="left|center_vertical"
android:textSize="15sp" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
- android:orientation="horizontal"
- android:padding="5dp" >
+ android:orientation="horizontal" >
<ImageView
android:id="@+id/avatar"
</RelativeLayout>
</LinearLayout>
- <adullact.publicrowdfunding.fragment.v4.detailProject.GraphiqueView
+ <adullact.publicrowdfunding.controller.project.details.GraphiqueView
android:id="@+id/graphique"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="50dp"
+ android:layout_marginBottom="60dp"
android:layout_marginTop="10dp" />
</LinearLayout>
- </ScrollView>
-
- <FrameLayout
- android:id="@+id/connect"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|bottom"
- android:layout_marginBottom="0dp"
- android:padding="10dip" >
-
- <Button
- android:id="@+id/payer"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/buttonshapes"
- android:gravity="center"
- android:text="Contribuer" />
- </FrameLayout>
- </FrameLayout>
+ </LinearLayout>
+ </ScrollView>
<FrameLayout
- android:id="@+id/filter"
+ android:id="@+id/connect"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="@drawable/filter" >
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal|bottom"
+ android:layout_marginBottom="0dp"
+ android:padding="10dip" >
+
+ <Button
+ android:id="@+id/payer"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center"
+ android:text="@string/contribute" />
</FrameLayout>
</FrameLayout>
\ No newline at end of file
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresher"
+ android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
android:layout_gravity="center"
android:background="@drawable/buttonshapes"
android:gravity="center"
- android:text="Commenter" />
+ android:text="@string/comment" />
</LinearLayout>
</FrameLayout>
- <FrameLayout
- android:id="@+id/alpha_comment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="@drawable/filter" >
- </FrameLayout>
-
-
</FrameLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
+ android:background="@color/background"
android:orientation="vertical" >
<ListView
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:text="@string/loading" />
</LinearLayout>
- <TextView
- android:id="@+id/empty"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center"
- android:text="Aucun projet" />
-
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresher"
android:layout_width="match_parent"
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
-</LinearLayout>
\ No newline at end of file
+</FrameLayout>
\ No newline at end of file
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
- <PreferenceCategory android:title="Utilisateur" >
+ <PreferenceCategory android:title="@string/user" >
<EditTextPreference
- android:dialogTitle="Modifier votre ville"
+ android:dialogTitle="@string/change_your_city"
android:key="edittext_preference_ville"
- android:summary="Votre ville (Affiché sur le profile)"
- android:title="Ville" />
+ android:summary="@string/your_city"
+ android:title="@string/city" />
<EditTextPreference
- android:dialogTitle="Modifier votre Nom"
+ android:dialogTitle="@string/change_your_name"
android:key="edittext_preference_nom"
- android:summary="Votre Nom"
- android:title="Nom" />
+ android:summary="@string/your_name"
+ android:title="@string/name" />
<EditTextPreference
- android:dialogTitle="Modifier votre Prenom"
+ android:dialogTitle="@string/change_your_first_name"
android:key="edittext_preference_prenom"
- android:summary="Votre prenom"
- android:title="Prenom" />
+ android:summary="@string/your_first_name"
+ android:title="@string/first_name" />
<EditTextPreference
- android:dialogTitle="Modifier votre email"
+ android:dialogTitle="@string/change_your_email"
android:key="edittext_preference_email"
- android:summary="Votre email"
- android:title="Email" />
+ android:summary="@string/your_email"
+ android:title="@string/email" />
<SwitchPreference
android:defaultValue="false"
android:key="genre"
- android:title="Genre" />
- </PreferenceCategory>
-
- <PreferenceCategory android:title="Compte" >
-
- <CheckBoxPreference
- android:key="checkbox_admin"
- android:summary="Administrateur"
- android:title="Passer administrateur" />
+ android:title="@string/gender" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="top"
- android:background="@color/background"
+ android:background="@color/background"
android:paddingBottom="4dp"
android:paddingTop="4dp" />
</android.support.v4.view.ViewPager>
-
- <FrameLayout
- android:id="@+id/front"
- android:layout_gravity="center"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
</FrameLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
+ android:background="@color/background"
android:orientation="vertical" >
- <LinearLayout
- android:id="@+id/llinear"
+ <FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" >
- <ImageView
- android:id="@+id/avatar"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_marginRight="6dip"
- android:contentDescription="@string/description_image_project"
- android:height="152dp"
- android:scaleType="fitXY"
- android:src="@drawable/male_user_icon" />
-
<RelativeLayout
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/buttonshapes" >
+ android:layout_height="wrap_content" >
+
+ <ImageView
+ android:id="@+id/avatar"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_marginRight="6dip"
+ android:contentDescription="@string/description_image_project"
+ android:height="152dp"
+ android:scaleType="fitXY"
+ android:src="@drawable/male_user_icon" />
<LinearLayout
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_toRightOf="@+id/avatar"
+ android:background="@drawable/buttonshapes"
android:orientation="vertical"
android:padding="6dip" >
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
- </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/admin_ribbon"
+ android:layout_width="57dp"
+ android:layout_height="56dp"
+ android:layout_gravity="right"
+ android:layout_margin="1dp"
+ android:background="@drawable/ribbon_profile"
+ android:contentDescription="@string/description_image_project" />
+
+ <TextView
+ android:id="@+id/text_admin"
+ android:layout_width="57dp"
+ android:layout_height="56dp"
+ android:layout_gravity="right"
+ android:layout_margin="1dp"
+ android:text="ADMIN"
+ android:textColor="#ffffff"
+ android:textStyle="bold" />
+ </FrameLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
--- /dev/null
+<?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="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="320dip"
+ android:layout_height="wrap_content"
+ android:background="@drawable/shadow"
+ android:orientation="vertical"
+ android:padding="20dp" >
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dip"
+ android:gravity="center"
+ android:text="Vous souhaitez"
+ android:textSize="25sp" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="match_parent"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+
+ <RadioGroup
+ android:layout_marginTop="10dp"
+ android:id="@+id/radioGroup"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" >
+
+ <RadioButton
+ android:id="@+id/validation"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:checked="true"
+ android:text="Valider le projet" />
+
+ <RadioButton
+ android:id="@+id/reject"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="refuser le projet" />
+
+
+ </RadioGroup>
+
+ <Button
+ android:id="@+id/valider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center"
+ android:text="@string/valider" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
<requestFocus />
</EditText>
- <CheckBox
- android:id="@+id/conditions"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:text="J'accepte les conditions d'utilisations" />
-
<Button
android:id="@+id/valider"
android:layout_width="match_parent"
--- /dev/null
+<?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="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+
+ <LinearLayout
+ android:id="@+id/loading"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <ProgressBar
+ android:id="@+id/progressBar1"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/loading" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/loadingLoadingInfo"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <ProgressBar
+ android:id="@+id/progressBar1LoadingInfo"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView1LoadingInfo"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textColor="#45C63B"
+ android:textSize="35sp"
+ android:text="@string/success" />
+
+ <TextView
+ android:id="@+id/textView1LoadingInfoSub"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textColor="#179CD5"
+ android:textSize="25sp"
+ android:text="@string/retrievePersonnelInfo" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="320dip"
+ android:layout_height="wrap_content"
+ android:background="@drawable/shadow"
+ android:orientation="vertical"
+ android:padding="20dp" >
+
+ <TextView
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dip"
+ android:gravity="center"
+ android:text="@string/authentication"
+ android:textSize="25sp" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="match_parent"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <EditText
+ android:id="@+id/login_connexion"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/login"
+ android:inputType="text"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+
+ <EditText
+ android:id="@+id/password_connexion"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/password"
+ android:inputType="textPassword"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+
+ <Button
+ android:id="@+id/valider_connexion"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center"
+ android:text="@string/connexion" />
+
+ <Button
+ android:id="@+id/inscription_button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center"
+ android:text="@string/creer_un_compte" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?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="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/loading"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <ProgressBar
+ android:id="@+id/progressBar1"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/loading" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="320dip"
+ android:layout_height="wrap_content"
+ android:background="@drawable/shadow"
+ android:orientation="vertical"
+ android:padding="20dp" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dip"
+ android:gravity="center"
+ android:text="@string/register"
+ android:textSize="25sp" />
+
+ <adullact.publicrowdfunding.views.SimpleLine
+ android:layout_width="match_parent"
+ android:layout_height="3dp"
+ android:layout_marginTop="10dp" />
+
+ <EditText
+ android:id="@+id/inscription_login"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/login"
+ android:inputType="text"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+
+ <EditText
+ android:id="@+id/inscription_password1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/password"
+ android:inputType="textPassword"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+
+ <EditText
+ android:id="@+id/inscription_password2"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
+ android:ems="10"
+ android:gravity="left|center_vertical"
+ android:hint="@string/confirmation_mdp"
+ android:inputType="textPassword"
+ android:textColor="#808080"
+ android:textSize="20sp" >
+ </EditText>
+
+ <Button
+ android:id="@+id/inscription_button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:background="@drawable/buttonshapes"
+ android:gravity="center"
+ android:text="@string/go_inscription" />
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!-- ANGLAIS -->
+ <string name="app_name">PublicrowdFunding</string>
+ <string name="login">Login</string>
+ <string name="password">Password</string>
+ <string name="creer_un_compte">Create an account</string>
+ <string name="connexion">Connection</string>
+ <string name="image_cadenas">Clef secure</string>
+ <string name="email">Email address</string>
+ <string name="go_inscription">Create my account</string>
+ <string name="project_name">Project name</string>
+ <string name="description_image_project">Project picture</string>
+ <string name="project_description">Project description</string>
+ <string name="project_end_date">End date</string>
+ <string name="add_project">Submit a project</string>
+ <string name="description_image_button">Image button</string>
+ <string name="valider">Validate</string>
+ <string name="aucune_financement">0e</string>
+ <string name="zero">0</string>
+ <string name="no_days"> 0 day</string>
+ <string name="participants">participants</string>
+ <string name="remain">Remaining</string>
+ <string name="funded">Harvested</string>
+ <string name="site_web">Website</string>
+ <string name="telephone">Phone number</string>
+ <string name="confirmation_mdp">Password confirmation</string>
+ <string name="loading">Loading in progress</string>
+ <string name="no_project">No project</string>
+ <string name="no_commentary">No comment</string>
+ <string name="login_or_register">Log In</string>
+ <string name="accomplish">Accomplish</string>
+ <string name="ask">Required</string>
+ <string name="contribute">Contribute to this project</string>
+ <string name="amount_contribute">Account in euro</string>
+ <string name="success">Successful connection</string>
+ <string name="retrievePersonnelInfo">Retrieve Personnel Info</string>
+ <string name="distance">Distance : </string>
+ <string name="error">An error occurred</string>
+ <string name="male">Male</string>
+ <string name="female">Female</string>
+ <string name="comment">Comment</string>
+ <string name="comments">Comments</string>
+ <string name="project_details">Project info</string>
+ <string name="project_location">Project location</string>
+ <string name="all_projects">All projects</string>
+ <string name="map_projects">Projects Map</string>
+ <string name="validate_projects">Validate projects</string>
+ <string name="preferences">Preferences</string>
+ <string name="change_account">Change account</string>
+ <string name="logout">Logout</string>
+ <string name="authentication">Authentication</string>
+ <string name="funding_progress">Funding progress</string>
+ <string name="sort_by">Sort by</string>
+ <string name="biggest_project">Biggest project</string>
+ <string name="smallest_project">Smallest project</string>
+ <string name="most_avanced">Most avanced</string>
+ <string name="closest">Closest</string>
+ <string name="user">User</string>
+ <string name="city">City</string>
+ <string name="name">Name</string>
+ <string name="first_name">First name</string>
+ <string name="your_city">Your city</string>
+ <string name="your_name">Your name</string>
+ <string name="your_first_name">Your first name</string>
+ <string name="change_your_city">Your first name</string>
+ <string name="change_your_name">Your first name</string>
+ <string name="change_your_first_name">Your first name</string>
+ <string name="gender">Gender</string>
+ <string name="your_email">Your Email</string>
+ <string name="project_submitted">Project Submitted</string>
+ <string name="bookmark">Bookmarks</string>
+ <string name="change_your_email">Change your Email</string>
+ <string name="financed">Financed</string>
+ <string name="register">Sign in</string>
+
+</resources>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!-- ESPAGNOL -->
+ <string name="app_name"></string>
+ <string name="login"></string>
+ <string name="password"></string>
+ <string name="creer_un_compte"></string>
+ <string name="connexion"></string>
+ <string name="image_cadenas"></string>
+ <string name="email"></string>
+ <string name="go_inscription"></string>
+ <string name="project_name"></string>
+ <string name="description_image_project"></string>
+ <string name="project_description"></string>
+ <string name="project_end_date"></string>
+ <string name="add_project"></string>
+ <string name="description_image_button"></string>
+ <string name="valider"></string>
+ <string name="aucune_financement"></string>
+ <string name="zero"></string>
+ <string name="no_days"></string>
+ <string name="participants"></string>
+ <string name="remain"></string>
+ <string name="funded"></string>
+ <string name="site_web"></string>
+ <string name="telephone"></string>
+ <string name="confirmation_mdp"></string>
+ <string name="loading"></string>
+ <string name="no_project"></string>
+ <string name="no_commentary"></string>
+ <string name="login_or_register"></string>
+ <string name="accomplish"></string>
+ <string name="ask"></string>
+ <string name="contribute"></string>
+ <string name="amount_contribute"></string>
+ <string name="success"></string>
+ <string name="retrievePersonnelInfo"></string>
+ <string name="distance"></string>
+ <string name="error"></string>
+ <string name="male"></string>
+ <string name="female"></string>
+ <string name="comment"></string>
+ <string name="comments"></string>
+ <string name="project_details"></string>
+ <string name="project_location"></string>
+ <string name="all_projects"></string>
+ <string name="map_projects"></string>
+ <string name="validate_projects"></string>
+ <string name="preferences"></string>
+ <string name="change_account"></string>
+ <string name="logout"></string>
+ <string name="authentication"></string>
+ <string name="funding_progress"></string>
+ <string name="sort_by"></string>
+ <string name="biggest_project"></string>
+ <string name="smallest_project"></string>
+ <string name="most_avanced"></string>
+ <string name="closest"></string>
+ <string name="user"></string>
+ <string name="city"></string>
+ <string name="name"></string>
+ <string name="first_name"></string>
+ <string name="your_city"></string>
+ <string name="your_name"></string>
+ <string name="your_first_name"></string>
+ <string name="change_your_city"></string>
+ <string name="change_your_name"></string>
+ <string name="change_your_first_name"></string>
+ <string name="gender"></string>
+ <string name="your_email"></string>
+ <string name="project_submitted"></string>
+ <string name="bookmark"></string>
+ <string name="change_your_email"></string>
+ <string name="financed"></string>
+ <string name="register"></string>
+
+</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
+ <!-- FRANCAIS -->
<string name="app_name">PublicrowdFunding</string>
<string name="login">Nom d\'utilisateur</string>
<string name="password">Mot de passe</string>
<string name="project_name">Nom du projet</string>
<string name="description_image_project">Illustration du projet</string>
<string name="project_description">Description du projet</string>
- <string name="nombre_participants">0 contributeurs</string>
<string name="project_end_date">Date de fin</string>
- <string name="till_day">Inf jours restants</string>
<string name="add_project">Soumettre un projet</string>
- <string name="projet_soumission">Projet proposé par lucas</string>
<string name="description_image_button">Bouton image</string>
<string name="valider">Valider</string>
<string name="aucune_financement">0e</string>
<string name="zero">0</string>
- <string name="no_days"> 0 jours</string>
+ <string name="no_days"> 0 jour</string>
<string name="participants">participants</string>
- <string name="restant">restant</string>
- <string name="recolter">récoltés</string>
+ <string name="remain">restant</string>
+ <string name="funded">récoltés</string>
<string name="site_web">Site internet</string>
<string name="telephone">Numéro de téléphone</string>
<string name="confirmation_mdp">Confirmation du mot de passe</string>
- <string name="loading">Chargement</string>
+ <string name="loading">Chargement en cours</string>
<string name="no_project">Aucun projet</string>
<string name="no_commentary">Aucun commentaire</string>
<string name="login_or_register">Identifiez-vous</string>
- <string name="remain">Restant</string>
<string name="accomplish">Accompli</string>
<string name="ask">Demandé</string>
- <string name="funded">Récoltés</string>
<string name="contribute">Contribuer à ce projet</string>
<string name="amount_contribute">Montant en euro</string>
<string name="success">Connexion réussie!</string>
<string name="retrievePersonnelInfo">Nous récupérons vos données personnelles</string>
+ <string name="distance">Distance : </string>
+ <string name="error">Une erreur s\'est produite</string>
+ <string name="male">Homme</string>
+ <string name="female">Femme</string>
+ <string name="comment">Commenter</string>
+ <string name="comments">Commentaires</string>
+ <string name="project_details">Détail du projet</string>
+ <string name="project_location">Emplacement du projet</string>
+ <string name="all_projects">Tout les projets</string>
+ <string name="map_projects">Carte des projets</string>
+ <string name="validate_projects">Valider des projets</string>
+ <string name="preferences">Préférences</string>
+ <string name="change_account">Changer de compte</string>
+ <string name="logout">Déconnexion</string>
+ <string name="authentication">Authentification</string>
+ <string name="funding_progress">Progression du financement</string>
+ <string name="sort_by">Sort by</string>
+ <string name="biggest_project">Le plus gros</string>
+ <string name="smallest_project">Le plus petit</string>
+ <string name="most_avanced">Le plus avancé</string>
+ <string name="closest">Le plus proche</string>
+ <string name="user">Utilisateur</string>
+ <string name="city">Ville</string>
+ <string name="name">Nom</string>
+ <string name="first_name">Prénom</string>
+ <string name="your_city">Votre ville</string>
+ <string name="your_name">Votre nom</string>
+ <string name="your_first_name">Votre prénom</string>
+ <string name="change_your_city">Modifier votre ville</string>
+ <string name="change_your_name">Modifier votre nom</string>
+ <string name="change_your_first_name">Modifier votre prénom</string>
+ <string name="gender">Sexe</string>
+ <string name="your_email">Votre Email</string>
+ <string name="project_submitted">Projet soumis</string>
+ <string name="bookmark">Favoris</string>
+ <string name="change_your_email">Modifier votre Email</string>
+ <string name="financed">Financé</string>
+ <string name="register">S\'inscrire</string>
+ <string name="days">%s days</string>
+ <string name="currency">%s €</string>
</resources>
\ No newline at end of file
<color name="bleu">#90083BA6</color>
<color name="monJaune">#ffff00A6</color>
<color name="white">#ffffff</color>
- <color name="background">#f0f0f0</color>
+ <color name="background">#e0e0e0</color>
<color name="red">#ff0000</color>
<color name="green">#00ff00</color>
<color name="blue">#0000ff</color>
<color name="yellow">#ffff00</color>
+ <color name="blue2">#a06990ee</color>
+ <color name="orange">#ffb95a</color>
<!-- color name="background">#0d0d0d0</color -->
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
+ <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- Application theme. -->
<item name="android:minHeight">30dip</item>
<item name="android:maxHeight">30dip</item>
</style>
+
+
+ <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
+ <item name="android:background">@color/blue2</item>
+ </style>
</resources>
\ No newline at end of file
package adullact.publicrowdfunding;
-import java.util.ArrayList;
+import java.util.List;
-import adullact.publicrowdfunding.controller.preferences.preferencesFragment;
-import adullact.publicrowdfunding.fragment.v4.register.ConnexionFragment;
+import adullact.publicrowdfunding.controller.profile.preferences.preferencesFragment;
+import adullact.publicrowdfunding.controller.project.all.ListProjectsFragment;
+import adullact.publicrowdfunding.controller.project.all.MapFragment;
+import adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment;
+import adullact.publicrowdfunding.controller.register.ConnexionFragment;
import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
-import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
-import adullact.publicrowdfunding.model.local.callback.WhatToDo;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Funding;
import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.Resource;
import adullact.publicrowdfunding.model.local.ressource.User;
import adullact.publicrowdfunding.model.local.utilities.Share;
-import adullact.publicrowdfunding.model.local.utilities.SyncServerToLocal;
-import adullact.publicrowdfunding.model.local.utilities.sortProjects;
+import adullact.publicrowdfunding.model.server.event.CreateEvent;
import adullact.publicrowdfunding.views.SimpleLine;
-import android.app.AlertDialog;
-import android.app.SearchManager;
+import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
-import android.view.LayoutInflater;
-import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.SearchView;
-import android.widget.SearchView.OnCloseListener;
-import android.widget.SearchView.OnQueryTextListener;
import android.widget.TextView;
+import android.widget.Toast;
import com.google.android.gms.maps.model.LatLng;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class MainActivity extends FragmentActivity {
private DrawerLayout mDrawerLayout;
private LinearLayout mDrawerList;
- public ActionBarDrawerToggle mDrawerToggle;
+ public static ActionBarDrawerToggle mDrawerToggle;
private Button m_button_add_projet;
private LinearLayout m_button_account;
private Button m_button_authentificate;
private Button m_button_map_projects;
private Button m_button_all_projects;
+ private Button m_button_change_account;
private Button m_button_deconnexion;
private Button m_Button_preferences;
private SimpleLine m_separator_2;
private SimpleLine m_separator_3;
- protected ArrayList<Project> p_project_displayed;
+ private User me;
- private SyncServerToLocal sync;
+ private boolean isTablet;
- private User me;
+ private android.widget.FrameLayout filter;
+
+ private Activity _this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- p_project_displayed = new ArrayList<Project>();
+ isTablet = isTabletDevice(this.getBaseContext());
- syncProjects();
+ _this = this;
- mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawerList = (LinearLayout) findViewById(R.id.left);
+ if (!isTablet) {
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
-
- mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
- R.drawable.ic_drawer, /* nav drawer image */
- R.string.ask, /* "open drawer" */
- R.string.ask /* "close drawer" */
- ) {
- public void onDrawerClosed(View view) {
- invalidateOptionsMenu();
- mDrawerLayout.setClickable(true);
- }
+ managerDrawerMenu(savedInstanceState);
+ }
- public void onDrawerOpened(View drawerView) {
- invalidateOptionsMenu();
- }
- };
- mDrawerLayout.setDrawerListener(mDrawerToggle);
+ mDrawerList = (LinearLayout) findViewById(R.id.left);
- if (savedInstanceState == null) {
- launchDefaultFragment();
- }
+ filter = (android.widget.FrameLayout) findViewById(R.id.big_filter);
gererPanneauMenu();
isConnect();
geolocalisation();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
-
- switch (item.getItemId()) {
- case R.id.action_sort:
- sort();
- break;
- default:
- return super.onOptionsItemSelected(item);
+ if (savedInstanceState == null) {
+ launchDefaultFragment();
}
- return true;
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
- mDrawerToggle.syncState();
+ if (!isTablet) {
+ mDrawerToggle.syncState();
+ }
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- mDrawerToggle.onConfigurationChanged(newConfig);
+ if (!isTablet) {
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
}
private void gererPanneauMenu() {
- final MainActivity _this = this;
this.invalidateOptionsMenu();
m_separator_1 = (SimpleLine) findViewById(R.id.separator_1);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
- // ft.setCustomAnimations(R.anim.enter, R.anim.exit);
Fragment fragment = new ConnexionFragment();
- ft.replace(R.id.content_frame, fragment);
+ ft.replace(R.id.big_font, fragment);
+ ft.setCustomAnimations(R.anim.popup_enter, R.anim.no_anim);
ft.commit();
- mDrawerLayout.closeDrawer(mDrawerList);
+ closeDrawer();
+
+ filter.setVisibility(View.VISIBLE);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(_this,
+ R.anim.fade_enter);
+ filter.setAnimation(fadeInAnimation);
+ filter.animate();
}
});
@Override
public void onClick(View v) {
- Intent in = new Intent(
- getBaseContext().getApplicationContext(),
- adullact.publicrowdfunding.controller.addProject.MainActivity.class);
+ FragmentTransaction ft = getSupportFragmentManager()
+ .beginTransaction();
- startActivity(in);
+ // ft.setCustomAnimations(R.anim.enter, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.add.addProjectFragment();
+ ft.addToBackStack(null);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+ closeDrawer();
}
});
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
- // ft.setCustomAnimations(R.anim.enter, R.anim.exit);
- Fragment fragment = new adullact.publicrowdfunding.fragment.v4.profile.ProfilePagerFragment();
+ Fragment fragment = new adullact.publicrowdfunding.controller.profile.ProfilePagerFragment();
Bundle bundle = new Bundle();
bundle.putString("idUser", me.getResourceId());
fragment.setArguments(bundle);
ft.replace(R.id.content_frame, fragment);
ft.commit();
- mDrawerLayout.closeDrawer(mDrawerList);
-
+ closeDrawer();
}
});
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- /*
- * Intent in = new Intent(
- * getBaseContext().getApplicationContext(),
- * adullact.publicrowdfunding
- * .controller.validateProject.MainActivity.class);
- * startActivity(in);
- */
+
+ FragmentTransaction ft = getSupportFragmentManager()
+ .beginTransaction();
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.validate.MainActivity();
+ Bundle bundle = new Bundle();
+ fragment.setArguments(bundle);
+ ft.addToBackStack(null);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+
+ closeDrawer();
}
});
// ft.setCustomAnimations(R.anim.enter, R.anim.exit);
Fragment fragment = new MapFragment();
-
+ ft.addToBackStack(null);
ft.replace(R.id.content_frame, fragment);
ft.commit();
- mDrawerLayout.closeDrawer(mDrawerList);
+ closeDrawer();
}
});
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
Fragment fragment = new preferencesFragment();
-
ft.replace(R.id.content_frame, fragment);
+ ft.addToBackStack(null);
ft.commit();
- mDrawerLayout.closeDrawer(mDrawerList);
+ closeDrawer();
}
});
}
});
+ m_button_change_account = (Button) findViewById(R.id.button_changeAccount);
+ m_button_change_account.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ FragmentTransaction ft = getSupportFragmentManager()
+ .beginTransaction();
+ Fragment fragment = new ConnexionFragment();
+ ft.replace(R.id.big_font, fragment);
+ ft.setCustomAnimations(R.anim.popup_enter, R.anim.no_anim);
+ ft.commit();
+
+ closeDrawer();
+ filter.setVisibility(View.VISIBLE);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(_this,
+ R.anim.fade_enter);
+ filter.setAnimation(fadeInAnimation);
+ filter.animate();
+
+ }
+ });
+
m_button_deconnexion = (Button) findViewById(R.id.button_deconnexion);
m_button_deconnexion.setOnClickListener(new View.OnClickListener() {
@Override
utilisateurVille = (TextView) findViewById(R.id.utilisateur_ville);
utilisateurName = (TextView) findViewById(R.id.utilisateur_name);
avatar = (ImageView) findViewById(R.id.avatar);
-
+ geolocalisation();
}
- public void setDrawerMenu(boolean connect) {
+ public void setDrawerMenu(boolean connect, boolean admin) {
if (connect) {
m_button_account.setVisibility(View.VISIBLE);
m_button_authentificate.setVisibility(View.GONE);
m_button_deconnexion.setVisibility(View.VISIBLE);
m_Button_preferences.setVisibility(View.VISIBLE);
m_button_add_projet.setVisibility(View.VISIBLE);
- m_button_validate_projects.setVisibility(View.VISIBLE);
+ m_button_change_account.setVisibility(View.VISIBLE);
m_separator_1.setVisibility(View.VISIBLE);
m_separator_2.setVisibility(View.VISIBLE);
m_separator_3.setVisibility(View.VISIBLE);
+ if (admin) {
+ m_button_validate_projects.setVisibility(View.VISIBLE);
+ } else {
+ m_button_validate_projects.setVisibility(View.GONE);
+ }
} else {
m_button_account.setVisibility(View.GONE);
m_button_authentificate.setVisibility(View.VISIBLE);
m_button_deconnexion.setVisibility(View.GONE);
m_Button_preferences.setVisibility(View.GONE);
m_button_add_projet.setVisibility(View.GONE);
+ m_button_change_account.setVisibility(View.GONE);
m_button_validate_projects.setVisibility(View.GONE);
m_separator_1.setVisibility(View.GONE);
}
public void isConnect() {
- try {
- Account account = Account.getOwn();
-
- setDrawerMenu(true);
- account.getUser(new WhatToDo<User>() {
-
- @Override
- public void hold(User resource) {
- me = resource;
- utilisateurName.setText(Share.formatString(resource
- .getPseudo()));
- utilisateurVille.setText(Share.formatString(resource
- .getCity()));
- if (resource.getGender().equals("0")) {
- avatar.setImageResource(R.drawable.male_user_icon);
- } else {
- avatar.setImageResource(R.drawable.female_user_icon);
- }
+ setDrawerMenu(false, false);
+ if (Account.isConnect()) {
+ try {
+ Account account = Account.getOwn();
+ setDrawerMenu(true, account.isAdmin());
+ account.getUser(new HoldToDo<User>() {
- }
+ @Override
+ public void hold(User resource) {
+ me = resource;
+ utilisateurName.setText(Share.formatString(resource
+ .getPseudo()));
+ utilisateurVille.setText(Share.formatString(resource
+ .getCity()));
+ if (resource.getGender().equals("0")) {
+ avatar.setImageResource(R.drawable.male_user_icon);
+ } else {
+ avatar.setImageResource(R.drawable.female_user_icon);
+ }
- @Override
- public void eventually() {
+ }
- }
+ });
+ } catch (NoAccountExistsInLocal e1) {
+
+ }
+ } else {
- });
- } catch (NoAccountExistsInLocal e1) {
- setDrawerMenu(false);
}
}
locationManager.requestLocationUpdates(locationProvider, 10000, 0,
locationListener);
} catch (Exception e) {
- System.out.println("Erreur 2");
+ e.printStackTrace();
}
}
try {
locationManager.removeUpdates(locationListener);
} catch (Exception e) {
- System.out.println("Erreur 1");
+ e.printStackTrace();
}
}
public void launchDefaultFragment() {
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction()
+ .disallowAddToBackStack();
Fragment fragment = new ListProjectsFragment();
fragment.setHasOptionsMenu(true);
ft.replace(R.id.content_frame, fragment, "allProjectFragment");
ft.commit();
- mDrawerLayout.closeDrawer(mDrawerList);
+ closeDrawer();
}
public void geolocalisation() {
.findFragmentByTag("allProjectFragment");
if (myFragment.isVisible()) {
if (Share.displayPosition == false) {
- sortProjects.sortAlmostFunded(p_project_displayed);
launchDefaultFragment();
locationManager.removeUpdates(locationListener);
locationListener = null;
}
} catch (NullPointerException e) {
- System.out.println("Initialisation");
+ e.printStackTrace();
}
}
}
- public void sort() {
- ArrayAdapter<String> adapter = null;
- if (Share.position == null) {
- String names[] = { "Le plus gros projet", "Le plus petit projet",
- "Le plus avancé" };
- adapter = new ArrayAdapter<String>(MainActivity.this,
- android.R.layout.simple_list_item_1, names);
- } else {
- String names[] = { "Le plus gros projet", "Le plus petit",
- "Le plus avancé", "Le plus proche (Défaut)" };
- adapter = new ArrayAdapter<String>(MainActivity.this,
- android.R.layout.simple_list_item_1, names);
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (!isTablet && MainActivity.mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
}
- AlertDialog.Builder alertDialog = new AlertDialog.Builder(
- MainActivity.this);
- LayoutInflater inflater = getLayoutInflater();
- View convertView = (View) inflater.inflate(R.layout.listeview, null);
- alertDialog.setView(convertView);
- alertDialog.setTitle("Trier par");
- ListView lv = (ListView) convertView.findViewById(R.id.liste);
-
- lv.setAdapter(adapter);
- final AlertDialog dialog = alertDialog.create();
- lv.setOnItemClickListener(new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
-
- switch (position) {
- case 0:
-
- sortProjects.sortBiggestProjectFirst(p_project_displayed);
- launchDefaultFragment();
- dialog.dismiss();
-
- break;
- case 1:
- sortProjects.sortBiggestProjectLast(p_project_displayed);
- launchDefaultFragment();
- dialog.dismiss();
- break;
- case 2:
-
- sortProjects.sortAlmostFunded(p_project_displayed);
- launchDefaultFragment();
- dialog.dismiss();
- break;
-
- case 3:
- sortProjects.sortClothersProject(p_project_displayed);
- launchDefaultFragment();
- dialog.dismiss();
- break;
-
- }
- }
- });
-
- dialog.show();
-
+ return false;
}
- public void search(Menu menu) {
- MenuItem searchItem;
- searchItem = menu.findItem(R.id.action_search);
- assert searchItem != null;
- SearchView searchView = (SearchView) searchItem.getActionView();
- SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
- if (null != searchManager) {
- searchView.setSearchableInfo(searchManager
- .getSearchableInfo(getComponentName()));
- }
- searchView.setIconifiedByDefault(true);
- searchView.setOnCloseListener(new OnCloseListener() {
+ private boolean isTabletDevice(Context context) {
- @Override
- public boolean onClose() {
- p_project_displayed = new ArrayList<Project>(sync.getProjects());
- launchDefaultFragment();
- return false;
- }
+ if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ }
- });
+ return false;
- searchView.setOnQueryTextListener(new OnQueryTextListener() {
+ }
- public boolean onQueryTextSubmit(String query) {
+ public void managerDrawerMenu(Bundle savedInstanceState) {
- p_project_displayed = sync.searchInName(query);
- launchDefaultFragment();
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
- return false;
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
+ R.drawable.ic_drawer, /* nav drawer image */
+ R.string.ask, /* "open drawer" */
+ R.string.ask /* "close drawer" */
+ ) {
+ public void onDrawerClosed(View view) {
+ invalidateOptionsMenu();
+ mDrawerLayout.setClickable(true);
}
- @Override
- public boolean onQueryTextChange(String newText) {
- return false;
+ public void onDrawerOpened(View drawerView) {
+ invalidateOptionsMenu();
}
-
- });
+ };
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
}
- public void syncProjects() {
-
- sync = SyncServerToLocal.getInstance();
- sync.sync(new HoldAllToDo<Project>() {
-
- @Override
- public void holdAll(ArrayList<Project> projects) {
-
- ArrayList<Project> allSync = new ArrayList<Project>(sync
- .getProjects());
- p_project_displayed = allSync;
+ public void closeDrawer() {
+ if (!isTablet) {
+ mDrawerLayout.closeDrawer(mDrawerList);
+ }
+ }
- launchDefaultFragment();
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == 1) {
+ if (resultCode == RESULT_OK) {
+ // Payement ok !
+ final String idProject = data.getStringExtra("idProject");
+ final String somme = data.getStringExtra("somme");
+ final FragmentManager fm = this.getSupportFragmentManager();
+ final List<Fragment> fragments = this
+ .getSupportFragmentManager().getFragments();
+ new Project().getCache(idProject).toResource(
+ new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ try {
+ resource.finance(somme,
+ new CreateEvent<Funding>() {
+
+ @Override
+ public void errorResourceIdAlreadyUsed() {
+ // TODO Auto-generated
+ // method stub
+
+ }
+
+ @Override
+ public void onCreate(
+ Funding resource) {
+ // Tout est ok !
+
+ for (Fragment fragment : fragments) {
+ if (fragment instanceof ProjectPagerFragment) {
+ fm.beginTransaction()
+ .detach(fragment)
+ .commit();
+ }
+ }
+ Bundle bundle = new Bundle();
+ bundle.putString(
+ "idProject",
+ idProject);
+
+ FragmentTransaction ft = getSupportFragmentManager()
+ .beginTransaction();
+ Fragment fragment = new ProjectPagerFragment();
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(
+ R.id.content_frame,
+ fragment);
+ Toast.makeText(
+ getBaseContext(),
+ "Participation prise en compte !",
+ Toast.LENGTH_LONG)
+ .show();
+
+ ft.commitAllowingStateLoss();
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ // TODO Auto-generated
+ // method stub
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ // TODO Auto-generated
+ // method stub
+
+ }
+
+ @Override
+ public void errorServer() {
+ // TODO Auto-generated
+ // method stub
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ });
}
- });
+ if (resultCode == RESULT_CANCELED) {
+ // Echec du payement.
+ }
+ }
}
-
}
\ No newline at end of file
package adullact.publicrowdfunding;
+import adullact.publicrowdfunding.model.local.ressource.Account;
import android.app.Application;
import android.content.Context;
+import android.content.SharedPreferences;
/**
- * Created by Ferrand on 19/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class PublicrowdFundingApplication extends Application {
private static Context m_context;
+ private static SharedPreferences m_sharedPreferences;
@Override
public void onCreate(){
super.onCreate();
PublicrowdFundingApplication.m_context = getApplicationContext();
- System.setProperty("http.keepAlive", "false");
+ PublicrowdFundingApplication.m_sharedPreferences = getSharedPreferences("prefs", 0);
+ System.setProperty("http.keepAlive", "false");
+
+ Account.autoConnect();
}
public static Context context () {
return PublicrowdFundingApplication.m_context;
}
+ public static SharedPreferences sharedPreferences () {
+ return PublicrowdFundingApplication.m_sharedPreferences;
+ }
+
}
--- /dev/null
+package adullact.publicrowdfunding.controller.adaptor;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class CarouselAdaptor extends BaseAdapter {
+
+ private ArrayList<Integer> mData = new ArrayList<Integer>(0);
+ private Context mContext;
+
+ public CarouselAdaptor(Context context) {
+ mContext = context;
+ }
+
+ public void setData(ArrayList<Integer> data) {
+ mData = data;
+ }
+
+ @Override
+ public int getCount() {
+ return mData.size();
+ }
+
+ @Override
+ public Object getItem(int pos) {
+ return mData.get(pos);
+ }
+
+ @Override
+ public long getItemId(int pos) {
+ return pos;
+ }
+
+ @Override
+ public View getView(int arg0, View arg1, ViewGroup arg2) {
+ ImageView mImage= new ImageView(mContext);
+ mImage.setImageResource(mData.get(arg0));
+ mImage.setScaleX((float) 1.7);
+ mImage.setScaleY((float) 1.7);
+ return mImage;
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.adaptor;
+
+import java.util.Vector;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Commentary;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.RatingBar;
+import android.widget.TextView;
+
+/**
+ *
+ * @author warting {@link https://github.com/warting/AndroidChatBubbles}
+ *
+ */
+public class CommentsAdaptor extends ArrayAdapter<Commentary> {
+
+ private TextView commentaire;
+ private TextView utilisateurName;
+ private TextView utilisateurVille;
+ private RatingBar rating;
+ private TextView titre;
+ private Vector<Commentary> commentaries = new Vector<Commentary>();
+ private ImageView avatar;
+ private CommentsAdaptor _this;
+
+ public void setCommentaries(Vector<Commentary> object) {
+ commentaries = object;
+ _this = this;
+ }
+
+ public CommentsAdaptor(Context context, int textViewResourceId) {
+ super(context, textViewResourceId);
+ this.notifyDataSetChanged();
+ }
+
+ public int getCount() {
+ return this.commentaries.size();
+ }
+
+ public Commentary getItem(int index) {
+ return this.commentaries.get(index);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View row = convertView;
+
+ LayoutInflater inflater = null;
+ if (row == null) {
+ inflater = (LayoutInflater) this.getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ row = inflater.inflate(R.layout.adaptor_comment, parent, false);
+ }
+
+ Commentary coment = getItem(position);
+
+ commentaire = (TextView) row.findViewById(R.id.comment);
+ commentaire.setText(Share.formatString(coment.getMessage()));
+
+ titre = (TextView) row.findViewById(R.id.titre);
+ titre.setText(Share.formatString(coment.getTitle()));
+
+ utilisateurVille = (TextView) row.findViewById(R.id.utilisateur_ville);
+
+ avatar = (ImageView) row.findViewById(R.id.avatar);
+
+ rating = (RatingBar) row.findViewById(R.id.rating);
+ rating.setRating((float) coment.getMark());
+ rating.setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+ });
+ rating.setFocusable(false);
+ utilisateurName = (TextView) row.findViewById(R.id.utilisateur_name);
+ coment.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ utilisateurName.setText(Share.formatString(resource.getPseudo()));
+ utilisateurVille.setText(Share.formatString(resource.getCity()));
+ if (resource.getGender().equals("0")) {
+ avatar.setImageResource(R.drawable.male_user_icon);
+ } else {
+ avatar.setImageResource(R.drawable.female_user_icon);
+ }
+ _this.notifyDataSetChanged();
+
+ }
+
+ });
+
+ return row;
+ }
+
+ public Bitmap decodeToBitmap(byte[] decodedByte) {
+ return BitmapFactory
+ .decodeByteArray(decodedByte, 0, decodedByte.length);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.adaptor;
+
+import java.util.HashMap;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.Calcul;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import adullact.publicrowdfunding.model.local.utilities.Utility;
+import adullact.publicrowdfunding.views.CustomProgressBar;
+import android.support.v4.app.FragmentActivity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
+import com.google.android.gms.maps.model.Marker;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class MarkerWindowAdaptor extends FragmentActivity implements InfoWindowAdapter {
+
+ private TextView titre_projet_liste;
+ private TextView description_projet_liste;
+ private TextView temps_restant_projet_liste;
+ private CustomProgressBar avancement_projet_liste;
+ private ImageView illustration;
+ private TextView sommeFunded;
+ private TextView sommeDemander;
+ private TextView distance;
+
+ private final HashMap<Marker, Project> markers;
+
+ private LayoutInflater inflater;
+
+ public MarkerWindowAdaptor(LayoutInflater inflater, HashMap<Marker, Project> markers) {
+ this.inflater=inflater;
+ this.markers = markers;
+
+ }
+
+ public void displayInfo(Project projet) {
+ titre_projet_liste.setText(projet.getName());
+ description_projet_liste.setText(projet.getDescription());
+ String days = this.getResources().getString(R.string.days, projet.getNumberOfDayToEnd());
+ temps_restant_projet_liste.setText(days);
+
+ String requested = this.getResources().getString(R.string.currency, projet.getRequestedFunding());
+ avancement_projet_liste.setProgress(projet.getPercentOfAchievement());
+ sommeDemander.setText(requested);
+ String currentFunded = this.getResources().getString(R.string.currency, projet.getCurrentFunding());
+ sommeFunded.setText(currentFunded);
+ if (projet.getIllustration() != 0) {
+ illustration.setImageResource(Utility.getDrawable(projet
+ .getIllustration()));
+ } else {
+ illustration.setImageResource(R.drawable.ic_launcher);
+ }
+
+ distance.setVisibility(View.GONE);
+ try {
+ distance.setText(R.string.distance
+ + Calcul.diplayDistance(Share.position,
+ projet.getPosition()));
+ distance.setVisibility(View.VISIBLE);
+ } catch (NullPointerException e) {
+ distance.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public View getInfoContents(Marker arg0) {
+ View v = inflater.inflate(
+ R.layout.fiche_project, null);
+
+ titre_projet_liste = (TextView) v.findViewById(R.id.titre_projet_liste);
+ description_projet_liste = (TextView) v
+ .findViewById(R.id.description_projet_liste);
+ temps_restant_projet_liste = (TextView) v
+ .findViewById(R.id.nombre_jour_restant_detail);
+ avancement_projet_liste = (CustomProgressBar) v
+ .findViewById(R.id.avancement_projet_liste);
+ illustration = (ImageView) v.findViewById(R.id.icon);
+ sommeDemander = (TextView) v.findViewById(R.id.sommeeDemande);
+
+ sommeFunded = (TextView) v.findViewById(R.id.sommeFund);
+ distance = (TextView) v.findViewById(R.id.distance);
+
+ displayInfo(markers.get(arg0));
+
+ return v;
+ }
+
+ @Override
+ public View getInfoWindow(Marker arg0) {
+ return null;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.adaptor;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.Calcul;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import adullact.publicrowdfunding.model.local.utilities.Utility;
+import adullact.publicrowdfunding.views.CustomProgressBar;
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ProjectAdaptor extends ArrayAdapter<Project> {
+
+ Context mContext;
+ int layoutResourceId;
+ ArrayList<Project> data;
+ private Activity activity;
+ private View v;
+
+ public ProjectAdaptor(Context context, int resource, ArrayList<Project> listItem, Activity activity) {
+ super(context, resource, listItem);
+ this.mContext = context;
+ this.layoutResourceId = resource;
+ this.data = listItem;
+ this.activity = activity;
+
+ }
+
+ private static class UserHolder {
+
+ public TextView titre_projet_liste;
+ public TextView description_projet_liste;
+ public TextView temps_restant_projet_liste;
+ public CustomProgressBar avancement_projet_liste;
+ public ImageView illustration;
+ public TextView sommeFunded;
+ public TextView sommeDemander;
+ public TextView distance;
+
+ }
+
+ @Override
+ public int getCount() {
+ // TODO Auto-generated method stub
+ return data.size();
+ }
+
+ public Project getItem(int index) {
+ return this.data.get(index);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ v = convertView;
+ UserHolder holder = new UserHolder();
+
+ // First let's verify the convertView is not null
+ if (convertView == null) {
+ // This a new view we inflate the new layout
+ LayoutInflater inflater = (LayoutInflater) mContext
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(layoutResourceId, null);
+
+ holder.titre_projet_liste = (TextView) v
+ .findViewById(R.id.titre_projet_liste);
+ holder.description_projet_liste = (TextView) v
+ .findViewById(R.id.description_projet_liste);
+ holder.temps_restant_projet_liste = (TextView) v
+ .findViewById(R.id.nombre_jour_restant_detail);
+ holder.avancement_projet_liste = (CustomProgressBar) v
+ .findViewById(R.id.avancement_projet_liste);
+ holder.illustration = (ImageView) v.findViewById(R.id.icon);
+ holder.sommeDemander = (TextView) v
+ .findViewById(R.id.sommeeDemande);
+
+ holder.sommeFunded = (TextView) v
+ .findViewById(R.id.sommeFund);
+ holder.distance = (TextView) v
+ .findViewById(R.id.distance);
+ v.setTag(holder);
+ } else {
+ holder = (UserHolder) v.getTag();
+ }
+ Project projet = data.get(position);
+ holder.titre_projet_liste.setText(projet.getName());
+ holder.description_projet_liste.setText(projet.getDescription());
+ String days = mContext.getResources().getString(R.string.days, projet.getNumberOfDayToEnd());
+ holder.temps_restant_projet_liste.setText(days);
+
+ holder.avancement_projet_liste.setProgress(projet
+ .getPercentOfAchievement());
+ String requested = mContext.getResources().getString(R.string.currency,projet.getRequestedFunding());
+ holder.sommeDemander.setText(requested);
+ String funded = mContext.getResources().getString(R.string.currency,projet.getCurrentFunding());
+ holder.sommeFunded.setText(funded);
+ if (projet.getIllustration() != 0) {
+ holder.illustration.setImageResource(Utility.getDrawable(projet
+ .getIllustration()));
+ } else {
+ holder.illustration.setImageResource(R.drawable.ic_launcher);
+ }
+
+ holder.distance.setVisibility(View.GONE);
+ try{
+ String distance = activity.getResources().getString(R.string.distance);
+ holder.distance.setText(distance + " " + Calcul.diplayDistance(Share.position, projet.getPosition()));
+ holder.distance.setVisibility(View.VISIBLE);
+ }catch(NullPointerException e){
+ holder.distance.setVisibility(View.GONE);
+ }
+
+ return v;
+
+ }
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.profile;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.ProjectAdaptor;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ListBookmarksFragment extends Fragment {
+
+ private ListView listeProjets;
+
+ private ArrayList<Project> projets;
+
+ private ArrayAdapter<Project> adapter;
+
+ private View view;
+
+ private TextView empty;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ view = inflater.inflate(R.layout.fragment_list_project_no_refresh,
+ container, false);
+
+ listeProjets = (ListView) view.findViewById(R.id.liste);
+
+ empty = (TextView) view.findViewById(R.id.empty);
+ listeProjets.setEmptyView(empty);
+
+ projets = new ArrayList<Project>();
+
+ adapter = new ProjectAdaptor(this.getActivity().getBaseContext(),
+ R.layout.adaptor_project, projets, getActivity());
+ listeProjets.setAdapter(adapter);
+
+ listeProjets.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ //ft.setCustomAnimations(R.anim.enter_2, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", projets.get(position).getResourceId());
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+ }
+ });
+
+ Bundle bundle = this.getArguments();
+ String idUser = bundle.getString("idUser");
+
+ Cache<User> cache = new User().getCache(idUser);
+ cache.toResource(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ resource.getBookmarkedProjects(new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ projets.add(resource);
+ adapter.notifyDataSetChanged();
+ }
+
+ });
+ }
+ });
+
+ return view;
+ }
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.profile;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.ProjectAdaptor;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ListFinancedProjectsFragment extends Fragment {
+
+ private ListView listeProjets;
+
+ private ArrayList<Project> projets;
+
+ private ArrayAdapter<Project> adapter;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ final View view = inflater.inflate(
+ R.layout.fragment_list_project_no_refresh, container, false);
+
+ listeProjets = (ListView) view.findViewById(R.id.liste);
+
+ TextView empty = (TextView) view.findViewById(R.id.empty);
+ listeProjets.setEmptyView(empty);
+
+ projets = new ArrayList<Project>();
+
+ adapter = new ProjectAdaptor(this.getActivity().getBaseContext(),
+ R.layout.adaptor_project, projets, getActivity());
+
+ listeProjets.setAdapter(adapter);
+
+ listeProjets.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ FragmentTransaction ft = getFragmentManager()
+ .beginTransaction();
+ // ft.setCustomAnimations(R.anim.enter_2, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", projets.get(position)
+ .getResourceId());
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+ }
+ });
+
+ Bundle bundle = this.getArguments();
+ String idUser = bundle.getString("idUser");
+
+ Cache<User> cache = new User().getCache(idUser);
+ cache.toResource(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ resource.getFundedProjects(new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ projets.add(resource);
+ adapter.notifyDataSetChanged();
+ }
+
+ });
+ }
+
+ });
+
+ return view;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.profile;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.ProjectAdaptor;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ListSubmitedProjectsFragment extends Fragment {
+
+ private ListView listeProjets;
+
+ private ArrayList<Project> projets;
+
+ private ArrayAdapter<Project> adapter;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ final View view = inflater.inflate(
+ R.layout.fragment_list_project_no_refresh, container, false);
+
+ listeProjets = (ListView) view.findViewById(R.id.liste);
+
+ TextView empty = (TextView) view.findViewById(R.id.empty);
+ listeProjets.setEmptyView(empty);
+
+ projets = new ArrayList<Project>();
+
+ adapter = new ProjectAdaptor(this.getActivity().getBaseContext(),
+ R.layout.adaptor_project, projets, getActivity());
+
+ listeProjets.setAdapter(adapter);
+
+ listeProjets.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ FragmentTransaction ft = getFragmentManager()
+ .beginTransaction();
+ // ft.setCustomAnimations(R.anim.enter_2, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", projets.get(position)
+ .getResourceId());
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+ }
+ });
+
+ Bundle bundle = this.getArguments();
+ String idUser = bundle.getString("idUser");
+
+ Cache<User> cache = new User().getCache(idUser);
+ cache.toResource(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ resource.getProposedProjects(new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ projets.add(resource);
+ adapter.notifyDataSetChanged();
+ }
+ });
+ }
+ });
+
+ return view;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.profile;
+
+import adullact.publicrowdfunding.R;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentStatePagerAdapter;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class PagerAdaptor extends FragmentStatePagerAdapter {
+
+ private String idUser;
+
+ private Context context;
+
+
+ private int[] titles = {R.string.project_submitted, R.string.bookmark, R.string.financed};
+
+ public PagerAdaptor(Context context, FragmentManager fm, String idUser) {
+ super(fm);
+ this.idUser = idUser;
+ this.context = context;
+ }
+
+ final int PAGE_COUNT = 3;
+
+ @Override
+ public int getCount() {
+ return PAGE_COUNT;
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+
+ Fragment fragment = null;
+ Bundle bundle = new Bundle();
+
+ switch (position) {
+
+ case 0:
+ fragment = new ListSubmitedProjectsFragment();
+ bundle.putString("idUser",idUser);
+ fragment.setArguments(bundle);
+ return fragment;
+ case 1:
+ fragment = new ListBookmarksFragment();
+ bundle.putString("idUser",idUser);
+ fragment.setArguments(bundle);
+ return fragment;
+ case 2:
+ fragment = new ListFinancedProjectsFragment();
+ bundle.putString("idUser",idUser);
+ fragment.setArguments(bundle);
+ return fragment;
+
+ default:
+ return new ListBookmarksFragment();
+ }
+ }
+
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ String title = context.getResources().getString(titles[position % PAGE_COUNT]);
+ return title;
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.profile;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.view.ViewPager;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
+import android.view.animation.RotateAnimation;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ProfilePagerFragment extends Fragment {
+
+ protected Project projetCurrent;
+
+ FragmentTransaction fragMentTra = null;
+ private String idUser;
+ private FragmentManager fm;
+
+ private TextView m_pseudo;
+ private TextView m_ville;
+ private ImageView m_avatar;
+
+ private FrameLayout ribbon;
+
+ private TextView m_admin;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ View view = inflater.inflate(R.layout.pager_tab_profile, container,
+ false);
+ ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
+
+ m_pseudo = (TextView) view.findViewById(R.id.pseudo);
+ m_ville = (TextView) view.findViewById(R.id.ville);
+
+ m_admin = (TextView) view.findViewById(R.id.text_admin);
+ RotateAnimation rotate = (RotateAnimation) AnimationUtils
+ .loadAnimation(getActivity(), R.anim.rotate);
+ m_admin.setAnimation(rotate);
+ ribbon = (FrameLayout) view.findViewById(R.id.admin_ribbon);
+ ribbon.setVisibility(View.GONE);
+
+ m_avatar = (ImageView) view.findViewById(R.id.avatar);
+
+ Bundle bundle = this.getArguments();
+ idUser = bundle.getString("idUser");
+
+ new User().getCache(idUser).toResource(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ m_pseudo.setText(Share.formatString(resource.getPseudo()));
+ m_ville.setText(Share.formatString(resource.getCity()));
+ if (resource.getGender().equals("0")) {
+ m_avatar.setImageResource(R.drawable.male_user_icon);
+ } else {
+ m_avatar.setImageResource(R.drawable.female_user_icon);
+ }
+
+ }
+
+ });
+
+ new Account().getCache(idUser).toResource(new HoldToDo<Account>() {
+
+ @Override
+ public void hold(Account resource) {
+ if(resource.isAdmin()){
+ m_admin.setVisibility(View.VISIBLE);
+ ribbon.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+
+ adullact.publicrowdfunding.MainActivity _this = (adullact.publicrowdfunding.MainActivity) getActivity();
+
+ fm = _this.getSupportFragmentManager();
+ fm.beginTransaction().disallowAddToBackStack().commit();
+
+ Context context = this.getActivity().getBaseContext();
+ PagerAdaptor adaptor = new PagerAdaptor(context, fm, idUser);
+ viewPager.setAdapter(adaptor);
+ viewPager.setCurrentItem(1);
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ fm.popBackStack();
+
+ return true;
+ }
+ return false;
+ }
+ });
+ return view;
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.profile.preferences;
+
+import adullact.publicrowdfunding.MainActivity;
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.server.event.UpdateEvent;
+import android.os.Bundle;
+import android.preference.EditTextPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.SwitchPreference;
+import android.support.v4.preference.PreferenceFragment;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class preferencesFragment extends PreferenceFragment {
+
+ private User user;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.layout.fragment_preferences);
+
+ /*
+ * Utilisateur
+ */
+
+ final EditTextPreference ville = (EditTextPreference) findPreference("edittext_preference_ville");
+ final EditTextPreference nom = (EditTextPreference) findPreference("edittext_preference_nom");
+ final EditTextPreference prenom = (EditTextPreference) findPreference("edittext_preference_prenom");
+ final EditTextPreference email = (EditTextPreference) findPreference("edittext_preference_email");
+
+ final SwitchPreference genre = (SwitchPreference) findPreference("genre");
+ genre.setSwitchTextOn(R.string.female);
+ genre.setSwitchTextOff(R.string.male);
+
+ /*
+ * Compte
+ */
+
+ try {
+ Account account = Account.getOwn();
+ account.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+
+ user = resource;
+ resource.getName();
+ ville.setText(resource.getCity());
+ nom.setText(resource.getName());
+ prenom.setText(resource.getFirstName());
+ email.setText("");
+ if (resource.getGender().equals("1")) {
+ genre.setChecked(true);
+ } else {
+ genre.setChecked(false);
+ }
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ this.getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ }
+
+ ville.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(Preference preference,
+ Object newValue) {
+ String value = (String) newValue;
+ user.setCity(value);
+ update();
+ return true;
+ }
+ });
+
+ genre.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(Preference preference,
+ Object newValue) {
+ Boolean value = (Boolean) newValue;
+ String gender = null;
+ if (value) {
+ gender = "1";
+ } else {
+ gender = "0";
+ }
+
+ user.setGender(gender);
+ update();
+ return true;
+ }
+ });
+
+ email.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ public boolean onPreferenceChange(Preference preference,
+ Object newValue) {
+ //String value = (String) newValue;
+ //user.setEmail(value);
+ update();
+ return true;
+ }
+ });
+
+
+ }
+
+ public void update() {
+ super.onResume();
+ MainActivity _this = (MainActivity) this.getActivity();
+ _this.isConnect();
+
+ try {
+ Account account = Account.getOwn();
+ account.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User user) {
+ user.serverUpdate(new UpdateEvent<User>() {
+
+ @Override
+ public void onUpdate(User resource) {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ @Override
+ public void errorResourceIdDoesNotExist() {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ @Override
+ public void errorAdministratorRequired() {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ @Override
+ public void errorServer() {
+ Toast.makeText(getActivity().getBaseContext(),
+ R.string.error, Toast.LENGTH_SHORT)
+ .show();
+
+ }
+
+ });
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ this.getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.add;
+
+import adullact.publicrowdfunding.R;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class addLocationProjectFragment extends Fragment implements
+ OnMapClickListener {
+
+ private GoogleMap map;
+ private Marker marker;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ View view = null;
+ try {
+ /*
+ view = inflater.inflate(R.layout.activity_maps, container, false);
+
+ map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
+ .findFragmentById(R.id.)).getMap();
+
+ map.setOnMapClickListener(this);
+ map.setMyLocationEnabled(true);
+*/
+ } catch (Exception e) {
+ e.printStackTrace();
+ TextView texte = new TextView(getActivity());
+ texte.setText(R.string.error);
+ view = texte;
+ }
+
+ marker = null;
+ return view;
+ }
+
+ @Override
+ public void onMapClick(LatLng arg0) {
+ Toast.makeText(getActivity().getApplicationContext(),
+ "Emplacement de votre projet ajouté", Toast.LENGTH_SHORT)
+ .show();
+ if (marker == null) {
+ marker = map.addMarker(new MarkerOptions().position(arg0).title(
+ "Votre projet"));
+ } else {
+ marker.remove();
+ marker = map.addMarker(new MarkerOptions().position(arg0).title(
+ "Votre projet"));
+ }
+ }
+
+ public LatLng getPosition() {
+ return marker.getPosition();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.add;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.CarouselAdaptor;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.local.utilities.Utility;
+import adullact.publicrowdfunding.model.server.event.CreateEvent;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.google.android.gms.maps.model.LatLng;
+import com.touchmenotapps.carousel.simple.HorizontalCarouselLayout;
+import com.touchmenotapps.carousel.simple.HorizontalCarouselLayout.CarouselInterface;
+import com.touchmenotapps.carousel.simple.HorizontalCarouselStyle;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class addProjectFragment extends Fragment {
+
+ private EditText m_titre;
+ private EditText m_Description;
+ private EditText m_edit_text_somme;
+ private EditText m_email;
+ private EditText m_phone;
+ private EditText m_website;
+
+ private TextView m_user_pseudo;
+ private TextView m_user_ville;
+
+ private DatePicker m_dateFin;
+
+ private Button m_valider;
+
+ private Context context;
+
+ private int m_illustration;
+
+ private addLocationProjectFragment _map;
+
+ private User user;
+
+ private ImageView avatar;
+
+ private HorizontalCarouselStyle mStyle;
+ private HorizontalCarouselLayout mCarousel;
+ private CarouselAdaptor mAdapter;
+ private ArrayList<Integer> mData;
+
+ private LinearLayout loading;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ View view = inflater.inflate(R.layout.fragment_add_project, container,
+ false);
+
+ context = this.getActivity().getApplicationContext();
+
+ m_titre = (EditText) view.findViewById(R.id.titre);
+ m_Description = (EditText) view.findViewById(R.id.description);
+ m_dateFin = (DatePicker) view.findViewById(R.id.date_de_fin);
+ m_valider = (Button) view.findViewById(R.id.button_valider);
+ m_edit_text_somme = (EditText) view.findViewById(R.id.edit_text_somme);
+ m_user_pseudo = (TextView) view
+ .findViewById(R.id.utilisateur_soumission);
+ m_user_ville = (TextView) view.findViewById(R.id.ville);
+
+ m_email = (EditText) view.findViewById(R.id.mail);
+ m_website = (EditText) view.findViewById(R.id.website);
+ m_phone = (EditText) view.findViewById(R.id.phone);
+
+ m_edit_text_somme = (EditText) view.findViewById(R.id.edit_text_somme);
+
+ avatar = (ImageView) view.findViewById(R.id.avatar);
+
+ mCarousel = (HorizontalCarouselLayout) view
+ .findViewById(R.id.carousel_layout);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+
+ mCarousel.setOnCarouselViewChangedListener(new CarouselInterface() {
+
+ @Override
+ public void onItemChangedListener(View v, int position) {
+ m_illustration = position;
+ }
+ });
+
+ m_valider.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ /*
+ * Validation
+ */
+ }
+ });
+
+ loadContent();
+
+ return view;
+ }
+
+ public void addProjectRequest() {
+
+ String titre = null;
+ if (m_titre.length() == 0) {
+ Toast.makeText(context, "Merci de mettre un titre",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ titre = m_titre.getText().toString();
+
+ String description = null;
+ if (m_Description.length() == 0) {
+ Toast.makeText(context, "Merci de mettre une description",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ description = m_Description.getText().toString();
+
+ String somme = null;
+ if (m_edit_text_somme.length() == 0) {
+ Toast.makeText(context, "Merci de mettre la somme désiré",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ somme = m_edit_text_somme.getText().toString();
+
+ try {
+ int s = Integer.parseInt(somme);
+ if (s < 1) {
+ Toast.makeText(context, "Le montant est invalide",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ } catch (Exception e) {
+ Toast.makeText(context, "Le montant est invalide",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ int day = m_dateFin.getDayOfMonth();
+ int month = m_dateFin.getMonth() + 1;
+ int year = m_dateFin.getYear();
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(year, month, day);
+
+ String Stryear = "" + year;
+ String StrMonth = null;
+ if (month < 10) {
+ StrMonth = "0" + month;
+ } else {
+ StrMonth = "" + month;
+ }
+
+ String StrDay = "" + day;
+ LatLng position = new LatLng(0, 0);
+ try {
+ position = _map.getPosition();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ new Project(titre, description, user.getResourceId(), somme,
+ Utility.stringToDateTime(Stryear + "-" + StrMonth + "-"
+ + StrDay + " 00:00:00"),
+ Utility.stringToDateTime(Stryear + "-" + StrMonth + "-"
+ + StrDay + " 00:00:00"), position, m_illustration,
+ m_email.getText().toString(), m_website.getText().toString(),
+ m_phone.getText().toString(), false)
+ .serverCreate(new CreateEvent<Project>() {
+ @Override
+ public void errorResourceIdAlreadyUsed() {
+
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onCreate(Project resource) {
+
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ Toast.makeText(context, "Vous devez vous authentifier",
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorServer() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+ });
+
+ }
+
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public void supprimerCalendarView() {
+ int currentapiVersion = android.os.Build.VERSION.SDK_INT;
+ if (currentapiVersion >= 11) {
+ m_dateFin.setCalendarViewShown(false);
+ }
+
+ }
+
+ public void loadMaps() {
+ try {
+ FragmentManager fm = getActivity().getSupportFragmentManager();
+ FragmentTransaction ft = fm.beginTransaction();
+ Fragment fragment = new addLocationProjectFragment();
+ ft.replace(R.id.mapView, fragment);
+ ft.commit();
+ _map = (addLocationProjectFragment) fragment;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void loadContent() {
+
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ try {
+ Account compte = Account.getOwn();
+ compte.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+
+ user = resource;
+
+
+ m_user_pseudo.setText(resource.getPseudo());
+ m_user_ville.setText(resource.getCity());
+ if (resource.getGender().equals("0")) {
+ avatar.setImageResource(R.drawable.male_user_icon);
+ } else {
+ avatar.setImageResource(R.drawable.female_user_icon);
+ }
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ e.printStackTrace();
+ }
+
+ m_illustration = 0;
+
+ mData = new ArrayList<Integer>();
+ mData.add(R.drawable.ic_launcher);
+ mData.add(R.drawable.roi);
+ mData.add(R.drawable.basketball);
+ mData.add(R.drawable.plante);
+ mData.add(R.drawable.fete);
+
+ mAdapter = new CarouselAdaptor(context);
+ mAdapter.setData(mData);
+ mStyle = new HorizontalCarouselStyle(context,
+ HorizontalCarouselStyle.NO_STYLE);
+ mCarousel.setStyle(mStyle);
+ mCarousel.setAdapter(mAdapter);
+
+ supprimerCalendarView();
+ loading.setVisibility(View.GONE);
+
+ }
+ }).start();
+
+ loadMaps();
+
+ }
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.all;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.ProjectAdaptor;
+import adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment;
+import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import adullact.publicrowdfunding.model.local.utilities.SyncServerToLocal;
+import android.app.AlertDialog;
+import android.app.SearchManager;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SearchView;
+import android.widget.SearchView.OnCloseListener;
+import android.widget.SearchView.OnQueryTextListener;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ListProjectsFragment extends Fragment {
+
+ private ListView listeProjets;
+
+ private SwipeRefreshLayout swipeView;
+
+ private ArrayAdapter<Project> adapter;
+
+ private LinearLayout loading;
+
+ private SyncServerToLocal sync;
+
+ private ArrayList<Project> p_project_displayed;
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ final View view = inflater.inflate(R.layout.fragment_liste_projet,
+ container, false);
+
+ p_project_displayed = new ArrayList<Project>();
+
+ listeProjets = (ListView) view.findViewById(R.id.liste);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+ loading.setVisibility(View.VISIBLE);
+
+ adapter = new ProjectAdaptor(this.getActivity().getBaseContext(),
+ R.layout.adaptor_project, p_project_displayed, getActivity());
+
+ listeProjets.setAdapter(adapter);
+ swipeView = (SwipeRefreshLayout) view.findViewById(R.id.refresher);
+ swipeView.setVisibility(View.GONE);
+ swipeView.setEnabled(false);
+
+ swipeView.setColorScheme(R.color.blue, R.color.green, R.color.yellow,
+ R.color.red);
+ swipeView
+ .setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ //swipeView.setRefreshing(true);
+ //reload();
+ fragmentReload();
+ }
+
+ });
+
+ listeProjets.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ ft.setCustomAnimations(R.anim.fade_enter, R.anim.fade_exit);
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", p_project_displayed.get(position).getResourceId());
+
+ Fragment fragment = new ProjectPagerFragment();
+ fragment.setArguments(bundle);
+ ft.addToBackStack(null);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+
+ }
+ });
+
+ listeProjets.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) {
+
+ }
+
+ @Override
+ public void onScroll(AbsListView absListView, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ if (firstVisibleItem == 0)
+ swipeView.setEnabled(true);
+ else
+ swipeView.setEnabled(false);
+ }
+ });
+ reload();
+ return view;
+
+ }
+
+ public void refresh() {
+ adapter.clear();
+ adapter.addAll(p_project_displayed);
+ adapter.notifyDataSetChanged();
+ swipeView.setRefreshing(false);
+ loading.setVisibility(View.GONE);
+ swipeView.setVisibility(View.VISIBLE);
+
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+
+ try{
+ menu.clear();
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ inflater.inflate(R.menu.menu_main, menu);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+
+ }
+
+ public String getByRessource(int ressource){
+ return this.getResources().getString(ressource);
+ }
+
+ public void sort() {
+ ArrayAdapter<String> adapter = null;
+
+ if (Share.position == null) {
+ String names[] = { getByRessource(R.string.biggest_project), getByRessource(R.string.smallest_project),
+ getByRessource(R.string.most_avanced) };
+ adapter = new ArrayAdapter<String>(getActivity(),
+ android.R.layout.simple_list_item_1, names);
+ } else {
+ String names[] = {getByRessource(R.string.biggest_project), getByRessource(R.string.smallest_project),
+ getByRessource(R.string.most_avanced), getByRessource(R.string.closest)};
+ adapter = new ArrayAdapter<String>(getActivity(),
+ android.R.layout.simple_list_item_1, names);
+ }
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(
+ getActivity());
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ View convertView = (View) inflater.inflate(R.layout.listeview, null);
+ alertDialog.setView(convertView);
+ alertDialog.setTitle(getByRessource(R.string.sort_by));
+ ListView lv = (ListView) convertView.findViewById(R.id.liste);
+
+ lv.setAdapter(adapter);
+ final AlertDialog dialog = alertDialog.create();
+ lv.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ switch (position) {
+ case 0:
+ p_project_displayed = sync.sortByRequestingProjectMaxToMin();
+ refresh();
+ dialog.dismiss();
+
+ break;
+ case 1:
+ p_project_displayed = sync.sortByRequestingProjectMinToMax();
+ refresh();
+ dialog.dismiss();
+ break;
+ case 2:
+ p_project_displayed = sync.sortByAlmostFunded();
+ refresh();
+ dialog.dismiss();
+ break;
+ case 3:
+ p_project_displayed = sync.sortByProximity();
+ refresh();
+ dialog.dismiss();
+ break;
+
+ }
+ }
+ });
+
+ dialog.show();
+
+ }
+
+ public void reload() {
+ sync = SyncServerToLocal.getInstance();
+ sync.sync(new HoldAllToDo<Project>() {
+ @Override
+ public void holdAll(ArrayList<Project> projects) {
+ ArrayList<Project> allSync = new ArrayList<Project>(sync
+ .restrictToValidatedProjects());
+ p_project_displayed = allSync;
+
+ refresh();
+
+ }
+ });
+ }
+
+ public void search(MenuItem searchItem) {
+
+ SearchView searchView = (SearchView) searchItem.getActionView();
+ SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
+ if (null != searchManager) {
+ searchView.setSearchableInfo(searchManager
+ .getSearchableInfo(getActivity().getComponentName()));
+ }
+ searchView.setIconifiedByDefault(true);
+ searchView.setOnCloseListener(new OnCloseListener() {
+
+ @Override
+ public boolean onClose() {
+ p_project_displayed = new ArrayList<Project>(sync.getProjects());
+ refresh();
+ return false;
+ }
+
+ });
+
+ searchView.setOnQueryTextListener(new OnQueryTextListener() {
+
+ public boolean onQueryTextSubmit(String query) {
+
+ p_project_displayed = sync.searchInName(query);
+ refresh();
+
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ return false;
+ }
+
+ });
+
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.action_search:
+ search(item);
+ break;
+ case R.id.action_sort:
+ sort();
+ break;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ return true;
+ }
+
+ public void fragmentReload(){
+
+ sync = SyncServerToLocal.getInstance();
+ sync.forceSyncAll(new HoldAllToDo<Project>() {
+ @Override
+ public void holdAll(ArrayList<Project> projects) {
+
+ ArrayList<Project> allSync = new ArrayList<Project>(sync
+ .restrictToValidatedProjects());
+ p_project_displayed = allSync;
+
+ refresh();
+
+ }
+ });
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.all;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.SyncServerToLocal;
+import android.app.ProgressDialog;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.CameraPosition;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class MapFragment extends Fragment implements OnInfoWindowClickListener {
+
+ private SupportMapFragment fragment;
+ private FragmentManager fm;
+ private ProgressDialog mprogressDialog;
+ private View rootView;
+ private GoogleMap googleMap;
+ private final HashMap<Marker, Project> markers = new HashMap<Marker, Project>();
+
+ private ArrayList<Project> projets;
+
+ private MapFragment _this;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ try {
+ rootView = inflater.inflate(R.layout.activity_maps, container,
+ false);
+
+ } catch (Exception e) {
+ TextView text = new TextView(getActivity());
+ text.setText(this.getResources().getString(R.string.error));
+ return text;
+ }
+
+ projets = new ArrayList<Project>();
+
+ _this = this;
+
+ mprogressDialog = new ProgressDialog(getActivity());
+ CharSequence message = this.getResources().getString(R.string.loading);
+ mprogressDialog.setMessage(message);
+ mprogressDialog.setTitle("Google Map");
+ mprogressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ mprogressDialog.show();
+
+ fragment = new SupportMapFragment();
+ fm = getFragmentManager();
+
+ final SyncServerToLocal sync = SyncServerToLocal.getInstance();
+ sync.sync(new HoldAllToDo<Project>() {
+ @Override
+ public void holdAll(ArrayList<Project> projects) {
+
+ projets = new ArrayList<Project>(sync
+ .restrictToValidatedProjects());
+
+ initMaps();
+
+ }
+ });
+
+ return rootView;
+ }
+
+ @Override
+ public void onInfoWindowClick(Marker marker) {
+
+ String id = markers.get(marker).getResourceId();
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.ProjectPagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", id);
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+
+ }
+
+ public void initMaps() {
+
+ try {
+
+ FragmentTransaction ft = fm.beginTransaction();
+ ft.replace(R.id.mapView, fragment, "mapAllFragment").commit();
+ fm.executePendingTransactions();
+
+ googleMap = ((SupportMapFragment) fm
+ .findFragmentByTag("mapAllFragment")).getMap();
+
+ for (Project proj : projets) {
+ MarkerOptions marker = new MarkerOptions();
+ marker.position(proj.getPosition());
+ marker.title(proj.getName());
+ Marker m = googleMap.addMarker(marker);
+
+ markers.put(m, proj);
+ }
+
+ googleMap.setOnInfoWindowClickListener(_this);
+ googleMap
+ .setInfoWindowAdapter(new adullact.publicrowdfunding.controller.adaptor.MarkerWindowAdaptor(
+ getLayoutInflater(null), markers));
+
+ googleMap.setMyLocationEnabled(true);
+
+ LatLng localisation = new LatLng(46.937199, 2.429674);
+
+ CameraPosition currentPlace = new CameraPosition.Builder()
+ .target(localisation).zoom(6f).build();
+
+ googleMap.moveCamera(CameraUpdateFactory
+ .newCameraPosition(currentPlace));
+
+
+ mprogressDialog.dismiss();
+
+ } catch (Exception e) {
+ this.getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ }
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Commentary;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.server.event.CreateEvent;
+import android.content.Context;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.RatingBar;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class CommentPopup extends Fragment {
+
+ private Fragment _this;
+
+ private EditText comment_title;
+ private EditText comment_message;
+
+ private CheckBox conditions;
+ private Button valider;
+
+ private Animation shake;
+
+ private RatingBar mark;
+
+ private Project projet;
+
+ private Context context;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ View view = inflater.inflate(R.layout.popup_add_comment, container,
+ false);
+
+ _this = this;
+ context = getActivity();
+
+ Bundle bundle = this.getArguments();
+ if (bundle != null) {
+ String idProject = bundle.getString("idProject");
+ getProject(idProject);
+
+ } else {
+ back();
+ }
+
+ comment_title = (EditText) view.findViewById(R.id.titre_comment);
+ comment_message = (EditText) view.findViewById(R.id.message_comment);
+
+ mark = (RatingBar) view.findViewById(R.id.mark);
+
+ conditions = (CheckBox) view.findViewById(R.id.conditions);
+ valider = (Button) view.findViewById(R.id.valider);
+
+ shake = AnimationUtils.loadAnimation(this.getActivity()
+ .getBaseContext(), R.anim.shake);
+
+ valider.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (!conditions.isChecked()) {
+ conditions.setTextColor(Color.parseColor("#ff0000"));
+ return;
+ }
+
+ if (comment_title.getText().length() < 1) {
+ comment_title.startAnimation(shake);
+ return;
+ }
+
+ if (comment_message.getText().length() < 1) {
+ comment_message.startAnimation(shake);
+ return;
+ }
+
+ try {
+ float rating = mark.getRating();
+ if (rating < 1) {
+ throw new Exception();
+ }
+ } catch (Exception e) {
+ mark.startAnimation(shake);
+ return;
+ }
+ commenter();
+ }
+
+ });
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+
+ back();
+ return false;
+ }
+ return false;
+ }
+ });
+
+ return view;
+
+ }
+
+ public void back() {
+
+ FragmentTransaction ft = getActivity().getSupportFragmentManager()
+ .beginTransaction();
+ ft.setCustomAnimations(R.anim.no_anim, R.anim.popup_exit);
+ ft.remove(_this);
+
+
+ // Multi Thread pour que l'animation s'éxécute
+ FrameLayout filter = (FrameLayout) getActivity().getWindow().getDecorView()
+ .findViewById(R.id.big_filter);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(_this.getActivity(), R.anim.fade_exit);
+ filter.setAnimation(fadeInAnimation);
+ ft.commit();
+ filter.animate();
+
+ }
+
+ public void commenter() {
+ String s_titre = comment_title.getText().toString();
+ String s_message = comment_message.getText().toString();
+ int rating = (int) mark.getRating();
+
+ try {
+ projet.postCommentary(s_titre, s_message, rating,
+ new CreateEvent<Commentary>() {
+
+ @Override
+ public void errorResourceIdAlreadyUsed() {
+ Toast.makeText(context,
+ R.string.error,
+ Toast.LENGTH_SHORT).show();
+ back();
+ }
+
+
+
+ @Override
+ public void onCreate(Commentary resource) {
+ Toast.makeText(context, "Commentaire ajouté !",
+ Toast.LENGTH_SHORT).show();
+ back();
+ ListCommentsFragment.reloadCommentFragment(getActivity(),projet);
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ Toast.makeText(context,
+ R.string.error,
+ Toast.LENGTH_SHORT).show();
+ back();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ Toast.makeText(context,
+ R.string.error,
+ Toast.LENGTH_SHORT).show();
+ back();
+
+ }
+
+
+
+ @Override
+ public void errorServer() {Toast.makeText(context,
+ R.string.error,
+ Toast.LENGTH_SHORT).show();
+ back();
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+ back();
+ e.printStackTrace();
+ }
+
+ }
+
+ public void getProject(String idProject) {
+ new Project().getCache(idProject)
+ .toResource(new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ projet = resource;
+
+ }
+
+ });
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import java.util.ArrayList;
+import java.util.Locale;
+
+import org.joda.time.DateTime;
+import org.joda.time.Interval;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.FundingInterval;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Align;
+import android.graphics.Path;
+import android.util.AttributeSet;
+import android.view.View;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class GraphiqueView extends View {
+
+ private Paint paint;
+ private Project projet;
+ private ArrayList<FundingInterval> graphData;
+ private Path path;
+ private Context context;
+
+ /**
+ * @param context
+ * The context of the application
+ */
+ public GraphiqueView(Context context) {
+ super(context);
+ paint = new Paint();
+ path = new Path();
+ graphData = new ArrayList<FundingInterval>();
+ this.context = context;
+ }
+
+ /**
+ * @param context
+ * The context of the application
+ * @param attrs
+ * The attributs
+ */
+ public GraphiqueView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ paint = new Paint();
+ graphData = new ArrayList<FundingInterval>();
+ path = new Path();
+ this.context = context;
+ }
+
+ public void setProject(Project projet) {
+ this.projet = projet;
+ }
+
+ /**
+ * Draw
+ */
+ protected void onDraw(Canvas canvas) {
+
+ int margin = 10;
+
+ int largeur = canvas.getWidth() - margin;
+ int offset = 100; // décalement vertical
+ int hauteur = canvas.getHeight() - offset - margin;
+ int nombreDeCarre = 10;
+ for (int i = 0; i < nombreDeCarre + 1; i++) {
+
+ if (i == 0) {
+ paint.setColor(Color.rgb(109, 195, 41));
+ }
+
+ // Horizontal
+ canvas.drawLine(0, i * (hauteur / nombreDeCarre) + offset, largeur,
+ i * (hauteur / nombreDeCarre) + offset, paint);
+
+ // Vertical
+ paint.setColor(Color.rgb(210, 210, 210));
+ canvas.drawLine(i * (largeur / nombreDeCarre), offset, i
+ * (largeur / nombreDeCarre), hauteur + offset, paint);
+
+ }
+
+ if (projet == null) {
+ return;
+ }
+
+ graphData = projet.getFundingIntervals();
+
+ paint.reset();
+ int xPos = (int) (canvas.getWidth() / 2);
+ int yPos = offset / 2;
+ paint.setTextAlign(Align.CENTER);
+ paint.setTextSize(40);
+ paint.setColor(Color.rgb(128, 128, 128));
+ String progress = context.getResources().getString(R.string.funding_progress).toUpperCase(Locale.getDefault());
+ canvas.drawText(progress, xPos, yPos, paint);
+
+ paint.reset();
+ // Ajout texte 100 %
+ xPos = (int) (6 * canvas.getWidth() / 10);
+ yPos = offset - 20;
+ paint.setTextSize(20);
+ paint.setColor(Color.rgb(109, 195, 41));
+ canvas.drawText("100 %", xPos, yPos, paint);
+
+ paint.reset();
+ // Ajout date de début
+ xPos = 0;
+ yPos = offset - 20;
+ paint.setTextSize(20);
+ paint.setColor(Color.rgb(160, 160, 160));
+ Interval in = projet.getFundingInterval();
+
+ DateTime dateStart = in.getStart();
+ String month = "";
+ if (dateStart.getMonthOfYear() < 10) {
+ month = "0" + dateStart.getMonthOfYear();
+ } else {
+ month = "" + dateStart.getMonthOfYear();
+ }
+
+ String monthEnd = "";
+ DateTime dateEnd = in.getEnd();
+ if (dateEnd.getMonthOfYear() < 10) {
+ monthEnd = "0" + dateEnd.getMonthOfYear();
+ } else {
+ monthEnd = "" + dateEnd.getMonthOfYear();
+ }
+
+ canvas.drawText(dateStart.getDayOfMonth() + "/" + month + "/"
+ + dateStart.getYear(), xPos, yPos, paint);
+
+ paint.reset();
+ // Ajout date de fin
+ xPos = (int) (canvas.getWidth() - 120);
+ yPos = offset - 20;
+ paint.setTextSize(20);
+ paint.setColor(Color.rgb(160, 160, 160));
+ canvas.drawText(dateEnd.getDayOfMonth() + "/" + monthEnd + "/"
+ + dateEnd.getYear(), xPos, yPos, paint);
+
+ // Exemple de coubre
+ long pourcentageAccomplie = 0;
+
+ int nbIteration = projet.getNbPeriod();
+ long somme = 0;
+ for (int i = 0; i < nbIteration; i++) {
+ long data = 0;
+ try {
+ if (graphData.get(i).getTotal() == -1) {
+ break;
+ }
+ data = graphData.get(i).getTotal();
+ } catch (Exception e) {
+ e.printStackTrace();
+ break;
+ }
+
+ somme += data;
+ long pourcentage = 0;
+ try {
+ pourcentage = (somme * 100)
+ / Long.parseLong(projet.getRequestedFunding());
+ } catch (ArithmeticException e) {
+ e.printStackTrace();
+ }
+ long newPourcentage = pourcentage;
+ if (newPourcentage > 100) {
+ newPourcentage = 100;
+ }
+
+ long yDepart = hauteur - ((pourcentageAccomplie * hauteur) / 100)
+ + offset;
+ long yArrive = hauteur - ((newPourcentage * hauteur) / 100)
+ + offset;
+
+ int xDepart = i * (largeur / nombreDeCarre);
+ int xArrive = (i + 1) * (largeur / nombreDeCarre);
+ if (xArrive > largeur) {
+ break;
+ }
+
+ paint.reset();
+ paint.setColor(Color.argb(150, 131, 182, 255));
+
+ path.reset();
+ path.setFillType(Path.FillType.EVEN_ODD);
+ path.moveTo(xDepart, yDepart);
+ path.lineTo(xArrive, yArrive);
+ path.lineTo(xArrive, hauteur + offset);
+ path.lineTo(xDepart, hauteur + offset);
+ path.lineTo(xDepart, yDepart);
+ path.close();
+
+ canvas.drawPath(path, paint);
+
+ // La ligne
+ paint.reset();
+ paint.setColor(Color.rgb(183, 0, 0));
+ paint.setStrokeWidth(2);
+ canvas.drawLine(xDepart, yDepart, xArrive, yArrive, paint);
+
+ pourcentageAccomplie = newPourcentage;
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class InfoProjectFragment extends Fragment {
+
+ private TextView m_titre;
+ private TextView m_description;
+ private TextView m_current_funding;
+ private TextView m_jour_restant;
+ private TextView m_utilisateur_soumission;
+ private TextView m_pourcentage_accomplish;
+ private TextView m_utilisateur_ville;
+ private TextView m_request_funding;
+
+ private Button m_payer;
+ private Button m_mail;
+ private Button m_website;
+ private Button m_call;
+
+ //private ImageView m_illustration;
+ private ImageView m_avatar;
+
+ private Project projetToDisplay;
+ private User user;
+
+ private FrameLayout layoutConnect;
+
+ private RelativeLayout layout_website;
+ private RelativeLayout layout_call;
+ private RelativeLayout layout_mail;
+
+ private GraphiqueView graph;
+
+ private View view;
+
+ private FragmentManager fm;
+
+ private LinearLayout loading;
+
+ private FrameLayout filter;
+
+ private ScrollView showLoaded;
+
+ private Context _this;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ view = inflater.inflate(R.layout.fragment_detail_project, container,
+ false);
+
+ _this = this.getActivity().getBaseContext();
+
+ fm = this.getActivity().getSupportFragmentManager();
+
+ filter = (FrameLayout) getActivity().getWindow().getDecorView().findViewById(R.id.big_filter);
+ filter.setVisibility(View.GONE);
+ layoutConnect = (FrameLayout) view.findViewById(R.id.connect);
+
+
+
+ showLoaded = (ScrollView) view.findViewById(R.id.showLoaded);
+ showLoaded.setVisibility(View.GONE);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+
+ layout_website = (RelativeLayout) view
+ .findViewById(R.id.layout_website);
+ layout_call = (RelativeLayout) view.findViewById(R.id.layout_call);
+ layout_mail = (RelativeLayout) view.findViewById(R.id.layout_mail);
+
+ graph = (GraphiqueView) view.findViewById(R.id.graphique);
+ DisplayMetrics metrics = new DisplayMetrics();
+ getActivity().getWindowManager().getDefaultDisplay()
+ .getMetrics(metrics);
+
+ android.view.ViewGroup.LayoutParams params = graph.getLayoutParams();
+ params.height = 500;
+ graph.setLayoutParams(params);
+
+ m_titre = (TextView) view.findViewById(R.id.titre_projet_detail);
+ m_description = (TextView) view.findViewById(R.id.detail_projet_detail);
+ m_payer = (Button) view.findViewById(R.id.payer);
+ m_jour_restant = (TextView) view
+ .findViewById(R.id.nombre_jour_restant_detail);
+ m_utilisateur_soumission = (TextView) view
+ .findViewById(R.id.utilisateur_soumission);
+ m_current_funding = (TextView) view.findViewById(R.id.sommeFund);
+ m_pourcentage_accomplish = (TextView) view
+ .findViewById(R.id.pourcentage_accomplit);
+ m_utilisateur_ville = (TextView) view.findViewById(R.id.ville);
+ m_request_funding = (TextView) view.findViewById(R.id.sommeRequestFund);
+
+ m_mail = (Button) view.findViewById(R.id.mail);
+ m_website = (Button) view.findViewById(R.id.website);
+ m_call = (Button) view.findViewById(R.id.phone);
+
+ //m_illustration = (ImageView) view.findViewById(R.id.icon);
+
+ m_avatar = (ImageView) view.findViewById(R.id.avatar);
+
+ isConnect();
+
+
+
+ Bundle bundle = this.getArguments();
+ if (bundle != null) {
+ String idProject = bundle.getString("idProject");
+ Cache<Project> projet = new Project().getCache(idProject);
+ projet.toResource(new HoldToDo<Project>() {
+ @Override
+ public void hold(Project project) {
+ projetToDisplay = project;
+ graph.setProject(projetToDisplay);
+ graph.invalidate();
+ displayInfo();
+ }
+ });
+ } else{
+ this.getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ }
+
+ return view;
+ }
+
+ public void isConnect() {
+ try {
+ Account.getOwn();
+ layoutConnect.setVisibility(View.VISIBLE);
+ } catch (NoAccountExistsInLocal e1) {
+ // layoutConnect.setVisibility(View.GONE);
+ }
+ }
+
+ public void displayInfo() {
+ /*
+ if (projetToDisplay.getIllustration() != 0) {
+ m_illustration.setImageResource(Utility.getDrawable(projetToDisplay
+ .getIllustration()));
+ } else {
+ m_illustration.setImageResource(R.drawable.ic_launcher);
+ }*/
+
+ if (projetToDisplay.getEmail() == null
+ || projetToDisplay.getEmail().length() == 0) {
+ layout_mail.setVisibility(View.GONE);
+ } else {
+ m_mail.setText(projetToDisplay.getEmail());
+ }
+
+ if (projetToDisplay.getWebsite() == null
+ || projetToDisplay.getWebsite().length() == 0) {
+ layout_website.setVisibility(View.GONE);
+ } else {
+ m_website.setText(projetToDisplay.getWebsite());
+ }
+
+ if (projetToDisplay.getPhone() == null
+ || projetToDisplay.getPhone().length() == 0) {
+ layout_call.setVisibility(View.GONE);
+ } else {
+ m_call.setText(projetToDisplay.getPhone());
+ }
+
+ m_request_funding.setText(projetToDisplay.getRequestedFunding() + "€");
+
+ projetToDisplay.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+ try {
+ user = resource;
+ m_utilisateur_soumission.setText(Share
+ .formatString(resource.getPseudo()));
+ m_utilisateur_ville.setText(Share.formatString(resource
+ .getCity()));
+ if (user.getGender().equals("0")) {
+ m_avatar.setImageResource(R.drawable.male_user_icon);
+ } else {
+ m_avatar.setImageResource(R.drawable.female_user_icon);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ });
+
+ LinearLayout userLayoutButton = (LinearLayout) view
+ .findViewById(R.id.layoutUser);
+
+ userLayoutButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ try {
+
+ FragmentTransaction ft = fm.beginTransaction();
+
+ // ft.setCustomAnimations(R.anim.enter, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.profile.ProfilePagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idUser", user.getResourceId());
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(false);
+ ft.addToBackStack(null);
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+
+ } catch (NullPointerException e) {
+ Toast.makeText(getActivity(), R.string.error,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ m_pourcentage_accomplish.setText(projetToDisplay
+ .getPercentOfAchievement() + "%");
+ m_current_funding.setText(projetToDisplay.getCurrentFunding() + "€");
+ projetToDisplay.getCreationDate();
+ m_titre.setText(projetToDisplay.getName());
+ m_description.setText(projetToDisplay.getDescription());
+ if (projetToDisplay.getNumberOfDayToEnd() > 1) {
+ m_jour_restant.setText("" + projetToDisplay.getNumberOfDayToEnd()
+ + " jours");
+ } else {
+ m_jour_restant.setText("" + projetToDisplay.getNumberOfDayToEnd()
+ + " jour");
+ }
+
+
+ m_payer.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ FragmentTransaction ft = fm.beginTransaction();
+
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.ParticipatePopup();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", projetToDisplay.getResourceId());
+ fragment.setArguments(bundle);
+ ft.addToBackStack(null);
+ ft.setCustomAnimations(R.anim.popup_enter, R.anim.no_anim);
+ ft.add(R.id.big_font, fragment);
+
+ ft.commit();
+
+ filter.setVisibility(View.VISIBLE);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(_this, R.anim.fade_enter);
+ filter.setAnimation(fadeInAnimation);
+ filter.animate();
+ }
+ });
+ showLoaded.setVisibility(View.VISIBLE);
+ loading.setVisibility(View.GONE);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.adaptor.CommentsAdaptor;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Commentary;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ListCommentsFragment extends Fragment {
+
+ private Button m_button_comment;
+
+ private ListView lv;
+
+ private Vector<Commentary> commentaries;
+
+ private LinearLayout layoutConnect;
+
+ protected CommentsAdaptor adapter;
+
+ private SwipeRefreshLayout swipeView;
+
+ private Project projetCurrent;
+
+ private FragmentManager fm;
+
+ private LinearLayout loading;
+ private FrameLayout loaded;
+
+ private FrameLayout filter;
+
+ private Context context;
+
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ final View view = inflater.inflate(R.layout.fragment_list_comments,
+ container, false);
+
+ context = this.getActivity().getBaseContext();
+ filter = (FrameLayout) this.getActivity().getWindow().getDecorView().findViewById(R.id.big_filter);
+ filter.setVisibility(View.GONE);
+
+ fm = this.getActivity().getSupportFragmentManager();
+
+ layoutConnect = (LinearLayout) view.findViewById(R.id.connect);
+ loaded = (FrameLayout) view.findViewById(R.id.showLoaded);
+ loaded.setVisibility(View.GONE);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+
+ isConnect();
+
+ commentaries = new Vector<Commentary>();
+
+ lv = (ListView) view.findViewById(R.id.commentaires);
+ adapter = new CommentsAdaptor(
+ getActivity().getApplicationContext(), R.layout.adaptor_comment);
+
+ adapter.setCommentaries(commentaries);
+
+ lv.setAdapter(adapter);
+
+ m_button_comment = (Button) view
+ .findViewById(R.id.button_comment);
+
+ TextView empty = (TextView) view.findViewById(R.id.empty);
+ lv.setEmptyView(empty);
+
+ Bundle bundle = this.getArguments();
+ if (bundle != null) {
+ String idProject = bundle.getString("idProject");
+ Cache<Project> projet = new Project().getCache(idProject);
+ projet.toResource(new HoldToDo<Project>() {
+ @Override
+ public void hold(Project project) {
+ projetCurrent = project;
+ displayInfo();
+ }
+ });
+ }
+
+ swipeView = (SwipeRefreshLayout) view.findViewById(R.id.refresher);
+ swipeView.setEnabled(false);
+ swipeView.setColorScheme(R.color.blue, R.color.green, R.color.yellow,
+ R.color.red);
+ swipeView
+ .setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ ListCommentsFragment.reloadCommentFragment(getActivity(),projetCurrent);
+
+ }
+
+ });
+
+ lv.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) {
+
+ }
+
+ @Override
+ public void onScroll(AbsListView absListView, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ if (firstVisibleItem == 0)
+ swipeView.setEnabled(true);
+ else
+ swipeView.setEnabled(false);
+ }
+ });
+
+ return view;
+
+ }
+
+ public void isConnect() {
+ if(Account.isConnect()) {
+ try {
+ Account.getOwn();
+ layoutConnect.setVisibility(View.VISIBLE);
+ } catch (NoAccountExistsInLocal e1) {
+ // layoutConnect.setVisibility(View.GONE);
+ }
+ }
+ }
+
+ public void displayInfo() {
+ projetCurrent.getCommentaries(new HoldAllToDo<Commentary>() {
+
+ @Override
+ public void holdAll(ArrayList<Commentary> resources) {
+ commentaries = new Vector<Commentary>(resources);
+
+ adapter.setCommentaries(commentaries);
+ adapter.notifyDataSetChanged();
+ loading.setVisibility(View.GONE);
+ loaded.setVisibility(View.VISIBLE);
+ }
+ });
+
+ lv.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ Commentary com = commentaries.get(position);
+ com.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+
+ FragmentTransaction ft = fm.beginTransaction();
+
+ // ft.setCustomAnimations(R.anim.enter, R.anim.exit);
+ Fragment fragment = new adullact.publicrowdfunding.controller.profile.ProfilePagerFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString("idUser", resource.getResourceId());
+ fragment.setArguments(bundle);
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+ ft.addToBackStack(null);
+ ft.commit();
+
+ }
+ });
+
+ }
+ });
+
+ m_button_comment.setOnClickListener(new OnClickListener(){
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ FragmentTransaction ft = fm.beginTransaction();
+
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.details.CommentPopup();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", projetCurrent.getResourceId());
+ fragment.setArguments(bundle);
+ ft.addToBackStack(null);
+ ft.setCustomAnimations(R.anim.popup_enter, R.anim.no_anim);
+ ft.add(R.id.big_font, fragment);
+ ft.commit();
+
+ filter.setVisibility(View.VISIBLE);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_enter);
+ filter.setAnimation(fadeInAnimation);
+ filter.animate();
+
+ }
+
+ });
+
+ }
+
+ public static void reloadCommentFragment(FragmentActivity activity, Project project) {
+
+ new Project().getCache(project.getResourceId()).forceRetrieve();
+
+ for (Fragment fragment : activity.getSupportFragmentManager()
+ .getFragments()) {
+ if (fragment instanceof adullact.publicrowdfunding.controller.project.details.ListCommentsFragment) {
+ activity.getSupportFragmentManager().beginTransaction()
+ .detach(fragment).attach(fragment).commit();
+ }
+
+ }
+
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.CameraPosition;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class MapFragment extends Fragment {
+
+ private SupportMapFragment fragment;
+ private FragmentManager fm;
+
+ private Project projetCurrent;
+
+ View rootView;
+ GoogleMap googleMap;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+
+ try {
+ rootView = inflater.inflate(R.layout.activity_maps, container,
+ false);
+
+ fragment = new SupportMapFragment();
+ fm = getFragmentManager();
+
+ FragmentTransaction ft = fm.beginTransaction();
+ ft.replace(R.id.mapView, fragment, "mapProjectDetail").commit();
+
+ } catch (Exception e) {
+ TextView text = new TextView(getActivity());
+ text.setText("Impossible de charger Google Map");
+ return text;
+ }
+
+ Bundle bundle = this.getArguments();
+ if (bundle != null) {
+ String idProject = bundle.getString("idProject");
+ Cache<Project> projet = new Project().getCache(idProject);
+ projet.toResource(new HoldToDo<Project>() {
+ @Override
+ public void hold(Project project) {
+
+ try {
+
+ projetCurrent = project;
+ final Handler handler = new Handler();
+ handler.post(new Runnable() {
+
+ @Override
+ public void run() {
+
+ Fragment fr = fm
+ .findFragmentByTag("mapProjectDetail");
+
+ if (fr == null) {
+ handler.postDelayed(this, 500);
+ } else {
+ googleMap = ((SupportMapFragment) fr)
+ .getMap();
+ }
+ if (googleMap != null) {
+ displayInfo();
+ handler.removeCallbacksAndMessages(null);
+
+ } else {
+ handler.postDelayed(this, 1000);
+ }
+ }
+ });
+
+ } catch (Exception e) {
+ TextView text = new TextView(getActivity());
+ text.setText("Impossible de charger Google Map");
+ rootView = text;
+ }
+ }
+ });
+ }
+ return rootView;
+ }
+
+ public void displayInfo() {
+ MarkerOptions marker = new MarkerOptions();
+ marker.position(projetCurrent.getPosition());
+ marker.snippet(projetCurrent.getDescription());
+ googleMap.addMarker(marker);
+
+ LatLng projectLocation = projetCurrent.getPosition();
+
+ CameraPosition currentPlace = new CameraPosition.Builder()
+ .target(projectLocation).zoom(9f).build();
+
+ googleMap.moveCamera(CameraUpdateFactory
+ .newCameraPosition(currentPlace));
+
+ }
+
+ public void onPause() {
+ super.onPause();
+ this.getActivity().getSupportFragmentManager().beginTransaction()
+ .detach(fragment).commit();
+ this.getActivity().getSupportFragmentManager().beginTransaction()
+ .detach(this).commit();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentStatePagerAdapter;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class PagerAdaptor extends FragmentStatePagerAdapter {
+
+ private String idProject;
+
+ private Context context;
+
+
+ private int[] titles = {R.string.comments, R.string.project_details,
+ R.string.project_location};
+
+ public PagerAdaptor(Context context, FragmentManager fm, String idProject) {
+ super(fm);
+ this.idProject = idProject;
+ this.context = context;
+ }
+
+ final int PAGE_COUNT = 3;
+
+ @Override
+ public int getCount() {
+ return PAGE_COUNT;
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+
+ Fragment fragment = null;
+ Bundle bundle = new Bundle();
+
+ switch (position) {
+
+ case 0:
+ fragment = new ListCommentsFragment();
+ bundle.putString("idProject", idProject);
+ fragment.setArguments(bundle);
+ fragment.setRetainInstance(false);
+ return fragment;
+ case 1:
+ fragment = new InfoProjectFragment();
+ bundle.putString("idProject", idProject);
+ fragment.setArguments(bundle);
+ fragment.setRetainInstance(false);
+ return fragment;
+ case 2:
+ fragment = new MapFragment();
+ bundle.putString("idProject", idProject);
+ fragment.setArguments(bundle);
+ fragment.setRetainInstance(false);
+ return fragment;
+
+ default:
+ return new InfoProjectFragment();
+ }
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ String titre = context.getResources().getString(titles[position % PAGE_COUNT]);
+ return titre;
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.project.participate.PaypalActivity;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ParticipatePopup extends Fragment {
+
+ private EditText somme;
+ private CheckBox conditions;
+ private Button valider;
+
+ private Animation shake;
+
+ private Fragment _this;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ View view = inflater.inflate(R.layout.popup_participate, container,
+ false);
+
+ _this = this;
+
+ somme = (EditText) view.findViewById(R.id.participation);
+ conditions = (CheckBox) view.findViewById(R.id.conditions);
+ valider = (Button) view.findViewById(R.id.valider);
+
+ shake = AnimationUtils.loadAnimation(this.getActivity()
+ .getBaseContext(), R.anim.shake);
+
+ Bundle bundle = this.getArguments();
+ final String idProject = bundle.getString("idProject");
+
+ valider.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (!conditions.isChecked()) {
+ conditions.setTextColor(Color.parseColor("#ff0000"));
+ return;
+ }
+
+ int sommeToFund = 0;
+ try {
+ sommeToFund = Integer.parseInt(somme.getText().toString());
+ } catch (Exception e) {
+ somme.startAnimation(shake);
+ return;
+ }
+ if (sommeToFund < 1) {
+ somme.startAnimation(shake);
+ }
+
+ back();
+
+ Intent intent = new Intent(getActivity(), PaypalActivity.class);
+ intent.putExtra("participation", sommeToFund);
+ intent.putExtra("idProject", idProject);
+ getActivity().startActivityForResult(intent, 1);
+ }
+
+ });
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+
+ back();
+
+ return true;
+ }
+ return false;
+ }
+ });
+ return view;
+
+ }
+
+ public void back() {
+ FragmentTransaction ft = getActivity().getSupportFragmentManager()
+ .beginTransaction();
+ ft.setCustomAnimations(R.anim.no_anim, R.anim.popup_exit);
+ ft.remove(_this);
+
+ FrameLayout filter = (FrameLayout) getActivity().getWindow()
+ .getDecorView().findViewById(R.id.big_filter);
+ Animation fadeInAnimation = AnimationUtils.loadAnimation(
+ _this.getActivity(), R.anim.fade_exit);
+ filter.setAnimation(fadeInAnimation);
+ ft.commit();
+ filter.animate();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.details;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.Bookmark;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.local.utilities.CanI;
+import adullact.publicrowdfunding.model.server.event.CreateEvent;
+import adullact.publicrowdfunding.model.server.event.DeleteEvent;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.ViewPager;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ProjectPagerFragment extends Fragment {
+
+ FragmentTransaction fragMentTra;
+ FragmentManager fm;
+ private String idProject;
+
+ private MenuItem star;
+
+ private boolean m_Is_favorite;
+
+ private Project projectCurrent;
+
+ private adullact.publicrowdfunding.MainActivity context;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ View view = inflater.inflate(R.layout.pager_tab, container, false);
+
+ Bundle bundle = this.getArguments();
+ idProject = bundle.getString("idProject");
+
+ context = (adullact.publicrowdfunding.MainActivity) getActivity();
+
+ fm = context.getSupportFragmentManager();
+ fm.beginTransaction().disallowAddToBackStack().commit();
+ Context context = this.getActivity().getBaseContext();
+ PagerAdaptor adaptor = new PagerAdaptor(context, fm, idProject);
+
+ ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
+ viewPager.setAdapter(adaptor);
+ viewPager.setCurrentItem(1);
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ fm.popBackStack();
+
+ return true;
+ }
+ return false;
+ }
+ });
+ return view;
+
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ try {
+ menu.clear(); // Permettra d'éviter les bugs de superpositions
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ inflater.inflate(R.menu.detail_projet, menu);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ star = menu.findItem(R.id.add_favorite);
+ initBookmark();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+
+ case R.id.add_favorite:
+ setBookmark();
+ break;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ return true;
+
+ }
+
+ public void setBookmark() {
+
+ try {
+ final Account account = Account.getOwn();
+ account.getUser(new HoldToDo<User>() {
+
+ @Override
+ public void hold(User resource) {
+
+ if (m_Is_favorite) {
+ resource.removeBookmark(projectCurrent,
+ new DeleteEvent<Bookmark>() {
+
+ @Override
+ public void errorResourceIdDoesNotExist() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void onDelete(Bookmark resource) {
+ m_Is_favorite = false;
+ Toast.makeText(context,
+ "Projet retiré de vos favoris",
+ Toast.LENGTH_SHORT).show();
+ changeColorStar();
+ new Account().getCache(
+ account.getResourceId())
+ .forceRetrieve();
+ }
+
+ @Override
+ public void errorAdministratorRequired() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorServer() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ });
+ } else {
+
+ resource.addBookmark(projectCurrent,
+ new CreateEvent<Bookmark>() {
+
+ @Override
+ public void errorResourceIdAlreadyUsed() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void onCreate(Bookmark resource) {
+ m_Is_favorite = true;
+ Toast.makeText(context,
+ "Projet ajouté à vos favoris",
+ Toast.LENGTH_SHORT).show();
+ changeColorStar();
+ new Account().getCache(
+ account.getResourceId())
+ .forceRetrieve();
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void errorServer() {
+ Toast.makeText(context, R.string.error,
+ Toast.LENGTH_SHORT).show();
+
+ }
+
+ });
+ }
+
+ }
+
+ });
+ } catch (NoAccountExistsInLocal e) {
+ Toast.makeText(context,
+ "Il faut un compte pour avoir des favoris !",
+ Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+ }
+
+ public void initBookmark() {
+
+ new Project().getCache(idProject).toResource(new HoldToDo<Project>() {
+
+ @Override
+ public void hold(Project resource) {
+ projectCurrent = resource;
+ function();
+
+ }
+
+ });
+
+ }
+
+ public void function() {
+ try {
+ Account.getOwn();
+ new CanI() {
+ @Override
+ protected void yes() {
+ m_Is_favorite = false;
+ }
+
+ @Override
+ protected void no() {
+ m_Is_favorite = true;
+ }
+
+ }.bookmark(projectCurrent);
+
+ } catch (NoAccountExistsInLocal e) {
+ m_Is_favorite = false;
+ }
+ changeColorStar();
+ }
+
+ public void changeColorStar() {
+ PorterDuffColorFilter filter;
+ if (m_Is_favorite) {
+
+ filter = new PorterDuffColorFilter(Color.YELLOW,
+ PorterDuff.Mode.SRC_ATOP);
+
+ } else {
+
+ filter = new PorterDuffColorFilter(Color.TRANSPARENT,
+ PorterDuff.Mode.SRC_ATOP);
+ }
+ try {
+ star.getIcon().setColorFilter(filter);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.participate;
+
+import java.math.BigDecimal;
+
+import org.json.JSONException;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+
+import com.paypal.android.sdk.payments.PayPalAuthorization;
+import com.paypal.android.sdk.payments.PayPalConfiguration;
+import com.paypal.android.sdk.payments.PayPalFuturePaymentActivity;
+import com.paypal.android.sdk.payments.PayPalPayment;
+import com.paypal.android.sdk.payments.PayPalService;
+import com.paypal.android.sdk.payments.PaymentActivity;
+import com.paypal.android.sdk.payments.PaymentConfirmation;
+
+public class PaypalActivity extends Activity {
+
+ private int participation;
+
+ private String idProject;
+
+ private static final String TAG = "paymentExample";
+
+ private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_NO_NETWORK;
+ private static final String CONFIG_CLIENT_ID = "";
+ private static final int REQUEST_CODE_PAYMENT = 5;
+ private static final int REQUEST_CODE_FUTURE_PAYMENT = 6;
+
+ private static PayPalConfiguration config = new PayPalConfiguration()
+ .environment(CONFIG_ENVIRONMENT).clientId(CONFIG_CLIENT_ID)
+ .merchantName("PublicrowdFunding Store")
+ .merchantPrivacyPolicyUri(Uri.parse(""))
+ .merchantUserAgreementUri(Uri.parse(""));
+
+ public void configurationPaypal() {
+ Intent intent = new Intent(this, PayPalService.class);
+ intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
+ startService(intent);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ configurationPaypal();
+
+ participation = getIntent().getExtras().getInt("participation", 0);
+ if (participation == 0) {
+ Toast.makeText(getApplicationContext(),
+ "Une Erreur s'est produite", Toast.LENGTH_SHORT).show();
+ finish();
+ }
+
+ idProject = this.getIntent().getExtras().getString("idProject");
+
+ /* Paypal */
+
+ PayPalPayment thingToBuy = getSommeParticipations(PayPalPayment.PAYMENT_INTENT_SALE);
+ Intent intent = new Intent(PaypalActivity.this, PaymentActivity.class);
+ intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
+ startActivityForResult(intent, REQUEST_CODE_PAYMENT);
+
+ }
+
+ private PayPalPayment getSommeParticipations(String paymentIntent) {
+ return new PayPalPayment(new BigDecimal(participation), "EUR",
+ "Participer au projet", paymentIntent);
+ }
+
+ public void onFuturePaymentPressed(View pressed) {
+ Intent intent = new Intent(PaypalActivity.this,
+ PayPalFuturePaymentActivity.class);
+
+ startActivityForResult(intent, REQUEST_CODE_FUTURE_PAYMENT);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ if (requestCode == REQUEST_CODE_PAYMENT) {
+ if (resultCode == Activity.RESULT_OK) {
+ PaymentConfirmation confirm = data
+ .getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
+ if (confirm != null) {
+ try {
+ Log.i(TAG, confirm.toJSONObject().toString(4));
+ Log.i(TAG, confirm.getPayment().toJSONObject()
+ .toString(4));
+ /**
+ * TODO: send 'confirm' (and possibly
+ * confirm.getPayment() to your server for verification
+ * or consent completion. See
+ * https://developer.paypal.com
+ * /webapps/developer/docs/integration
+ * /mobile/verify-mobile-payment/ for more details.
+ *
+ * For sample mobile backend interactions, see
+ * https://github
+ * .com/paypal/rest-api-sdk-python/tree/master
+ * /samples/mobile_backend
+ */
+
+ String somme = ""+participation;
+ Intent returnIntent = new Intent();
+ returnIntent.putExtra("idProject", idProject);
+ returnIntent.putExtra("somme", somme);
+ setResult(RESULT_OK, returnIntent);
+ finish();
+
+ } catch (JSONException e) {
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ }
+ }
+ } else if (resultCode == Activity.RESULT_CANCELED) {
+
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
+
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ }
+
+ } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
+ if (resultCode == Activity.RESULT_OK) {
+ PayPalAuthorization auth = data
+ .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
+ if (auth != null) {
+ try {
+ Log.i("FuturePaymentExample", auth.toJSONObject()
+ .toString(4));
+
+ String authorization_code = auth.getAuthorizationCode();
+ Log.i("FuturePaymentExample", authorization_code);
+
+ sendAuthorizationToServer(auth);
+ Toast.makeText(getApplicationContext(),
+ "Future Payment code received from PayPal",
+ Toast.LENGTH_LONG).show();
+
+ } catch (JSONException e) {
+
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ }
+ }
+ } else if (resultCode == Activity.RESULT_CANCELED) {
+
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
+
+ Intent returnIntent = new Intent();
+ setResult(RESULT_CANCELED, returnIntent);
+ finish();
+ }
+ }
+ }
+
+ private void sendAuthorizationToServer(PayPalAuthorization authorization) {
+
+ /**
+ * TODO: Send the authorization response to your server, where it can
+ * exchange the authorization code for OAuth access and refresh tokens.
+ *
+ * Your server must then store these tokens, so that your server code
+ * can execute payments for this user in the future.
+ *
+ * A more complete example that includes the required app-server to
+ * PayPal-server integration is available from
+ * https://github.com/paypal/
+ * rest-api-sdk-python/tree/master/samples/mobile_backend
+ */
+
+ }
+
+ public void onFuturePaymentPurchasePressed(View pressed) {
+ // Get the Application Correlation ID from the SDK
+ String correlationId = PayPalConfiguration
+ .getApplicationCorrelationId(this);
+
+ Log.i("FuturePaymentExample", "Application Correlation ID: "
+ + correlationId);
+
+ Toast.makeText(getApplicationContext(),
+ "App Correlation ID received from SDK", Toast.LENGTH_LONG)
+ .show();
+ }
+
+ @Override
+ public void onDestroy() {
+ // Stop service when done
+ stopService(new Intent(this, PayPalService.class));
+ super.onDestroy();
+ }
+
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.project.validate;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.SyncServerToLocal;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class MainActivity extends Fragment {
+
+ private ListView listeProjets;
+
+ private SwipeRefreshLayout swipeView;
+
+ private ArrayAdapter<Project> adapter;
+
+ private LinearLayout loading;
+
+ private FrameLayout filter;
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ final View view = inflater.inflate(R.layout.fragment_liste_projet,
+ container, false);
+
+ listeProjets = (ListView) view.findViewById(R.id.liste);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+
+ filter = (FrameLayout) this.getActivity().getWindow().getDecorView().findViewById(R.id.big_filter);
+ filter.setVisibility(View.GONE);
+
+ TextView empty = (TextView) view.findViewById(R.id.empty);
+ listeProjets.setEmptyView(empty);
+
+ refresh();
+
+ swipeView = (SwipeRefreshLayout) view.findViewById(R.id.refresher);
+ swipeView.setEnabled(false);
+ swipeView.setColorScheme(R.color.blue, R.color.green, R.color.yellow,
+ R.color.red);
+ swipeView
+ .setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ swipeView.setEnabled(true);
+ refresh();
+
+ }
+
+ });
+
+ listeProjets.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
+ Fragment fragment = new adullact.publicrowdfunding.controller.project.validate.validatePopup();
+
+ String idProject = adapter.getItem(position).getResourceId();
+ Bundle bundle = new Bundle();
+ bundle.putString("idProject", idProject);
+ fragment.setArguments(bundle);
+
+ ft.setCustomAnimations(R.anim.popup_enter, R.anim.no_anim);
+ ft.add(R.id.big_font, fragment);
+ ft.commit();
+
+ filter.setVisibility(View.VISIBLE);
+
+ }
+ });
+
+ listeProjets.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) {
+
+ }
+
+ @Override
+ public void onScroll(AbsListView absListView, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
+ if (firstVisibleItem == 0)
+ swipeView.setEnabled(true);
+ else
+ swipeView.setEnabled(false);
+ }
+ });
+ loading.setVisibility(View.GONE);
+ return view;
+
+ }
+
+ public void refresh() {
+
+ final SyncServerToLocal sync = SyncServerToLocal.getInstance();
+ sync.sync(new HoldAllToDo<Project>() {
+
+ @Override
+ public void holdAll(ArrayList<Project> projects) {
+
+ adapter = new ValidateProjectAdaptor(getActivity().getBaseContext(),
+ R.layout.adaptor_project, sync.restrictToNotValidatedProjects());
+ adapter.clear();
+ adapter.addAll(projects);
+ adapter.notifyDataSetChanged();
+ swipeView.setRefreshing(false);
+
+ listeProjets.setAdapter(adapter);
+
+ }
+ });
+
+
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+
+ try {
+ menu.clear();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ inflater.inflate(R.menu.menu_main, menu);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.project.validate;
+
+import java.util.ArrayList;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.utilities.Calcul;
+import adullact.publicrowdfunding.model.local.utilities.Share;
+import adullact.publicrowdfunding.model.local.utilities.Utility;
+import adullact.publicrowdfunding.views.CustomProgressBar;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ValidateProjectAdaptor extends ArrayAdapter<Project> {
+
+ Context mContext;
+ int layoutResourceId;
+ ArrayList<Project> data;
+
+ public ValidateProjectAdaptor(Context context, int resource, ArrayList<Project> listItem) {
+ super(context, resource, listItem);
+ this.mContext = context;
+ this.layoutResourceId = resource;
+ this.data = listItem;
+ }
+
+ private static class UserHolder {
+
+ public TextView titre_projet_liste;
+ public TextView description_projet_liste;
+ public TextView temps_restant_projet_liste;
+ public CustomProgressBar avancement_projet_liste;
+ public ImageView illustration;
+ public TextView sommeFunded;
+ public TextView sommeDemander;
+ public TextView distance;
+
+ }
+
+ @Override
+ public int getCount() {
+ // TODO Auto-generated method stub
+ return data.size();
+ }
+
+ public Project getItem(int index) {
+ return this.data.get(index);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ UserHolder holder = new UserHolder();
+
+ // First let's verify the convertView is not null
+ if (convertView == null) {
+ // This a new view we inflate the new layout
+ LayoutInflater inflater = (LayoutInflater) mContext
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(layoutResourceId, null);
+
+ holder.titre_projet_liste = (TextView) v
+ .findViewById(R.id.titre_projet_liste);
+ holder.description_projet_liste = (TextView) v
+ .findViewById(R.id.description_projet_liste);
+ holder.temps_restant_projet_liste = (TextView) v
+ .findViewById(R.id.nombre_jour_restant_detail);
+ holder.avancement_projet_liste = (CustomProgressBar) v
+ .findViewById(R.id.avancement_projet_liste);
+ holder.illustration = (ImageView) v.findViewById(R.id.icon);
+ holder.sommeDemander = (TextView) v
+ .findViewById(R.id.sommeeDemande);
+
+ holder.sommeFunded = (TextView) v
+ .findViewById(R.id.sommeFund);
+ holder.distance = (TextView) v
+ .findViewById(R.id.distance);
+
+ v.setTag(holder);
+ } else {
+ holder = (UserHolder) v.getTag();
+ }
+
+ Project projet = data.get(position);
+ holder.titre_projet_liste.setText(projet.getName());
+ holder.description_projet_liste.setText(projet.getDescription());
+ holder.temps_restant_projet_liste.setText(projet.getNumberOfDayToEnd()
+ + " jours");
+
+ holder.avancement_projet_liste.setProgress(projet
+ .getPercentOfAchievement());
+ holder.sommeDemander.setText(projet.getRequestedFunding()+"€");
+ holder.sommeFunded.setText(projet.getCurrentFunding()+"€");
+ if (projet.getIllustration() != 0) {
+ holder.illustration.setImageResource(Utility.getDrawable(projet
+ .getIllustration()));
+ } else {
+ holder.illustration.setImageResource(R.drawable.ic_launcher);
+ }
+
+ holder.distance.setVisibility(View.GONE);
+ try{
+ holder.distance.setText("Distance : "+Calcul.diplayDistance(Share.position, projet.getPosition()));
+ holder.distance.setVisibility(View.VISIBLE);
+ }catch(NullPointerException e){
+ holder.distance.setVisibility(View.GONE);
+ }
+
+ return v;
+
+ }
+}
--- /dev/null
+package adullact.publicrowdfunding.controller.project.validate;
+
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.server.event.UpdateEvent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.RadioGroup;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class validatePopup extends Fragment {
+
+ private validatePopup _this;
+
+ private Button valider;
+
+ private Project currentProject;
+
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ super.onCreateView(inflater, container, savedInstanceState);
+ final View view = inflater.inflate(R.layout.popup_activer, container,
+ false);
+
+ _this = this;
+
+ valider = (Button) view.findViewById(R.id.valider);
+ Bundle bundle = this.getArguments();
+
+ final String idProject = bundle.getString("idProject");
+
+ final RadioGroup selected = (RadioGroup) view.findViewById(R.id.radioGroup);
+
+ new Project().getCache(idProject).toResource(new HoldToDo<Project>(){
+
+ @Override
+ public void hold(Project resource) {
+ currentProject = resource;
+ }
+ });
+
+ valider.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+
+ switch(selected.getCheckedRadioButtonId()){
+ case R.id.validation:
+
+ currentProject.setValidate(true);
+ update();
+ break;
+ case R.id.reject:
+ currentProject.setValidate(false);
+ update();
+ default:
+ return;
+ }
+ }
+
+ });
+
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+
+ back();
+ return true;
+ }
+ return false;
+ }
+ });
+ return view;
+
+ }
+
+ public void back() {
+
+ FragmentTransaction ft = getActivity().getSupportFragmentManager()
+ .beginTransaction();
+ ft.setCustomAnimations(R.anim.no_anim, R.anim.popup_exit);
+ ft.remove(_this);
+ ft.commit();
+
+ // Multi Thread pour que l'animation s'éxécute
+
+ new Handler().postDelayed(new Runnable() {
+ public void run() {
+ try {
+ getActivity().getWindow().getDecorView()
+ .findViewById(R.id.big_filter)
+ .setVisibility(View.GONE);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 500);
+ }
+
+ public void update(){
+ currentProject.serverUpdate(new UpdateEvent<Project>(){
+
+ @Override
+ public void onUpdate(Project resource) {
+ back();
+
+ }
+
+ @Override
+ public void errorResourceIdDoesNotExist() {
+ back();
+
+ }
+
+ @Override
+ public void errorAdministratorRequired() {
+ back();
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ back();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ back();
+
+ }
+
+ @Override
+ public void errorServer() {
+ back();
+
+ }
+
+ });
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.register;
+
+import adullact.publicrowdfunding.MainActivity;
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
+import adullact.publicrowdfunding.model.local.ressource.Account;
+import adullact.publicrowdfunding.model.local.ressource.User;
+import adullact.publicrowdfunding.model.server.event.AuthenticationEvent;
+import adullact.publicrowdfunding.model.server.request.AuthenticationRequest;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class ConnexionFragment extends Fragment {
+
+ private EditText m_login;
+ private EditText m_password;
+ private Button m_buttonValider;
+ private Button m_buttonInscription;
+ private Context context;
+
+ private LinearLayout loading;
+ private LinearLayout loadingPersonnelInfo;
+
+ private Fragment _this;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ final View view = inflater.inflate(R.layout.popup_connect,
+ container, false);
+
+ context = getActivity();
+
+ _this = this;
+
+ m_login = (EditText) view.findViewById(R.id.login_connexion);
+ m_password = (EditText) view.findViewById(R.id.password_connexion);
+
+ m_buttonValider = (Button) view.findViewById(R.id.valider_connexion);
+ m_buttonInscription = (Button) view.findViewById(R.id.inscription_button);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+ loading.setVisibility(View.GONE);
+
+ loadingPersonnelInfo = (LinearLayout) view.findViewById(R.id.loadingLoadingInfo);
+ loadingPersonnelInfo.setVisibility(View.GONE);
+
+ m_buttonValider.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ if (m_login.length() == 0) {
+ Toast.makeText(context, "Vous avez oublié le login",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (m_password.length() == 0) {
+
+ Toast.makeText(context, "Vous avez oublié le mot de passe",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+
+ loading.setVisibility(View.VISIBLE);
+ String login = m_login.getText().toString();
+ String password = m_password.getText().toString();
+
+ new AuthenticationRequest(login, password,
+ new AuthenticationEvent() {
+ @Override
+ public void errorUsernamePasswordDoesNotMatch(
+ String username, String password) {
+
+ Toast.makeText(context,
+ "Login ou mot de passe incorect",
+ Toast.LENGTH_LONG).show();
+ loading.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onAuthentication() {
+ try {
+ loading.setVisibility(View.GONE);
+ loadingPersonnelInfo.setVisibility(View.VISIBLE);
+ Account.getOwn().getUser(new HoldToDo<User>() {
+ @Override
+ public void hold(User resource) {
+ Toast.makeText(context, "Bienvenue " + resource.getPseudo(), Toast.LENGTH_LONG).show();
+
+ MainActivity _this = (MainActivity) getActivity();
+ _this.isConnect();
+
+ back();
+
+
+ }
+ });
+ } catch (NoAccountExistsInLocal noAccountExistsInLocal) {
+ Toast.makeText(context, "Impossible de se conncecté", Toast.LENGTH_LONG).show();
+
+ }
+ }
+
+ @Override
+ public void errorNetwork() {
+
+ Toast.makeText(
+ context,
+ "Connexion impossible au serveur, veuillez vérifier vos paramètres resaux.",
+ Toast.LENGTH_LONG).show();
+ loading.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void errorServer() {
+ Toast.makeText(getActivity().getBaseContext(),
+ "Une erreur s'est produite", Toast.LENGTH_SHORT)
+ .show();
+
+ }
+ }).execute();
+ }
+ });
+
+ m_buttonInscription.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+
+
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ Fragment fragment = new RegisterFragement();
+
+ ft.replace(R.id.big_font, fragment);
+ String login = m_login.getText().toString();
+ Bundle bundle = new Bundle();
+ bundle.putString("login", login);
+ fragment.setArguments(bundle);
+ ft.addToBackStack(null);
+ ft.commit();
+
+ }
+ });
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener(new OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+
+ back();
+ return true;
+ }
+ return false;
+ }
+ });
+ return view;
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ menu.findItem(R.id.action_search).setVisible(false);
+ menu.findItem(R.id.action_sort).setVisible(false);
+ }
+
+ public void back() {
+
+ FragmentTransaction ft = getActivity().getSupportFragmentManager()
+ .beginTransaction();
+ ft.setCustomAnimations(R.anim.no_anim, R.anim.popup_exit);
+ ft.remove(_this);
+ ft.commit();
+
+ // Multi Thread pour que l'animation s'éxécute
+
+ new Handler().postDelayed(new Runnable() {
+ public void run() {
+ try {
+ getActivity().getWindow().getDecorView()
+ .findViewById(R.id.big_filter)
+ .setVisibility(View.GONE);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 500);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package adullact.publicrowdfunding.controller.register;
+
+import adullact.publicrowdfunding.MainActivity;
+import adullact.publicrowdfunding.R;
+import adullact.publicrowdfunding.controller.project.all.ListProjectsFragment;
+import adullact.publicrowdfunding.model.server.event.RegistrationEvent;
+import adullact.publicrowdfunding.model.server.request.RegistrationRequest;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnKeyListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class RegisterFragement extends Fragment {
+
+ private EditText m_login;
+ private EditText m_password1;
+ private EditText m_password2;
+ private Button m_button;
+
+ private LinearLayout loading;
+
+ private Context context;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ final View view = inflater.inflate(R.layout.popup_register,
+ container, false);
+
+ context = getActivity();
+
+ m_login = (EditText) view.findViewById(R.id.inscription_login);
+ m_password1 = (EditText) view.findViewById(R.id.inscription_password1);
+ m_password2 = (EditText) view.findViewById(R.id.inscription_password2);
+ m_button = (Button) view.findViewById(R.id.inscription_button);
+
+ loading = (LinearLayout) view.findViewById(R.id.loading);
+ loading.setVisibility(View.GONE);
+
+
+ Bundle bundle = this.getArguments();
+ if(bundle != null){
+ String login = bundle.getString("login");
+ m_login.setText(login);
+ }
+
+ m_button.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ if (m_login.length() == 0) {
+ Toast.makeText(context,
+ "Vous avez oublié le pseudo", Toast.LENGTH_SHORT)
+ .show();
+ return;
+ }
+
+ if (m_password1.length() == 0) {
+ Toast.makeText(context,
+ "Vous avez oublié le 1er mot de passes",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (m_password2.length() == 0) {
+ Toast.makeText(context,
+ "Vous avez oublié le 2e mot de passes",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (!m_password1.getText().toString()
+ .equals(m_password2.getText().toString())) {
+ Toast.makeText(context,
+ "Les mots de passe sont différents : ",
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ loading.setVisibility(View.VISIBLE);
+
+ String username = m_login.getText().toString();
+ String password = m_password1.getText().toString();
+
+
+ // Je differencie compte (username + password) et user
+ // maintenant, je te divise ta requête
+
+ new RegistrationRequest(username, password, username, new RegistrationEvent() {
+ @Override
+ public void onRegister() {
+ Toast.makeText(context, "Bienvenue "+m_login.getText().toString(), Toast.LENGTH_SHORT).show();
+
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ //ft.setCustomAnimations(R.anim.enter, R.anim.exit);
+ Fragment fragment = new ListProjectsFragment();
+ fragment.setHasOptionsMenu(true);
+ ft.replace(R.id.content_frame, fragment);
+
+ MainActivity _this = (MainActivity) getActivity();
+ _this.isConnect();
+
+ ft.commit();
+ }
+
+ @Override
+ public void errorUsernameAlreadyUsed() {
+ loading.setVisibility(View.GONE);
+ Toast.makeText(context, "Username déjà pris", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void errorPseudoAlreadyUsed() {
+ loading.setVisibility(View.GONE);
+ Toast.makeText(context, "Username déjà pris", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void errorNetwork() {
+ loading.setVisibility(View.GONE);
+ Toast.makeText(context, "Probléme de connection", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void errorServer() {
+ loading.setVisibility(View.GONE);
+ Toast.makeText(getActivity().getBaseContext(),
+ "Une erreur s'est produite", Toast.LENGTH_SHORT)
+ .show();
+
+ }
+ }).execute();
+ }
+ });
+
+ view.setFocusableInTouchMode(true);
+ view.requestFocus();
+ view.setOnKeyListener( new OnKeyListener()
+ {
+ @Override
+ public boolean onKey( View v, int keyCode, KeyEvent event )
+ {
+ if( keyCode == KeyEvent.KEYCODE_BACK )
+ {
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ //ft.setCustomAnimations(R.anim.enter, R.anim.exit);
+ Fragment fragment = new ConnexionFragment();
+ ft.replace(R.id.big_font, fragment);
+
+ ft.commit();
+ return true;
+ }
+ return false;
+ }
+ } );
+
+ return view;
+
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ menu.findItem(R.id.action_search).setVisible(false);
+ menu.findItem(R.id.action_sort).setVisible(false);
+ }
+
+
+
+}
\ No newline at end of file
package adullact.publicrowdfunding.model.exception;
/**
- * Created by Ferrand on 16/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class NoAccountExistsInLocal extends Exception {
package adullact.publicrowdfunding.model.local.cache;
+import java.util.ArrayList;
import java.util.Comparator;
import org.joda.time.DateTime;
import adullact.publicrowdfunding.model.server.event.RetrieveEvent;
/**
- * Created by Ferrand on 18/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class Cache<TResource extends Resource<TResource, ?, ?>> {
private Sync<TResource> m_resource;
private DateTime m_dateTime;
+ private ArrayList<WhatToDo<TResource>> m_pendingWhatToDo;
public Cache(TResource resource) {
this.m_resource = new Sync<TResource>(resource);
+ this.m_pendingWhatToDo = new ArrayList<WhatToDo<TResource>>();
+
this.m_dateTime = null;
}
return m_resource.id;
}
+ final public Cache<TResource> useIt() {
+ m_resource.resource.overrideCache(this);
+
+ return this;
+ }
+
public Cache<TResource> declareUpToDate() {
m_dateTime = DateTime.now();
return this;
}
+ public void setResource(TResource resource) {
+ m_resource.resource = resource;
+ }
+
public Cache<TResource> forceRetrieve() {
m_dateTime = null;
}
public void toResource(final WhatToDo<TResource> whatToDo) {
- boolean timeToRetrieve;
- if(m_dateTime == null) {
- timeToRetrieve = true;
- }
- else {
- Duration duration = new Duration(m_dateTime, DateTime.now());
- timeToRetrieve = (duration.getStandardMinutes() > 15);// Data may be outdated
- }
- if(timeToRetrieve) {
+ if(timeToRetrieve()) {
final RetrieveEvent<TResource> event = new RetrieveEvent<TResource>() {
@Override
public void errorResourceIdDoesNotExists(String id) {
m_resource.setState(Sync.State.deleted);
- whatToDo.give(m_resource);
- whatToDo.eventually();
+ workWithResource();
}
@Override
else {
m_resource.setState(Sync.State.unchanged);
}
- m_dateTime = DateTime.now();
- whatToDo.give(m_resource);
- whatToDo.eventually();
+ afterRetrieve();
+
+ workWithResource();
}
@Override
public void errorNetwork() {
- whatToDo.give(m_resource);
- whatToDo.eventually();
+ workWithResource();
+ }
+
+ @Override
+ public void errorServer() {
+ workWithResource();
}
};
- m_resource.resource.serverRetrieve(event);
+
+ if(addToPendingWhatToDo(whatToDo)) {
+ m_resource.resource.serverRetrieve(event);
+ }
}
else {
whatToDo.give(m_resource);
whatToDo.eventually();
}
}
+
+ protected boolean timeToRetrieve() {
+ if(m_dateTime == null) {
+ return true;
+ }
+ else {
+ Duration duration = new Duration(m_dateTime, DateTime.now());
+ return (duration.getStandardMinutes() > 15);// Data may be outdated
+ }
+ }
+
+ protected void afterRetrieve() {
+ m_dateTime = DateTime.now();
+ }
+
+ /**
+ *
+ * @param whatToDo
+ * @return true if new queue was created
+ */
+ private boolean addToPendingWhatToDo(WhatToDo<TResource> whatToDo) {
+ boolean res = m_pendingWhatToDo.isEmpty();
+ m_pendingWhatToDo.add(whatToDo);
+
+ return res;
+ }
+
+ private void workWithResource() {
+ for(WhatToDo<TResource> whatToDo : m_pendingWhatToDo) {
+ whatToDo.give(m_resource);
+ whatToDo.eventually();
+ }
+ m_pendingWhatToDo.clear();
+ }
}
--- /dev/null
+package adullact.publicrowdfunding.model.local.cache;
+
+import adullact.publicrowdfunding.model.local.ressource.Project;
+import adullact.publicrowdfunding.model.local.ressource.User;
+
+/*import com.vladium.utils.IObjectProfileNode;
+import com.vladium.utils.ObjectProfiler;*/
+
+/**
+ * Created by Ferrand on 04/09/2014.
+ */
+public class CacheCleaner {
+ /* --- Singleton --- */
+ private static CacheCleaner m_instance = null;
+ private CacheCleaner() {
+ }
+
+ public static CacheCleaner getInstance() {
+ if(m_instance == null) {
+ m_instance = new CacheCleaner();
+ }
+
+ return m_instance;
+ }
+ /* ----------------- */
+
+ public void fill() {
+ int nbUser = 0;
+ int nbProject = 0;
+ /*IObjectProfileNode profile = ObjectProfiler.profile(Resource.cachedResource);
+
+ Log.d("Triumvirat", "Initial size : " + profile.size() + " bytes");*/
+
+ /* User */
+ for(int i = 0; i < nbUser; i++) {
+ User user = new User();
+ user.setResourceId(generate(6));
+ user.setFirstName(generate(6));
+ user.setName(generate(6));
+ user.setGender(generate(1));
+ user.setCity(generate(10));
+
+ user.getCache();
+ }
+ /*profile = ObjectProfiler.profile(Resource.cachedResource);
+ Log.d("Triumvirat", "Adding " + nbUser + " users : " + profile.size() + " bytes");*/
+ /* ---- */
+
+ /* Project */
+ /* User */
+ for(int i = 0; i < nbProject; i++) {
+ Project project = new Project(random(10000), false, generate(15), generate(300), false, generate(6), "10000", "100", "2014-05-06 19:56:21", "2014-05-06 19:56:21", "2014-05-06 19:56:21", 50., 50., 0, generate(10), generate(30), generate(10));
+
+ project.getCache();
+ }
+ /*profile = ObjectProfiler.profile(Resource.cachedResource);
+ Log.d("Triumvirat", "Adding " + nbProject + " projects : " + profile.size() + " bytes");*/
+ /* ---- */
+ /* ------ */
+
+ /*profile = ObjectProfiler.profile(Resource.cachedResource);
+
+ Log.d("Triumvirat", "Final size : " + profile.size() + " bytes");*/
+ }
+
+
+ public static String generate(int length) {
+ String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ StringBuffer pass = new StringBuffer();
+ for(int x=0;x<length;x++) {
+ int i = (int)Math.floor(Math.random() * (chars.length() -1));
+ pass.append(chars.charAt(i));
+ }
+ return pass.toString();
+ }
+
+ public static int random(int max) {
+ return (int) Math.floor(Math.random() * max);
+ }
+
+ public void run() {
+ /*System.out.println("Runing time");
+ Scheduler.Worker worker = Schedulers.newThread().createWorker();
+ worker.schedulePeriodically(new Action0() {
+ @Override
+ public void call() {
+ HashMap<String, HashMap<String, Cache>> cachedResource = Resource.cachedResource;
+ for(Map.Entry<String, HashMap<String, Cache>> entry : cachedResource.entrySet()) {
+ System.out.println ("=== " + entry.getKey() + " ===");
+ for(Map.Entry<String, Cache> entryCache : entry.getValue().entrySet()) {
+ System.out.println ("id : " + entry.getKey());
+ IObjectProfileNode profile = ObjectProfiler.profile(entryCache.getValue());
+
+ System.out.println ("obj size = " + profile.size () + " bytes");
+ System.out.println (profile.dump ());
+ //entryCache.getValue().clean();
+ }
+ System.out.println ("=== ====================== ===");
+ }
+ }
+ }, 1, 3, TimeUnit.SECONDS);*/
+ }
+}
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 19/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class CacheSet<TResource extends Resource<TResource, ?, ?>> {
private TreeSet<Cache<TResource>> m_resource;
--- /dev/null
+package adullact.publicrowdfunding.model.local.cache;
+
+import adullact.publicrowdfunding.model.local.ressource.Resource;
+
+/**
+ * @author Ferrand and Nelaupe
+ */
+public class Local<TResource extends Resource<TResource, ?, ?>> extends Cache<TResource> {
+ private boolean m_firstTime;
+
+ public Local(TResource resource) {
+ super(resource);
+
+ m_firstTime = true;
+ }
+
+ @Override
+ protected boolean timeToRetrieve() {
+ return m_firstTime;
+ }
+
+ @Override
+ protected void afterRetrieve() {
+ m_firstTime = false;
+ }
+
+}
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
+ * @author Ferrand and Nelaupe
+ *
* Give meta data about resource.
- *
- * Created by Ferrand on 27/07/2014.
*/
public class Sync<TResource extends Resource<TResource, ?, ?>> {
public static enum State {
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 27/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class HoldAllToDo<TResource extends Resource<TResource, ?, ?>> extends WhatToDo<TResource> {
private ArrayList<TResource> m_resources;
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class HoldPerStateToDo<TResource extends Resource<TResource, ?, ?>> extends WhatToDo<TResource> {
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class HoldToDo<TResource extends Resource<TResource, ?, ?>> extends WhatToDo<TResource> {
@Override
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 19/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class NothingToDo<TResource extends Resource<TResource, ?, ?>> extends WhatToDo<TResource> {
@Override
package adullact.publicrowdfunding.model.local.callback;
+import rx.Scheduler;
+import rx.functions.Action0;
+import rx.schedulers.Schedulers;
import adullact.publicrowdfunding.model.local.cache.Sync;
import adullact.publicrowdfunding.model.local.ressource.Resource;
/**
- * Created by Ferrand on 18/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class WhatToDo<TResource extends Resource<TResource, ?, ?>> {
private Sync<TResource> m_resource;
}
public final void give(final Sync<TResource> resource) {
- m_resource = resource;
- hold(m_resource.resource);
+ Scheduler.Worker worker = Schedulers.trampoline().createWorker();
+ worker.schedule(new Action0() {
+
+ @Override
+ public void call() {
+ m_resource = resource;
+ hold(m_resource.resource);
+ }
+
+ });
}
public abstract void hold(final TResource resource);
import android.database.sqlite.SQLiteDatabase;
/**
- * Created by Ferrand on 20/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ProjectsDatabase {
/* --- Singleton --- */
null // The sort order
);
+
while (cursor.moveToNext()) {
Project project = new Project(
cursor.getInt(0), // id
- cursor.getInt(1) == 0 ? false : true, // validate
+ (cursor.getInt(1) == 1), // validate
cursor.getString(2), // title
cursor.getString(3), // description
- cursor.getInt(4) == 0 ? false : true, // validate
+ (cursor.getInt(4) == 1), // validate
cursor.getString(5), // proposed by
cursor.getString(6), // requested funding
cursor.getString(7), // current funding
ContentValues values = new ContentValues();
values.put(ProjectsTable.COLUMN_NAME_ID, project.getResourceId());
- values.put(ProjectsTable.COLUMN_NAME_ACTIVE, project.isActive() == false ? 0 : 1);
+ values.put(ProjectsTable.COLUMN_NAME_ACTIVE, project.isActive() ? 1 : 0);
values.put(ProjectsTable.COLUMN_NAME_TITLE, project.getName());
values.put(ProjectsTable.COLUMN_NAME_DESCRIPTION, project.getDescription());
- values.put(ProjectsTable.COLUMN_NAME_VALIDATE, project.isValidate() == false ? 0 : 1);
+ values.put(ProjectsTable.COLUMN_NAME_VALIDATE, project.isValidate() ? 1 : 0);
values.put(ProjectsTable.COLUMN_NAME_PROPOSED_BY, project.getUser().getResourceId());
values.put(ProjectsTable.COLUMN_NAME_REQUESTED_FUNDING, project.getRequestedFunding());
values.put(ProjectsTable.COLUMN_NAME_CURRENT_FUNDING, project.getCurrentFunding());
SQLiteDatabase db = m_helper.getWritableDatabase();
ContentValues values = new ContentValues();
- values.put(ProjectsTable.COLUMN_NAME_ACTIVE, project.isActive() == false ? 0 : 1);
+ values.put(ProjectsTable.COLUMN_NAME_ACTIVE, !project.isActive() ? 0 : 1);
values.put(ProjectsTable.COLUMN_NAME_TITLE, project.getName());
values.put(ProjectsTable.COLUMN_NAME_DESCRIPTION, project.getDescription());
- values.put(ProjectsTable.COLUMN_NAME_VALIDATE, project.isValidate() == false ? 0 : 1);
+ values.put(ProjectsTable.COLUMN_NAME_VALIDATE, !project.isValidate() ? 0 : 1);
values.put(ProjectsTable.COLUMN_NAME_PROPOSED_BY, project.getUser().getResourceId());
values.put(ProjectsTable.COLUMN_NAME_REQUESTED_FUNDING, project.getRequestedFunding());
values.put(ProjectsTable.COLUMN_NAME_CURRENT_FUNDING, project.getCurrentFunding());
values.put(ProjectsTable.COLUMN_NAME_CONTACT_PHONE, project.getPhone());
values.put(ProjectsTable.COLUMN_NAME_CONTACT_WEBSITE, project.getWebsite());
- String selection = ProjectsTable.COLUMN_NAME_ID;
+ String selection = ProjectsTable.COLUMN_NAME_ID + " = ?";
String[] selectionArgs = {project.getResourceId()};
db.update(ProjectsTable.TABLE_NAME, values, selection, selectionArgs);
public void delete(Project project) {
SQLiteDatabase db = m_helper.getWritableDatabase();
- String selection = ProjectsTable.COLUMN_NAME_ID;
+ String selection = ProjectsTable.COLUMN_NAME_ID + " = ?";
String[] selectionArgs = {project.getResourceId()};
db.delete(ProjectsTable.TABLE_NAME, selection, selectionArgs);
import android.database.sqlite.SQLiteOpenHelper;
/**
- * Created by Ferrand on 20/07/2014.
+ * @author Ferrand and Nelaupe
*/
public final class ProjectsDatabaseHelper extends SQLiteOpenHelper {
- public static final int DATABASE_VERSION = 2;
+ public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "PublicrowFunding.db";
public ProjectsDatabaseHelper() {
import android.provider.BaseColumns;
/**
- * Created by Ferrand on 20/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ProjectsTable implements BaseColumns {
private ProjectsTable() {}
COLUMN_NAME_ACTIVE + INTEGER_TYPE + NOT_NULL + COMMA +
COLUMN_NAME_TITLE + TEXT_TYPE + NOT_NULL + COMMA +
COLUMN_NAME_DESCRIPTION + TEXT_TYPE + COMMA +
- COLUMN_NAME_VALIDATE + NUMERIC_TYPE + NOT_NULL + COMMA +
+ COLUMN_NAME_VALIDATE + INTEGER_TYPE + NOT_NULL + COMMA +
COLUMN_NAME_PROPOSED_BY + TEXT_TYPE + NOT_NULL + COMMA +
COLUMN_NAME_REQUESTED_FUNDING + NUMERIC_TYPE + COMMA +
COLUMN_NAME_CURRENT_FUNDING + NUMERIC_TYPE + NOT_NULL + COMMA +
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-import org.joda.time.DateTime;
-
import rx.Observable;
import adullact.publicrowdfunding.PublicrowdFundingApplication;
import adullact.publicrowdfunding.model.exception.NoAccountExistsInLocal;
import adullact.publicrowdfunding.model.local.cache.Cache;
+import adullact.publicrowdfunding.model.local.cache.Local;
+import adullact.publicrowdfunding.model.local.callback.HoldToDo;
import adullact.publicrowdfunding.model.local.callback.WhatToDo;
-import adullact.publicrowdfunding.model.local.utilities.Utility;
import adullact.publicrowdfunding.model.server.entities.RowAffected;
import adullact.publicrowdfunding.model.server.entities.ServerAccount;
import adullact.publicrowdfunding.model.server.entities.Service;
import adullact.publicrowdfunding.model.server.entities.SimpleServerResponse;
-import android.content.Context;
import android.content.SharedPreferences;
/**
- * Created by Ferrand on 16/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class Account extends Resource<Account, ServerAccount, ServerAccount> {
/* ---- Singleton ---- */
private static Account m_own = null;
private void initialize() throws NoAccountExistsInLocal {
- SharedPreferences sharedPreferences = m_context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
- if(!sharedPreferences.contains(KEY_USERNAME) || !sharedPreferences.contains(KEY_USERNAME) || !sharedPreferences.contains(KEY_USERNAME)) {
- {
- m_own = null;
- throw new NoAccountExistsInLocal();
- }
+ SharedPreferences sharedPreferences = PublicrowdFundingApplication.sharedPreferences();
+ if(!sharedPreferences.contains(KEY_USERNAME) || !sharedPreferences.contains(KEY_PASSWORD) || !sharedPreferences.contains(KEY_PSEUDO) || !sharedPreferences.contains(KEY_ADMIN)) {
+ m_own = null;
+ throw new NoAccountExistsInLocal();
}
m_username = sharedPreferences.getString(KEY_USERNAME, "");
- m_password = sharedPreferences.getString(KEY_PASSWORD, "");
- m_lastSync = Utility.stringToDateTime(sharedPreferences.getString(KEY_LAST_SYNC, ""));
+ m_password = decrypt("mystery", sharedPreferences.getString(KEY_PASSWORD, ""));
+ m_administrator = sharedPreferences.getBoolean(KEY_ADMIN, false);
+
+ User user = new User();
+ user.setResourceId(sharedPreferences.getString(KEY_PSEUDO, ""));
+ m_user = new Local<User>(user).useIt();
+
+ new Local<Account>(this).useIt();
}
public static Account getOwn() throws NoAccountExistsInLocal {
if(m_own == null) {
try {
- m_own = new Account(PublicrowdFundingApplication.context());
+ m_own = new Account();
m_own.initialize();
}
catch(NoAccountExistsInLocal exception) {
return m_own;
}
- private Account(Context context) {
- this.m_context = context;
- }
/* ------------------- */
/* --- Static const to store --- */
- private static final String FILE_NAME = "logs";
private static final String KEY_USERNAME = "name";
private static final String KEY_PASSWORD = "password";
- private static final String KEY_LAST_SYNC = "last sync";
+ private static final String KEY_ADMIN = "admin";
+ private static final String KEY_PSEUDO = "pseudo";
/* ----------------------------- */
/* ----- Resource ----- */
ServerAccount res = new ServerAccount();
res.username = m_username;
res.password = m_password;
- res.administrator = m_administrator;
+ res.administrator = m_administrator ? 1 : 0;
res.pseudo = m_user.getResourceId();
return res;
}
@Override
public Account makeCopyFromServer(ServerAccount serverAccount) {
- return null;
+ Account res = new Account();
+ res.m_username = serverAccount.username;
+ res.m_administrator = (serverAccount.administrator == 1);
+ res.m_anonymous = false;
+ res.m_user = new User().getCache(serverAccount.pseudo);
+
+ return res;
}
@Override
public Account syncFromServer(ServerAccount serverAccount) {
- this.m_username = serverAccount.username;
- this.m_lastSync = DateTime.now();
- this.m_administrator = serverAccount.administrator;
- this.m_anonymous = false;
- this.m_context = PublicrowdFundingApplication.context();
- this.m_user = new User().getCache(serverAccount.pseudo);
+ this.m_username = serverAccount.username;
+ this.m_administrator = (serverAccount.administrator == 1);
+ this.m_anonymous = false;
+ this.m_user = new User().getCache(serverAccount.pseudo);
- return this;
+ return this;
}
@Override
/* ---- Own data ---- */
private String m_username;
private String m_password;
- private DateTime m_lastSync;
private boolean m_administrator;
private boolean m_anonymous;
- private Context m_context;
/* ------------------ */
/* --- References --- */
public Account() {
this.m_username = null;
this.m_password = null;
- this.m_lastSync = null;
this.m_administrator = false;
this.m_anonymous = true;
- this.m_context = null;
}
public Account(String username, String password, String pseudo) {
this.m_username = username;
this.m_password = password;
this.m_user = new User().getCache(pseudo);
- this.m_lastSync = null;
this.m_administrator = false;
this.m_anonymous = false;
- this.m_context = null;
}
public void setOwn() {
m_own = this;
- }
-
- public void setLastSync(DateTime lastSync) {
- this.m_lastSync = lastSync;
+ save();
}
public boolean isAdmin() {
return m_administrator;
}
- public DateTime getLastSync() {
- return m_lastSync;
- }
-
public String getUsername() {
return m_username;
}
public Cache<User> getUser() {
return m_user;
}
-
+
public void setAdmin(){
- m_administrator = true;
+ m_administrator = true;
}
-
+
+ public static boolean isConnect(){
+ return (m_own != null);
+ }
+
+ public static boolean autoConnect() {
+ try {
+ Account.getOwn();
+ return true;
+ } catch (NoAccountExistsInLocal noAccountExistsInLocal) {
+ return false;
+ }
+ }
+
public static void disconnect(){
- m_own = null;
+ Account own = m_own;
+ m_own = null;
+
+ SharedPreferences.Editor editor = PublicrowdFundingApplication.sharedPreferences().edit();
+
+ editor.remove(KEY_USERNAME);
+ editor.remove(KEY_PASSWORD);
+ editor.remove(KEY_PSEUDO);
+ editor.remove(KEY_ADMIN);
+ editor.apply();
+
+ own.getUser(new HoldToDo<User>() {
+ @Override
+ public void hold(User user) {
+ new Cache<User>(user).declareUpToDate().useIt();
+ }
+ });
+ new Cache<Account>(own).declareUpToDate().useIt();
}
+
+
+
- public void save() {
- SharedPreferences sharedPreferences = m_context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+ private void save() {
+ SharedPreferences.Editor editor = PublicrowdFundingApplication.sharedPreferences().edit();
- sharedPreferences.edit().putString(KEY_USERNAME, m_username);
- sharedPreferences.edit().putString(KEY_PASSWORD, m_password);
- sharedPreferences.edit().putString(KEY_LAST_SYNC, Utility.DateTimeToString(m_lastSync));
- sharedPreferences.edit().commit();
+ editor.putString(KEY_USERNAME, m_username);
+ editor.putString(KEY_PASSWORD, encrypt("mystery", m_password));
+ editor.putString(KEY_PSEUDO, m_user.getResourceId());
+ editor.putBoolean(KEY_ADMIN, m_administrator);
+
+ editor.apply();
}
/* --------- Cryptography part ------------ */
private final static String HEX = "0123456789ABCDEF";
- private static String encrypt(String seed, String password) throws Exception {
- byte[] rawKey = getRawKey(seed.getBytes());
- byte[] result = encrypt(rawKey, password.getBytes());
+ private static String encrypt(String seed, String password) {
+ byte[] result;
+ try {
+ byte[] rawKey = getRawKey(seed.getBytes());
+ result = encrypt(rawKey, password.getBytes());
+ }
+ catch(Exception exception) {
+ return password;
+ }
return toHex(result);
}
- private static String decrypt(String seed, String encrypted) throws Exception {
- byte[] rawKey = getRawKey(seed.getBytes());
- byte[] enc = toByte(encrypted);
- byte[] result = decrypt(rawKey, enc);
+ private static String decrypt(String seed, String encrypted) {
+ byte[] result;
+ try {
+ byte[] rawKey = getRawKey(seed.getBytes());
+ byte[] enc = toByte(encrypted);
+ result = decrypt(rawKey, enc);
+ }
+ catch(Exception exception) {
+ return encrypted;
+ }
return new String(result);
}
return decrypted;
}
- private static String toHex(String txt) {
- return toHex(txt.getBytes());
- }
- private static String fromHex(String hex) {
- return new String(toByte(hex));
- }
-
private static byte[] toByte(String hexString) {
int len = hexString.length()/2;
byte[] result = new byte[len];
import adullact.publicrowdfunding.model.server.request.ListerRequest;
/**
- * Created by Ferrand on 08/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class Bookmark extends Resource<Bookmark, ServerBookmark, ServerBookmark> {
import adullact.publicrowdfunding.model.server.entities.Service;
import adullact.publicrowdfunding.model.server.entities.SimpleServerResponse;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class Commentary extends Resource<Commentary, ServerCommentary, ServerCommentary>{
/* ---- Own data ---- */
commentary.m_user = new User().getCache(serverCommentary.username);
commentary.m_project = new Project().getCache(serverCommentary.projectID);
commentary.m_creationDate = Utility.stringToDateTime(serverCommentary.creationDate);
+ commentary.getCache().declareUpToDate();
return commentary;
}
import adullact.publicrowdfunding.model.server.event.ListerEvent;
import adullact.publicrowdfunding.model.server.request.ListerRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class Funding extends Resource<Funding, ServerFunding, ServerFunding> {
private int m_id;
private Cache<User> m_from;
funding.m_to = new Project().getCache(serverFunding.projectID);
funding.m_value = new BigDecimal(serverFunding.value);
funding.m_date = Utility.stringToDateTime(serverFunding.creationDate);
+ funding.getCache().declareUpToDate();
return funding;
}
@Override
public Observable<RowAffected> methodPOST(Service service) {
- System.out.println("appel de la méthode post");
return service.createFunding(toServerResource());
}
import com.google.android.gms.maps.model.LatLng;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class Project extends Resource<Project, ServerProject, DetailedServerProject> {
/* ----- Resource ----- */
public ServerProject toServerResource() {
ServerProject serverProject = new ServerProject();
serverProject.id = m_id == null ? -1 : m_id;
- serverProject.active = m_active;
+ serverProject.active = m_active ? 1 : 0;
serverProject.name = m_name;
serverProject.description = m_description;
serverProject.proposedBy = m_proposedBy.getResourceId() ;
serverProject.creationDate = m_creationDate.toString();
serverProject.latitude = m_position.latitude;
serverProject.longitude = m_position.longitude;
- serverProject.validate = m_validate;
+ serverProject.validate = m_validate ? 1 : 0;
serverProject.illustration = m_illustration;
serverProject.beginDate = m_fundingInterval.getStart().toString();
serverProject.endDate = m_fundingInterval.getEnd().toString();
public Project makeCopyFromServer(ServerProject serverProject) {
Project res = new Project();
res.m_id = serverProject.id;
- res.m_active = serverProject.active;
+ res.m_active = (serverProject.active == 1);
res.m_name = serverProject.name;
res.m_description = serverProject.description;
res.m_funding = new CacheSet<Funding>();
res.m_currentFunding = new BigDecimal(serverProject.currentFunding);
res.m_creationDate = Utility.stringToDateTime(serverProject.creationDate);
res.m_position = new LatLng(serverProject.latitude, serverProject.longitude);
- res.m_validate = serverProject.validate;
+ res.m_validate = (serverProject.validate == 1);
res.m_illustration = serverProject.illustration;
res.m_fundingInterval = new Interval(Utility.stringToDateTime(serverProject.beginDate), Utility.stringToDateTime(serverProject.endDate));
res.m_email = serverProject.email;
res.m_website = serverProject.website;
res.m_phone = serverProject.phone;
-
+
return res;
}
@Override
public Project syncFromServer(DetailedServerProject detailedServerProject) {
this.m_id = detailedServerProject.id;
- this.m_active = detailedServerProject.active;
+ this.m_active = (detailedServerProject.active == 1);
this.m_name = detailedServerProject.name;
this.m_description = detailedServerProject.description;
this.m_funding = new CacheSet<Funding>();
this.m_currentFunding = new BigDecimal(detailedServerProject.currentFunding);
this.m_creationDate = Utility.stringToDateTime(detailedServerProject.creationDate);
this.m_position = new LatLng(detailedServerProject.latitude, detailedServerProject.longitude);
- this.m_validate = detailedServerProject.validate;
+ this.m_validate = (detailedServerProject.validate == 1);
this.m_illustration = detailedServerProject.illustration;
this.m_fundingInterval = new Interval(Utility.stringToDateTime(detailedServerProject.beginDate), Utility.stringToDateTime(detailedServerProject.endDate));
this.m_fundingIntervals = new ArrayList<FundingInterval>();
this.m_email = detailedServerProject.email;
this.m_website = detailedServerProject.website;
this.m_phone = detailedServerProject.phone;
-
+
// Now, we calculate 10 periods for graphics
calculatePeriods();
final long numberOfDayByPeriod = m_fundingInterval.toDuration().getStandardDays() / 10;
+
for(final ServerFunding serverFunding : detailedServerProject.fundedBy) {
- final Cache<Funding> funding = new Funding().getCache(Integer.toString(serverFunding.id)).declareUpToDate();
- funding.toResource(new HoldToDo<Funding>() {
- @Override
- public void hold(Funding resource) {
- resource.syncFromServer(serverFunding);
- long numberOfDayFromBegin = new Duration(m_fundingInterval.getStart(), resource.getDate()).getStandardDays();
- m_fundingIntervals.get((int) (numberOfDayFromBegin/numberOfDayByPeriod)).addFunding(resource);
- m_funding.add(funding);
+ Funding funding = new Funding().makeCopyFromServer(serverFunding);
+ long numberOfDayFromBegin = new Duration(m_fundingInterval.getStart(), funding.getDate()).getStandardDays();
+ if(numberOfDayFromBegin < 0) {
+ System.err.println("A funding was ignore, because his creation date is before beginning date of project");
+ }
+ else {
+ int index;
+ if(numberOfDayByPeriod == 0) {
+ index = 0;
+ }
+ else {
+ index = (int) (numberOfDayFromBegin/numberOfDayByPeriod);
}
- });
+ m_fundingIntervals.get(index).addFunding(funding);
+ m_funding.add(funding);
+ }
+
}
for(final ServerCommentary serverCommentary : detailedServerProject.commentedBy) {
- final Cache<Commentary> commentary = new Commentary().getCache(Integer.toString(serverCommentary.id)).declareUpToDate();
- commentary.toResource(new HoldToDo<Commentary>() {
- @Override
- public void hold(Commentary resource) {
- resource.syncFromServer(serverCommentary);
- m_commentaries.add(commentary);
- }
- });
+ m_commentaries.add(new Commentary().makeCopyFromServer(serverCommentary).getCache());
}
return this;
public void serverListerToSync(ListerEvent<Project> listerEvent, DateTime lastSync) {
HashMap<String, String> filter = new HashMap<String, String>();
- filter.put("lastSync", lastSync.toString());
+ filter.put("lastSync", Utility.DateTimeToString(lastSync));
(new ListerRequest<Project, ServerProject, DetailedServerProject>(this, filter, listerEvent)).execute();
}
/* -------------------- */
- private Integer m_id;
+ private Integer m_id;
private boolean m_active;
- private String m_name;
- private String m_description;
+ private String m_name;
+ private String m_description;
private Cache<User> m_proposedBy;
private CacheSet<Funding> m_funding;
private CacheSet<Commentary> m_commentaries;
- private BigDecimal m_requestedFunding;
- private BigDecimal m_currentFunding;
- private DateTime m_creationDate;
- private Interval m_fundingInterval;
- private LatLng m_position;
- private ArrayList<FundingInterval> m_fundingIntervals;
- private boolean m_validate;
- private int m_illustration;
- private String m_email;
- private String m_website;
- private String m_phone;
+ private BigDecimal m_requestedFunding;
+ private BigDecimal m_currentFunding;
+ private DateTime m_creationDate;
+ private Interval m_fundingInterval;
+ private LatLng m_position;
+ private ArrayList<FundingInterval> m_fundingIntervals;
+ private boolean m_validate;
+ private int m_illustration;
+ private String m_email;
+ private String m_website;
+ private String m_phone;
public Project() {
this.m_id = null;
public Project(String name, String description, String proposedBy, String requestedFunding, DateTime beginDate, DateTime endDate, LatLng position, int illustration, String email, String website, String phone, boolean validate) {
this.m_id = null;
- this.m_name = name;
- this.m_description = description;
+ this.m_name = name;
+ this.m_description = description;
this.m_proposedBy = new User().getCache(proposedBy);
- this.m_requestedFunding = new BigDecimal(requestedFunding);
- this.m_currentFunding = new BigDecimal("0");
- this.m_creationDate = DateTime.now();
- this.m_fundingInterval = new Interval(beginDate, endDate);
- this.m_fundingIntervals = new ArrayList<FundingInterval>();
- this.m_position = position;
- this.m_validate = validate;
- this.m_illustration = illustration;
- this.m_email = email;
- this.m_website = website;
- this.m_phone = phone;
-
- // Now, we calculate 10 periods for graphics
+ this.m_requestedFunding = new BigDecimal(requestedFunding);
+ this.m_currentFunding = new BigDecimal("0");
+ this.m_creationDate = DateTime.now();
+ this.m_fundingInterval = new Interval(beginDate, endDate);
+ this.m_fundingIntervals = new ArrayList<FundingInterval>();
+ this.m_position = position;
+ this.m_validate = validate;
+ this.m_illustration = illustration;
+ this.m_email = email;
+ this.m_website = website;
+ this.m_phone = phone;
+
+ // Now, we calculate 10 periods for graphics
calculatePeriods();
- }
+ }
/**
* Reserved for local database
*/
public Project(Integer id, boolean active, String name, String description, boolean validate, String proposedBy, String requestedFunding, String currentFunding, String creationDate, String beginDate, String endDate, Double latitude, Double longitude, Integer illustration, String email, String website, String phone) {
- this.m_id = id;
+ this.m_id = id;
this.m_active = active;
this.m_name = name;
this.m_description = description;
this.m_position = new LatLng(latitude, longitude);
this.m_validate = validate;
this.m_illustration = illustration;
- this.m_email = email;
- this.m_website = website;
- this.m_phone = phone;
+ this.m_email = email;
+ this.m_website = website;
+ this.m_phone = phone;
// Now, we calculate 10 periods for graphics
calculatePeriods();
}
-
-
+
+
// Sert pour le graphique pour couter la ligne au jour en cours et qu'elle ne continue pas dans le futur.
public int getNbPeriod(){
- int numberOfPeriod = 10;
- DateTime startDateTime = m_fundingInterval.getStart();
- long numberOfDayBetweenStartAndEnd = m_fundingInterval.toDuration().getStandardDays();
- long dayByPeriod = numberOfDayBetweenStartAndEnd/numberOfPeriod;
- DateTime today = new DateTime();
- for(int i = 0; i < (numberOfPeriod-1); i++){
- if(!startDateTime.isBefore(today)){
- return i;
- } else{
- startDateTime = startDateTime.plusDays((int) dayByPeriod);
- }
+ int numberOfPeriod = 10;
+ DateTime startDateTime = m_fundingInterval.getStart();
+ long numberOfDayBetweenStartAndEnd = m_fundingInterval.toDuration().getStandardDays();
+ long dayByPeriod = numberOfDayBetweenStartAndEnd/numberOfPeriod;
+ DateTime today = new DateTime();
+ for(int i = 0; i < (numberOfPeriod-1); i++){
+ if(!startDateTime.isBefore(today)){
+ return i;
+ } else{
+ startDateTime = startDateTime.plusDays((int) dayByPeriod);
}
-
- return 10;
+ }
+
+ return 10;
}
private void calculatePeriods() {
long numberOfDayBetweenStartAndEnd = m_fundingInterval.toDuration().getStandardDays();
long dayByPeriod = numberOfDayBetweenStartAndEnd/numberOfPeriod;
for(int i = 0; i < (numberOfPeriod-1); i++){
- m_fundingIntervals.add(new FundingInterval(new Interval(startDateTime, startDateTime.plusDays((int) dayByPeriod))));
- startDateTime = startDateTime.plusDays((int) dayByPeriod);
+ m_fundingIntervals.add(new FundingInterval(new Interval(startDateTime, startDateTime.plusDays((int) dayByPeriod))));
+ startDateTime = startDateTime.plusDays((int) dayByPeriod);
}
m_fundingIntervals.add(new FundingInterval(new Interval(startDateTime, endDateTime)));
}
- public String getName() {
- return m_name;
- }
+ public String getName() {
+ return m_name;
+ }
- public String getDescription(){
- return m_description;
- }
+ public String getDescription(){
+ return m_description;
+ }
public String getRequestedFunding(){
return m_requestedFunding.toString();
}
+ public Long getRequestedFundingLongValue(){
+ return m_requestedFunding.longValue();
+ }
+
+
public String getCurrentFunding(){
return m_currentFunding.toString();
}
}
public LatLng getPosition(){
- return m_position;
- }
+ return m_position;
+ }
public boolean isValidate() {
return m_validate;
public void validate() {
m_validate = true;
}
-
+
+ public void setValidate(boolean validate) {
+ m_validate = validate;
+ }
+
+
public long getNumberOfDayToEnd(){
- return new Duration(m_creationDate,m_fundingInterval.getEnd()).getStandardDays();
-
+ return new Duration(m_creationDate,m_fundingInterval.getEnd()).getStandardDays();
+
}
-
+
public Interval getFundingInterval(){
- return this.m_fundingInterval;
+ return this.m_fundingInterval;
}
public ArrayList<FundingInterval> getFundingIntervals(){
return m_fundingIntervals.get(index);
}
-
+
public String getEmail(){
- return m_email;
+ return m_email;
}
-
+
public String getWebsite(){
- return m_website;
+ return m_website;
}
-
+
public String getPhone(){
- return m_phone;
- }
-
- /**
- * @return percent of achievement, may be upper than 100.
- */
- public int getPercentOfAchievement() {
- try{
- return ((m_currentFunding.divide(m_requestedFunding)).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN)).intValue();
- }catch(ArithmeticException e){
- e.printStackTrace();
- return 0;
- }
- }
-
- /**
- * @param value
- * @brief Add value to current funding.
- */
- public void finance(final String value, final CreateEvent<Funding> fundingCreateEvent) throws NoAccountExistsInLocal {
- // m_currentFunding = m_currentFunding.add(new BigDecimal(value));
-
- // Et on appel le serveur aussis ^^
-
-
- Account account = Account.getOwn();
- final Project _this = this;
- account.getUser(new HoldToDo<User>() {
- @Override
- public void hold(User resource) {
- new Funding(resource, _this, "", value).serverCreate(new CreateEvent<Funding>() {
-
- @Override
- public void errorResourceIdAlreadyUsed() {
- fundingCreateEvent.errorResourceIdAlreadyUsed();
-
- }
-
- @Override
- public void onCreate(Funding resource) {
- m_currentFunding = m_currentFunding.add(new BigDecimal(value));
- fundingCreateEvent.onCreate(resource);
-
- }
-
- @Override
- public void errorAuthenticationRequired() {
- fundingCreateEvent.errorAuthenticationRequired();
-
- }
-
- @Override
- public void errorNetwork() {
- fundingCreateEvent.errorNetwork();
-
- }
-
- });
- }
- });
-
-
-
-
-
- }
+ return m_phone;
+ }
+
+ /**
+ * @return percent of achievement, may be upper than 100.
+ */
+ public Integer getPercentOfAchievement() {
+ if(m_requestedFunding.compareTo(BigDecimal.ZERO) == 0) {
+ return 0;
+ }
+ else {
+ return ((m_currentFunding.divide(m_requestedFunding)).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN)).intValue();
+ }
+ }
+
+ /**
+ * @param value
+ * @brief Add value to current funding.
+ */
+ public void finance(final String value, final CreateEvent<Funding> fundingCreateEvent) throws NoAccountExistsInLocal {
+ Account account = Account.getOwn();
+ final Project _this = this;
+ account.getUser(new HoldToDo<User>() {
+ @Override
+ public void hold(User resource) {
+ new Funding(resource, _this, "", value).serverCreate(new CreateEvent<Funding>() {
+
+ @Override
+ public void errorResourceIdAlreadyUsed() {
+ fundingCreateEvent.errorResourceIdAlreadyUsed();
+ }
+
+ @Override
+ public void onCreate(Funding resource) {
+ m_currentFunding = m_currentFunding.add(new BigDecimal(value));
+ fundingCreateEvent.onCreate(resource);
+
+ }
+
+ @Override
+ public void errorAuthenticationRequired() {
+ fundingCreateEvent.errorAuthenticationRequired();
+
+ }
+
+ @Override
+ public void errorNetwork() {
+ fundingCreateEvent.errorNetwork();
+
+ }
+
+ @Override
+ public void errorServer() {
+ fundingCreateEvent.errorServer();
+ }
+
+ });
+ }
+ });
+ }
public void postCommentary(final String title, final String text, final double mark, final CreateEvent<Commentary> commentaryCreateEvent) throws NoAccountExistsInLocal {
Account account = Account.getOwn();
@Override
public void onCreate(Commentary commentary) {
- _this.m_commentaries.add(commentary.getCache());
+ _this.m_commentaries.add(commentary.getCache().declareUpToDate());
commentaryCreateEvent.onCreate(commentary);
}
commentaryCreateEvent.errorNetwork();
}
+ @Override
+ public void errorServer() {
+ commentaryCreateEvent.errorServer();
+ }
+
@Override
public void errorAuthenticationRequired() {
commentaryCreateEvent.errorAuthenticationRequired();
import adullact.publicrowdfunding.model.server.request.UpdateRequest;
/**
- * Created by Ferrand on 18/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class Resource<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource> {
/* ---- Cache manager ---- */
if (cachedType == null) {
cachedType = new HashMap<String, Cache>();
cachedResource.put(getClass().getSimpleName(), cachedType);
- m_cache = new Cache<TResource>((TResource) this);
+ m_cache = cacheInstance();
cachedType.put(id, m_cache);
}
else {
m_cache = cachedType.get(id);
if(m_cache == null) {
- m_cache = new Cache<TResource>((TResource) this);
+ m_cache = cacheInstance();
cachedType.put(id, m_cache);
}
}
return m_cache;
}
+
+ final public void overrideCache(Cache<TResource> cache) {
+ HashMap<String, Cache> cachedType = cachedResource.get(getClass().getSimpleName());
+ if (cachedType == null) {
+ cachedType = new HashMap<String, Cache>();
+ cachedResource.put(getClass().getSimpleName(), cachedType);
+ m_cache = cache;
+ cachedType.put(cache.getResourceId(), m_cache);
+ }
+ else {
+ m_cache = cache;
+ cachedType.put(cache.getResourceId(), m_cache);
+ }
+ }
+
+ protected Cache<TResource> cacheInstance() {
+ return new Cache<TResource>((TResource) this);
+ }
/* ----------------------- */
private boolean m_changed;
import java.util.Map;
import rx.Observable;
-import adullact.publicrowdfunding.model.local.cache.Cache;
import adullact.publicrowdfunding.model.local.cache.CacheSet;
import adullact.publicrowdfunding.model.local.callback.HoldAllToDo;
import adullact.publicrowdfunding.model.local.callback.HoldToDo;
import adullact.publicrowdfunding.model.server.entities.RowAffected;
import adullact.publicrowdfunding.model.server.entities.ServerBookmark;
import adullact.publicrowdfunding.model.server.entities.ServerFunding;
+import adullact.publicrowdfunding.model.server.entities.ServerProject;
import adullact.publicrowdfunding.model.server.entities.ServerUser;
import adullact.publicrowdfunding.model.server.entities.Service;
import adullact.publicrowdfunding.model.server.entities.SimpleServerResponse;
import adullact.publicrowdfunding.model.server.event.DeleteEvent;
/**
- *
- * @author Ferrand
- *
+ * @author Ferrand and Nelaupe
*/
public class User extends Resource<User, ServerUser, DetailedServerUser> {
private String m_pseudo;
private String m_city;
private String m_gender;
// private String m_email;
+ private CacheSet<Project> m_proposedProjects;
private CacheSet<Bookmark> m_bookmarks;
private CacheSet<Funding> m_funding;
user.m_firstName = serverUser.firstName;
user.m_city = serverUser.city;
user.m_gender = serverUser.sexe;
+ user.m_proposedProjects = new CacheSet<Project>();
user.m_bookmarks = new CacheSet<Bookmark>();
user.m_funding = new CacheSet<Funding>();
this.m_city = detailedServerUser.city;
//this.m_email = detailedServerUser.mail;
this.m_gender = detailedServerUser.sexe;
-
+
+ this.m_proposedProjects = new CacheSet<Project>();
+
+ for(final ServerProject serverProject : detailedServerUser.proposedProjects) {
+ m_proposedProjects.add(new Project().makeCopyFromServer(serverProject).getCache());
+ }
+
this.m_bookmarks = new CacheSet<Bookmark>();
for(final ServerBookmark serverBookmark : detailedServerUser.bookmarkedProjects) {
- final Cache<Bookmark> bookmarks = new Bookmark().getCache(Integer.toString(serverBookmark.id)).declareUpToDate();
- bookmarks.toResource(new HoldToDo<Bookmark>() {
- @Override
- public void hold(Bookmark resource) {
- resource.syncFromServer(serverBookmark);
- m_bookmarks.add(bookmarks);
- }
- });
+ m_bookmarks.add(new Bookmark().makeCopyFromServer(serverBookmark).getCache());
}
this.m_funding = new CacheSet<Funding>();
for(final ServerFunding serverFunding : detailedServerUser.fundedProjects) {
- final Cache<Funding> funded = new Funding().getCache(Integer.toString(serverFunding.id)).declareUpToDate();
- funded.toResource(new HoldToDo<Funding>() {
- @Override
- public void hold(Funding resource) {
- resource.syncFromServer(serverFunding);
- m_funding.add(funded);
- }
- });
+ //m_funding.add(new Funding().makeCopyFromServer(serverFunding).getCache(Integer.toString(serverFunding.id)));
}
return this;
}
@Override
public void onCreate(Bookmark resource) {
- m_bookmarks.add(resource);
+ m_bookmarks.add(resource.getCache().declareUpToDate());
bookmarkCreateEvent.onCreate(resource);
}
public void errorNetwork() {
bookmarkCreateEvent.errorNetwork();
}
+
+ @Override
+ public void errorServer() {
+ bookmarkCreateEvent.errorServer();
+ }
});
}
public void removeBookmark(final Project project, final DeleteEvent<Bookmark> bookmarkDeleteEvent) {
- System.out.println("remove bookmark"+m_bookmarks.toString());
- System.out.println("project id : "+project.getResourceId());
m_bookmarks.forEach(new HoldToDo<Bookmark>() {
@Override
public void hold(Bookmark bookmark) {
- System.out.println("Loop : id "+bookmark.getProject().getResourceId());
if(bookmark.getProject().getResourceId().equals(project.getResourceId())) {
m_bookmarks.stopForEach();
bookmark.serverDelete(new DeleteEvent<Bookmark>() {
@Override
public void onDelete(Bookmark resource) {
- System.out.println("On supprime le bookmark depuis user");
- m_bookmarks.remove(resource);
+ m_bookmarks.remove(resource.getCache().declareUpToDate());
bookmarkDeleteEvent.onDelete(resource);
}
public void errorNetwork() {
bookmarkDeleteEvent.errorNetwork();
}
+
+ @Override
+ public void errorServer() {
+ bookmarkDeleteEvent.errorServer();
+ }
});
}
}
});
}
+ public void getProposedProjects(final WhatToDo<Project> projectWhatToDo) {
+ m_proposedProjects.forEach(projectWhatToDo);
+ }
+
public void getBookmarkedProjects(final WhatToDo<Project> projectWhatToDo) {
m_bookmarks.forEach(new HoldAllToDo<Bookmark>() {
import com.google.android.gms.maps.model.LatLng;
+/**
+ * @author Ferrand and Nelaupe
+ */
public final class Calcul {
- public static int distance (LatLng a, LatLng b)
+ public static Integer distance (LatLng a, LatLng b)
{
double earthRadius = 3958.75;
double latDiff = Math.toRadians(b.latitude-a.latitude);
import adullact.publicrowdfunding.model.local.ressource.User;
/**
- * Created by Ferrand on 29/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class CanI {
public void validate(Project project) {
import adullact.publicrowdfunding.model.local.ressource.Funding;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class FundingInterval {
private Interval m_interval;
package adullact.publicrowdfunding.model.local.utilities;
-import java.util.Locale;
-
import com.google.android.gms.maps.model.LatLng;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class Share {
public static LatLng position;
public static boolean displayPosition;
public static String formatString(String str) {
- try {
- return str.substring(0, 1).toUpperCase(Locale.getDefault())
- + str.substring(1).toLowerCase(Locale.getDefault());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
+ String res;
+ if(str.length() > 1) {
+ res = str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
+ }
+ else {
+ if(str.length() == 1) {
+ res = str.toUpperCase();
+ }
+ else {
+ res = "";
+ }
+ }
+
+ return res;
}
}
package adullact.publicrowdfunding.model.local.utilities;
+import android.content.SharedPreferences;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.regex.Pattern;
-import org.joda.time.DateTime;
-
-import rx.Scheduler;
-import rx.functions.Action0;
-import rx.schedulers.Schedulers;
+import adullact.publicrowdfunding.PublicrowdFundingApplication;
import adullact.publicrowdfunding.model.local.callback.NothingToDo;
import adullact.publicrowdfunding.model.local.callback.WhatToDo;
import adullact.publicrowdfunding.model.local.database.ProjectsDatabase;
-import adullact.publicrowdfunding.model.local.ressource.Account;
import adullact.publicrowdfunding.model.local.ressource.Project;
import adullact.publicrowdfunding.model.server.event.ListerEvent;
+import rx.Scheduler;
+import rx.functions.Action0;
+import rx.schedulers.Schedulers;
/**
- * Created by Ferrand on 19/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class SyncServerToLocal {
/* --- Singleton --- */
for(Project project : projects) {
m_projects.add(project);
+ project.getCache(); // create a cache
}
+
+ SharedPreferences sharedPreferences = PublicrowdFundingApplication.sharedPreferences();
+ m_lastSync = Utility.stringToDateTime(sharedPreferences.getString(KEY_LAST_SYNC, "2000-01-01 00:00:00"));
}
+
public static SyncServerToLocal getInstance() {
if(m_instance == null) {
m_instance = new SyncServerToLocal();
/* ----------------- */
private TreeSet<Project> m_projects;
+ private DateTime m_lastSync;
+ private Searcher m_currentSearcher;
+ private Comparator<Project> m_currentComparator;
+ private static String KEY_LAST_SYNC = "lastSync";
public TreeSet<Project> getProjects() {
return m_projects;
}
+ public void forceSyncAll(final WhatToDo<Project> projectWhatToDo) {
+ m_lastSync = new DateTime(2000, 1, 1, 0, 0);
+ sync(projectWhatToDo);
+ }
+
public void sync() {
sync(new NothingToDo<Project>());
}
public void sync(final WhatToDo<Project> projectWhatToDo) {
- final DateTime now = DateTime.now();
+ final DateTime now = DateTime.now(DateTimeZone.getDefault());
final SyncServerToLocal _this = this;
ListerEvent<Project> event = new ListerEvent<Project>() {
@Override
public void onLister(ArrayList<Project> projects) {
- Account.getOwnOrAnonymous().setLastSync(now);
+ m_lastSync = now;
+ SharedPreferences.Editor editor = PublicrowdFundingApplication.sharedPreferences().edit();
+
+ editor.putString(KEY_LAST_SYNC, Utility.DateTimeToString(m_lastSync));
+ editor.apply();
final ArrayList<Project> newProjects = new ArrayList<Project>();
final ArrayList<Project> updatedProjects = new ArrayList<Project>();
if(project.isActive()) {
if(m_projects.contains(project)) {
updatedProjects.add(project);
+ project.getCache().forceRetrieve().setResource(project);
}
else {
newProjects.add(project);
+ project.getCache(); // create a cache
}
}
else {
projectWhatToDo.hold(project);
}
- m_projects.addAll(projects);
+ m_projects.addAll(newProjects);
+ m_projects.removeAll(deletedProject);
+
_this.syncLocalDatabase(newProjects, updatedProjects, deletedProject);
projectWhatToDo.eventually();
}
public void errorNetwork() {
projectWhatToDo.eventually();
}
+
+ @Override
+ public void errorServer() {
+ projectWhatToDo.eventually();
+ }
};
- if(Account.getOwnOrAnonymous().getLastSync() == null) {
- (new Project()).serverLister(event);
- }
- else {
- (new Project()).serverListerToSync(event, Account.getOwnOrAnonymous().getLastSync());
- }
+
+ new Project().serverListerToSync(event, m_lastSync);
}
private void syncLocalDatabase(final ArrayList<Project> newProjects, final ArrayList<Project> updatedProjects, final ArrayList<Project> deletedProjects) {
boolean searchTest(Project project, String motif);
}
+ private interface Filter {
+ boolean filterTest(Project project);
+ }
+
+
public ArrayList<Project> searchInName(final String motif) {
return search(motif, new Searcher() {
@Override
});
}
+ public ArrayList<Project> restrictToValidatedProjects() {
+ return restrict(new Filter() {
+ @Override
+ public boolean filterTest(Project project) {
+ return project.isValidate();
+ }
+ });
+ }
+
+ public ArrayList<Project> restrictToNotValidatedProjects() {
+ return restrict(new Filter() {
+ @Override
+ public boolean filterTest(Project project) {
+ return !project.isValidate();
+ }
+ });
+ }
+
+ private ArrayList<Project> restrict(Filter filter) {
+ ArrayList<Project> res = new ArrayList<Project>();
+
+ for(Project project : m_projects) {
+ if(filter.filterTest(project)) {
+ res.add(project);
+ }
+ }
+
+ return res;
+ }
+
+
private ArrayList<Project> search(final String motif, Searcher searcher) {
+ m_currentSearcher = searcher;
ArrayList<Project> res = new ArrayList<Project>();
for(Project project : m_projects) {
return res;
}
+
+ public ArrayList<Project> sortByRequestingProjectMaxToMin() {
+ return sort(new Comparator<Project>() {
+ @Override
+ public int compare(Project lhs, Project rhs) {
+ return rhs.getRequestedFundingLongValue().compareTo(lhs.getRequestedFundingLongValue());
+ }
+ });
+ }
+
+ public ArrayList<Project> sortByRequestingProjectMinToMax() {
+ return sort(new Comparator<Project>() {
+ @Override
+ public int compare(Project lhs, Project rhs) {
+ return lhs.getRequestedFundingLongValue().compareTo(rhs.getRequestedFundingLongValue());
+ }
+ });
+ }
+
+ public ArrayList<Project> sortByAlmostFunded() {
+ return sort(new Comparator<Project>() {
+ @Override
+ public int compare(Project lhs, Project rhs) {
+ return rhs.getPercentOfAchievement().compareTo(lhs.getPercentOfAchievement());
+ }
+ });
+
+ }
+
+ public ArrayList<Project> sortByProximity() {
+ return sort(new Comparator<Project>() {
+ @Override
+ public int compare(Project lhs, Project rhs) {
+ return Calcul.distance(Share.position, rhs.getPosition()).compareTo(Calcul.distance(Share.position, lhs.getPosition()));
+ }
+ });
+
+ }
+
+ private ArrayList<Project> sort(final Comparator<Project> sorter) {
+ m_currentComparator = sorter;
+ ArrayList<Project> res = new ArrayList<Project>(m_projects);
+
+ Collections.sort(res, sorter);
+
+ return res;
+ }
}
import adullact.publicrowdfunding.R;
/**
- * Created by Ferrand on 03/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class Utility {
private static DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
import adullact.publicrowdfunding.model.server.event.Event;
import adullact.publicrowdfunding.model.server.request.Request;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class ServerObject
<TRequest extends Request<TRequest, TEvent, TErrorHandler>,
TEvent extends Event<TRequest, TEvent, TErrorHandler>,
import java.util.ArrayList;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class DetailedServerProject extends ServerProject {
import java.util.ArrayList;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class DetailedServerUser extends ServerUser {
- public ArrayList<ServerProject> projects; // All project
+ public ArrayList<ServerProject> proposedProjects;
public ArrayList<ServerFunding> fundedProjects;
public ArrayList<ServerBookmark> bookmarkedProjects;
public ArrayList<ServerCommentary> commentaries;
package adullact.publicrowdfunding.model.server.entities;
/**
- * Created by Ferrand on 19/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class RowAffected {
public String id;
package adullact.publicrowdfunding.model.server.entities;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerAccount {
public String username;
public String password;
public String pseudo;
- public boolean administrator;
+ public int administrator;
}
package adullact.publicrowdfunding.model.server.entities;
-
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerBookmark {
public int id;
package adullact.publicrowdfunding.model.server.entities;
-
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerCommentary {
public int id;
package adullact.publicrowdfunding.model.server.entities;
-
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerFunding {
public int id;
package adullact.publicrowdfunding.model.server.entities;
-
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerProject {
public int id;
- public boolean active;
+ public int active;
public String proposedBy;
- public boolean validate;
+ public int validate;
public String name;
public String description;
public String currentFunding;
package adullact.publicrowdfunding.model.server.entities;
/**
- * Created by Ferrand on 16/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerRegistrationResponse {
public int accountOK;
package adullact.publicrowdfunding.model.server.entities;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class ServerUser {
public String pseudo;
import rx.Observable;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public interface Service {
// Check
package adullact.publicrowdfunding.model.server.entities;
/**
- * Created by Ferrand on 21/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class SimpleServerResponse {
public String code;
import adullact.publicrowdfunding.model.server.request.AdministratorRequest;
/**
- * Created by Ferrand on 15/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class AdministratorErrorHandler<
TRequest extends AdministratorRequest<TRequest, TEvent, TErrorHandler>,
import adullact.publicrowdfunding.model.server.event.AuthenticatedEvent;
import adullact.publicrowdfunding.model.server.request.AuthenticatedRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class AuthenticatedErrorHandler
<TRequest extends AuthenticatedRequest<TRequest, TEvent, TErrorHandler>,
TEvent extends AuthenticatedEvent<TRequest, TEvent, TErrorHandler>,
import adullact.publicrowdfunding.model.server.request.AuthenticationRequest;
/**
- * Created by Ferrand on 26/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class AuthenticationErrorHandler extends AuthenticatedErrorHandler<AuthenticationRequest, AuthenticationEvent, AuthenticationErrorHandler> {
}
import adullact.publicrowdfunding.model.server.event.CreateEvent;
import adullact.publicrowdfunding.model.server.request.CreateRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class CreateErrorHandler<TResource extends Resource<TResource, ?, ?>>
extends AuthenticatedErrorHandler<CreateRequest<TResource,?,?>,CreateEvent<TResource>,CreateErrorHandler<TResource>> {
private boolean m_resourceIdAlreadyExist = false;
import adullact.publicrowdfunding.model.server.event.DeleteEvent;
import adullact.publicrowdfunding.model.server.request.DeleteRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class DeleteErrorHandler<TResource extends Resource<TResource, ?, ?>>
extends AdministratorErrorHandler<DeleteRequest<TResource, ?, ?>, DeleteEvent<TResource>, DeleteErrorHandler<TResource>> {
private boolean m_resourceIdDoesNotExist = false;
import adullact.publicrowdfunding.model.server.event.Event;
import adullact.publicrowdfunding.model.server.request.Request;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class ErrorHandler
<TRequest extends Request<TRequest, TEvent, TErrorHandler>,
TEvent extends Event<TRequest, TEvent, TErrorHandler>,
TErrorHandler extends ErrorHandler<TRequest, TEvent, TErrorHandler>>
extends ServerObject<TRequest, TEvent, TErrorHandler> implements retrofit.ErrorHandler {
private boolean m_networkError = false;
+ private boolean m_serverError = false;
public void manageCallback() {
if(m_networkError) {
event().errorNetwork();
}
+ if(m_serverError) {
+ event().errorServer();
+ }
}
@Override
public Throwable handleError(RetrofitError error) {
m_networkError = error.isNetworkError();
+
+ if(error.getResponse().getStatus() == 500) {
+ m_serverError = true;
+ }
+
return error;
}
import adullact.publicrowdfunding.model.server.event.ListerEvent;
import adullact.publicrowdfunding.model.server.request.ListerRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class ListerErrorHandler<TResource extends Resource<TResource, ?, ?>>
extends ErrorHandler<ListerRequest<TResource,?,?>,ListerEvent<TResource>,ListerErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.request.RegistrationRequest;
/**
- * Created by Ferrand on 16/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class RegistrationErrorHandler extends ErrorHandler<RegistrationRequest, RegistrationEvent, RegistrationErrorHandler> {
import adullact.publicrowdfunding.model.server.event.RetrieveEvent;
import adullact.publicrowdfunding.model.server.request.RetrieveRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class RetrieveErrorHandler<TResource extends Resource<TResource, ?, ?>>
extends ErrorHandler<RetrieveRequest<TResource,?,?>,RetrieveEvent<TResource>,RetrieveErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.event.UpdateEvent;
import adullact.publicrowdfunding.model.server.request.UpdateRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class UpdateErrorHandler<TResource extends Resource<TResource, ?, ?>>
extends AdministratorErrorHandler<UpdateRequest<TResource, ?, ?>, UpdateEvent<TResource>, UpdateErrorHandler<TResource>> {
private boolean m_resourceIdDoesNotExist = false;
import adullact.publicrowdfunding.model.server.request.AdministratorRequest;
/**
- * Created by Ferrand on 15/08/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class AdministratorEvent<
TRequest extends AdministratorRequest<TRequest, TEvent, TErrorHandler>,
import adullact.publicrowdfunding.model.server.request.AuthenticatedRequest;
import adullact.publicrowdfunding.model.server.request.AuthenticationRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class AuthenticatedEvent
<TRequest extends AuthenticatedRequest<TRequest, TEvent, TErrorHandler>,
TEvent extends AuthenticatedEvent<TRequest, TEvent, TErrorHandler>,
public void errorNetwork() {
contextualEvent.errorNetwork();
}
+
+ @Override
+ public void errorServer() {
+ contextualEvent.errorServer();
+ }
});
request.execute();
}
import adullact.publicrowdfunding.model.server.request.AuthenticationRequest;
/**
- * Created by Ferrand on 26/07/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class AuthenticationEvent extends AuthenticatedEvent<AuthenticationRequest, AuthenticationEvent, AuthenticationErrorHandler> {
import adullact.publicrowdfunding.model.server.errorHandler.CreateErrorHandler;
import adullact.publicrowdfunding.model.server.request.CreateRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class CreateEvent<TResource extends Resource<TResource, ?, ?>>
extends AuthenticatedEvent<CreateRequest<TResource,?,?>,CreateEvent<TResource>,CreateErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.errorHandler.DeleteErrorHandler;
import adullact.publicrowdfunding.model.server.request.DeleteRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class DeleteEvent<TResource extends Resource<TResource, ?, ?>>
extends AdministratorEvent<DeleteRequest<TResource, ?, ?>, DeleteEvent<TResource>, DeleteErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.request.Request;
/**
- * @author Ferrand
- *
+ * @author Ferrand and Nelaupe
+ *
* @param <TRequest>
* @Brief Event is a abstract functions handle to requester.
*/
/* Callback functions */
public abstract void errorNetwork();
+ public abstract void errorServer();
/* ----------------- */
final protected void retry(){
import adullact.publicrowdfunding.model.server.errorHandler.ListerErrorHandler;
import adullact.publicrowdfunding.model.server.request.ListerRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class ListerEvent<TResource extends Resource<TResource, ?, ?>>
extends Event<ListerRequest<TResource,?,?>,ListerEvent<TResource>,ListerErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.request.RegistrationRequest;
/**
- * Created by Ferrand on 16/08/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class RegistrationEvent extends Event<RegistrationRequest, RegistrationEvent, RegistrationErrorHandler> {
import adullact.publicrowdfunding.model.server.errorHandler.RetrieveErrorHandler;
import adullact.publicrowdfunding.model.server.request.RetrieveRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class RetrieveEvent<TResource extends Resource<TResource, ?, ?>>
extends Event<RetrieveRequest<TResource,?,?>,RetrieveEvent<TResource>,RetrieveErrorHandler<TResource>> {
/* Callback functions */
import adullact.publicrowdfunding.model.server.errorHandler.UpdateErrorHandler;
import adullact.publicrowdfunding.model.server.request.UpdateRequest;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class UpdateEvent<TResource extends Resource<TResource, ?, ?>>
extends AdministratorEvent<UpdateRequest<TResource, ?, ?>, UpdateEvent<TResource>, UpdateErrorHandler<TResource>> {
import adullact.publicrowdfunding.model.server.event.AdministratorEvent;
/**
- * Created by Ferrand on 15/08/2014.
+ * @author Ferrand and Nelaupe
*/
public abstract class AdministratorRequest<
TRequest extends AdministratorRequest<TRequest, TEvent, TErrorHandler>,
import adullact.publicrowdfunding.model.server.errorHandler.AuthenticatedErrorHandler;
import adullact.publicrowdfunding.model.server.event.AuthenticatedEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public abstract class AuthenticatedRequest
<TRequest extends AuthenticatedRequest<TRequest, TEvent, TErrorHandler>,
TEvent extends AuthenticatedEvent<TRequest, TEvent, TErrorHandler>,
import adullact.publicrowdfunding.model.server.event.AuthenticationEvent;
/**
- * Created by Ferrand on 26/07/2014.
+ * @author Ferrand and Nelaupe
*/
public class AuthenticationRequest extends AuthenticatedRequest<AuthenticationRequest, AuthenticationEvent, AuthenticationErrorHandler> {
import adullact.publicrowdfunding.model.server.errorHandler.CreateErrorHandler;
import adullact.publicrowdfunding.model.server.event.CreateEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class CreateRequest<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource>
extends
AuthenticatedRequest<CreateRequest<TResource,?,?>,CreateEvent<TResource>,CreateErrorHandler<TResource>> {
public void call(RowAffected response) {
done();
m_resource.setResourceId(response.id);
+
event().onCreate(m_resource);
}
}, new Action1<Throwable>() {
package adullact.publicrowdfunding.model.server.request;
import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Action0;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import adullact.publicrowdfunding.model.local.ressource.Resource;
import adullact.publicrowdfunding.model.server.errorHandler.DeleteErrorHandler;
import adullact.publicrowdfunding.model.server.event.DeleteEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class DeleteRequest<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource>
extends AdministratorRequest<DeleteRequest<TResource, ?, ?>, DeleteEvent<TResource>, DeleteErrorHandler<TResource>> {
private TResource m_resource;
.subscribe(new Action1<SimpleServerResponse>() {
@Override
public void call(SimpleServerResponse response) {
- System.out.println("execution suppression 1");
done();
event().onDelete(m_resource);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
- System.out.println("execution suppression 2");
errorHandler().manageCallback();
}
- }, new Action0() {
- @Override
- public void call() {
- System.out.println("execution suppression 3");
-
- }
});
}
}
\ No newline at end of file
import adullact.publicrowdfunding.model.server.errorHandler.ListerErrorHandler;
import adullact.publicrowdfunding.model.server.event.ListerEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class ListerRequest<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource>
extends Request<ListerRequest<TResource,?,?>,ListerEvent<TResource>,ListerErrorHandler<TResource>> {
private TResource m_resource;
import adullact.publicrowdfunding.model.server.event.RegistrationEvent;
/**
- * Created by Ferrand on 16/08/2014.
+ * @author Ferrand and Nelaupe
*/
public class RegistrationRequest extends Request<RegistrationRequest, RegistrationEvent, RegistrationErrorHandler> {
private String m_username;
@Override
public void call(ServerRegistrationResponse response) {
if(response.accountOK == 0 || response.userOK == 0) {
- errorHandler().manageCallback();
+ errorHandler().manageCallback(response);
return;
}
import adullact.publicrowdfunding.model.server.event.Event;
/**
- *
- * @author Ferrand
- *
+ * @author Ferrand and Nelaupe
*/
public abstract class Request
<TRequest extends Request<TRequest, TEvent, TErrorHandler>,
protected void defineRequestInterceptor(RequestInterceptor requestInterceptor) {
m_service = new RestAdapter.Builder()
- .setLogLevel(RestAdapter.LogLevel.FULL)
+ .setLogLevel(RestAdapter.LogLevel.FULL)
.setRequestInterceptor(requestInterceptor)
.setErrorHandler(errorHandler())
.setEndpoint(SERVER_URL).build()
import adullact.publicrowdfunding.model.server.errorHandler.RetrieveErrorHandler;
import adullact.publicrowdfunding.model.server.event.RetrieveEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class RetrieveRequest<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource>
extends Request<RetrieveRequest<TResource,?,?>,RetrieveEvent<TResource>,RetrieveErrorHandler<TResource>> {
private TResource m_resource;
import retrofit.RequestInterceptor;
import android.util.Base64;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class SecurityRequestInterceptor implements RequestInterceptor {
private String username;
@Override
public void intercept(RequestFacade requestFacade) {
requestFacade.addHeader("apiKey", "azerty");
+ requestFacade.addHeader("Connection", "close");
if(authenticator) {
final String userAndPassword = username + ":" + password;
final String encodedUserAndPassword = "Basic " + Base64.encodeToString(userAndPassword.getBytes(), 0);
requestFacade.addHeader("Authorization", encodedUserAndPassword);
- requestFacade.addHeader("Connection", "close");
+ requestFacade.addHeader("User", username);
+ requestFacade.addHeader("Password", password);
}
}
import adullact.publicrowdfunding.model.server.errorHandler.UpdateErrorHandler;
import adullact.publicrowdfunding.model.server.event.UpdateEvent;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class UpdateRequest<TResource extends Resource<TResource, TServerResource, TDetailedServerResource>, TServerResource, TDetailedServerResource extends TServerResource>
extends AdministratorRequest<UpdateRequest<TResource, ?, ?>, UpdateEvent<TResource>, UpdateErrorHandler<TResource>> {
private TResource m_resource;
import android.util.AttributeSet;
import android.widget.ProgressBar;
+/**
+ * @author Ferrand and Nelaupe
+ */
public class CustomProgressBar extends ProgressBar {
public CustomProgressBar(Context context) {
import android.view.View;
/**
- * @author Nelaupe Lucas
+ * @author Ferrand and Nelaupe
*/
public class SimpleLine extends View {