profile actions

This commit is contained in:
cimenmus
2017-10-25 00:07:05 +03:00
parent 95da99ba07
commit 40a660239c
25 changed files with 967 additions and 210 deletions

2
.idea/misc.xml generated
View File

@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.pizzalink.android">
<uses-permission android:name="android.permission.INTERNET" />
@@ -13,39 +12,36 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.WelcomeActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.LoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.RegisterActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.OrderActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.ForgotPasswordActivity"
android:screenOrientation="portrait" />
<activity android:name=".activity.MyAddressesActivity" />
<activity android:name=".activity.UpdatePasswordActivity" />
<activity android:name=".activity.AddAddressActivity"></activity>
</application>
</manifest>

View File

@@ -0,0 +1,15 @@
package ch.pizzalink.android.activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import ch.pizzalink.android.R;
public class AddAddressActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_address);
}
}

View File

@@ -0,0 +1,161 @@
package ch.pizzalink.android.activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.adapter.recycler.MyAddressesRecyclerAdapter;
import ch.pizzalink.android.api.ApiEndPoints;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseArray;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.AddressModel;
import ch.pizzalink.android.model.DeleteAddressResponseModel;
import ch.pizzalink.android.view.PizzalinkToolbar;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MyAddressesActivity extends BaseActivity {
@BindView(R.id.myAddressesToolbar) PizzalinkToolbar myAddressesToolbar;
@BindView(R.id.myAddressesRecyclerView) RecyclerView myAddressesRecyclerView;
@BindView(R.id.addNewAddressButton) Button addNewAddressButton;
@BindString(R.string.alert_delete_address) String deleteAddressAlertText;
@BindString(R.string.address_deleted) String addressDeletedText;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private MyAddressesRecyclerAdapter addressesRecyclerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_addresses);
ButterKnife.bind(this);
initViews();
getCustomerAddresses();
}
@OnClick(R.id.addNewAddressButton)
public void onClick(){
startActivity(new Intent(this, AddAddressActivity.class));
}
private void initViews(){
myAddressesToolbar.setBackIconClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
initRecyclerView();
}
private void getCustomerAddresses(){
DialogHelper.showLoadingDialog();
Call<ResponseArray<AddressModel>> call = ApiService.apiInterface.getCustomerAddresses(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseArray<AddressModel>>() {
@Override
public void onResponse(Call<ResponseArray<AddressModel>> call, Response<ResponseArray<AddressModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
fillAndNotifyAdapter(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseArray<AddressModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void fillAndNotifyAdapter(ArrayList<AddressModel> addressModels){
AddressModel.checkNull(addressModels);
addressList.clear();
addressList.addAll(addressModels);
addressesRecyclerAdapter.notifyDataSetChanged();
}
private void initRecyclerView(){
addressesRecyclerAdapter = new MyAddressesRecyclerAdapter(addressList, new RecyclerItemClickListener() {
@Override
public void onItemClick(View view, final int position) {
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, deleteAddressAlertText,
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
deleteAddress(position);
}
},
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
});
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
myAddressesRecyclerView.setLayoutManager(layoutManager);
myAddressesRecyclerView.setAdapter(addressesRecyclerAdapter);
}
private void deleteAddress(final int position){
DialogHelper.hideLoadingDialog();
Call<ResponseObject<DeleteAddressResponseModel>> call = ApiService.apiInterface.deleteAddress(
ApiEndPoints.API_DELETE_ADDRESS + SessionHelper.getCustomerToken().getToken(),
addressList.get(position).getId());
call.enqueue(new Callback<ResponseObject<DeleteAddressResponseModel>>() {
@Override
public void onResponse(Call<ResponseObject<DeleteAddressResponseModel>> call, Response<ResponseObject<DeleteAddressResponseModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body() != null &&
response.body().isSuccess()){
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, addressDeletedText);
addressList.remove(position);
addressesRecyclerAdapter.notifyDataSetChanged();
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<DeleteAddressResponseModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
}

View File

@@ -0,0 +1,115 @@
package ch.pizzalink.android.activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.HashMap;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.api.ApiEndPoints;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.helper.ViewHelper;
import ch.pizzalink.android.view.PizzalinkEditText;
import ch.pizzalink.android.view.PizzalinkToolbar;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UpdatePasswordActivity extends BaseActivity {
@BindView(R.id.updatePasswordToolbar) PizzalinkToolbar updatePasswordToolbar;
@BindView(R.id.oldPasswordPizzalinkEditText) PizzalinkEditText oldPasswordPizzalinkEditText;
@BindView(R.id.newPasswordPizzalinkEditText) PizzalinkEditText newPasswordPizzalinkEditText;
@BindView(R.id.confirmNewPasswordPizzalinkEditText) PizzalinkEditText confirmNewPasswordPizzalinkEditText;
@BindView(R.id.updatePasswordButton) Button updatePasswordButton;
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
@BindString(R.string.alert_passwords_not_matched) String passwordsNotMatchedText;
@BindString(R.string.password_updated) String passwordUpdatedText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_password);
ButterKnife.bind(this);
initViews();
}
@OnClick(R.id.updatePasswordButton)
protected void onClick(){
ViewHelper.hideKeyboard();
if(checkFields())
updatePassword();
}
private void initViews(){
updatePasswordToolbar.setBackIconClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
}
private boolean checkFields(){
if(oldPasswordPizzalinkEditText.isEmpty() ||
newPasswordPizzalinkEditText.isEmail() ||
confirmNewPasswordPizzalinkEditText.isEmpty()){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, fillAllFieldsText);
return false;
}
if(!newPasswordPizzalinkEditText.getText().equals(confirmNewPasswordPizzalinkEditText.getText())){
DialogHelper.showAlertDialog(BaseActivity.currentActivity, passwordsNotMatchedText);
return false;
}
return true;
}
private void updatePassword(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.updatePassword(
ApiEndPoints.API_UPDATE_PASSWORD + SessionHelper.getCustomerToken().getToken(),
getUpdatePasswordRequestParams());
call.enqueue(new Callback<ResponseObject>() {
@Override
public void onResponse(Call<ResponseObject> call, Response<ResponseObject> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
DialogHelper.showDialogWithPositiveButton(BaseActivity.currentActivity, passwordUpdatedText);
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private HashMap<String, Object> getUpdatePasswordRequestParams(){
HashMap<String, Object> params = new HashMap<>();
params.put("oldPassword", oldPasswordPizzalinkEditText.getText());
params.put("password", newPasswordPizzalinkEditText.getText());
params.put("confirm", confirmNewPasswordPizzalinkEditText.getText());
return params;
}
}

View File

@@ -0,0 +1,117 @@
package ch.pizzalink.android.adapter.recycler;
import android.support.v7.widget.AppCompatRadioButton;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import ch.pizzalink.android.R;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.AddressModel;
/**
* Created by cimenmus on 24.10.2017.
*/
public class MyAddressesRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private final int HOLDER_ADDRESS = 0;
private final int HOLDER_SPACE = 1;
private ArrayList<AddressModel> addressList = new ArrayList<>();
private RecyclerItemClickListener recyclerItemClickListener;
public static class OrderViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.addressTextView) TextView addressTextView;
@BindView(R.id.deleteAddressImageView) ImageView deleteAddressImageView;
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
super(view);
ButterKnife.bind(this, view);
deleteAddressImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(recyclerItemClickListener != null)
recyclerItemClickListener.onItemClick(deleteAddressImageView, getAdapterPosition());
}
});
}
}
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
public SpaceViewHolder(final View view) {
super(view);
}
}
@Override
public int getItemViewType(int position) {
if(position == addressList.size())
return HOLDER_SPACE;
return HOLDER_ADDRESS;
}
public MyAddressesRecyclerAdapter(ArrayList<AddressModel> addressList,
RecyclerItemClickListener recyclerItemClickListener){
this.addressList = addressList;
this.recyclerItemClickListener = recyclerItemClickListener;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
RecyclerView.ViewHolder viewHolder;
View view;
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
switch (viewType){
case HOLDER_ADDRESS:
view = inflater.inflate(R.layout.row_my_address, viewGroup, false);
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
break;
case HOLDER_SPACE:
view = inflater.inflate(R.layout.row_space, viewGroup, false);
viewHolder = new SpaceViewHolder(view);
break;
default:
view = inflater.inflate(R.layout.row_my_address, viewGroup, false);
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case HOLDER_ADDRESS :
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
orderViewHolder.addressTextView.setText(addressList.get(position).getAddress());
break;
case HOLDER_SPACE :
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
break;
}
}
@Override
public int getItemCount() {
return addressList.size() + 1 ;
}
}

