Commit 51dcba8f authored by Schoumi's avatar Schoumi

Initial Commit from new workspace for android studio

parents
app/build/*
build/*
.gradle/*
.idea/*
gradle/*
gradlew*
import-summary.txt
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="BloodDonation" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="play-services-6.5.87" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
</component>
</module>
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "fr.mobdev.blooddonation"
minSdkVersion 11
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:21.0.3'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.mobdev.blooddonation"
android:versionCode="4"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<supports-screens
android:largeScreens="false"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="false" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name=".App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library
android:name="com.google.android.maps"
android:required="false" />
<!-- google Maps API -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBtxQBjEu5XZ0Gw_ObqTx-iCaCsLth4Id8" />
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.AboutActivity"
android:parentActivityName=".activity.MainActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".activity.PrefsActivity"
android:parentActivityName=".activity.MainActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".activity.DonationActivity"
android:parentActivityName=".activity.MainActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".activity.DonationInfoActivity"
android:parentActivityName=".activity.MainActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver android:name=".service.BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".service.AlarmReceiver" />
<activity
android:name=".activity.NotificationsActivity"
android:label="@string/title_activity_notifications"
android:parentActivityName=".activity.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="fr.mobdev.blooddonation.activity.MainActivity" />
</activity>
</application>
</manifest>
\ No newline at end of file
package fr.mobdev.blooddonation;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import android.app.Application;
public class App extends Application {
private Tracker tracker;
public void onCreate(){
super.onCreate();
tracker = null;
getTracker();
}
synchronized Tracker getTracker() {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
if(tracker == null)
tracker = analytics.newTracker(R.xml.analytics);
return tracker;
}
}
This diff is collapsed.
package fr.mobdev.blooddonation;
import java.util.EventListener;
import java.util.List;
import fr.mobdev.blooddonation.objects.BloodSite;
public interface NetworkListener extends EventListener{
void bloodSiteListChanged(List<BloodSite> sites);
}
This diff is collapsed.
package fr.mobdev.blooddonation;
import java.util.EventListener;
public interface NewDonationListener extends EventListener {
public void needUpdate();
}
package fr.mobdev.blooddonation;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import fr.mobdev.blooddonation.activity.MainActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
public class PrefFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference pref = findPreference("info_change");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent newIntent = new Intent(getActivity(), MainActivity.class);
newIntent.putExtra("modify", true);
startActivity(newIntent);
return true;
}
});
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) {
if(key.equals("deactivate_localisation"))
{
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
//update user location to the location in his profile
HashMap<String,Object> userData = Database.getInstance(getActivity()).getUserInformation();
Geocoder coder = new Geocoder(getActivity());
String city = (String) userData.get("CityName");
String postal = (String) userData.get("Postal");
try {
List<Address> addr = coder.getFromLocationName(city+" "+postal, 1);
if(!addr.isEmpty())
{
Database.getInstance(getActivity()).updateUserLoc(addr.get(0).getLatitude(), addr.get(0).getLongitude());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
}
}
package fr.mobdev.blooddonation;
import java.util.EventListener;
public interface RegisterListener extends EventListener {
void processNewRegistration();
}
package fr.mobdev.blooddonation;
import java.util.EventListener;
import android.view.View;
public interface SelectionModeListener extends EventListener {
void selectionModeChange(View v);
}
package fr.mobdev.blooddonation.activity;
import com.google.android.gms.analytics.GoogleAnalytics;
import fr.mobdev.blooddonation.R;
import android.app.Activity;
import android.os.Bundle;
public class AboutActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
getActionBar().setTitle(R.string.about);
}
@Override
public void onStart() {
super.onStart();
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
@Override
public void onStop() {
super.onStop();
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
}
package fr.mobdev.blooddonation.activity;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import com.google.android.gms.analytics.GoogleAnalytics;
import fr.mobdev.blooddonation.Database;
import fr.mobdev.blooddonation.NewDonationListener;
import fr.mobdev.blooddonation.R;
import fr.mobdev.blooddonation.SelectionModeListener;
import fr.mobdev.blooddonation.custom_object.DrawerAdapter;
import fr.mobdev.blooddonation.custom_object.DrawerItem;
import fr.mobdev.blooddonation.dialog.AddDonationDialog;
import fr.mobdev.blooddonation.enums.DrawerItemType;
import fr.mobdev.blooddonation.objects.Donation;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;
public class DonationActivity extends FragmentActivity {
ListView donation_list;
List<Donation> donations;
SelectionModeListener listener;
boolean isOnSelection;
List<DrawerItem> items;
MenuItem del_item;
Context context;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.donation);
donation_list = (ListView) findViewById(R.id.donation_list);
items = new ArrayList<DrawerItem>();
isOnSelection = false;
context = this;
listener = new SelectionModeListener() {
@Override
public void selectionModeChange(View v) {
isOnSelection = !isOnSelection;
if(isOnSelection)
{
for(DrawerItem item:items)
{
item.setType(DrawerItemType.STATE_CHECK);
}
selectView(v);
del_item.setVisible(true);
DrawerAdapter adapter = new DrawerAdapter(context,R.layout.drawer_item, 0, items);
donation_list.setAdapter(adapter);
}
else
{
for(DrawerItem item:items)
{
item.setType(DrawerItemType.STATE_NORMAL);
item.setSelected(false);
}
del_item.setVisible(false);
DrawerAdapter adapter = new DrawerAdapter(context,R.layout.drawer_item, 0, items);
donation_list.setAdapter(adapter);
}
}
};
donation_list.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View v, int pos, long id) {
if(!isOnSelection)
{
listener.selectionModeChange(v);
}
else
{
selectView(v);
}
return true;
}
});
donation_list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int arg2, long id) {
selectView(v);
}
});
updateDonationList();
getActionBar().setTitle(R.string.donations);
}
@Override
public void onStart() {
super.onStart();
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
@Override
public void onStop() {
super.onStop();
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
private void selectView(View v)
{
if(isOnSelection)
{
TextView view = (TextView) v.findViewById(R.id.pos);
long donationId = Integer.valueOf((String) view.getText());
for(DrawerItem item:items)
{
item.setType(DrawerItemType.STATE_CHECK);
if(item.getPos() == donationId)
{
item.setSelected(!item.isSelected());
}
}
DrawerAdapter adapter = new DrawerAdapter(context,R.layout.drawer_item, 0, items);
donation_list.setAdapter(adapter);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.donnation_menu, menu);
del_item = menu.findItem(R.id.action_del);
del_item.setVisible(false);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add:
addDonation();
return true;
case R.id.action_del:
askRemoveDonation();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void onBackPressed(){
if(isOnSelection)
{
listener.selectionModeChange(null);
}
else
{
finish();
}
}
private void addDonation()
{
AddDonationDialog dialog = new AddDonationDialog();
Bundle bundle = new Bundle();
bundle.putInt("siteId", -1);
dialog.setArguments(bundle);
dialog.setListener(new NewDonationListener() {
@Override
public void needUpdate() {
updateDonationList();
}
});
dialog.show(getSupportFragmentManager(), "add donation dialog");
}
private void askRemoveDonation()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.delete_donation_message)
.setCancelable(false)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
removeSelectedDonation();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
private void removeSelectedDonation()
{
List<Donation> deletedList = new ArrayList<Donation>();
for(int i = 0; i<items.size(); i++)
{
DrawerItem item = items.get(i);
if(item.isSelected())
{
deletedList.add(donations.get(i));
}
}
Database.getInstance(this).deleteDonation(deletedList);
updateDonationList();
}
private void updateDonationList()
{
donations = Database.getInstance(this).getDonations();
items.clear();
for(Donation don : donations)
{
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
df.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
String texte = df.format(don.getDate().getTime());
texte += " - ";
texte += don.getCityName();
if(don.getCityName().length() > 0)
texte += " - ";
switch(don.getDonationType())
{
case TOTAL_BLOOD:
texte += getResources().getStringArray(R.array.donation_type)[0];
break;
case PLASMA:
texte += getResources().getStringArray(R.array.donation_type)[1];
break;
case PLATELET:
texte += getResources().getStringArray(R.array.donation_type)[2];