Merge pull request #11 from DevHugo/update_favs_list_autmaticly
Met à jours la liste des favoris automatiquement
This commit is contained in:
commit
c1d9dc70ea
@ -25,8 +25,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_6
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
@ -35,6 +35,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|
||||||
release {
|
release {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,11 +49,18 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
compile.exclude group: 'stax'
|
||||||
|
compile.exclude group: 'xpp3'
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile 'com.android.support:appcompat-v7:+'
|
compile 'com.android.support:appcompat-v7:+'
|
||||||
compile 'com.android.support:support-v4:+'
|
compile 'com.android.support:support-v4:+'
|
||||||
compile 'com.android.support:recyclerview-v7:+'
|
compile 'com.android.support:recyclerview-v7:+'
|
||||||
|
compile 'com.android.support:cardview-v7:+'
|
||||||
|
|
||||||
compile 'com.google.android.gms:play-services:4.3.23'
|
compile 'com.google.android.gms:play-services:4.3.23'
|
||||||
compile 'com.melnykov:floatingactionbutton:1.2.0'
|
compile 'com.melnykov:floatingactionbutton:1.2.0'
|
||||||
compile 'com.pnikosis:materialish-progress:1.5'
|
compile 'com.pnikosis:materialish-progress:1.5'
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@ -18,7 +17,7 @@
|
|||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version"/>
|
android:value="@integer/google_play_services_version"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".listfavorites.ListFavoritesActivity"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
@ -27,37 +26,37 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ShopDisplay"
|
android:name=".shopdetail.DetailShopActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:parentActivityName=".MainActivity">
|
android:parentActivityName=".listfavorites.ListFavoritesActivity">
|
||||||
<!-- Parent activity meta-data to support API level 7+ -->
|
<!-- Parent activity meta-data to support API level 7+ -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".MainActivity"/>
|
android:value=".listfavorites.ListFavoritesActivity"/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.ALTERNATIVE"/>
|
<category android:name="android.intent.category.ALTERNATIVE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ShopSearch"
|
android:name=".search.SearchActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:parentActivityName=".MainActivity">
|
android:parentActivityName=".listfavorites.ListFavoritesActivity">
|
||||||
<!-- Parent activity meta-data to support API level 7+ -->
|
<!-- Parent activity meta-data to support API level 7+ -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".MainActivity"/>
|
android:value=".listfavorites.ListFavoritesActivity"/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.ALTERNATIVE"/>
|
<category android:name="android.intent.category.ALTERNATIVE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ShopUpdate"
|
android:name=".updateshop.UpdateShopActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:parentActivityName=".ShopDisplay">
|
android:parentActivityName=".shopdetail.DetailShopActivity">
|
||||||
<!-- Parent activity meta-data to support API level 7+ -->
|
<!-- Parent activity meta-data to support API level 7+ -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".ShopDisplay"/>
|
android:value=".shopdetail.DetailShopActivity"/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.ALTERNATIVE"/>
|
<category android:name="android.intent.category.ALTERNATIVE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package com.amine.horaires;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
|
|
||||||
public class App extends Application {
|
|
||||||
|
|
||||||
public App() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,9 +12,8 @@ import com.amine.horaires.bdd.FavorisDao;
|
|||||||
import com.amine.horaires.models.Shop;
|
import com.amine.horaires.models.Shop;
|
||||||
import com.amine.horaires.util.Configuration;
|
import com.amine.horaires.util.Configuration;
|
||||||
|
|
||||||
class OptionsActivity extends AppCompatActivity {
|
public class OptionsActivity extends AppCompatActivity {
|
||||||
MenuItem favMenu = null;
|
|
||||||
boolean isFav = false;
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
@ -22,7 +21,10 @@ class OptionsActivity extends AppCompatActivity {
|
|||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
/*
|
||||||
|
* Default operation, when the user click on the menu.
|
||||||
|
*/
|
||||||
|
public boolean defaultOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_mail:
|
case R.id.action_mail:
|
||||||
Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
|
Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
|
||||||
@ -42,22 +44,7 @@ class OptionsActivity extends AppCompatActivity {
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_reload:
|
case R.id.action_reload:
|
||||||
MainActivity.razOrFavs(OptionsActivity.this);
|
//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;
|
return true;
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
this.finish();
|
this.finish();
|
||||||
@ -67,23 +54,4 @@ class OptionsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
package com.amine.horaires;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
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);
|
|
||||||
|
|
||||||
searchButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (name.getText().toString().trim().length() > 0 && location.getText().toString().trim().length() > 0) {
|
|
||||||
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(), getResources().getString(R.string.fail_localize_user), 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(), getResources().getString(R.string.fail_localize_user), 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 = "";
|
|
||||||
URL url = null;
|
|
||||||
try {
|
|
||||||
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) {
|
|
||||||
Log.e("ShopSearch", "The API doesn't respond correctly. Asked url was " + url.toString(), e);
|
|
||||||
} catch (ProtocolException e) {
|
|
||||||
Log.e("ShopSearch", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e("ShopSearch", "The API response is not readable. Url was " + url.toString(), e);
|
|
||||||
} finally {
|
|
||||||
// Makes sure that the InputStream is closed after the app is finished using it.
|
|
||||||
if (is != null)
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -55,4 +55,4 @@ class FavorisBdd extends SQLiteOpenHelper {
|
|||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,6 +65,10 @@ public class FavorisDao {
|
|||||||
bdd = maBaseSQLite.getWritableDatabase();
|
bdd = maBaseSQLite.getWritableDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openReadable() {
|
||||||
|
bdd = maBaseSQLite.getWritableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
bdd.close();
|
bdd.close();
|
||||||
}
|
}
|
||||||
@ -156,4 +160,4 @@ public class FavorisDao {
|
|||||||
cursor.close();
|
cursor.close();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package com.amine.horaires.listfavorites;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import com.amine.horaires.OptionsActivity;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.bdd.FavorisDao;
|
||||||
|
import com.amine.horaires.listshop.ListShopsFragment;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
import com.amine.horaires.search.SearchActivity;
|
||||||
|
import com.amine.horaires.util.Configuration;
|
||||||
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
|
import de.cketti.library.changelog.ChangeLog;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListFavoritesActivity extends OptionsActivity {
|
||||||
|
|
||||||
|
private Fragment currentFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
|
||||||
|
// However, if we're being restored from a previous state,
|
||||||
|
// then we don't need to do anything and should return or else
|
||||||
|
// we could end up with overlapping fragments.
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new Fragment to be placed in the activity layout
|
||||||
|
currentFragment = new ListShopsFragment();
|
||||||
|
|
||||||
|
// Get all favorites shops
|
||||||
|
FavorisDao dao = FavorisDao.getInstance(getApplicationContext());
|
||||||
|
dao.openReadable();
|
||||||
|
ArrayList<Shop> shops = dao.getAllFavoris();
|
||||||
|
|
||||||
|
// Update the list
|
||||||
|
ListFavoritesSingleton.getInstance().setFavoritesShops(shops);
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putParcelableArrayList("list", shops);
|
||||||
|
args.putString("errorEmptyList", getErrorMessageListFavoritesEmpty());
|
||||||
|
|
||||||
|
currentFragment.setArguments(args);
|
||||||
|
|
||||||
|
// Add the fragment to the 'fragment_container' FrameLayout
|
||||||
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, currentFragment).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save user country
|
||||||
|
saveUserCountry();
|
||||||
|
|
||||||
|
// Display changelog
|
||||||
|
ChangeLog cl = new ChangeLog(this);
|
||||||
|
if (cl.isFirstRun()) {
|
||||||
|
cl.getLogDialog().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure SearchButton
|
||||||
|
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
search();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume(){
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
Log.w("com.amine.horaires", "onResume()");
|
||||||
|
|
||||||
|
// We should tell to the list that we have updated something
|
||||||
|
if (currentFragment != null) {
|
||||||
|
List<Shop> shops = ListFavoritesSingleton.getInstance().getFavoritesShops();
|
||||||
|
|
||||||
|
if (!shops.isEmpty()) {
|
||||||
|
((ListShopsFragment) currentFragment).updateList(shops);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when the fragment want to launch the Search.
|
||||||
|
*/
|
||||||
|
private void search() {
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessageListFavoritesEmpty() {
|
||||||
|
return getString(R.string.listvide);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We save the user country to display the best api url.
|
||||||
|
*/
|
||||||
|
private void saveUserCountry() {
|
||||||
|
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
Configuration.pays = tm.getSimCountryIso().toUpperCase();
|
||||||
|
if (Configuration.pays == null || Configuration.pays.equals("") || Configuration.pays.isEmpty())
|
||||||
|
Configuration.pays = ListFavoritesActivity.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||||
|
return defaultOptionsItemSelected (menuItem);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.amine.horaires.listshop;
|
||||||
|
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListShopsAdapter extends RecyclerView.Adapter<ListShopsAdapter.ShopViewHolder> {
|
||||||
|
|
||||||
|
private List<Shop> shops;
|
||||||
|
|
||||||
|
ListShopsAdapter(List<Shop> shop){
|
||||||
|
this.shops = shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Shop> getShops() {return shops; }
|
||||||
|
|
||||||
|
public void setShops(List<Shop> shops) { this.shops = shops; }
|
||||||
|
|
||||||
|
public class ShopViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private CardView cv;
|
||||||
|
private TextView shopName;
|
||||||
|
private TextView shopAddress;
|
||||||
|
|
||||||
|
ShopViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
cv = (CardView)itemView.findViewById(R.id.card_view);
|
||||||
|
shopName = (TextView)itemView.findViewById(R.id.shop_name);
|
||||||
|
shopAddress = (TextView)itemView.findViewById(R.id.shop_adress);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextView getShopName() {
|
||||||
|
return shopName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextView getShopAddress() {
|
||||||
|
return shopAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShopViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_shop_item, parent, false);
|
||||||
|
ShopViewHolder pvh = new ShopViewHolder(v);
|
||||||
|
return pvh;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ShopViewHolder holder, int position) {
|
||||||
|
holder.getShopName().setText(shops.get(position).getName());
|
||||||
|
holder.getShopAddress().setText(shops.get(position).getAdresse());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return shops.size();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.amine.horaires.listshop;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
import com.amine.horaires.shopdetail.DetailShopActivity;
|
||||||
|
import com.amine.horaires.util.RecyclerItemClickListener;
|
||||||
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListShopsFragment extends Fragment {
|
||||||
|
private List<Shop> shops;
|
||||||
|
private ListShopsAdapter adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.fragment_list_shops, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
shops = getArguments().getParcelableArrayList("list");
|
||||||
|
|
||||||
|
// Get list android component
|
||||||
|
RecyclerView favsRecyclerView = (RecyclerView) getView().findViewById(R.id.list);
|
||||||
|
|
||||||
|
if (shops.isEmpty()) {
|
||||||
|
favsRecyclerView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
TextView emptyView = (TextView) getView().findViewById(R.id.empty_list);
|
||||||
|
emptyView.setVisibility(View.VISIBLE);
|
||||||
|
emptyView.setText(getArguments().getString("errorEmptyList"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Create an Adapter: provides access to the data items and is also responsible for making a View for each item
|
||||||
|
adapter = new ListShopsAdapter(shops);
|
||||||
|
favsRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
// Create a LayoutManager: Layout Manager is responsible for measuring and positioning item views within a RecyclerView
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
|
||||||
|
favsRecyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
// Improve performances, the list have a fixed size
|
||||||
|
favsRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
|
// Open the shop on click
|
||||||
|
favsRecyclerView.addOnItemTouchListener(
|
||||||
|
new RecyclerItemClickListener(getActivity().getApplicationContext(),
|
||||||
|
new RecyclerItemClickListener.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(View view, final int position) {
|
||||||
|
final Intent i = new Intent(view.getContext(), DetailShopActivity.class);
|
||||||
|
final Handler handler = new Handler();
|
||||||
|
Runnable t = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
i.putExtra("shop", shops.get(position));
|
||||||
|
getActivity().startActivity(i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handler.post(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateList (List<Shop> listOfShops) {
|
||||||
|
adapter.setShops(listOfShops);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -219,6 +219,24 @@ public class Shop implements Parcelable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Shop shop = (Shop) o;
|
||||||
|
|
||||||
|
if (name != null ? !name.equals(shop.name) : shop.name != null) return false;
|
||||||
|
return !(adresse != null ? !adresse.equals(shop.adresse) : shop.adresse != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = name != null ? name.hashCode() : 0;
|
||||||
|
result = 31 * result + (adresse != null ? adresse.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeInt(id);
|
dest.writeInt(id);
|
||||||
@ -237,4 +255,4 @@ public class Shop implements Parcelable {
|
|||||||
dest.writeByte((byte) (wifi ? 1 : 0));
|
dest.writeByte((byte) (wifi ? 1 : 0));
|
||||||
dest.writeByte((byte) (AccesHandicape ? 1 : 0));
|
dest.writeByte((byte) (AccesHandicape ? 1 : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.amine.horaires.search;
|
||||||
|
|
||||||
|
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface OnSearchResult {
|
||||||
|
void onPostExecute(List<Shop> result);
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.amine.horaires.search;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import com.amine.horaires.listshop.ListShopsFragment;
|
||||||
|
import com.amine.horaires.OptionsActivity;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SearchActivity extends OptionsActivity implements OnSearchResult {
|
||||||
|
|
||||||
|
private FloatingActionButton fab;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_search);
|
||||||
|
|
||||||
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
|
||||||
|
// However, if we're being restored from a previous state,
|
||||||
|
// then we don't need to do anything and should return or else
|
||||||
|
// we could end up with overlapping fragments.
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new Fragment to be placed in the activity layout
|
||||||
|
SearchFragment firstFragment = new SearchFragment();
|
||||||
|
|
||||||
|
// Add the fragment to the 'fragmentContainer' FrameLayout
|
||||||
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, firstFragment).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure SearchButton
|
||||||
|
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
search();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fab.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when the fragment want to launch the Search.
|
||||||
|
*/
|
||||||
|
private void search() {
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The search have found some result, need to update the fragments
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPostExecute(List<Shop> result) {
|
||||||
|
ListShopsFragment listSearchResultFragment = new ListShopsFragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putParcelableArrayList("list", (ArrayList) result);
|
||||||
|
args.putString("errorEmptyList", getErrorMessageResultListEmpty());
|
||||||
|
|
||||||
|
listSearchResultFragment.setArguments(args);
|
||||||
|
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
|
transaction.replace(R.id.fragmentContainer, listSearchResultFragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
|
||||||
|
// Commit the transaction
|
||||||
|
transaction.commit();
|
||||||
|
|
||||||
|
fab.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||||
|
return defaultOptionsItemSelected (menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessageResultListEmpty() {
|
||||||
|
return getString(R.string.resultatRechercheVide);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,175 @@
|
|||||||
|
package com.amine.horaires.search;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
import com.amine.horaires.shopdetail.UpdateActionBar;
|
||||||
|
import com.amine.horaires.util.MyLocation;
|
||||||
|
import com.amine.horaires.util.Parseur;
|
||||||
|
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.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class SearchFragment extends Fragment {
|
||||||
|
|
||||||
|
private EditText name;
|
||||||
|
private EditText location;
|
||||||
|
private Button searchButton;
|
||||||
|
|
||||||
|
private RelativeLayout loading;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.fragment_search, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
// If the user is not connected to a network, display an error
|
||||||
|
if (!Utils.checkDeviceConnected (getActivity().getApplicationContext())) {
|
||||||
|
Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.fail_connexion), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Android component form
|
||||||
|
name = (EditText) getView().findViewById(R.id.name);
|
||||||
|
location = (EditText) getView().findViewById(R.id.location);
|
||||||
|
searchButton = (Button) getView().findViewById(R.id.searchAction);
|
||||||
|
|
||||||
|
// Load icons. Useful to show to the user, that something is loading.
|
||||||
|
loading = (RelativeLayout) getView().findViewById(R.id.loading);
|
||||||
|
|
||||||
|
searchButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// If the user complete the form
|
||||||
|
if (name.getText().toString().trim().length() > 0 && location.getText().toString().trim().length() > 0) {
|
||||||
|
|
||||||
|
// Show to the user that we performs the user
|
||||||
|
loading.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
SearchTask s = new SearchTask();
|
||||||
|
s.execute(Utils.generateUrlForTextLocation(name.getText().toString(), location.getText().toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getView().findViewById(R.id.gpsAction).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
if (name.getText().toString().trim().length() > 0) {
|
||||||
|
|
||||||
|
loading.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
MyLocation myLocation = new MyLocation();
|
||||||
|
boolean gotLocation = myLocation.getLocation(getActivity().getApplicationContext(), new MyLocation.LocationResult() {
|
||||||
|
@Override
|
||||||
|
public void gotLocation(Location location) {
|
||||||
|
if (location == null) {
|
||||||
|
displayLocalizeError();
|
||||||
|
} else {
|
||||||
|
URL url = Utils.generateUrlForLatLng(name.getText().toString(), location.getLatitude() + "", location.getLongitude() + "");
|
||||||
|
SearchTask s = new SearchTask();
|
||||||
|
s.execute(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!gotLocation) {
|
||||||
|
displayLocalizeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.fail_fill_form), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayLocalizeError () {
|
||||||
|
Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.fail_localize_user), 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 = "";
|
||||||
|
URL url = null;
|
||||||
|
try {
|
||||||
|
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) {
|
||||||
|
Log.e("ShopSearch", "The API doesn't respond correctly. Asked url was " + url.toString(), e);
|
||||||
|
} catch (ProtocolException e) {
|
||||||
|
Log.e("ShopSearch", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e("ShopSearch", "The API response is not readable. Url was " + url.toString(), e);
|
||||||
|
} finally {
|
||||||
|
// Makes sure that the InputStream is closed after the app is finished using it.
|
||||||
|
if (is != null)
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
if (conn != null)
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
return contentAsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String string) {
|
||||||
|
super.onPostExecute(string);
|
||||||
|
|
||||||
|
loading.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
List<Shop> shops = new Parseur().parserShops(string);
|
||||||
|
|
||||||
|
((OnSearchResult) getActivity()).onPostExecute(shops);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.amine.horaires.shopdetail;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import com.amine.horaires.OptionsActivity;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
|
||||||
|
public class DetailShopActivity extends OptionsActivity implements UpdateActionBar {
|
||||||
|
|
||||||
|
private MenuItem favMenu;
|
||||||
|
private DetailShopFragment detailShopFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_detail_shop);
|
||||||
|
|
||||||
|
Shop s = getIntent().getExtras().getParcelable("shop");
|
||||||
|
|
||||||
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
|
||||||
|
// However, if we're being restored from a previous state,
|
||||||
|
// then we don't need to do anything and should return or else
|
||||||
|
// we could end up with overlapping fragments.
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new Fragment to be placed in the activity layout
|
||||||
|
detailShopFragment = new DetailShopFragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putParcelable("shop", s);
|
||||||
|
|
||||||
|
detailShopFragment.setArguments(args);
|
||||||
|
|
||||||
|
// Add the fragment to the 'fragmentContainer' FrameLayout
|
||||||
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, detailShopFragment).commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
|
||||||
|
updateFavsIcon(detailShopFragment.getFav());
|
||||||
|
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||||
|
boolean isActionPerformed = defaultOptionsItemSelected(menuItem);
|
||||||
|
|
||||||
|
if (isActionPerformed) {
|
||||||
|
return isActionPerformed;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (menuItem.getItemId() == R.id.action_fav) {
|
||||||
|
detailShopFragment.updateFav();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFavsIcon(boolean isFav) {
|
||||||
|
|
||||||
|
if (isFav) {
|
||||||
|
favMenu.setIcon(R.mipmap.ic_turned_in_black_24dp);
|
||||||
|
} else {
|
||||||
|
favMenu.setIcon(R.mipmap.ic_turned_in_not_black_24dp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +1,23 @@
|
|||||||
package com.amine.horaires;
|
package com.amine.horaires.shopdetail;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.amine.horaires.R;
|
||||||
import com.amine.horaires.bdd.FavorisDao;
|
import com.amine.horaires.bdd.FavorisDao;
|
||||||
|
import com.amine.horaires.listfavorites.ListFavoritesSingleton;
|
||||||
import com.amine.horaires.models.Shop;
|
import com.amine.horaires.models.Shop;
|
||||||
import com.amine.horaires.util.Configuration;
|
import com.amine.horaires.updateshop.UpdateShopActivity;
|
||||||
import com.amine.horaires.util.Parseur;
|
import com.amine.horaires.util.Parseur;
|
||||||
import com.amine.horaires.util.Utils;
|
import com.amine.horaires.util.Utils;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
@ -31,41 +31,48 @@ import java.net.URL;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class ShopDisplay extends OptionsActivity {
|
public class DetailShopFragment extends Fragment implements UpdateFav {
|
||||||
|
|
||||||
|
private boolean isFav = false;
|
||||||
|
private Shop s;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
super.onCreate(savedInstanceState);
|
Bundle savedInstanceState) {
|
||||||
setContentView(R.layout.shop_display);
|
return inflater.inflate(R.layout.fragment_detail_shop, container, false);
|
||||||
Shop s = getIntent().getExtras().getParcelable("shop");
|
}
|
||||||
|
|
||||||
Configuration.currentShop = s;
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
FavorisDao dao = FavorisDao.getInstance(ShopDisplay.this);
|
s = getArguments().getParcelable("shop");
|
||||||
dao.open();
|
FavorisDao dao = FavorisDao.getInstance(getActivity().getApplicationContext());
|
||||||
|
dao.openReadable();
|
||||||
List<Shop> fs = dao.getAllFavoris();
|
List<Shop> fs = dao.getAllFavoris();
|
||||||
dao.close();
|
|
||||||
|
|
||||||
while (!isFav && !fs.isEmpty()) {
|
while (!isFav && !fs.isEmpty()) {
|
||||||
isFav = fs.remove(0).getId() == Configuration.currentShop.getId();
|
isFav = fs.remove(0).getId() == s.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFav) {
|
if (isFav) {
|
||||||
SearchTask st = new SearchTask();
|
SearchTask st = new SearchTask();
|
||||||
st.execute(Utils.generateUrlForId(s.getId()));
|
st.execute(Utils.generateUrlForId(s.getId()));
|
||||||
s = Configuration.currentShop;
|
|
||||||
dao.open();
|
dao.open();
|
||||||
dao.updateFavori(s);
|
dao.updateFavori(s);
|
||||||
dao.close();
|
dao.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
generateView(s);
|
generateView(s);
|
||||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.fab);
|
||||||
|
|
||||||
final Shop finalS = s;
|
final Shop finalS = s;
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent i = new Intent(getBaseContext(), ShopUpdate.class);
|
final Intent i = new Intent(getActivity().getApplicationContext(), UpdateShopActivity.class);
|
||||||
i.putExtra("shop", finalS);
|
i.putExtra("shop", finalS);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
@ -73,20 +80,19 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateView(final Shop s) {
|
private void generateView(final Shop s) {
|
||||||
Configuration.currentShop = s;
|
|
||||||
|
|
||||||
ImageView imageResult = (ImageView) findViewById(R.id.imageView);
|
ImageView imageResult = (ImageView) getView().findViewById(R.id.imageView);
|
||||||
|
|
||||||
ImageTask t = new ImageTask(imageResult);
|
ImageTask t = new ImageTask(imageResult);
|
||||||
t.execute(s.getHoraires());
|
t.execute(s.getHoraires());
|
||||||
|
|
||||||
TextView shopName = (TextView) findViewById(R.id.shopName);
|
TextView shopName = (TextView) getView().findViewById(R.id.shopName);
|
||||||
TextView shopAddress = (TextView) findViewById(R.id.shopAdress);
|
TextView shopAddress = (TextView) getView().findViewById(R.id.shopAdress);
|
||||||
TextView shopOpen = (TextView) findViewById(R.id.shopOpen);
|
TextView shopOpen = (TextView) getView().findViewById(R.id.shopOpen);
|
||||||
TextView shopStatus = (TextView) findViewById(R.id.shopStatus);
|
TextView shopStatus = (TextView) getView().findViewById(R.id.shopStatus);
|
||||||
ImageView wifi = (ImageView) findViewById(R.id.wifi);
|
ImageView wifi = (ImageView) getView().findViewById(R.id.wifi);
|
||||||
ImageView parking = (ImageView) findViewById(R.id.parking);
|
ImageView parking = (ImageView) getView().findViewById(R.id.parking);
|
||||||
ImageView access = (ImageView) findViewById(R.id.handi);
|
ImageView access = (ImageView) getView().findViewById(R.id.handi);
|
||||||
|
|
||||||
shopName.setText(s.getName());
|
shopName.setText(s.getName());
|
||||||
shopAddress.setText(s.getAdresse());
|
shopAddress.setText(s.getAdresse());
|
||||||
@ -107,7 +113,7 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
parking.setAlpha((float) 0.1);
|
parking.setAlpha((float) 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
|
getView().findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(s.getUrl()));
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(s.getUrl()));
|
||||||
@ -115,7 +121,7 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
findViewById(R.id.callButton).setOnClickListener(new View.OnClickListener() {
|
getView().findViewById(R.id.callButton).setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String numeroAppeler = "tel:" + s.getTel();
|
String numeroAppeler = "tel:" + s.getTel();
|
||||||
startActivity(new Intent(Intent.ACTION_DIAL, Uri
|
startActivity(new Intent(Intent.ACTION_DIAL, Uri
|
||||||
@ -123,7 +129,7 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
findViewById(R.id.gpsButton).setOnClickListener(new View.OnClickListener() {
|
getView().findViewById(R.id.gpsButton).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new
|
Intent intent = new
|
||||||
@ -135,24 +141,36 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// @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
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public void updateFav() {
|
||||||
MenuInflater inflater = getMenuInflater();
|
FavorisDao dao = FavorisDao.getInstance(getActivity().getApplicationContext());
|
||||||
inflater.inflate(R.menu.main_activity_actions_shop, menu);
|
|
||||||
favMenu = menu.findItem(R.id.action_fav);
|
if (isFav) {
|
||||||
updateFavStatus();
|
dao.open();
|
||||||
return super.onCreateOptionsMenu(menu);
|
dao.deleteFavori(s.getId());
|
||||||
|
dao.close();
|
||||||
|
|
||||||
|
// Notify the favorites list that he remove a shop
|
||||||
|
ListFavoritesSingleton.getInstance().getFavoritesShops().remove(s);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
dao.open();
|
||||||
|
dao.insertFavori(s);
|
||||||
|
dao.close();
|
||||||
|
|
||||||
|
// Notify the favorites list that he added a shop
|
||||||
|
ListFavoritesSingleton.getInstance().getFavoritesShops().add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
isFav = !isFav;
|
||||||
|
((UpdateActionBar) getActivity()).updateFavsIcon(isFav);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getFav() {
|
||||||
|
return isFav;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImageTask extends AsyncTask<String, Void, Bitmap> {
|
public class ImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
@ -182,7 +200,7 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
|
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Log.e("ShopDisplay", "The API doesn't respond correctly. Asked url was "+url.toString(), e);
|
Log.e("ShopDisplay", "The API doesn't respond correctly. Asked url was " + url.toString(), e);
|
||||||
} catch (ProtocolException e) {
|
} catch (ProtocolException e) {
|
||||||
Log.e("ShopDisplay", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
Log.e("ShopDisplay", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -231,11 +249,11 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
contentAsString = contentAsString + reader.nextLine();
|
contentAsString = contentAsString + reader.nextLine();
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Log.e("ShopDisplay", "The API doesn't respond correctly. Asked url was " + url.toString(), e);
|
Log.e("ShopDisplay", "The API doesn't respond correctly. Asked url was " + url.toString(), e);
|
||||||
} catch (ProtocolException e) {
|
} catch (ProtocolException e) {
|
||||||
Log.e("ShopDisplay", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
Log.e("ShopDisplay", "The protocol doesn't seems to be HTTP. Url was " + url.toString(), e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("ShopDisplay", "The API response is not readable. Url was " + url.toString(), e);
|
Log.e("ShopDisplay", "The API response is not readable. Url was " + url.toString(), e);
|
||||||
} finally {
|
} finally {
|
||||||
// Makes sure that the InputStream is closed after the app is finished using it.
|
// Makes sure that the InputStream is closed after the app is finished using it.
|
||||||
if (is != null)
|
if (is != null)
|
||||||
@ -251,7 +269,8 @@ public class ShopDisplay extends OptionsActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String string) {
|
protected void onPostExecute(String string) {
|
||||||
super.onPostExecute(string);
|
super.onPostExecute(string);
|
||||||
Configuration.currentShop = new Parseur().parserShops(string).get(0);
|
s = new Parseur().parserShops(string).get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.amine.horaires.shopdetail;
|
||||||
|
|
||||||
|
public interface UpdateActionBar {
|
||||||
|
void updateFavsIcon (boolean isFav);
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.amine.horaires.shopdetail;
|
||||||
|
|
||||||
|
public interface UpdateFav {
|
||||||
|
void updateFav ();
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.amine.horaires;
|
package com.amine.horaires.updateshop;
|
||||||
|
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -6,6 +6,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
import com.amine.horaires.R;
|
||||||
import com.amine.horaires.models.Horaires;
|
import com.amine.horaires.models.Horaires;
|
||||||
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
|
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
|
||||||
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.amine.horaires.updateshop;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import com.amine.horaires.OptionsActivity;
|
||||||
|
import com.amine.horaires.R;
|
||||||
|
import com.amine.horaires.models.Shop;
|
||||||
|
import com.amine.horaires.shopdetail.DetailShopFragment;
|
||||||
|
|
||||||
|
public class UpdateShopActivity extends OptionsActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_update_shop);
|
||||||
|
|
||||||
|
Shop s = getIntent().getExtras().getParcelable("shop");
|
||||||
|
|
||||||
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
|
||||||
|
// However, if we're being restored from a previous state,
|
||||||
|
// then we don't need to do anything and should return or else
|
||||||
|
// we could end up with overlapping fragments.
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new Fragment to be placed in the activity layout
|
||||||
|
UpdateShopFragment updateShopFragment = new UpdateShopFragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putParcelable("shop", s);
|
||||||
|
|
||||||
|
updateShopFragment.setArguments(args);
|
||||||
|
|
||||||
|
// Add the fragment to the 'fragmentContainer' FrameLayout
|
||||||
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, updateShopFragment).commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,17 @@
|
|||||||
package com.amine.horaires;
|
package com.amine.horaires.updateshop;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import com.amine.horaires.R;
|
||||||
import com.amine.horaires.models.Horaires;
|
import com.amine.horaires.models.Horaires;
|
||||||
import com.amine.horaires.models.Shop;
|
import com.amine.horaires.models.Shop;
|
||||||
import com.amine.horaires.util.Utils;
|
import com.amine.horaires.util.Utils;
|
||||||
@ -24,28 +28,34 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class ShopUpdate extends OptionsActivity {
|
public class UpdateShopFragment extends Fragment {
|
||||||
private ArrayList<Horaires> h;
|
private ArrayList<Horaires> h;
|
||||||
private RelativeLayout loading;
|
private RelativeLayout loading;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
super.onCreate(savedInstanceState);
|
Bundle savedInstanceState) {
|
||||||
setContentView(R.layout.update_shop);
|
return inflater.inflate(R.layout.fragment_update_shop, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
loading = (RelativeLayout) findViewById(R.id.loading);
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
final Shop s = getIntent().getExtras().getParcelable("shop");
|
|
||||||
|
|
||||||
ListView hList = (ListView) findViewById(R.id.horaires_list);
|
loading = (RelativeLayout) getView().findViewById(R.id.loading);
|
||||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
||||||
Button save = (Button) findViewById(R.id.button);
|
final Shop s = getArguments().getParcelable("shop");
|
||||||
|
|
||||||
|
ListView hList = (ListView) getView().findViewById(R.id.horaires_list);
|
||||||
|
FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.fab);
|
||||||
|
Button save = (Button) getView().findViewById(R.id.button);
|
||||||
|
|
||||||
h = new ArrayList<Horaires>();
|
h = new ArrayList<Horaires>();
|
||||||
|
|
||||||
initializeHoraires();
|
initializeHoraires();
|
||||||
|
|
||||||
final UpdateAdapter adapter = new UpdateAdapter(this, h, getFragmentManager());
|
final UpdateAdapter adapter = new UpdateAdapter(getActivity().getApplicationContext(), h, getActivity().getFragmentManager());
|
||||||
|
|
||||||
hList.setAdapter(adapter);
|
hList.setAdapter(adapter);
|
||||||
|
|
||||||
@ -137,7 +147,7 @@ public class ShopUpdate extends OptionsActivity {
|
|||||||
protected void onPostExecute(String string) {
|
protected void onPostExecute(String string) {
|
||||||
loading.setVisibility(View.GONE);
|
loading.setVisibility(View.GONE);
|
||||||
super.onPostExecute(string);
|
super.onPostExecute(string);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.success_update_shop), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.success_update_shop), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.amine.horaires.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.GestureDetector;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
|
||||||
|
private OnItemClickListener mListener;
|
||||||
|
|
||||||
|
public interface OnItemClickListener {
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
}
|
||||||
|
|
||||||
|
GestureDetector mGestureDetector;
|
||||||
|
|
||||||
|
public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
|
||||||
|
mListener = listener;
|
||||||
|
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@Override public boolean onSingleTapUp(MotionEvent e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
|
||||||
|
View childView = view.findChildViewUnder(e.getX(), e.getY());
|
||||||
|
if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
|
||||||
|
mListener.onItemClick(childView, view.getChildPosition(childView));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) { }
|
||||||
|
|
||||||
|
@Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package com.amine.horaires.util;
|
package com.amine.horaires.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -10,6 +13,10 @@ import java.net.URLEncoder;
|
|||||||
public class Utils {
|
public class Utils {
|
||||||
public static URL generateUrlForTextLocation(String name, String location) {
|
public static URL generateUrlForTextLocation(String name, String location) {
|
||||||
try {
|
try {
|
||||||
|
System.out.print(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")));
|
||||||
return new URL(Configuration.getAPIUrl() + "/api?key="
|
return new URL(Configuration.getAPIUrl() + "/api?key="
|
||||||
+ Configuration.key + "&h=" + Configuration.hashtag
|
+ Configuration.key + "&h=" + Configuration.hashtag
|
||||||
+ "&get=shops" + "&loc=" + URLEncoder.encode(location, "ISO-8859-1")
|
+ "&get=shops" + "&loc=" + URLEncoder.encode(location, "ISO-8859-1")
|
||||||
@ -63,4 +70,12 @@ public class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkDeviceConnected(Context context) {
|
||||||
|
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
// Need permission : android.permission.ACCESS_NETWORK_STATE
|
||||||
|
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
|
||||||
|
|
||||||
|
return (networkInfo != null && networkInfo.isConnected());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
26
Les Horaires/src/main/res/layout/activity_detail_shop.xml
Normal file
26
Les Horaires/src/main/res/layout/activity_detail_shop.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<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"
|
||||||
|
fab:fab_colorNormal="@color/accent"
|
||||||
|
fab:fab_colorPressed="@color/primary_dark" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,43 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_height="fill_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:background="@color/background"
|
android:background="@color/background"
|
||||||
tools:context="${relativePackage}.${activSityClass}">
|
tools:context="${relativePackage}.${activSityClass}">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<FrameLayout
|
||||||
android:id="@+id/favs_list"
|
android:id="@+id/fragmentContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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
|
<com.melnykov.fab.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_gravity="bottom|right"
|
android:layout_gravity="bottom|right"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:src="@mipmap/plus"
|
fab:fab_colorNormal="@color/accent"
|
||||||
fab:fab_colorNormal="@color/accent"
|
android:src="@mipmap/plus"
|
||||||
fab:fab_colorPressed="@color/primary_dark"/>
|
fab:fab_colorPressed="@color/primary_dark"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
23
Les Horaires/src/main/res/layout/activity_search.xml
Normal file
23
Les Horaires/src/main/res/layout/activity_search.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<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"
|
||||||
|
fab:fab_colorNormal="@color/accent"
|
||||||
|
android:src="@mipmap/plus"
|
||||||
|
fab:fab_colorPressed="@color/primary_dark"/>
|
||||||
|
</RelativeLayout>
|
12
Les Horaires/src/main/res/layout/activity_update_shop.xml
Normal file
12
Les Horaires/src/main/res/layout/activity_update_shop.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
31
Les Horaires/src/main/res/layout/card_shop_item.xml
Normal file
31
Les Horaires/src/main/res/layout/card_shop_item.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/card_view"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
card_view:cardCornerRadius="4dp"
|
||||||
|
card_view:contentPadding="20dp">
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shop_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/primary"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shop_adress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/primary_dark"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</android.support.v7.widget.CardView>
|
@ -1,36 +0,0 @@
|
|||||||
<?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>
|
|
148
Les Horaires/src/main/res/layout/fragment_detail_shop.xml
Normal file
148
Les Horaires/src/main/res/layout/fragment_detail_shop.xml
Normal 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>
|
29
Les Horaires/src/main/res/layout/fragment_list_shops.xml
Normal file
29
Les Horaires/src/main/res/layout/fragment_list_shops.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/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:textColor="@color/primary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
111
Les Horaires/src/main/res/layout/fragment_search.xml
Normal file
111
Les Horaires/src/main/res/layout/fragment_search.xml
Normal 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="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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/text_form_search"/>
|
||||||
|
|
||||||
|
<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/text_form_search"/>
|
||||||
|
|
||||||
|
<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="@color/progressWheelColor"
|
||||||
|
wheel:matProg_progressIndeterminate="true"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
63
Les Horaires/src/main/res/layout/fragment_update_shop.xml
Normal file
63
Les Horaires/src/main/res/layout/fragment_update_shop.xml
Normal 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="@color/background"
|
||||||
|
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="@color/progressWheelColor"
|
||||||
|
wheel:matProg_progressIndeterminate="true"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -1,148 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,111 +0,0 @@
|
|||||||
<?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="@color/progressWheelColor"
|
|
||||||
wheel:matProg_progressIndeterminate="true"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -7,4 +7,5 @@
|
|||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
|
android:background="@color/background"
|
||||||
android:textColor="@color/text_dark"/>
|
android:textColor="@color/text_dark"/>
|
@ -2,7 +2,7 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="72sp"
|
android:layout_height="72sp"
|
||||||
android:background="#ffffff"
|
android:background="@color/background"
|
||||||
android:gravity="center_vertical|center|center_horizontal"
|
android:gravity="center_vertical|center|center_horizontal"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
@ -22,6 +22,7 @@
|
|||||||
android:layout_weight=".3"
|
android:layout_weight=".3"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
|
android:background="@color/background"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:textColor="@color/text_dark"/>
|
android:textColor="@color/text_dark"/>
|
||||||
|
|
||||||
@ -32,6 +33,7 @@
|
|||||||
android:layout_weight=".3"
|
android:layout_weight=".3"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
|
android:background="@color/background"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/text_dark"/>
|
android:textColor="@color/text_dark"/>
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
<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="@color/progressWheelColor"
|
|
||||||
wheel:matProg_progressIndeterminate="true"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -27,7 +27,10 @@
|
|||||||
<string name="contact">Contacter le dev</string>
|
<string name="contact">Contacter le dev</string>
|
||||||
<string name="time_slot_error">Merci d\'utiliser des tranches de 5 minutes maximum</string>
|
<string name="time_slot_error">Merci d\'utiliser des tranches de 5 minutes maximum</string>
|
||||||
<string name="success_update_shop">Mise à jour effectuée!</string>
|
<string name="success_update_shop">Mise à jour effectuée!</string>
|
||||||
|
<string name="resultatRechercheVide">Aucun résultat n\'a été trouvé</string>
|
||||||
<string name="fail_localize_user">Petit soucis lors de la localisation</string>
|
<string name="fail_localize_user">Petit soucis lors de la localisation</string>
|
||||||
|
<string name="fail_fill_form">Oops. Préciser ce que vous rechercher d\'abord</string>
|
||||||
|
<string name="fail_connexion">Oops. Aucune connexion à internet. Utilisez vos favoris</string>
|
||||||
<string-array name="days_arrays">
|
<string-array name="days_arrays">
|
||||||
<item>Lundi</item>
|
<item>Lundi</item>
|
||||||
<item>Mardi</item>
|
<item>Mardi</item>
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
<color name="accent">#ffab00</color>
|
<color name="accent">#ffab00</color>
|
||||||
<color name="text_primary">#FFFFFF</color>
|
<color name="text_primary">#FFFFFF</color>
|
||||||
<color name="text_dark">#000000</color>
|
<color name="text_dark">#000000</color>
|
||||||
|
<color name="text_card">#000000</color>
|
||||||
|
<color name="text_form_search">#9c27b0</color>
|
||||||
|
<color name="text_white">#FFFFFF</color>
|
||||||
<color name="background">#EEEEEE</color>
|
<color name="background">#EEEEEE</color>
|
||||||
<color name="progressWheelColor">#5588FF</color>
|
<color name="progressWheelColor">#5588FF</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user