Public code.

This commit is contained in:
aminecmi 2015-06-06 21:33:55 +02:00
parent 0f03f8daac
commit e99c3e7ea5
108 changed files with 3158 additions and 0 deletions

39
Les Horaires/.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
/build
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse stuff
.classpath
.project
.settings
# Gradle stuff
.gradle/
build/
.idea/
out/
*.iml
Thumbs.db

61
Les Horaires/build.gradle Normal file
View File

@ -0,0 +1,61 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.amine.horaires"
minSdkVersion 14
targetSdkVersion 22
versionCode 39
versionName "2.1.2"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
lintOptions {
checkReleaseBuilds true
abortOnError false
}
signingConfigs {
release {
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.wdullaer:materialdatetimepicker:1.3.0'
compile 'de.cketti.library.changelog:ckchangelog:1.2.2'
}

17
Les Horaires/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:/Users/Amine/Desktop/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -0,0 +1,13 @@
package com.amine.horaires;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.amine.horaires"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".ShopDisplay"
android:label="@string/app_name"
android:parentActivityName=".MainActivity">
<!-- Parent activity meta-data to support API level 7+ -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
<intent-filter>
<category android:name="android.intent.category.ALTERNATIVE"/>
</intent-filter>
</activity>
<activity
android:name=".ShopSearch"
android:label="@string/app_name"
android:parentActivityName=".MainActivity">
<!-- Parent activity meta-data to support API level 7+ -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
<intent-filter>
<category android:name="android.intent.category.ALTERNATIVE"/>
</intent-filter>
</activity>
<activity
android:name=".ShopUpdate"
android:label="@string/app_name"
android:parentActivityName=".ShopDisplay">
<!-- Parent activity meta-data to support API level 7+ -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ShopDisplay"/>
<intent-filter>
<category android:name="android.intent.category.ALTERNATIVE"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,15 @@
package com.amine.horaires;
import android.app.Application;
public class App extends Application {
public App() {
super();
}
@Override
public void onCreate() {
super.onCreate();
}
}

View File

@ -0,0 +1,132 @@
package com.amine.horaires;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.TextView;
import com.amine.horaires.bdd.FavorisDao;
import com.amine.horaires.models.Shop;
import com.amine.horaires.util.Configuration;
import com.amine.horaires.util.Parseur;
import com.melnykov.fab.FloatingActionButton;
import de.cketti.library.changelog.ChangeLog;
import java.util.ArrayList;
public class MainActivity extends OptionsActivity {
private static RecyclerView mRecyclerView;
private static RecyclerView.Adapter mAdapter;
private static ArrayList<Shop> myDataset;
private static TextView emptyView;
static void razOrFavs(Context c) {
FavorisDao dao = FavorisDao.getInstance(c);
dao.open();
myDataset = dao.getAllFavoris();
dao.close();
if (myDataset.isEmpty()) {
mRecyclerView.setVisibility(View.GONE);
emptyView.setVisibility(View.VISIBLE);
} else {
mAdapter = new SearchAdapter(myDataset, c);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setVisibility(View.VISIBLE);
emptyView.setVisibility(View.GONE);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkLocale();
ChangeLog cl = new ChangeLog(this);
if (cl.isFirstRun()) {
cl.getLogDialog().show();
}
mRecyclerView = (RecyclerView) findViewById(R.id.favs_list);
emptyView = (TextView) findViewById(R.id.empty_list);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.attachToRecyclerView(mRecyclerView);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent i = new Intent(getBaseContext(), ShopSearch.class);
startActivityForResult(i, 0);
}
});
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
// specify an adapter (see also next example)
myDataset = new ArrayList<Shop>();
razOrFavs(getBaseContext());
}
private void checkLocale() {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Configuration.pays = tm.getSimCountryIso().toUpperCase();
if (Configuration.pays == null || Configuration.pays.equals("") || Configuration.pays.isEmpty())
Configuration.pays = MainActivity.this.getResources().getConfiguration().locale.getCountry();
SharedPreferences settings = getSharedPreferences("UserInfo", 0);
if (settings.getString("Pays", "") == null || !settings.getString("Pays", "").equals(Configuration.pays)) {
settings = getSharedPreferences("UserInfo", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("Pays", Configuration.pays);
editor.apply();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case (0): {
if (resultCode == Activity.RESULT_OK) {
myDataset = new ArrayList<Shop>();
String result = data.getStringExtra("result");
myDataset = new Parseur().parserShops(result);
if (myDataset.isEmpty()) {
mRecyclerView.setVisibility(View.GONE);
emptyView.setVisibility(View.VISIBLE);
} else {
mAdapter = new SearchAdapter(myDataset, getBaseContext());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setVisibility(View.VISIBLE);
emptyView.setVisibility(View.GONE);
}
}
break;
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions_main, menu);
return super.onCreateOptionsMenu(menu);
}
}

View File

@ -0,0 +1,89 @@
package com.amine.horaires;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import com.amine.horaires.bdd.FavorisDao;
import com.amine.horaires.models.Shop;
import com.amine.horaires.util.Configuration;
class OptionsActivity extends AppCompatActivity {
MenuItem favMenu = null;
boolean isFav = false;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_mail:
Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Les Horaires");
intent.setData(Uri.parse("mailto:amine.bou.dev@gmail.com")); // or just "mailto:" for blank
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.
startActivity(intent);
return true;
case R.id.action_about:
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
// Content of the dialog
dialog.setContentView(R.layout.activity_more);
dialog.show();
return true;
case R.id.action_reload:
MainActivity.razOrFavs(OptionsActivity.this);
return true;
case R.id.action_fav:
FavorisDao dao = FavorisDao.getInstance(OptionsActivity.this);
if (isFav) {
// REMOVE
dao.open();
dao.deleteFavori(Configuration.currentShop.getId());
dao.close();
updateFavStatus(false);
} else {
dao.open();
dao.insertFavori(Configuration.currentShop);
dao.close();
updateFavStatus(true);
}
return true;
case android.R.id.home:
this.finish();
return (true);
default:
return false;
}
}
private void updateFavStatus(boolean state) {
if (state) {
favMenu.setIcon(R.mipmap.ic_turned_in_black_24dp);
} else {
favMenu.setIcon(R.mipmap.ic_turned_in_not_black_24dp);
}
}
void updateFavStatus() {
FavorisDao dao = FavorisDao.getInstance(OptionsActivity.this);
dao.open();
Shop sh = dao.getFavori(Configuration.currentShop.getId());
dao.close();
if (sh == null) {
updateFavStatus(false);
} else {
updateFavStatus(true);
}
}
}

View File

@ -0,0 +1,88 @@
package com.amine.horaires;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.amine.horaires.models.Shop;
import java.util.ArrayList;
public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder> {
private final ArrayList<Shop> mDataset;
private final Context c;
// Provide a suitable constructor (depends on the kind of dataset)
public SearchAdapter(ArrayList<Shop> myDataset, Context c) {
mDataset = myDataset;
this.c = c;
}
// Create new views (invoked by the layout manager)
@Override
public SearchAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.fav_list_item, parent, false);
// set the view's size, margins, paddings and layout parameters
return new ViewHolder((RelativeLayout) v, c, mDataset);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
holder.shopAddr.setText(mDataset.get(position).getAdresse());
holder.shopName.setText(mDataset.get(position).getName());
}
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataset.size();
}
// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
// each data item is just a string in this case
public final TextView shopName;
public final TextView shopAddr;
private final Context c;
private final ArrayList<Shop> mDataset;
public ViewHolder(RelativeLayout v, Context c, ArrayList<Shop> mDataset) {
super(v);
v.setOnClickListener(this);
shopName = (TextView) v.findViewById(R.id.shop_name);
shopAddr = (TextView) v.findViewById(R.id.shop_adress);
this.c = c;
this.mDataset = mDataset;
}
@Override
public void onClick(View view) {
final Intent i = new Intent(view.getContext(), ShopDisplay.class);
final Handler handler = new Handler();
Runnable t = new Runnable() {
public void run() {
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("shop", mDataset.get(getLayoutPosition()));
c.startActivity(i);
}
};
handler.post(t);
}
}
}

View File

@ -0,0 +1,249 @@
package com.amine.horaires;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.amine.horaires.bdd.FavorisDao;
import com.amine.horaires.models.Shop;
import com.amine.horaires.util.Configuration;
import com.amine.horaires.util.Parseur;
import com.amine.horaires.util.Utils;
import com.melnykov.fab.FloatingActionButton;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.List;
import java.util.Scanner;
public class ShopDisplay extends OptionsActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shop_display);
Shop s = getIntent().getExtras().getParcelable("shop");
Configuration.currentShop = s;
FavorisDao dao = FavorisDao.getInstance(ShopDisplay.this);
dao.open();
List<Shop> fs = dao.getAllFavoris();
dao.close();
while (!isFav && !fs.isEmpty()) {
isFav = fs.remove(0).getId() == Configuration.currentShop.getId();
}
if (isFav) {
SearchTask st = new SearchTask();
st.execute(Utils.generateUrlForId(s.getId()));
s = Configuration.currentShop;
dao.open();
dao.updateFavori(s);
dao.close();
}
generateView(s);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
final Shop finalS = s;
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent i = new Intent(getBaseContext(), ShopUpdate.class);
i.putExtra("shop", finalS);
startActivity(i);
}
});
}
private void generateView(final Shop s) {
Configuration.currentShop = s;
ImageView imageResult = (ImageView) findViewById(R.id.imageView);
ImageTask t = new ImageTask(imageResult);
t.execute(s.getHoraires());
TextView shopName = (TextView) findViewById(R.id.shopName);
TextView shopAddress = (TextView) findViewById(R.id.shopAdress);
TextView shopOpen = (TextView) findViewById(R.id.shopOpen);
TextView shopStatus = (TextView) findViewById(R.id.shopStatus);
ImageView wifi = (ImageView) findViewById(R.id.wifi);
ImageView parking = (ImageView) findViewById(R.id.parking);
ImageView access = (ImageView) findViewById(R.id.handi);
shopName.setText(s.getName());
shopAddress.setText(s.getAdresse());
shopOpen.setText("Le magasin est " + (s.isOuvert() ? "ouvert" : "fermé"));
if (s.isOuvert()) {
shopStatus.setText(s.getOpenStatus());
}
if (!s.isWifi()) {
wifi.setAlpha((float) 0.1);
}
if (!s.isAccesHandicape()) {
access.setAlpha((float) 0.1);
}
if (!s.isParking()) {
parking.setAlpha((float) 0.1);
}
findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(s.getUrl()));
startActivity(browserIntent);
}
});
findViewById(R.id.callButton).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String numeroAppeler = "tel:" + s.getTel();
startActivity(new Intent(Intent.ACTION_DIAL, Uri
.parse(numeroAppeler)));
}
});
findViewById(R.id.gpsButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new
Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?q="
+ s.getAdresse() + "@" + s.getLat() + "," + s.getLng() + "")
);
startActivity(intent);
}
});
}
// @todo: use this to update the shop if connected.
private boolean checkDeviceConnected() {
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// Need permission : android.permission.ACCESS_NETWORK_STATE
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions_shop, menu);
favMenu = menu.findItem(R.id.action_fav);
updateFavStatus();
return super.onCreateOptionsMenu(menu);
}
public class ImageTask extends AsyncTask<String, Void, Bitmap> {
private final ImageView contenu;
public ImageTask(ImageView contenu) {
this.contenu = contenu;
}
@Override
protected Bitmap doInBackground(String... params) {
URL url;
Bitmap b = null;
try {
url = new URL(params[0]);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
b = BitmapFactory.decodeStream(is);
is.close();
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return b;
}
protected void onPostExecute(Bitmap b) {
this.contenu.setImageBitmap(b);
}
}
private class SearchTask extends AsyncTask<URL, Void, String> {
@Override
protected String doInBackground(URL... params) {
HttpURLConnection conn = null;
InputStream is = null;
String contentAsString = "";
try {
URL url = params[0];
conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
is = conn.getInputStream();
// Convert the InputStream into a String
Scanner reader = new Scanner(is, "ISO-8859-1");
while (reader.hasNextLine()) {
contentAsString = contentAsString + reader.nextLine();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// Makes sure that the InputStream is closed after the app is finished using it.
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (conn != null)
conn.disconnect();
}
return contentAsString;
}
@Override
protected void onPostExecute(String string) {
super.onPostExecute(string);
Configuration.currentShop = new Parseur().parserShops(string).get(0);
}
}
}

View File

@ -0,0 +1,134 @@
package com.amine.horaires;
import android.content.Intent;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.amine.horaires.util.MyLocation;
import com.amine.horaires.util.Utils;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.Scanner;
public class ShopSearch extends OptionsActivity {
private MyLocation myLocation;
private RelativeLayout loading;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shop_search);
final EditText name = (EditText) findViewById(R.id.name);
final EditText location = (EditText) findViewById(R.id.location);
loading = (RelativeLayout) findViewById(R.id.loading);
Button searchButton = (Button) findViewById(R.id.searchAction);
// @todo form validation (empty ...)
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loading.setVisibility(View.VISIBLE);
SearchTask s = new SearchTask();
s.execute(Utils.generateUrlForTextLocation(name.getText().toString(), location.getText().toString()));
}
});
findViewById(R.id.gpsAction).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loading.setVisibility(View.VISIBLE);
MyLocation.LocationResult locationResult = new MyLocation.LocationResult() {
@Override
public void gotLocation(Location location) {
if (location == null) {
Toast.makeText(getApplicationContext(), "Petit soucis lors de la localisation", Toast.LENGTH_SHORT).show();
} else {
URL url = Utils.generateUrlForLatLng(name.getText().toString(), location.getLatitude() + "", location.getLongitude() + "");
SearchTask s = new SearchTask();
s.execute(url);
}
}
};
myLocation = new MyLocation();
boolean gotLocation = myLocation.getLocation(getApplicationContext(),
locationResult);
if (!gotLocation) {
Toast.makeText(getApplicationContext(), "Erreur de localisation.", Toast.LENGTH_SHORT).show();
}
}
});
}
private class SearchTask extends AsyncTask<URL, Void, String> {
@Override
protected String doInBackground(URL... params) {
HttpURLConnection conn = null;
InputStream is = null;
String contentAsString = "";
try {
URL url = params[0];
conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
is = conn.getInputStream();
// Convert the InputStream into a String
Scanner reader = new Scanner(is, "ISO-8859-1");
while (reader.hasNextLine()) {
contentAsString = contentAsString + reader.nextLine();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// Makes sure that the InputStream is closed after the app is finished using it.
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (conn != null)
conn.disconnect();
}
return contentAsString;
}
@Override
protected void onPostExecute(String string) {
super.onPostExecute(string);
loading.setVisibility(View.GONE);
Intent resultIntent = new Intent();
resultIntent.putExtra("result", string);
setResult(MainActivity.RESULT_OK, resultIntent);
finish();
}
}
}

View File

@ -0,0 +1,144 @@
package com.amine.horaires;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.amine.horaires.models.Horaires;
import com.amine.horaires.models.Shop;
import com.amine.horaires.util.Utils;
import com.melnykov.fab.FloatingActionButton;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
public class ShopUpdate extends OptionsActivity {
private ArrayList<Horaires> h;
private RelativeLayout loading;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.update_shop);
loading = (RelativeLayout) findViewById(R.id.loading);
final Shop s = getIntent().getExtras().getParcelable("shop");
ListView hList = (ListView) findViewById(R.id.horaires_list);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
Button save = (Button) findViewById(R.id.button);
h = new ArrayList<Horaires>();
initializeHoraires();
final UpdateAdapter adapter = new UpdateAdapter(this, h, getFragmentManager());
hList.setAdapter(adapter);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Horaires h = adapter.getItem(adapter.getCount() - 1);
adapter.add(new Horaires(h));
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loading.setVisibility(View.VISIBLE);
ArrayList<HashMap<String, Integer>> periodes = new ArrayList<HashMap<String, Integer>>();
Collections.sort(h);
String periodsString = "";
int i = 0;
for (Horaires hor : h) {
periodsString += "&periods[0][" + i + "][day]=" + hor.getDay();
periodsString += "&periods[0][" + i + "][from_h]=" + hor.getFrom_h();
periodsString += "&periods[0][" + i + "][to_h]=" + hor.getTo_h();
periodsString += "&periods[0][" + i + "][to_m]=" + hor.getTo_m();
i++;
}
// Toast.makeText(getApplicationContext(), "Cette fonctionnalité est en attente de validation par Les-horaires.fr", Toast.LENGTH_SHORT).show();
UpdateTask u = new UpdateTask();
u.execute(Utils.generateUrlForEdit(s.getId(), periodsString));
}
});
}
private void initializeHoraires() {
h.add(new Horaires(1));
}
private class UpdateTask extends AsyncTask<URL, Void, String> {
@Override
protected String doInBackground(URL... params) {
HttpURLConnection conn = null;
InputStream is = null;
String contentAsString = "";
try {
URL url = params[0];
conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
// Starts the query
conn.connect();
is = conn.getInputStream();
// Convert the InputStream into a String
Scanner reader = new Scanner(is, "ISO-8859-1");
while (reader.hasNextLine()) {
contentAsString = contentAsString + reader.nextLine();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// Makes sure that the InputStream is closed after the app is finished using it.
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (conn != null)
conn.disconnect();
}
return contentAsString;
}
@Override
protected void onPostExecute(String string) {
loading.setVisibility(View.GONE);
super.onPostExecute(string);
Toast.makeText(getApplicationContext(), "Mise à jour effectuée!", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -0,0 +1,98 @@
package com.amine.horaires;
import android.app.FragmentManager;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.amine.horaires.models.Horaires;
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
import java.util.ArrayList;
class UpdateAdapter extends ArrayAdapter<Horaires> {
private final ArrayList<Horaires> horaires;
private final Context context;
private final FragmentManager fm;
public UpdateAdapter(Context context, ArrayList<Horaires> objects, FragmentManager fm) {
super(context, R.layout.update_horaire_item, objects);
this.context = context;
this.horaires = objects;
this.fm = fm;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.update_horaire_item, parent, false);
final Horaires h = horaires.get(position);
final TextView timeFrom = (TextView) rowView.findViewById(R.id.from);
timeFrom.setText(String.format("%02d", h.getFrom_h()) + ":" + String.format("%02d", h.getFrom_m()));
final TextView timeTo = (TextView) rowView.findViewById(R.id.to);
timeTo.setText(String.format("%02d", h.getTo_h()) + ":" + String.format("%02d", h.getTo_m()));
String[] days = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.context, R.layout.spinner_item, days);
final Spinner s = (Spinner) rowView.findViewById(R.id.spinner);
s.setAdapter(adapter);
s.setSelection(h.getDay() - 1);
s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
h.setDay(position + 1);
s.setSelection(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
timeFrom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimePickerDialog f = TimePickerDialog.newInstance(new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int hours, int minutes) {
if (minutes % 5 == 0) {
timeFrom.setText(String.format("%02d", hours) + ":" + String.format("%02d", minutes));
h.setFrom_h(hours);
h.setFrom_m(minutes);
} else {
Toast.makeText(context, "Merci d'utiliser des tranches de 5 minutes maximum", Toast.LENGTH_SHORT).show();
}
}
}, h.getFrom_h(), h.getFrom_m(), true);
f.show(fm, "from");
}
});
timeTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimePickerDialog t = TimePickerDialog.newInstance(new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int hours, int minutes) {
if (minutes % 5 == 0) {
timeTo.setText(String.format("%02d", hours) + ":" + String.format("%02d", minutes));
h.setTo_h(hours);
h.setTo_m(minutes);
} else {
Toast.makeText(context, "Merci d'utiliser des tranches de 5 minutes maximum", Toast.LENGTH_SHORT).show();
}
}
}, h.getTo_h(), h.getTo_m(), true);
t.show(fm, "to");
}
});
return rowView;
}
}

