Implementacja formularzy zamówienia

This commit is contained in:
PawelZielinski 2021-02-20 01:46:38 +01:00
parent e3a4fa9fcd
commit 3d3d2ffb23
15 changed files with 483 additions and 27 deletions

View File

@ -13,7 +13,7 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
buildTypes { buildTypes {
@ -30,9 +30,10 @@ android {
dependencies { dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.basgeekball:awesome-validation:4.2'
} }

View File

@ -1,8 +1,8 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;

View File

@ -9,7 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.PizzujemyV3"> android:theme="@style/Theme.PizzujemyV3">
<activity android:name=".CartActivity"></activity> <activity android:name=".CollectFormActivity"></activity>
<activity android:name=".DeliveryFormActivity" />
<activity android:name=".CartActivity" />
<activity android:name=".Menu" /> <activity android:name=".Menu" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>

View File

@ -1,7 +1,6 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Intent; import androidx.appcompat.app.AppCompatActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;

View File

@ -1,10 +1,9 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Context; import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable; import androidx.annotation.NonNull;
import android.support.annotation.NonNull; import androidx.annotation.Nullable;
import android.support.annotation.Nullable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -14,7 +13,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
public class CartAdapter extends ArrayAdapter<Pizza> { public class CartAdapter extends ArrayAdapter<Pizza> {

View File

@ -0,0 +1,51 @@
package com.example.pizzujemyv3;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.basgeekball.awesomevalidation.AwesomeValidation;
import com.basgeekball.awesomevalidation.ValidationStyle;
import com.basgeekball.awesomevalidation.utility.RegexTemplate;
public class CollectFormActivity extends AppCompatActivity {
EditText tUserName, tUserNameS, tPhoneNumber;
Button zamowButton;
AwesomeValidation awesomeValidation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collect_form);
tUserName = findViewById(R.id.txtUserName);
tUserNameS = findViewById(R.id.txtUserNameS);
tPhoneNumber = findViewById(R.id.txtPhoneNumber);
zamowButton = findViewById((R.id.Confirm));
awesomeValidation = new AwesomeValidation(ValidationStyle.BASIC);
awesomeValidation.addValidation(this,R.id.txtUserName, RegexTemplate.NOT_EMPTY,R.string.invalid_name);
awesomeValidation.addValidation(this,R.id.txtUserNameS, RegexTemplate.NOT_EMPTY,R.string.invalid_nameS);
awesomeValidation.addValidation(this,R.id.txtPhoneNumber, "[5-9]{1}[0-9]{9}$",R.string.invalid_number);
zamowButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
if (awesomeValidation.validate()){
Intent intent = new Intent(CollectFormActivity.this, Menu.class);
startActivity(intent);
}
else{
Toast.makeText(getApplicationContext(),"Wprowadź dane poprawnie", Toast.LENGTH_LONG).show();
}
}
});
}
}

View File

@ -0,0 +1,60 @@
package com.example.pizzujemyv3;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.basgeekball.awesomevalidation.AwesomeValidation;
import com.basgeekball.awesomevalidation.ValidationStyle;
import com.basgeekball.awesomevalidation.utility.RegexTemplate;
public class DeliveryFormActivity extends AppCompatActivity {
EditText tUserName, tUserNameS, tPhoneNumber, tCity, tStreet, tStreetNumber;
Button zamowButton;
AwesomeValidation awesomeValidation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collect_form);
tUserName = findViewById(R.id.txtUserName);
tUserNameS = findViewById(R.id.txtUserNameS);
tPhoneNumber = findViewById(R.id.txtPhoneNumber);
tCity = findViewById(R.id.txtCity);
tStreet = findViewById(R.id.txtStreet);
tStreetNumber = findViewById(R.id.txtStreetNumber);
zamowButton = findViewById((R.id.Confirm));
awesomeValidation = new AwesomeValidation(ValidationStyle.BASIC);
awesomeValidation.addValidation(this,R.id.txtUserName, RegexTemplate.NOT_EMPTY,R.string.invalid_name);
awesomeValidation.addValidation(this,R.id.txtUserNameS, RegexTemplate.NOT_EMPTY,R.string.invalid_nameS);
awesomeValidation.addValidation(this,R.id.txtPhoneNumber, "[5-9]{1}[0-9]{9}$",R.string.invalid_number);
awesomeValidation.addValidation(this,R.id.txtCity, RegexTemplate.NOT_EMPTY,R.string.invalid_nameS);
awesomeValidation.addValidation(this,R.id.txtStreet, RegexTemplate.NOT_EMPTY,R.string.invalid_nameS);
awesomeValidation.addValidation(this,R.id.txtStreetNumber, RegexTemplate.NOT_EMPTY,R.string.invalid_nameS);
zamowButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
if (awesomeValidation.validate()){
Intent intent = new Intent(DeliveryFormActivity.this, Menu.class);
startActivity(intent);
}
else{
Toast.makeText(getApplicationContext(),"Wprowadź dane poprawnie", Toast.LENGTH_LONG).show();
}
}
});
}
}