View File

@@ -23,5 +23,7 @@ public class ApiEndPoints {
public static final String API_FORGOT_PASSWORD = PREFIX + "forgotPassword" + SUFFIX;
public static final String API_GET_ZONE_LIST = PREFIX + "getCities" + SUFFIX;
public static final String API_GET_COUNTRY_LIST = PREFIX + "getCountries" + SUFFIX;
public static final String API_GET_CUSTOMER_PROFILE = PREFIX + "getCustomerInfo" + SUFFIX;
public static final String API_UPDATE_PASSWORD = PREFIX + "passwordUpdate" + SUFFIX + "&token=";
public static final String API_DELETE_ADDRESS = PREFIX + "deleteAddress" + SUFFIX + "&token=";
}

View File

@@ -22,7 +22,7 @@ public class ApiErrorUtils {
BaseResponse baseResponse = (BaseResponse) response.body();
if(baseResponse.getErrorCode() == ApiConstants.APP_ERROR_CODE_AUTHORIZATION){
if(baseResponse != null &&baseResponse.getErrorCode() == ApiConstants.APP_ERROR_CODE_AUTHORIZATION){
SharedPrefsHelper.clearCustomerInfo();
SharedPrefsHelper.clearCustomerToken();
SharedPrefsHelper.setCustomerLoggedIn(false);

View File

@@ -6,6 +6,7 @@ import ch.pizzalink.android.model.AddProductToBasketResponseModel;
import ch.pizzalink.android.model.AddressModel;
import ch.pizzalink.android.model.AppVersionModel;
import ch.pizzalink.android.model.CountryModel;
import ch.pizzalink.android.model.DeleteAddressResponseModel;
import ch.pizzalink.android.model.PaymentMethodModel;
import ch.pizzalink.android.model.PaymentMethodsResponseModel;
import ch.pizzalink.android.model.ShippingMethodModel;
@@ -112,5 +113,17 @@ public interface ApiInterface {
@GET(ApiEndPoints.API_GET_COUNTRY_LIST)
Call<ResponseArray<CountryModel>> getCountryList();
@GET(ApiEndPoints.API_GET_CUSTOMER_PROFILE)
Call<ResponseObject<UserModel>> getCustomerProfile(@Query("token") String token);
@FormUrlEncoded
@POST
Call<ResponseObject> updatePassword(@Url String url, @FieldMap HashMap<String, Object> body);
@FormUrlEncoded
@POST
Call<ResponseObject<DeleteAddressResponseModel>> deleteAddress(@Url String url,
@Field("address_id") String addressId);
}

View File

@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
@@ -18,12 +19,16 @@ import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.LoginActivity;
import ch.pizzalink.android.activity.MyAddressesActivity;
import ch.pizzalink.android.activity.UpdatePasswordActivity;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.helper.SharedPrefsHelper;
import ch.pizzalink.android.model.UserModel;
import ch.pizzalink.android.view.PizzalinkInfoView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -34,12 +39,17 @@ import retrofit2.Response;
public class ProfileFragment extends BaseFragment {
@BindView(R.id.logoutButton) Button logoutButton;
@BindView(R.id.firstnamePizzalinkInfoLayout) PizzalinkInfoView firstnamePizzalinkInfoLayout;
@BindView(R.id.lastnamePizzalinkInfoLayout) PizzalinkInfoView lastnamePizzalinkInfoLayout;
@BindView(R.id.emailPizzalinkInfoLayout) PizzalinkInfoView emailPizzalinkInfoLayout;
@BindView(R.id.phonePizzalinkInfoLayout) PizzalinkInfoView phonePizzalinkInfoLayout;
@BindView(R.id.myAddressesLayout) RelativeLayout myAddressesLayout;
@BindView(R.id.updatePasswordLayout) RelativeLayout updatePasswordLayout;
@BindView(R.id.logoutLayout) RelativeLayout logoutLayout;
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
@BindString(R.string.alert_logout) String logoutAlertText;
public static final java.lang.String FRAGMENT_NAME = "profileFragment";
public ProfileFragment() {}
@@ -58,11 +68,20 @@ public class ProfileFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_profile, container, false);
ButterKnife.bind(this, view);
initViews();
getCustomerProfile();
return view;
}
@OnClick(R.id.logoutButton)
@OnClick({R.id.myAddressesLayout, R.id.updatePasswordLayout, R.id.logoutLayout})
public void onClick(View view){
switch (view.getId()){
case R.id.myAddressesLayout:
startActivity(new Intent(BaseActivity.currentActivity, MyAddressesActivity.class));
break;
case R.id.updatePasswordLayout:
startActivity(new Intent(BaseActivity.currentActivity, UpdatePasswordActivity.class));
break;
case R.id.logoutLayout:
DialogHelper.showTwoButtonsDialog(BaseActivity.currentActivity, logoutAlertText,
new MaterialDialog.SingleButtonCallback() {
@Override
@@ -75,13 +94,51 @@ public class ProfileFragment extends BaseFragment {
dialog.dismiss();
}
});
break;
}
}
private void initViews(){
setPizzalinkToolbarFields(false, fragmentTitle);
}
private void getCustomerProfile(){
DialogHelper.showLoadingDialog();
Call<ResponseObject<UserModel>> call = ApiService.apiInterface.getCustomerProfile(
SessionHelper.getCustomerToken().getToken());
call.enqueue(new Callback<ResponseObject<UserModel>>() {
@Override
public void onResponse(Call<ResponseObject<UserModel>> call, Response<ResponseObject<UserModel>> response) {
DialogHelper.hideLoadingDialog();
if(response.isSuccessful() &&
response.body().getData() != null &&
response.body().isSuccess()){
setFields(response.body().getData());
}
else {
ApiErrorUtils.parseError(response);
}
}
@Override
public void onFailure(Call<ResponseObject<UserModel>> call, Throwable t) {
DialogHelper.hideLoadingDialog();
DialogHelper.showFailedDialog();
}
});
}
private void setFields(UserModel user){
user.checkNull();
SessionHelper.saveCustomer(user);
firstnamePizzalinkInfoLayout.setText(user.getFirstname());
lastnamePizzalinkInfoLayout.setText(user.getLastname());
emailPizzalinkInfoLayout.setText(user.getEmail());
phonePizzalinkInfoLayout.setText(user.getTelephone());
}
private void logOutOnWeb(){
DialogHelper.showLoadingDialog();
Call<ResponseObject> call = ApiService.apiInterface.logout(SessionHelper.getCustomerToken().getToken());

View File

@@ -21,6 +21,7 @@ import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.helper.SharedPrefsHelper;
import ch.pizzalink.android.view.PizzalinkInfoView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -31,11 +32,11 @@ import retrofit2.Response;
public class OrderSummaryFragment extends OrderBaseFragment {
@BindView(R.id.orderPersonFullnameTextView) TextView orderPersonFullnameTextView;
@BindView(R.id.orderShippingMethodTextView) TextView orderShippingMethodTextView;
@BindView(R.id.orderShippingAddressTextView) TextView orderShippingAddressTextView;
@BindView(R.id.orderPaymentMethodTextView) TextView orderPaymentMethodTextView;
@BindView(R.id.orderTotalTextView) TextView orderTotalTextView;
@BindView(R.id.orderPersonFullnamePizzalinkInfoLayout) PizzalinkInfoView orderPersonFullnamePizzalinkInfoLayout;
@BindView(R.id.orderShippingMethodPizzalinkInfoLayout) PizzalinkInfoView orderShippingMethodPizzalinkInfoLayout;
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout) PizzalinkInfoView orderShippingAddressPizzalinkInfoLayout;
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout) PizzalinkInfoView orderPaymentMethodPizzalinkInfoLayout;
@BindView(R.id.orderTotalPizzalinkInfoLayout) PizzalinkInfoView orderTotalPizzalinkInfoLayout;
@BindString(R.string.confirm_order) String confirmOrderText;
@@ -80,11 +81,11 @@ public class OrderSummaryFragment extends OrderBaseFragment {
orderActivity = (OrderActivity) getActivity();
orderPersonFullnameTextView.setText(SessionHelper.getUser().getFullname());
orderShippingMethodTextView.setText(orderActivity.getSelectedShippingMethod().getTitle());
orderShippingAddressTextView.setText(orderActivity.getSelectedShippingAddress().getAddress());
orderPaymentMethodTextView.setText(orderActivity.getSelectedPaymentMethod().getTitle());
orderTotalTextView.setText(orderActivity.getCartInfo().getTotals().get(0).getText());
orderPersonFullnamePizzalinkInfoLayout.setText(SessionHelper.getUser().getFullname());
orderShippingMethodPizzalinkInfoLayout.setText(orderActivity.getSelectedShippingMethod().getTitle());
orderShippingAddressPizzalinkInfoLayout.setText(orderActivity.getSelectedShippingAddress().getAddress());
orderPaymentMethodPizzalinkInfoLayout.setText(orderActivity.getSelectedPaymentMethod().getTitle());
orderTotalPizzalinkInfoLayout.setText(orderActivity.getCartInfo().getTotals().get(0).getText());
}
private void createOrder(){

View File

@@ -132,7 +132,6 @@ public class DialogHelper {
}
})
.show();
}
public static void showPasswordResetDialog(final Context context) {

View File

@@ -0,0 +1,18 @@
package ch.pizzalink.android.model;
/**
* Created by cimenmus on 24.10.2017.
*/
public class DeleteAddressResponseModel {
private String address_id;
public String getAddress_id() {
return address_id;
}
public void setAddress_id(String address_id) {
this.address_id = address_id;
}
}

View File

@@ -10,6 +10,7 @@ import com.google.gson.annotations.SerializedName;
public class UserModel {
@Expose @SerializedName("customer_id") private String id;
@Expose @SerializedName("address_id") private String addressId;
private String firstname;
private String lastname;
private String email;
@@ -21,6 +22,9 @@ public class UserModel {
if(id == null)
id = "";
if(addressId == null)
addressId = "";
if(firstname == null)
firstname = "";
@@ -49,6 +53,14 @@ public class UserModel {
this.id = id;
}
public String getAddressId() {
return addressId;
}
public void setAddressId(String addressId) {
this.addressId = addressId;
}
public String getFirstname() {
return firstname;
}

View File

@@ -3,7 +3,6 @@ package ch.pizzalink.android.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@@ -11,7 +10,6 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

View File

@@ -0,0 +1,60 @@
package ch.pizzalink.android.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import ch.pizzalink.android.R;
/**
* Created by cimenmus on 24.10.2017.
*/
public class PizzalinkInfoView extends LinearLayout {
private View rootView;
private TextView descriptionTextView;
private TextView textview;
private String description;
private String text;
public PizzalinkInfoView(Context context) {
super(context);
init(context);
}
public PizzalinkInfoView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PizzalinkInfoView, 0, 0);
try {
description = a.getString(R.styleable.PizzalinkInfoView_description);
text = a.getString(R.styleable.PizzalinkInfoView_infoText);
} finally {
a.recycle();
}
init(context);
}
private void init(Context context) {
rootView = inflate(context, R.layout.layout_pizzalink_view, this);
descriptionTextView = (TextView) rootView.findViewById(R.id.descriptionTextView);
textview = (TextView) rootView.findViewById(R.id.infoTextView);
if(description == null)
description = "";
if(text == null)
text = "";
descriptionTextView.setText(description);
textview.setText(text);
}
public String getText(){
return textview.getText().toString().trim();
}
public void setText(String text){
textview.setText(text);
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ch.pizzalink.android.activity.AddAddressActivity">
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="ch.pizzalink.android.activity.MyAddressesActivity">
<ch.pizzalink.android.view.PizzalinkToolbar
android:id="@+id/myAddressesToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/my_addresses"
android:background="@color/white"
app:showBackIcon="true"
app:titleTextColor="@color/black" />
<android.support.v7.widget.RecyclerView
android:id="@+id/myAddressesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/myAddressesToolbar"
android:layout_above="@+id/addNewAddressButton"/>
<Button
android:id="@+id/addNewAddressButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
style="@style/PizzalinkButton"
android:text="@string/add_new_address"
android:layout_alignParentBottom="true"/>
</RelativeLayout>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context="ch.pizzalink.android.activity.UpdatePasswordActivity">
<ch.pizzalink.android.view.PizzalinkToolbar
android:id="@+id/updatePasswordToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/activity_title_update_password"
android:background="@color/white"
app:showBackIcon="true"
app:titleTextColor="@color/black" />
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/oldPasswordPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:inputType="password"
app:hint="@string/hint_old_password"/>
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/newPasswordPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:inputType="password"
app:hint="@string/hint_new_password"/>
<ch.pizzalink.android.view.PizzalinkEditText
android:id="@+id/confirmNewPasswordPizzalinkEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:inputType="password"
app:hint="@string/hint_confirm_new_password"/>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="16dp" />
<Button
android:id="@+id/updatePasswordButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
style="@style/PizzalinkButton"
android:text="@string/update_app" />
</LinearLayout>

View File

@@ -1,6 +1,6 @@
<?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:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -19,151 +19,35 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderPersonFullnamePizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/order_person_fullname"
android:textStyle="bold"
android:textSize="12sp"
android:textColor="@color/heater"/>
app:description="@string/order_person_fullname" />
<TextView
android:id="@+id/orderPersonFullnameTextView"
android:layout_width="wrap_content"
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderShippingMethodPizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aytaç Cici"
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textColor="@color/black"/>
app:description="@string/order_shipping_method" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<TextView
android:layout_width="wrap_content"
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderShippingAddressPizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/order_shipping_method"
android:textStyle="bold"
android:textSize="12sp"
android:textColor="@color/heater"/>
app:description="@string/order_shipping_address" />
<TextView
android:id="@+id/orderShippingMethodTextView"
android:layout_width="wrap_content"
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderPaymentMethodPizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Selber Abholen"
android:textColor="@color/black"
android:layout_marginTop="4dp"
android:textStyle="bold" />
app:description="@string/order_payment_method" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<TextView
android:layout_width="wrap_content"
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/orderTotalPizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/order_shipping_address"
android:textStyle="bold"
android:textSize="12sp"
android:textColor="@color/heater"/>
<TextView
android:id="@+id/orderShippingAddressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="Aytaç Cici A Street B. Avanue 1004 ABC Schweiz"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_payment_method"
android:textColor="@color/heater"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="@+id/orderPaymentMethodTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kreditkarten-Kartenzahlung"
android:textColor="@color/black"
android:layout_marginTop="4dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_total"
android:textColor="@color/heater"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="@+id/orderTotalTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="CHF 30.00"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
app:description="@string/order_total" />
</LinearLayout>

View File

@@ -1,26 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/actvity_default_background_color_1">
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/firstnamePizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/profile_firstname" />
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/lastnamePizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/profile_lastname" />
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/emailPizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/profile_email" />
<ch.pizzalink.android.view.PizzalinkInfoView
android:id="@+id/phonePizzalinkInfoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:description="@string/profile_telephone" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
<RelativeLayout
android:id="@+id/myAddressesLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile Fragment"
android:layout_centerInParent="true"
android:textColor="@color/black"/>
android:text="@string/my_addresses"
android:layout_marginTop="4dp"
android:textColor="@color/black"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/arrow1"
android:layout_toStartOf="@+id/arrow1"/>
<Button
android:id="@+id/logoutButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="@string/button_logout"
style="@style/PizzalinkButton"
android:layout_alignParentBottom="true"/>
<ImageView
android:id="@+id/arrow1"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_back"
android:tint="@color/venus"
android:padding="6dp"
android:rotation="180"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
<RelativeLayout
android:id="@+id/updatePasswordLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/update_password"
android:layout_marginTop="4dp"
android:textColor="@color/black"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/arrow2"
android:layout_toStartOf="@+id/arrow2"/>
<ImageView
android:id="@+id/arrow2"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_back"
android:tint="@color/venus"
android:padding="6dp"
android:rotation="180"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
<RelativeLayout
android:id="@+id/logoutLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_logout"
android:layout_marginTop="4dp"
android:textColor="@color/black"
android:layout_centerVertical="true" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/shadow"/>
</LinearLayout>
</ScrollView>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_person_fullname"
android:textColor="@color/heater"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="@+id/infoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aytaç Cici"
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textColor="@color/black"/>
</LinearLayout>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="12dp">
<TextView
android:id="@+id/addressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="48dp"
android:layout_marginEnd="24dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/deleteAddressImageView"
android:layout_toStartOf="@+id/deleteAddressImageView"
android:layout_centerVertical="true"
android:textColor="@color/black" />
<ImageView
android:id="@+id/deleteAddressImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:src="@drawable/ic_cancel_2"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>

View File

@@ -23,4 +23,9 @@
<attr name="dropdownHint" format="string" />
</declare-styleable>
<declare-styleable name="PizzalinkInfoView">
<attr name="description" format="string" />
<attr name="infoText" format="string" />
</declare-styleable>
</resources>

View File

@@ -73,7 +73,7 @@
<!-- LoginActivity-->
<!-- ProfileFragment-->
<string name="button_logout">ÇIKIŞ YAP</string>
<string name="button_logout">Çıkış Yap</string>
<!-- ProfileFragment-->
<!-- OrderHistoryFragment-->
@@ -153,10 +153,35 @@
<string name="order_total">TOTAL</string>
<!-- OrderSummaryFragment-->
<!-- ProfileFragment-->
<string name="profile_firstname">AD</string>
<string name="profile_lastname">SOYAD</string>
<string name="profile_telephone">TELEFON NUMARASI</string>
<string name="profile_email">EMAIL</string>
<string name="my_addresses">Adreslerim</string>
<string name="update_password">Şifremi Güncelle</string>
<!-- ProfileFragment-->
<!-- OrderResultFragment-->
<string name="order_successed">Siparişiniz başarı ile alınmıştır. Siparişinizin detaylarını sipariş geçmişinden görebilir ve siparişinizi takip edebilirsiniz.</string>
<!-- OrderSummaryFragment-->
<!-- UpdatePasswordActivity-->
<string name="activity_title_update_password">Şifre Güncelle</string>
<string name="hint_old_password">Eski Şifre</string>
<string name="hint_new_password">Yeni Şifre</string>
<string name="hint_confirm_new_password">Yeni Şifre (Tekrar)</string>
<string name="password_updated">Şifreniz başarı ile güncellenmiştir.</string>
<!-- UpdatePasswordActivity-->
<!-- MyAddressesActivity-->
<string name="activity_title_my_addresses">Adreslerim</string>
<string name="add_new_address">EKLE</string>
<string name="new_address_added">Adresiniz başarı ile eklendi.</string>
<string name="alert_delete_address">Adresinizi silmek istediğinize emin misiniz?</string>
<string name="address_deleted">Adresiniz başarı ile silindi.</string>
<!-- MyAddressesActivity-->
<string-array name="stepperLabels">
<item>Shipping Method</item>
<item>Shipping Address</item>