View File

@ -0,0 +1,58 @@
package com.amine.horaires.bdd;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
class FavorisBdd extends SQLiteOpenHelper {
private static final String TABLE_FAVORIS = "shop_favoris";
private static final String COL_ID = "ID";
private static final String COL_NOM = "Nom";
private static final String COL_ADR = "Adresse";
private static final String COL_ZIP = "Zip";
private static final String COL_LAT = "Lat";
private static final String COL_LNG = "Lng";
private static final String COL_TEL = "Tel";
private static final String COL_CITY = "City";
private static final String COL_OUVERT = "Ouvert";
private static final String COL_HORAIRES = "Horaires";
private static final String COL_URL = "Url";
private static final String COL_OPENSTATUS = "OpenStatus";
private static final String COL_PARKING = "Parking";
private static final String COL_WIFI = "Wifi";
private static final String COL_HANDI = "Handi";
private static final String COL_IDPOI = "IDPoi";
private static final String CREATE_BDD = "CREATE TABLE " + TABLE_FAVORIS + " (" +
COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COL_NOM + " TEXT, " +
COL_ADR + " TEXT, " +
COL_ZIP + " INTEGER, " +
COL_LAT + " TEXT, " +
COL_LNG + " TEXT, " +
COL_TEL + " VARCHAR(40), " +
COL_CITY + " TEXT, " +
COL_OUVERT + " SHORT, " +
COL_HORAIRES + " TEXT, " +
COL_URL + " TEXT, " +
COL_OPENSTATUS + " TEXT, " +
COL_PARKING + " SHORT, " +
COL_WIFI + " SHORT, " +
COL_HANDI + " SHORT, " +
COL_IDPOI + " VARCHAR(40) NOT NULL);";
public FavorisBdd(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_BDD);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

View File

@ -0,0 +1,159 @@
package com.amine.horaires.bdd;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.amine.horaires.models.Shop;
import java.util.ArrayList;
public class FavorisDao {
private static final int VERSION_BDD = 1;// pour le onupgrade de BaseSQL
private static final String NOM_BDD = "shops.db";
private static final String TABLE_FAVORIS = "shop_favoris";
private static final String COL_NOM = "Nom";
private static final String COL_ADR = "Adresse";
private static final String COL_ZIP = "Zip";
private static final String COL_LAT = "Lat";
private static final String COL_LNG = "Lng";
private static final String COL_TEL = "Tel";
private static final String COL_CITY = "City";
private static final String COL_OUVERT = "Ouvert";
private static final String COL_HORAIRES = "Horaires";
private static final String COL_URL = "Url";
private static final String COL_OPENSTATUS = "OpenStatus";
private static final String COL_PARKING = "Parking";
private static final String COL_WIFI = "Wifi";
private static final String COL_HANDI = "Handi";
private static final String COL_IDPOI = "IDPoi";
private static final int NUM_COL_NOM = 1;
private static final int NUM_COL_ADR = 2;
private static final int NUM_COL_ZIP = 3;
private static final int NUM_COL_LAT = 4;
private static final int NUM_COL_LNG = 5;
private static final int NUM_COL_TEL = 6;
private static final int NUM_COL_CITY = 7;
private static final int NUM_COL_OUVERT = 8;
private static final int NUM_COL_HORAIRES = 9;
private static final int NUM_COL_URL = 10;
private static final int NUM_COL_OPENSTATUS = 11;
private static final int NUM_COL_PARKING = 12;
private static final int NUM_COL_WIFI = 13;
private static final int NUM_COL_HANDI = 14;
private static final int NUM_COL_IDPOI = 15;
private static FavorisDao instance = null;
private final FavorisBdd maBaseSQLite;
private SQLiteDatabase bdd;
private FavorisDao(Context context) {
maBaseSQLite = new FavorisBdd(context, NOM_BDD, null, VERSION_BDD);
}
public static FavorisDao getInstance(Context c) {
if (instance == null) {
instance = new FavorisDao(c);
return instance;
} else {
return instance;
}
}
public void open() {
bdd = maBaseSQLite.getWritableDatabase();
}
public void close() {
bdd.close();
}
public void insertFavori(Shop favori) {
ContentValues values = getContentValues(favori);
bdd.insert(TABLE_FAVORIS, null, values);
}
private ContentValues getContentValues(Shop favori) {
ContentValues values = new ContentValues();
values.put(COL_IDPOI, favori.getId());
values.put(COL_NOM, favori.getName());
values.put(COL_ADR, favori.getAdresse());
values.put(COL_ZIP, favori.getZip());
values.put(COL_LAT, favori.getLat());
values.put(COL_LNG, favori.getLng());
values.put(COL_TEL, favori.getTel());
values.put(COL_CITY, favori.getCity());
values.put(COL_OUVERT, favori.isOuvert());
values.put(COL_HORAIRES, favori.getHoraires());
values.put(COL_URL, favori.getUrl());
values.put(COL_OPENSTATUS, favori.getOpenStatus());
values.put(COL_PARKING, favori.isParking());
values.put(COL_WIFI, favori.isWifi());
values.put(COL_HANDI, favori.isAccesHandicape());
return values;
}
public void updateFavori(Shop favori) {
ContentValues values = getContentValues(favori);
bdd.update(TABLE_FAVORIS, values, COL_IDPOI + " LIKE " + "\"" + favori.getId() + "\"", null);
}
public void deleteFavori(int id) {
bdd.delete(TABLE_FAVORIS, COL_IDPOI + " LIKE \"" + id + "\"", null);
}
public Shop getFavori(int id) {
Cursor c = bdd.query(TABLE_FAVORIS, null, COL_IDPOI + " LIKE \"" + id
+ "\"", null, null, null, null);
c.moveToFirst();
Shop s = cursorToFavori(c);
c.close();
return s;
}
private Shop cursorToFavori(Cursor c) {
if (c.getCount() == 0) {
return null;
} else {
Shop f = new Shop();
f.setId(c.getInt(NUM_COL_IDPOI));
f.setName(c.getString(NUM_COL_NOM));
f.setAdresse(c.getString(NUM_COL_ADR));
f.setZip(c.getString(NUM_COL_ZIP));
f.setLat(c.getString(NUM_COL_LAT));
f.setLng(c.getString(NUM_COL_LNG));
f.setTel(c.getString(NUM_COL_TEL));
f.setCity(c.getString(NUM_COL_CITY));
f.setOuvert(c.getShort(NUM_COL_OUVERT) != 0);
f.setHoraires(c.getString(NUM_COL_HORAIRES));
f.setUrl(c.getString(NUM_COL_URL));
f.setOpenStatus(c.getString(NUM_COL_OPENSTATUS));
f.setParking(c.getShort(NUM_COL_PARKING) != 0);
f.setWifi(c.getShort(NUM_COL_WIFI) != 0);
f.setAccesHandicape(c.getShort(NUM_COL_HANDI) != 0);
f.setId(c.getInt(NUM_COL_IDPOI));
return f;
}
}
public ArrayList<Shop> getAllFavoris() {
Cursor c = bdd.rawQuery("SELECT * FROM " + TABLE_FAVORIS, null);
return cursorToListeFavoris(c);
}
private ArrayList<Shop> cursorToListeFavoris(Cursor cursor) {
ArrayList<Shop> list = new ArrayList<Shop>();
if (cursor.getCount() != 0) {
if (cursor.moveToFirst()) {
while (!cursor.isAfterLast()) {
list.add(cursorToFavori(cursor));
cursor.moveToNext();
}
}
}
cursor.close();
return list;
}
}

View File

@ -0,0 +1,112 @@
package com.amine.horaires.models;
import android.support.annotation.NonNull;
public class Horaires implements Comparable {
/*
periods[N][title] Title of N period - optional
periods[N][T][day] 1 (Monday) to 7 (Sunday) - Day of opening window T for period N
periods[N][T][from_h] 0 to 23 - Hour of beginning of opening window T for period N
periods[N][T][from_m] 0 to 59 (minutes) - Minute of beginning of opening window T for period N
periods[N][T][to_h] 0 to 32 (8am the next morning) - Hour of end of opening window T for period N
periods[N][T][to_m] 0 to 59 (minutes) - Minute of end of opening window T for period N
*/
private int day;
private int from_h;
private int from_m;
private int to_h;
private int to_m;
public Horaires(int day) {
this.day = day;
this.from_h = 8;
this.from_m = 0;
this.to_h = 18;
this.to_m = 0;
}
public Horaires() {
this.day = 1;
this.from_h = 8;
this.from_m = 0;
this.to_h = 18;
this.to_m = 0;
}
public Horaires(Horaires h) {
this.day = h.getDay();
this.from_h = h.getFrom_h();
this.from_m = h.getFrom_m();
this.to_h = h.getTo_h();
this.to_m = h.getTo_m();
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getFrom_h() {
return from_h;
}
public void setFrom_h(int from_h) {
this.from_h = from_h;
}
public int getFrom_m() {
return from_m;
}
public void setFrom_m(int from_m) {
this.from_m = from_m;
}
public int getTo_h() {
return to_h;
}
public void setTo_h(int to_h) {
this.to_h = to_h;
}
public int getTo_m() {
return to_m;
}
public void setTo_m(int to_m) {
this.to_m = to_m;
}
@Override
public int compareTo(@NonNull Object another) {
Horaires h = (Horaires) another;
return this.day - h.day;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Horaires horaires = (Horaires) o;
return this.day == horaires.day;
}
@Override
public int hashCode() {
int result = day;
result = 31 * result + from_h;
result = 31 * result + from_m;
result = 31 * result + to_h;
result = 31 * result + to_m;
return result;
}
}

View File

@ -0,0 +1,240 @@
package com.amine.horaires.models;
import android.os.Parcel;
import android.os.Parcelable;
public class Shop implements Parcelable {
public static final Parcelable.Creator<Shop> CREATOR = new Parcelable.Creator<Shop>() {
@Override
public Shop createFromParcel(Parcel source) {
return new Shop(source);
}
@Override
public Shop[] newArray(int size) {
return new Shop[size];
}
};
private int id;
private String name;
private String adresse;
private String zip;
private String lat;
private String lng;
private String tel;
private String city;
private boolean ouvert;
private String horaires;
private String url;
private String openStatus;
private boolean parking;
private boolean wifi;
private boolean AccesHandicape;
public Shop() {
}
public Shop(int id, String name, String adresse, String zip, String lat,
String lng, String tel, String city,
boolean ouvert, String horaires, String url, String openStatus,
boolean parking, boolean wifi, boolean accesHandicape) {
this.id = id;
this.name = name;
this.adresse = adresse;
this.zip = zip;
this.lat = lat;
this.lng = lng;
this.tel = tel;
this.city = city;
this.ouvert = ouvert;
this.horaires = horaires;
this.url = url;
this.openStatus = openStatus;
this.parking = parking;
this.wifi = wifi;
AccesHandicape = accesHandicape;
}
private Shop(Parcel in) {
id = in.readInt();
name = in.readString();
adresse = in.readString();
zip = in.readString();
lat = in.readString();
lng = in.readString();
tel = in.readString();
city = in.readString();
ouvert = in.readByte() != 0;
horaires = in.readString();
url = in.readString();
openStatus = in.readString();
parking = in.readByte() != 0;
wifi = in.readByte() != 0;
AccesHandicape = in.readByte() != 0;
}
@Override
public String toString() {
return "Shop{" +
"id=" + id +
", name='" + name + '\'' +
", adresse='" + adresse + '\'' +
", zip='" + zip + '\'' +
", lat='" + lat + '\'' +
", lng='" + lng + '\'' +
", tel='" + tel + '\'' +
", city='" + city + '\'' +
", ouvert=" + ouvert +
", horaires='" + horaires + '\'' +
", url='" + url + '\'' +
", openStatus='" + openStatus + '\'' +
", parking=" + parking +
", wifi=" + wifi +
", AccesHandicape=" + AccesHandicape +
'}';
}
public boolean isAccesHandicape() {
return AccesHandicape;
}
public void setAccesHandicape(boolean accesHandicape) {
AccesHandicape = accesHandicape;
}
public String getOpenStatus() {
return openStatus;
}
public void setOpenStatus(String openStatus) {
this.openStatus = openStatus;
}
public boolean isParking() {
return parking;
}
public void setParking(boolean parking) {
this.parking = parking;
}
public boolean isWifi() {
return wifi;
}
public void setWifi(boolean wifi) {
this.wifi = wifi;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public boolean isOuvert() {
return ouvert;
}
public void setOuvert(boolean ouvert) {
this.ouvert = ouvert;
}
public String getHoraires() {
return horaires;
}
public void setHoraires(String horaires) {
this.horaires = horaires;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(name);
dest.writeString(adresse);
dest.writeString(zip);
dest.writeString(lat);
dest.writeString(lng);
dest.writeString(tel);
dest.writeString(city);
dest.writeByte((byte) (ouvert ? 1 : 0));
dest.writeString(horaires);
dest.writeString(url);
dest.writeString(openStatus);
dest.writeByte((byte) (parking ? 1 : 0));
dest.writeByte((byte) (wifi ? 1 : 0));
dest.writeByte((byte) (AccesHandicape ? 1 : 0));
}
}

View File

@ -0,0 +1,23 @@
package com.amine.horaires.util;
import com.amine.horaires.models.Shop;
public class Configuration {
// Cles necessaires pour l'api lesHorraires
public static final String key = "REPLACE_THIS_WITH_KEY";
public static final String hashtag = "REPLACE_THIS_WITH_A_HASHTAG";
public static String pays = "FR";
public static Shop currentShop = null;
public static String getAPIUrl() {
if (pays.equals("FR"))
return "http://www.les-horaires.fr";
else if (pays.equals("GB"))
return "http://www.shopping-time.co.uk";
else if (pays.equals("US"))
return "http://www.shopping-time.com";
return "http://www.les-horaires.fr";
}
}

View File

@ -0,0 +1,129 @@
package com.amine.horaires.util;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import java.util.Timer;
import java.util.TimerTask;
// http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-a/3145655#3145655
public class MyLocation {
private Timer timer1;
private LocationManager lm;
private LocationResult locationResult;
private final LocationListener locationListenerGps = new LocationListener() {
public void onLocationChanged(Location location) {
timer1.cancel();
locationResult.gotLocation(location);
lm.removeUpdates(this);
lm.removeUpdates(locationListenerNetwork);
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};
private final LocationListener locationListenerNetwork = new LocationListener() {
public void onLocationChanged(Location location) {
timer1.cancel();
locationResult.gotLocation(location);
lm.removeUpdates(this);
lm.removeUpdates(locationListenerGps);
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};
private boolean gps_enabled = false;
private boolean network_enabled = false;
public boolean getLocation(Context context, LocationResult result) {
locationResult = result;
if (lm == null)
lm = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
try {
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception ex) {
Log.w("LOC", "gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);");
}
try {
network_enabled = lm
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (Exception ex) {
Log.w("LOC", "network_enabled = lm .isProviderEnabled(LocationManager.NETWORK_PROVIDER);");
}
if (!gps_enabled && !network_enabled)
return false;
if (gps_enabled)
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locationListenerGps);
if (network_enabled)
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
locationListenerNetwork);
timer1 = new Timer();
timer1.schedule(new GetLastLocation(), 20000);
return true;
}
public void cancelTimer() {
timer1.cancel();
lm.removeUpdates(locationListenerGps);
lm.removeUpdates(locationListenerNetwork);
}
public static abstract class LocationResult {
public abstract void gotLocation(Location location);
}
private class GetLastLocation extends TimerTask {
@Override
public void run() {
lm.removeUpdates(locationListenerGps);
lm.removeUpdates(locationListenerNetwork);
Location net_loc = null, gps_loc = null;
if (gps_enabled)
gps_loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (network_enabled)
net_loc = lm
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (gps_loc != null && net_loc != null) {
if (gps_loc.getTime() > net_loc.getTime())
locationResult.gotLocation(gps_loc);
else
locationResult.gotLocation(net_loc);
return;
}
if (gps_loc != null) {
locationResult.gotLocation(gps_loc);
return;
}
if (net_loc != null) {
locationResult.gotLocation(net_loc);
return;
}
locationResult.gotLocation(null);
}
}
}

View File

@ -0,0 +1,224 @@
package com.amine.horaires.util;
import com.amine.horaires.models.Shop;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
/**
* Parseur qui permet de parcourir le fichier xml genere
*/
public class Parseur {
/**
* Parcours le fichier xml , insere les donnees de l'utilisateur et son
* historique
*
* @return une arraylist de collections
*/
public ArrayList<Shop> parserShops(String contenuDuFichier) {
final ArrayList<Shop> listeMagasins = new ArrayList<Shop>();
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
DefaultHandler handler = new DefaultHandler() {
Shop magasin;
boolean url = false;
boolean name = false;
boolean address = false;
boolean ville = false;
boolean zip = false;
boolean lat = false;
boolean lng = false;
boolean tel = false;
boolean img = false;
boolean open = false;
boolean open_status = false;
boolean pmr = false;
boolean wifi = false;
boolean freepark = false;
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
if (qName.equalsIgnoreCase("shop"))
magasin = new Shop();
if (qName.equalsIgnoreCase("url"))
url = true;
if (qName.equalsIgnoreCase("name"))
name = true;
if (qName.equalsIgnoreCase("address"))
address = true;
if (qName.equalsIgnoreCase("city"))
ville = true;
if (qName.equalsIgnoreCase("zip"))
zip = true;
if (qName.equalsIgnoreCase("lat"))
lat = true;
if (qName.equalsIgnoreCase("lng"))
lng = true;
if (qName.equalsIgnoreCase("tel"))
tel = true;
if (qName.equalsIgnoreCase("img"))
img = true;
if (qName.equalsIgnoreCase("open"))
open = true;
if (qName.equalsIgnoreCase("open_status"))
open_status = true;
if (qName.equalsIgnoreCase("pmr"))
pmr = true;
if (qName.equalsIgnoreCase("pmr"))
pmr = true;
if (qName.equalsIgnoreCase("wifi"))
wifi = true;
if (qName.equalsIgnoreCase("freepark"))
freepark = true;
if (qName.equalsIgnoreCase("shop")) {
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
String nameA = attributes.getQName(i);
String valueA = attributes.getValue(i);
if (nameA.compareTo("id") == 0) {
magasin.setId(Integer.parseInt(valueA));
}
}
}
}
public void endElement(String uri, String localName,
String qName) throws SAXException {
if (qName.equalsIgnoreCase("shop"))
listeMagasins.add(magasin);
}
public void characters(char ch[], int start, int length)
throws SAXException {
if (url) {
magasin.setUrl(new String(ch, start, length));
url = false;
}
if (name) {
magasin.setName(new String(ch, start, length));
name = false;
}
if (address) {
magasin.setAdresse(new String(ch, start, length));
address = false;
}
if (ville) {
magasin.setCity(new String(ch, start, length));
ville = false;
}
if (zip) {
magasin.setZip(new String(ch, start, length));
zip = false;
}
if (lat) {
magasin.setLat(new String(ch, start, length));
lat = false;
}
if (lng) {
magasin.setLng(new String(ch, start, length));
lng = false;
}
if (tel) {
magasin.setTel(new String(ch, start, length));
tel = false;
}
if (img) {
magasin.setHoraires(new String(ch, start, length));
img = false;
}
if (open) {
magasin.setOuvert(new String(ch, start, length)
.compareTo("1") == 0);
open = false;
}
if (open_status) {
magasin.setOpenStatus(new String(ch, start, length));
open_status = false;
}
if (pmr) {
magasin.setAccesHandicape(new String(ch, start, length)
.compareTo("1") == 0);
pmr = false;
}
if (wifi) {
magasin.setWifi(new String(ch, start, length)
.compareTo("1") == 0);
wifi = false;
}
if (freepark) {
magasin.setParking(new String(ch, start, length)
.compareTo("1") == 0);
freepark = false;
}
}
};
InputStream inputStream = new ByteArrayInputStream(
contenuDuFichier.getBytes());
Reader reader = new InputStreamReader(inputStream, "UTF-8");
InputSource is = new InputSource(reader);
is.setEncoding("UTF-8");
saxParser.parse(is, handler);
} catch (Exception e) {
e.printStackTrace();
}
return listeMagasins;
}
}

View File

@ -0,0 +1,64 @@
package com.amine.horaires.util;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
public class Utils {
public static URL generateUrlForTextLocation(String name, String location) {
try {
return new URL(Configuration.getAPIUrl() + "/api?key="
+ Configuration.key + "&h=" + Configuration.hashtag
+ "&get=shops" + "&loc=" + URLEncoder.encode(location, "ISO-8859-1")
+ "&name=" + URLEncoder.encode(name, "ISO-8859-1"));
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
public static URL generateUrlForLatLng(String name, String lat,
String lng) {
try {
return new URL(Configuration.getAPIUrl() + "/api?key="
+ Configuration.key + "&h=" + Configuration.hashtag
+ "&get=shops" + "&lng=" + lng + "&lat=" + lat + "&name="
+ URLEncoder.encode(name, "ISO-8859-1") + "&order=distance");
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
public static URL generateUrlForId(int idPoi) {
try {
return new URL(Configuration.getAPIUrl() + "/api?key="
+ Configuration.key + "&h=" + Configuration.hashtag
+ "&get=shop" + "&id=" + idPoi);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
public static URL generateUrlForEdit(int idPoi, String periodsString) {
try {
return new URL(Configuration.getAPIUrl() + "/api?key="
+ Configuration.key + "&h=" + Configuration.hashtag
+ "&get=edit" + "&id=" + idPoi + periodsString);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,43 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
tools:context="${relativePackage}.${activSityClass}">
<android.support.v7.widget.RecyclerView
android:id="@+id/favs_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:scrollbars="vertical"
/>
<TextView
android:id="@+id/empty_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:gravity="center"
android:text="@string/listvide"
android:textColor="@color/primary"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@mipmap/plus"
fab:fab_colorNormal="@color/accent"
fab:fab_colorPressed="@color/primary_dark"/>
</RelativeLayout>

View File

@ -0,0 +1,74 @@
<?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/primary_dark"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Librairies"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/accent"/>
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://github.com/wdullaer/MaterialDateTimePicker"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://github.com/pnikosis/materialish-progress"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://github.com/makovkastar/FloatingActionButton"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Icônes"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/accent"/>
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://thenounproject.com/term/wheelchair-accessible/13098/#"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://thenounproject.com/term/wifi/47165/"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="https://github.com/google/material-design-icons"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="72dp"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingBottom="20dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:id="@+id/shop_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/primary"
android:textSize="16sp"/>
<TextView
android:id="@+id/shop_adress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/accent"
android:textSize="14sp"/>
</RelativeLayout>

View File

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="192sp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/descriptionHoraire"
android:elevation="1dp"/>
<TextView
android:id="@+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="208dp"
android:textColor="@color/accent"
android:textSize="24sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/shopAdress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/shopName"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:textColor="@color/primary"
android:textSize="16sp"
android:textStyle="italic"/>
<TextView
android:id="@+id/shopOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/shopAdress"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="20sp"
android:textColor="@color/text_dark"
android:textSize="14sp"/>
<TextView
android:id="@+id/shopStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/shopOpen"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="8sp"
android:textColor="@color/text_dark"/>
<LinearLayout
android:id="@+id/imageStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/shopStatus"
android:layout_marginBottom="16sp"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="16sp"
android:elevation="1dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/wifi"
android:layout_width="120sp"
android:layout_height="120sp"
android:contentDescription="@string/descriptionWifi"
android:focusable="false"
android:src="@mipmap/wifi"
/>
<ImageView
android:id="@+id/parking"
android:layout_width="120sp"
android:layout_height="120sp"
android:contentDescription="@string/descriptionParking"
android:src="@mipmap/parking"/>
<ImageView
android:id="@+id/handi"
android:layout_width="120sp"
android:layout_height="120sp"
android:contentDescription="@string/descriptionHandi"
android:src="@mipmap/handi"/>
</LinearLayout>
<ImageButton
android:id="@+id/callButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imageStatus"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16sp"
android:layout_marginRight="16sp"
android:contentDescription="@string/descriptionCall"
android:elevation="1dp"
android:src="@mipmap/call"
/>
<ImageButton
android:id="@+id/gpsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/callButton"
android:layout_marginRight="16sp"
android:layout_toLeftOf="@+id/callButton"
android:layout_toStartOf="@+id/callButton"
android:contentDescription="@string/descriptionMap"
android:elevation="1dp"
android:src="@mipmap/map"
/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@mipmap/ic_create_black_24dp"
fab:fab_colorNormal="@color/accent"
fab:fab_colorPressed="@color/primary_dark"/>
</RelativeLayout>

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="50sp"
android:text="@string/what"
android:textColor="@color/text_dark"
android:textSize="12sp"/>
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView2"
android:layout_marginBottom="16sp"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="16sp"
android:inputType="text"
android:singleLine="true"
android:textColor="@color/primary_dark"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/name"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="50sp"
android:text="@string/where"
android:textColor="@color/text_dark"/>
<EditText
android:id="@+id/location"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView3"
android:layout_marginLeft="16sp"
android:layout_marginRight="16sp"
android:layout_marginTop="16sp"
android:ems="10"
android:inputType="textPostalAddress"
android:singleLine="true"
android:textColor="@color/primary_dark"/>
<Button
android:id="@+id/searchAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/location"
android:layout_marginLeft="16sp"
android:layout_marginTop="73dp"
android:text="@string/find"
android:textColor="@color/accent"/>
<ImageButton
android:id="@+id/gpsAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/searchAction"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="16sp"
android:contentDescription="@string/descriptionButtonGps"
android:src="@android:drawable/ic_menu_compass"
/>
<RelativeLayout
android:id="@+id/loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elevation="1dp"
android:orientation="horizontal"
android:visibility="gone">
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progress_wheel"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
wheel:matProg_barColor="#5588FF"
wheel:matProg_progressIndeterminate="true"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/textView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="52dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000000"/>

View File

@ -0,0 +1,40 @@
<?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="72sp"
android:background="#ffffff"
android:gravity="center_vertical|center|center_horizontal"
android:orientation="horizontal">
<Spinner
android:id="@+id/spinner"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".4"
android:entries="@array/days_arrays"
android:prompt="@string/jour"
/>
<TextView
android:id="@+id/from"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:clickable="true"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:textColor="#000000"/>
<TextView
android:id="@+id/to"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:clickable="true"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:textAlignment="center"
android:textColor="#000000"/>
</LinearLayout>

View File

@ -0,0 +1,63 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
tools:context="${relativePackage}.${activSityClass}">
<ListView
android:id="@+id/horaires_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:scrollbars="vertical"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@mipmap/ic_alarm_add_black_24dp"
fab:fab_colorNormal="@color/accent"
fab:fab_colorPressed="@color/primary_dark"
tools:ignore="RelativeOverlap"/>
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/save"
android:textColor="@color/accent"/>
<RelativeLayout
android:id="@+id/loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elevation="1dp"
android:orientation="horizontal"
android:visibility="gone">
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progress_wheel"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
wheel:matProg_barColor="#5588FF"
wheel:matProg_progressIndeterminate="true"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -0,0 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/action_about"
android:title="@string/about"
/>
<item
android:id="@+id/action_mail"
android:title="@string/contact"
/>
</menu>

View File

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:horaires="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_reload"
android:icon="@mipmap/ic_cached_black_24dp"
android:title="@string/vider"
horaires:showAsAction="ifRoom"/>
</menu>

View File

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:horaires="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_fav"
android:icon="@mipmap/ic_turned_in_not_black_24dp"
android:title="@string/favoris"
horaires:showAsAction="ifRoom"/>
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Les Horaires</string>
<string name="about">À propos</string>
<string name="settings">Paramètres</string>
<string name="jour">Jour</string>
<string name="ouverture">Ouverture</string>
<string name="fermeture">Fermeture</string>
<string name="vider">Retrourner aux favoris</string>
<string name="favoris">Favoris</string>
<string name="what">Quoi ?</string>
<string name="listvide">Votre liste de magasins est vide.</string>
<string name="save">Sauvegarder</string>
<string name="where">Où ?</string>
<string name="find">Chercher</string>
<string name="descriptionHoraire">Horaires</string>
<string name="descriptionButtonGps">Boutton GPS</string>
<string name="descriptionWifi">Wifi</string>
<string name="descriptionParking">Parking</string>
<string name="descriptionHandi">Mobilité réduite</string>
<string name="descriptionCall">Appeler</string>
<string name="descriptionMap">Maps</string>
<string name="changelog_full_title">Changements</string>
<string name="changelog_title">Nouveautés</string>
<string name="changelog_ok_button">OK</string>
<string name="changelog_show_full">Plus…</string>
<string name="contact">Contacter le dev</string>
<string-array name="days_arrays">
<item>Lundi</item>
<item>Mardi</item>
<item>Mercredi</item>
<item>Jeudi</item>
<item>Vendredi</item>
<item>Samedi</item>
<item>Dimanche</item>
</string-array>
</resources>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:textColorSecondary">@color/text_dark</item>
</style>
<style name="SpinnerItem">
<item name="android:textAppearance">@color/primary_dark</item>
</style>
<style name="Spinner">
<item name="android:checkMark">@color/primary</item>
</style>
</resources>

View File

@ -0,0 +1,37 @@
<resources>
<string name="app_name">Les Horaires</string>
<string name="about">À propos</string>
<string name="settings">Paramètres</string>
<string name="jour">Jour</string>
<string name="ouverture">Ouverture</string>
<string name="fermeture">Fermeture</string>
<string name="vider">Retrourner aux favoris</string>
<string name="favoris">Favoris</string>
<string name="what">Quoi ?</string>
<string name="listvide">Votre liste de magasins est vide.</string>
<string name="save">Sauvegarder</string>
<string name="where">Où ?</string>
<string name="find">Chercher</string>
<string name="descriptionHoraire">Horaires</string>
<string name="descriptionButtonGps">Boutton GPS</string>
<string name="descriptionWifi">Wifi</string>
<string name="descriptionParking">Parking</string>
<string name="descriptionHandi">Mobilité réduite</string>
<string name="descriptionCall">Appeler</string>
<string name="descriptionMap">Maps</string>
<string name="changelog_full_title">Changements</string>
<string name="changelog_title">Nouveautés</string>
<string name="changelog_ok_button">OK</string>
<string name="changelog_show_full">Plus…</string>
<string name="contact">Contacter le dev</string>
<string-array name="days_arrays">
<item>Lundi</item>
<item>Mardi</item>
<item>Mercredi</item>
<item>Jeudi</item>
<item>Vendredi</item>
<item>Samedi</item>
<item>Dimanche</item>
</string-array>
</resources>

View File

@ -0,0 +1,29 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:textColorSecondary">@color/text_dark</item>
</style>
<style name="SpinnerItem">
<item name="android:textAppearance">@color/primary_dark</item>
</style>
<style name="Spinner">
<item name="android:checkMark">@color/primary</item>
</style>
<color name="primary">#9c27b0</color>
<color name="primary_dark">#6a1b9a</color>
<color name="accent">#ffab00</color>
<color name="text_primary">#FFFFFF</color>
<color name="text_dark">#000000</color>
<color name="background">#EEEEEE</color>
</resources>

Some files were not shown because too many files have changed in this diff Show More