View File

@ -1,13 +1,13 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
Button menuButton; Button menuButton, dowozButton, odbiorButton;
public static SQLiteHelper sqLiteHelper; public static SQLiteHelper sqLiteHelper;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -24,7 +24,27 @@ public class MainActivity extends AppCompatActivity {
}); });
sqLiteHelper = new SQLiteHelper(this, "pizza.sqlite", null, 1); odbiorButton = findViewById(R.id.odbior);
sqLiteHelper.queryData("CREATE TABLE IF NOT EXISTS PIZZA(name VARCHAR, price VARCHAR, image BLOG)"); odbiorButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, CollectFormActivity.class);
startActivity(intent);
}
});
dowozButton = findViewById(R.id.dowoz);
dowozButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, DeliveryFormActivity.class);
startActivity(intent);
}
});
} }
} }

View File

@ -1,12 +1,11 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,10 +1,9 @@
package com.example.pizzujemyv3; package com.example.pizzujemyv3;
import android.content.Context; import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable; import androidx.annotation.NonNull;
import android.support.annotation.NonNull; import androidx.annotation.Nullable;
import android.support.annotation.Nullable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -14,7 +13,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
public class PizzaAdapter extends ArrayAdapter<Pizza> { public class PizzaAdapter extends ArrayAdapter<Pizza> {

View File

@ -5,7 +5,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement; import android.database.sqlite.SQLiteStatement;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
public class SQLiteHelper extends SQLiteOpenHelper { public class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) { public SQLiteHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {

View File

@ -0,0 +1,126 @@
<?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"
tools:context=".DeliveryFormActivity"
android:background="@drawable/decha"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20sp"
android:orientation="vertical"
android:layout_weight="0.8"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20sp"
android:orientation="vertical"
android:layout_weight="0.2"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:id="@+id/txtUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#20FFFFFF"
android:hint="@string/imię"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></EditText>
<EditText
android:id="@+id/txtUserNameS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/nazwisko"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txtUserName"></EditText>
<EditText
android:id="@+id/txtPhoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/telefon"
android:inputType="phone"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtUserNameS"></EditText>
<Button
android:id="@+id/Confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#10FFFFFF"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:text="@string/zamow"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="50sp"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,190 @@
<?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"
tools:context=".DeliveryFormActivity"
android:background="@drawable/decha"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20sp"
android:orientation="vertical"
android:layout_weight="0.8"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20sp"
android:orientation="vertical"
android:layout_weight="0.2"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:id="@+id/txtUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#20FFFFFF"
android:hint="@string/imię"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></EditText>
<EditText
android:id="@+id/txtUserNameS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/nazwisko"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txtUserName"></EditText>
<EditText
android:id="@+id/txtPhoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/telefon"
android:inputType="phone"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtUserNameS"></EditText>
<EditText
android:id="@+id/txtCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/miasto"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txtPhoneNumber"></EditText>
<EditText
android:id="@+id/txtStreet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/ulica"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txtCity"></EditText>
<EditText
android:id="@+id/txtStreetNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#20FFFFFF"
android:hint="@string/numerDomu"
android:inputType="text"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="#55FFFFFF"
android:textSize="30sp"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txtStreet"></EditText>
<Button
android:id="@+id/Confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#10FFFFFF"
android:shadowColor="#55000000"
android:shadowDx="6"
android:shadowDy="6"
android:shadowRadius="6"
android:text="@string/zamow"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="50sp"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>

View File

@ -8,4 +8,14 @@
<string name="activity_main_label">ActivityMain</string> <string name="activity_main_label">ActivityMain</string>
<string name="activity_menu_label">Menu</string> <string name="activity_menu_label">Menu</string>
<string name="zamow">Zamów</string> <string name="zamow">Zamów</string>
<string name="imię">Imię</string>
<string name="nazwisko">Nazwisko</string>
<string name="telefon">Numer telefonu</string>
<string name="miasto">Miasto</string>
<string name="ulica">Ulica</string>
<string name="numerDomu">Numer</string>
<string name="invalid_name">Wprowadź imie</string>
<string name="invalid_nameS">Wprowadź nazwisko</string>
<string name="invalid_number">Wprowadź poprawny numer telefonu</string>
</resources> </resources>

View File

@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit