Skip to content

Commit

Permalink
Merge pull request #172 from xTeamTEICM/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
kostasmantz authored Jan 15, 2018
2 parents 92920d3 + 165a0f9 commit 7a7a0a0
Show file tree
Hide file tree
Showing 39 changed files with 234 additions and 374 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled true
}
debug {
testCoverageEnabled true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,39 @@
import org.junit.Test;

import eu.jnksoftware.discountfinderandroid.R;
import eu.jnksoftware.discountfinderandroid.ui.general.Login;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

public class MenuCustomerTest {

/*@Rule
public ActivityTestRule<MenuCustomer> menuCustomerActivityTestRule = new ActivityTestRule<>(MenuCustomer.class);
@Rule
public ActivityTestRule<Login> menuCustomerActivityTestRule = new ActivityTestRule<>(Login.class);

@Before
public void setUp() throws Exception {
}

@Test
public void menuCustomerComponentsDisplayed(){
onView(withId(R.id.tvNewDiscounts)).check(matches(isDisplayed()));
onView(withId(R.id.filtersBtn)).check(matches(isDisplayed()));
onView(withId(R.id.settingsBtn)).check(matches(isDisplayed()));
// onView(withId(R.id.showDiscountsButton)).check(matches(isDisplayed()));
onView(withId(R.id.aboutBtn)).check(matches(isDisplayed()));
onView(withId(R.id.showShopsButton)).check(matches(isDisplayed()));
public void menuCustomerComponentsDisplayed() throws InterruptedException {
onView(withId(R.id.loginEMailField)).perform(typeText("[email protected]"),closeSoftKeyboard());
onView(withId(R.id.loginPasswordField)).perform(typeText("myPassword"),closeSoftKeyboard());
onView(withId(R.id.loginBtn)).perform(click());
Thread.sleep(5000);
onView(withId(R.id.menuCustomerDiscountsButton)).check(matches(isDisplayed()));
onView(withId(R.id.menuCustomerPreferenceButton)).check(matches(isDisplayed()));
onView(withId(R.id.menuCustomerAboutButton)).check(matches(isDisplayed()));
onView(withId(R.id.tvMenuCustomerTopDiscounts)).check(matches(isDisplayed()));
}

@Test
public void testShopsButtonClick(){
//onView(withId(R.id.showDiscountsButton)).perform(click());
// onView(withId(R.id.shopsList)).check(matches(isDisplayed()));
}
@Test
public void testAboutButtonClick(){
onView(withId(R.id.aboutBtn)).perform(click());
onView(withText("Copyright Alright Reserved")).check(matches(isDisplayed()));
}
@After
public void tearDown() throws Exception {
}
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.clearText;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
Expand Down Expand Up @@ -56,9 +57,9 @@ public void checkBlankLastName(){
}

@Test
public void checkBlankEmail(){
public void checkBlankEmail() {
onView(withId(R.id.firstNameField)).perform(clearText(),typeText(firstName));
onView(withId(R.id.lastNameField)).perform(clearText(),typeText(lastName));
onView(withId(R.id.lastNameField)).perform(clearText(),typeText(lastName),closeSoftKeyboard());
onView(withId(R.id.eMailField)).perform(clearText(),typeText(""));
onView(withId(R.id.passwordField)).perform(clearText(),typeText(password));
Espresso.closeSoftKeyboard();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package eu.jnksoftware.discountfinderandroid.Apis;

import android.widget.Toast;

import com.google.gson.Gson;

import eu.jnksoftware.discountfinderandroid.Utilities.ManageSharePrefs;
import eu.jnksoftware.discountfinderandroid.models.Location;
Expand All @@ -13,9 +10,6 @@
import retrofit2.Callback;
import retrofit2.Response;

/**
* Created by makis on 21/12/2017.
*/

public class HttpCall {
private IuserService iuserService;
Expand All @@ -30,7 +24,7 @@ public int setFcmToken(FcmToken token, String auth){
call.enqueue(new Callback<Void>() {

@Override
public void onResponse(retrofit2.Call<Void> call, Response<Void> response) {
public void onResponse(retrofit2.Call<Void> call, Response<Void> response) throws NullPointerException {
if (response.isSuccessful()) {
statusCode[0] = response.code();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package eu.jnksoftware.discountfinderandroid.Apis;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitClient {
private static Retrofit retrofit=null;

public static Retrofit getClient(String url){
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(interceptor).build();

if(retrofit==null){

retrofit=new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
}
return retrofit; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Created by dito on 12/5/2017.
*/

public class UpdatePostShop {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class CustomerMenu extends AppCompatActivity
private GeoLocation location;
private boolean doubleBackPress;
private TextView navHeaderEmail;
private TextView navHeaderName;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -85,8 +84,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.customer_menu, menu);
navHeaderEmail = findViewById(R.id.tvNavHeaderUserEmail);
navHeaderName = findViewById(R.id.tvNavHeaderUserName);
setUpNavHeaderInfo(getIntent().getStringExtra("email"),"Kostas");
setUpNavHeaderInfo(getIntent().getStringExtra("email"));

return true;
}
Expand Down Expand Up @@ -189,8 +187,7 @@ public void run(){
doubleBackPress = true;
}

private void setUpNavHeaderInfo(String email,String name) {
private void setUpNavHeaderInfo(String email) {
this.navHeaderEmail.setText(email);
this.navHeaderName.setText(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ public class TopDiscount {
private String shopName;
private String category;
private String shortDescription;
private int finalPrice;
private double finalPrice;
private String productImageURL;
private int discountId;
private double shopLatPos;
private double shopLogPos;

public TopDiscount(String shortDescription, String productImage) {
this.shortDescription = shortDescription;
Expand All @@ -23,4 +21,24 @@ public String getShortDescription() {
public String getProductImage() {
return productImageURL;
}

public int getDiscountId() {
return discountId;
}

public String getShopName() {
return shopName;
}

public String getCategory() {
return category;
}

public double getFinalPrice() {
return finalPrice;
}

public String getProductImageURL() {
return productImageURL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* Created by makis on 21/12/2017.
*/

public class FcmToken {
@SerializedName("deviceToken")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -26,7 +26,6 @@
import java.util.Locale;

import eu.jnksoftware.discountfinderandroid.R;
import eu.jnksoftware.discountfinderandroid.models.Location;

public class ChooseStoreLocation extends FragmentActivity implements OnMapReadyCallback {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;


public interface IuserService {
Expand Down Expand Up @@ -60,10 +59,11 @@ public interface IuserService {
@GET("category")
Call<List<Category>> fetchCategories();

@GET("/api/discount/find/{distance}")
@GET("discount/find/{distance}")
Call<List<Discount>> getDiscounts(@Path("distance") int distance , @Header("Authorization") String auth);

@GET("/api/discount/top/{distance}")
@Headers({("Content-Type:application/json"),("Accept:application/json")})
@GET("discount/top/{distance}")
Call<List<TopDiscount>> getTopDiscounts(@Path("distance") int distance , @Header("Authorization") String auth);

@Headers({("Content-Type:application/json"),("Accept:application/json")})
Expand All @@ -82,8 +82,8 @@ public interface IuserService {


@Headers({("Content-Type:application/json"),("Accept:application/json")})
@PUT("shop")
Call<Void> updateShop(@Body UpdatePostShop updatePostShop, @Header("Authorization") String auth);
@PUT("shop/{id}")
Call<Void> updateShop(@Path("id") int id,@Body UpdatePostShop updatePostShop, @Header("Authorization") String auth);


@Headers({("Content-Type:application/json"),("Accept:application/json")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public Call<DiscountPreferencesPostResponse> postDiscountPreferences(String cate
return delegate.returningResponse(discountPreferencesPostResponse).postDiscountPreferences(category,price,tags,auth);
}





@Override
public Call<List<DiscountPreferencesResponse>> getDiscountsPreference(String auth) {
List<DiscountPreferencesResponse> preferencesResponses=new ArrayList<>();
Expand Down Expand Up @@ -136,8 +132,8 @@ public Call<Void> addShop(PostShop postShop, String auth) {
}

@Override
public Call<Void> updateShop(UpdatePostShop updatePostShop, String auth) {
return delegate.returningResponse(null).updateShop(updatePostShop,auth);
public Call<Void> updateShop(int id,UpdatePostShop updatePostShop, String auth) {
return delegate.returningResponse(null).updateShop(id,updatePostShop,auth);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package eu.jnksoftware.discountfinderandroid.services;

import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.json.JSONException;
import org.json.JSONObject;

import eu.jnksoftware.discountfinderandroid.Apis.HttpCall;
import eu.jnksoftware.discountfinderandroid.Utilities.ManageSharePrefs;
import eu.jnksoftware.discountfinderandroid.models.token.FcmToken;
import eu.jnksoftware.discountfinderandroid.models.token.User;
import eu.jnksoftware.discountfinderandroid.ui.general.Login;


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.jnksoftware.discountfinderandroid.ui.customer;

import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
Expand All @@ -10,13 +9,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import eu.jnksoftware.discountfinderandroid.Apis.ApiUtils;
import eu.jnksoftware.discountfinderandroid.R;
import eu.jnksoftware.discountfinderandroid.Utilities.ManageSharePrefs;
import eu.jnksoftware.discountfinderandroid.models.discounts.TopDiscount;
import eu.jnksoftware.discountfinderandroid.services.IuserService;
import eu.jnksoftware.discountfinderandroid.ui.customer.adapters.TopDiscountAdapter;
Expand All @@ -29,7 +27,7 @@ public class MenuCustomer extends Fragment {
private IuserService iuserService;
private String auth;
private RecyclerView topDiscountsRecycler;
private TopDiscountAdapter topDiscountAdapter;

private List<TopDiscount> topDiscounts;

@Nullable
Expand All @@ -44,16 +42,6 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
auth = getArguments().getString("auth");
topDiscountsRecycler = view.findViewById(R.id.topDiscountsRecyclerView);
iuserService= ApiUtils.getUserService();

// SEE WHATS WITH THIS,FROM MERGE
// myLocation =ManageSharePrefs.readLocation("");
// if (myLocation==null) {
// Toast.makeText(getApplicationContext(), "No location ", Toast.LENGTH_LONG).show();
// GeoLocation myGeoloc =new GeoLocation();
// myLocation.setLogPos(myGeoloc.getLongitude());
// myLocation.setLatPos(myGeoloc.getLatitude());
// }
// ManageSharePrefs.writeLocation(myLocation);
setUpRecycler();
topDiscounts = new ArrayList<>();
getTopDiscounts();
Expand All @@ -64,7 +52,6 @@ public void setUpRecycler(){
manager.setOrientation(LinearLayoutManager.HORIZONTAL);
topDiscountsRecycler.setLayoutManager(manager);
topDiscountsRecycler.setItemAnimator(new DefaultItemAnimator());
// topDiscountsRecycler.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
topDiscountsRecycler.setHasFixedSize(true);
}

Expand All @@ -88,4 +75,5 @@ public void onFailure(Call<List<TopDiscount>> call, Throwable t) {
});
}


}
Loading

0 comments on commit 7a7a0a0

Please sign in to comment.