Commit e7ab521d authored by sullykh's avatar sullykh

initial commit

parents
#Thu May 18 15:19:29 BST 2023
gradle.version=8.0
# Default ignored files
/shelf/
/workspace.xml
project58
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.example.project58"
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {SQL_CREATE_MOVIE
debug{
minifyEnabled true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures{
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.example.project58'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// implementation 'com.google.firebase:firebase-auth:21.1.0'
// implementation project(path: ':app')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
\ No newline at end of file
{
"project_info": {
"project_number": "739585044562",
"project_id": "temp-performance-booking",
"storage_bucket": "temp-performance-booking.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:739585044562:android:c7f45172ef6b0f4721ef8b",
"android_client_info": {
"package_name": "com.example.project58"
}
},
"oauth_client": [
{
"client_id": "739585044562-hrgn5cvolibp2rfkdr4q9lm28r4dukb5.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDQDqoIGuUxiW4PM0vKQCf_XWOJMPOwE5s"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "739585044562-hrgn5cvolibp2rfkdr4q9lm28r4dukb5.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.example.project58;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.project58", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project58">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Project58">
<activity
android:name="com.example.project58.UserTickets"
android:exported="false" />
<activity
android:name="com.example.project58.Ticket"
android:exported="false" />
<activity
android:name="com.example.project58.PerformanceDetails"
android:exported="false" />
<activity
android:name="com.example.project58.Home"
android:exported="false" >
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name="com.example.project58.SignIn"
android:exported="false" />
<activity
android:name="com.example.project58.SignUp"
android:exported="false" />
<activity
android:name="com.example.project58.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.project58.BookSeats"
android:exported="false" />
<activity
android:name="com.example.project58.PickSeat"
android:exported="true" />
</application>
</manifest>
\ No newline at end of file
package com.example.project58;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class BookSeats extends Home {
TextView receiptContent;
Button confirmBooking;
@SuppressLint({"SuspiciousIndentation", "MissingInflatedId"})
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receipt);
receiptContent = findViewById(R.id.receiptContent);
confirmBooking = findViewById(R.id.btnConfirmSeats);
//getting intent data from previous activity
Intent i = getIntent();
String perfTitle = i.getStringExtra("perfTitle");
int totalCost = i.getIntExtra("totalBookingCost",39);
String[] selectedSeats = i.getStringArrayListExtra("selectedSeats").toArray(new String[0]);
String selectedSeatsText = "";
//calculating selected seats
for(String s : selectedSeats){
selectedSeatsText += "[S"+s+"] ";
}
//calculating text that will be shown in the ticket
String receiptText=
" <b>Performance :</b>"+ " "+perfTitle+"<br /><br />"+
" <b>Selected Seats :</b>"+" "+selectedSeatsText+"<br /><br />" +
" <b>Total Cost :</b>"+" "+"£"+totalCost+"<br /><br />"+
" <b>Ticket Code :</b>"+" "+(perfTitle+" : "+selectedSeatsText).hashCode()+"<br /><br />";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
receiptContent.setText(Html.fromHtml(receiptText , Html.FROM_HTML_MODE_COMPACT));
}else
receiptContent.setText(Html.fromHtml(receiptText));
String finalSelectedSeatsText = selectedSeatsText;
confirmBooking.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//when confirm booking button is clicked
//getting logged in user data and seating data from database
SharedPreferences emailPref = getSharedPreferences("logged_in_email",MODE_PRIVATE);
String email = emailPref.getString("email","");
SharedPreferences sharedPreferences = getSharedPreferences("seats_remaining", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
//Saving booking data to database
Set<String> oldSet = sharedPreferences.getStringSet("selectedSeatsSet"+perfTitle,new HashSet<>());
Set<String> newSet = new HashSet<>(Arrays.asList(selectedSeats));
editor.putStringSet(perfTitle + " : "+ finalSelectedSeatsText,newSet);
Set<String> tickets_ids = sharedPreferences.getStringSet("tickets_ids"+email,new HashSet<>());
String title = perfTitle + " : "+finalSelectedSeatsText;
tickets_ids.add(title+" ( "+title.hashCode()+" )");
Log.e("adding tid",perfTitle+" : "+finalSelectedSeatsText);
editor.putStringSet("tickets_ids"+email,tickets_ids);
newSet.addAll(oldSet);
editor.putStringSet("selectedSeatsSet"+perfTitle,newSet);
int totalSeats = sharedPreferences.getInt(perfTitle,39);
editor.putInt(perfTitle, Math.max(totalSeats - selectedSeats.length, 0));
editor.apply();
//starting Home activity
Intent myintent=new Intent(BookSeats.this, Home.class);
startActivity(myintent);
finish();
}
});
invalidateOptionsMenu();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//inflating options menu in this activity
boolean res = super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(true);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(true);
return res;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
package com.example.project58;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Home extends AppCompatActivity implements SearchView.OnQueryTextListener {
ArrayList<performancesListItem> list = new ArrayList<>();
List<Integer> images = Arrays.asList(
R.drawable.perf1,
R.drawable.perf2,
R.drawable.perf3,
R.drawable.perf4,
R.drawable.perf5,
R.drawable.perf6
);
List<String> titles = Arrays.asList(
"A Midsummer Night's Dream by William Shakespeare",
"Antigone by William Sophocles",
"Hamlet by William Shakespeare",
"The Merchant of Venice by William Shakespeare",
"The Tempest by William Shakespeare",
"Oedipus the King by Sophocles"
);
List<String> description = Arrays.asList(
"19:00 Saturday 3 June 2023,\nDean's Park, York\n\n\t\t\u2022 Has wheelchair access.\n\n\t\t\u2022 Performance includes flashing lights.",
"21:00 Thursday 20 September 2023,\nCrypt, York Minister, York\n\n\t\t\u2022 Must be able to climb 20 steps.",
"18:00 19 May 2023,\nClifford's Tower, York\n\n\t\t\u2022 Must be able to climb 20 steps.\n\n\t\t\u2022 Performance includes flashing lights.",
"20:00 Sunday April 23 2023,\nMerchant Adventure's Hall, York\n\n\t\t\u2022 Has wheelchair access.",
"14:00 Saturday 19 August 2023,\nMillenneum Bridge, York\n\n\t\t\u2022 Has wheelchair access.",
"20:00 Friday 28 July 2023,\nSt Mary's Abbey, Museum Gardens, York\n\n\t\t\u2022 Has wheelchair access."
);
List<String> tickets_remaining_details = Arrays.asList(
"\n\n\t\t\u2022 On Stage\n\t\t\u2022 Grass",
"\n\n\t\t\u2022 Inner Circle\n\t\t\u2022 Outer Circle\n\t\t\u2022 Standing",
"\n\n\t\t\u2022 Seated\n\t\t\u2022 Standing",
"\n\n\t\t\u2022 Seated",
"\n\n\t\t\u2022 Boat A\n\t\t\u2022 Boat B\n\t\t\u2022 Riverbank",
"\n\n\t\t\u2022 Seated\n\t\t\u2022 Standing"
);
ListView listView;
SQLiteDatabase wdb;
LinearLayout sortLayout;
Button sortByNameAsc,sortByNameDsc,sortButton;
SearchView searchView;
ArrayList<Integer> total_seats = new ArrayList<>();
boolean sortLayoutHidden = true;
boolean is_sorted_desc = false;
MyListAdapter listAdapter;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
wdb = databaseValidateUserClass.getWritable(this);
sortByNameAsc = findViewById(R.id.sort_by_name_asc);
sortByNameDsc = findViewById(R.id.sort_by_name_dsc);
sortLayout = findViewById(R.id.sort_layout);
sortButton = findViewById(R.id.sort_button);
listView = findViewById(R.id.listview);
listView.setClickable(true);
searchView = findViewById(R.id.search_view);
sortButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//when sortButton is clicked
if (sortLayoutHidden){
sortLayoutHidden = false;
sortLayout.setVisibility(View.VISIBLE);
sortButton.setText("Hide");
}
else{
sortLayoutHidden = true;
sortLayout.setVisibility(View.GONE);
sortButton.setText("Sort");
}
}
});
//getting seating information from database
SharedPreferences sharedPreferences = getSharedPreferences("seats_remaining", Context.MODE_PRIVATE);
for(int i=0; i<titles.size(); i++){//adding items to list
performancesListItem item = new performancesListItem(titles.get(i), images.get(i));
list.add(item);
total_seats.add(sharedPreferences.getInt(titles.get(i),39));
}
//setting adapter to listview
Home.this.listAdapter = new MyListAdapter(Home.this,list);
listView.setAdapter(listAdapter);
listView.setTextFilterEnabled(true);
//when sort by name asc is clicked
sortByNameAsc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(is_sorted_desc){
is_sorted_desc = false;
Collections.reverse(titles);
Collections.reverse(description);
Collections.reverse(images);
Collections.reverse(tickets_remaining_details);
Collections.reverse(total_seats);
Collections.reverse(list);
Home.this.listAdapter = new MyListAdapter(Home.this,list);
listView.setAdapter(listAdapter);
}
}
});
//when sort by name dsc is clicked
sortByNameDsc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!is_sorted_desc){
is_sorted_desc = true;
Collections.reverse(titles);
Collections.reverse(description);
Collections.reverse(images);
Collections.reverse(tickets_remaining_details);
Collections.reverse(total_seats);
Collections.reverse(list);
Home.this.listAdapter = new MyListAdapter(Home.this,list);
listView.setAdapter(listAdapter);
}
}
});
//adding searchview listener for searching text in list view
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(Home.this);
searchView.setSubmitButtonEnabled(true);
searchView.setQueryHint("Search Performance");
//when any listitem is clicked
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(Home.this,PerformanceDetails.class);
i.putExtra("perfTitle", titles.get(position));
i.putExtra("perfDetails", description.get(position));
i.putExtra("ticketsRemainingDetails","Tickets Types (remaining "+sharedPreferences.getInt(titles.get(position),39)+" ) "+"(Cost £50)"+ tickets_remaining_details.get(position));
i.putExtra("totalSeats",total_seats.get(position));
startActivity(i);
}
});
invalidateOptionsMenu();
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
//when any options item is clicked
int id = item.getItemId();
switch (id) {
case R.id.nav_myTickets:
Log.e("onOp","onOp");
startActivity(new Intent(Home.this,UserTickets.class));
finish();
return true;
case R.id.nav_performances:
startActivity(new Intent(Home.this,Home.class));
finish();
return true;
case R.id.nav_logOut:
SharedPreferences sharedPreferences = getSharedPreferences("logged_in_email",MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("email","null");
editor.apply();
Intent i = new Intent(Home.this, MainActivity.class);
startActivity(i);
finish();
return true;
case R.id.nav_quitApp:
finishAffinity();
System.exit(0);
return true;
default:
return false;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.navigation_menu, menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(false);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(true);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
//when text is changed in search bar
if (TextUtils.isEmpty(newText)) {
listView.clearTextFilter();
} else {
listView.setFilterText(newText);
}
return true;
}
}
\ No newline at end of file
package com.example.project58;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button signup,signin;
@Override
public void onStart() {
super.onStart();
}
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
signin = findViewById(R.id.signin);
signup = findViewById(R.id.signup);
signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//when user clicks signin button go to signin activity
Intent i = new Intent(getApplicationContext(), SignIn.class);
startActivity(i);
finish();
}
});
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//when user clicks signup button go to signup activity
Intent i = new Intent(getApplicationContext(), SignUp.class);
startActivity(i);
}
});
//checking if user is already logged in then start Home screen directly
SharedPreferences sharedPreferences = getSharedPreferences("logged_in_email",MODE_PRIVATE);
String logged_in_user = sharedPreferences.getString("email","null");
if (!logged_in_user.equals("null")){
startActivity(new Intent(MainActivity.this,Home.class));
finish();
}
}
}
\ No newline at end of file
package com.example.project58;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
//This class is list adapter for performances list in the Home screen
public class MyListAdapter extends BaseAdapter implements Filterable {
public Context context;
public ArrayList<performancesListItem> employeeArrayList;
public ArrayList<performancesListItem> orig;
public MyListAdapter(Context context, ArrayList<performancesListItem> employeeArrayList) {
super();
this.context = context;
this.employeeArrayList = employeeArrayList;
}
public class MyListHolder
{
TextView name;
ImageView image;
}
//method for filtering the list when user types in the search box
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
final FilterResults oReturn = new FilterResults();
final ArrayList<performancesListItem> results = new ArrayList<performancesListItem>();
if (orig == null)
orig = employeeArrayList;
if (constraint != null) {
if (orig != null && orig.size() > 0) {
for (final performancesListItem g : orig) {
if (g.title.toLowerCase()
.contains(constraint.toString()))
results.add(g);
}
}
oReturn.values = results;
}
return oReturn;
}
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
employeeArrayList = (ArrayList<performancesListItem>) results.values;
notifyDataSetChanged();
}
};
}
//when data in search box is changed
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
}
//return the total size of list items
@Override
public int getCount() {
return employeeArrayList.size();
}
//return a list item
@Override
public Object getItem(int position) {
return employeeArrayList.get(position);
}
//returns a list item id
@Override
public long getItemId(int position) {
return position;
}
//inflate each list item to the screen according to their respective data
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyListHolder holder;
if(convertView==null)
{
convertView=LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
holder=new MyListHolder();
holder.name=(TextView) convertView.findViewById(R.id.performance_name);
holder.image=(ImageView) convertView.findViewById(R.id.performance_image);
convertView.setTag(holder);
}
else
{
holder=(MyListHolder) convertView.getTag();
}
holder.name.setText(employeeArrayList.get(position).title);
holder.image.setImageResource(employeeArrayList.get(position).image);
return convertView;
}
}
\ No newline at end of file
package com.example.project58;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
// this is list adapter for tickets list in my tickets screen
public class MyTicketsListAdapter extends ArrayAdapter<TicketsListItem> {
public MyTicketsListAdapter(Context context, ArrayList<TicketsListItem> list){
super(context, R.layout.ticket_list_item,list);
}
//inflate each ticket list item with their respective data
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TicketsListItem item = getItem(position);
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.ticket_list_item,parent,false);
}
TextView title = convertView.findViewById(R.id.ticket_name);
TextView amount = convertView.findViewById(R.id.ticket_amount);
title.setText(item.title);
amount.setText(String.valueOf(item.amount));
return convertView;
}
}
package com.example.project58;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class PerformanceDetails extends Home {
TextView title;
TextView perfDetails;
TextView ticketsRemaining;
Button book_now;
int totalSeats;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_performance_details);
title = findViewById(R.id.perf_title);
perfDetails = findViewById(R.id.perf_details);
ticketsRemaining = findViewById(R.id.tickets_remaining);
book_now = findViewById(R.id.book_now);
//getting intent data from previous activity
Intent i = getIntent();
title.setText(i.getStringExtra("perfTitle"));
perfDetails.setText(i.getStringExtra("perfDetails"));
ticketsRemaining.setText(i.getStringExtra("ticketsRemainingDetails"));
totalSeats = i.getIntExtra("totalSeats",39);
if(totalSeats==0){
book_now.setEnabled(false);
book_now.setVisibility(View.GONE);
}
//when book_now is clicked
book_now.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(PerformanceDetails.this,PickSeat.class);
i.putExtra("perfTitle",title.getText().toString());
i.putExtra("perfDetails",perfDetails.getText().toString());
i.putExtra("totalSeats",totalSeats);
startActivity(i);
finish();
}
});
invalidateOptionsMenu();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//inflating options menu in this screen
boolean res = super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(true);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(true);
return res;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
\ No newline at end of file
package com.example.project58;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class PickSeat extends Home {
Boolean[] btnSelected= new Boolean[40]; // array to store selected or not selected status of each seat
int noOfSelectedSeats = 0;
int totalSeats;
int totalBookingCost;
int seatCost = 50;
String perfTitle;
String perfDetails;
ArrayList<String> selectedSeats = new ArrayList<>();
// SQLiteDatabase wdb;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pick_seat);
final ArrayList<Integer> selectedButtons=new ArrayList<Integer>();
//getting intent data from previous activity
Intent in = getIntent();
totalSeats = in.getIntExtra("totalSeats",39);
perfTitle = in.getStringExtra("perfTitle");
perfDetails= in.getStringExtra("perfDetails");
//getting seating information from database
SharedPreferences sharedPreferences = getSharedPreferences("seats_remaining", Context.MODE_PRIVATE);
Set<String> bookedSeats = sharedPreferences.getStringSet("selectedSeatsSet"+perfTitle,new HashSet<>());
// if there are some seats already booked
if (bookedSeats != null) {
for (String i : bookedSeats) {
Log.e("booked Seat",i);
if(i=="") break;
String buttonID = "btn"+i;
Log.e("booked seat",i);
int resID = getResources().getIdentifier(buttonID, "id", getPackageName());
Button btn = (Button) (findViewById(resID));
btn.setBackground(getResources().getDrawable(R.drawable.booked));
btn.setEnabled(false);
}
}
// set btnselected flag as false for all buttons
for(int i=0;i<40;i++){
btnSelected[i]=false;
}
Button[] seatButtons = new Button[40];
//
for (int i = 1; i < seatButtons.length; i++) {
int m = i;
String buttonID = "btn" + m;
int resID = getResources().getIdentifier(buttonID, "id", getPackageName());
seatButtons[i] = ((Button) findViewById(resID));
final int finalId = resID;
final int buttonNum = i;
// set listeners to all buttons
if (seatButtons[i].isEnabled() && noOfSelectedSeats<=totalSeats) {
seatButtons[i].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button btn = (Button) findViewById(finalId);
if (!btnSelected[buttonNum]) {
//when seat is clicked
btn.setBackground(getResources().getDrawable(R.drawable.selected));
btnSelected[buttonNum] = true;
noOfSelectedSeats=noOfSelectedSeats+1;
selectedButtons.add(buttonNum);
} else {
//when seat is not selected
btn.setBackground(getResources().getDrawable(R.drawable.available));
btnSelected[buttonNum] = false;
noOfSelectedSeats=noOfSelectedSeats-1;
try {
selectedButtons.remove(selectedButtons.indexOf(buttonNum));
}
catch(Exception ex)
{
System.out.println(ex);
}
}
}
});
}
}
//when user presses the confirm seats button
Button btnProceed = (Button) findViewById(R.id.btnConfirmSeats);
btnProceed.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//
for (int i = 0; i < selectedButtons.size(); i++) {
System.out.println("Seat no "+selectedButtons.get(i));
}
// calculating total cost and adding selected seats to selectedSeats
for(int i : selectedButtons){
selectedSeats.add(String.valueOf(i));
totalBookingCost += seatCost;
Log.e("selected seat no", String.valueOf(i));
}
//if no seat is selected then don't allow user to go to ticket confirm screen
if(totalBookingCost == 0){
Toast.makeText(PickSeat.this, "Please select some seats first", Toast.LENGTH_SHORT).show();
return;
}
Intent myintent = new Intent(PickSeat.this, BookSeats.class);
myintent.putStringArrayListExtra("selectedSeats", selectedSeats);
myintent.putExtra("totalBookingCost",totalBookingCost);
myintent.putExtra("perfTitle",perfTitle);
myintent.putExtra("perfDetails",perfDetails);
startActivity(myintent);
finish();
Log.e("totalcost", String.valueOf(totalBookingCost));
}
});
invalidateOptionsMenu();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//inflating options menu in this screen
boolean res = super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(true);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(true);
return res;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
package com.example.project58;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class SignIn extends AppCompatActivity {
Button signInButton;
EditText email, passwd;
SQLiteDatabase wdb;
TextView signup;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
signInButton = findViewById(R.id.signin_button);
email = findViewById(R.id.editTextEmail);
passwd = findViewById(R.id.editTextPassword);
wdb = databaseValidateUserClass.getWritable(this);
signup = findViewById(R.id.sign_up_button);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SignIn.this, SignUp.class));
finish();
}
});
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String emailS, passwdS;
emailS = String.valueOf(email.getText());
passwdS = String.valueOf(passwd.getText());
//if user has not entered email
if (TextUtils.isEmpty(emailS)) {
Toast.makeText(SignIn.this, "please enter email !!!", Toast.LENGTH_SHORT).show();
return;
}
//if user has not entered password
if (TextUtils.isEmpty(passwdS)) {
Toast.makeText(SignIn.this, "please enter password !!!", Toast.LENGTH_SHORT).show();
return;
}
//select query for getting user from database
final String selectQuery = "SELECT Email,Password FROM USER ";
boolean isValid = databaseValidateUserClass.checkUser(emailS, passwdS, selectQuery);
if (isValid) { // if username and email are valid , go to PickMovie Activity
SharedPreferences sharedPreferences = getSharedPreferences("logged_in_email",MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("email",emailS);
editor.apply();
Intent i = new Intent(getApplicationContext(), Home.class);
startActivity(i);
finish();
} else { // if for a registered user ,email id is not correct
Toast.makeText(SignIn.this, "Please enter Correct email and password !!!", Toast.LENGTH_SHORT).show();
email.setText(null);
email.setHint("Email");
passwd.setText(null);
passwd.setHint("Password");
}
}
});
}
@Override
public void onBackPressed() {
super.onBackPressed();
//start mainactivity on back pressed
startActivity(new Intent(SignIn.this, MainActivity.class));
finish();
}
}
\ No newline at end of file
package com.example.project58;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class SignUp extends AppCompatActivity {
Button signupButton;
EditText name, email, passwd,rePasswd;
TextView sigin;
SQLiteDatabase wdb;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
getSupportActionBar().hide();
signupButton = findViewById(R.id.signup_button);
name = findViewById(R.id.editTextPersonName);
email = findViewById(R.id.editTextEmail);
passwd = findViewById(R.id.editTextPassword);
rePasswd = findViewById(R.id.editTextRePass);
sigin = findViewById(R.id.sign_in_button);
wdb = databaseValidateUserClass.getWritable(this);
sigin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SignUp.this, SignIn.class));
finish();
}
});
signupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String emailS, passwdS,rePasswdS,userS;
emailS = String.valueOf(email.getText());
passwdS = String.valueOf(passwd.getText());
rePasswdS = String.valueOf(rePasswd.getText());
userS = String.valueOf(name.getText());
//if username is not entered
if (TextUtils.isEmpty(userS)) {
Toast.makeText(SignUp.this, "please enter username !!!", Toast.LENGTH_SHORT).show();
return;
}
//if email is not entered
if (TextUtils.isEmpty(emailS)) {
Toast.makeText(SignUp.this, "please enter email !!!", Toast.LENGTH_SHORT).show();
return;
}
// if password is not entered
if (TextUtils.isEmpty(passwdS)) {
Toast.makeText(SignUp.this, "please enter password !!!", Toast.LENGTH_SHORT).show();
return;
}
//if repassword is not entered
if (TextUtils.isEmpty(rePasswdS)) {
Toast.makeText(SignUp.this, "please enter re password !!!", Toast.LENGTH_SHORT).show();
return;
}
//if password dont match
if(!passwdS.equals(rePasswdS)){
Toast.makeText(SignUp.this, "password don't match !!!", Toast.LENGTH_SHORT).show();
return;
}
final String selectQuery = "SELECT Email FROM USER ";
boolean isValid = databaseValidateUserClass.isAlreadyRegistered(emailS, selectQuery);
if(isValid) // if username already exists in database
{
email.setText(null);
email.setHint("Email");
passwd.setText(null);
passwd.setHint("Password");
Toast.makeText(SignUp.this, "This username is already registerd.Please Pick another or Log In!!", Toast.LENGTH_SHORT).show();
}
else{ // if username is not found in database , then register new user
ContentValues values = new ContentValues();
values.put("Email", emailS);
values.put("Password", passwdS);
long newRowId = wdb.insert("USER", null, values);
Toast.makeText(SignUp.this, "Registered Successfully", Toast.LENGTH_SHORT).show();
SharedPreferences sharedPreferences = getSharedPreferences("logged_in_email",MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("email",emailS);
editor.apply();
Intent i = new Intent(getApplicationContext(), Home.class);
startActivity(i);
finish();
}
}
});
}
@Override
public void onBackPressed() {
super.onBackPressed();
//starting main activity when back button is pressed
startActivity(new Intent(SignUp.this, MainActivity.class));
finish();
}
}
\ No newline at end of file
package com.example.project58;
import androidx.annotation.NonNull;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class Ticket extends Home {
TextView title,content;
Button cancelTicket;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receipt);
title = findViewById(R.id.receiptTitle);
content = findViewById(R.id.receiptContent);
cancelTicket = findViewById(R.id.btnConfirmSeats);
}
@SuppressLint("SetTextI18n")
@Override
protected void onResume() {
super.onResume();
cancelTicket.setText("Cancel Ticket");
//getting intent from this activity was started
Intent i = getIntent();
String perfTitle = i.getStringExtra("perfTitle");
String[] selectedSeats = i.getStringArrayListExtra("selectedSeats").toArray(new String[0]);
String title_text,selected_seats_text;
int in;
int colon_in = 0;
int ticket_code_in = 0;
//calculating performance title , selected seats and unique ticked code
for( in = 0 ; in<perfTitle.length(); in++){
if(perfTitle.charAt(in)==':'){
colon_in = in;
}
if(perfTitle.charAt(in) == '('){
ticket_code_in = in;
break;
}
}
//displaying data on the screen
title_text = perfTitle.substring(0,colon_in-1);
selected_seats_text = perfTitle.substring(colon_in+2,ticket_code_in-1);
String ticket_code = perfTitle.substring(ticket_code_in,perfTitle.length());
int totalCost = (selected_seats_text.length()/6) * 50;
title.setText("Ticket");
String receiptText=
" <b>Performance :</b>"+ " "+perfTitle+"<br /><br />"+
" <b>Selected Seats :</b>"+" "+selected_seats_text+"<br /><br />" +
" <b>Total Cost :</b>"+" "+"£"+totalCost+"<br /><br />"+
" <b>Ticket Code :</b>"+" "+ticket_code+"<br /><br />";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
content.setText(Html.fromHtml(receiptText , Html.FROM_HTML_MODE_COMPACT));
}else
content.setText(Html.fromHtml(receiptText));
cancelTicket.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//if cancel ticket button is clicked
//getting logged in user data and seating data from database
SharedPreferences emailPref = getSharedPreferences("logged_in_email",MODE_PRIVATE);
String email = emailPref.getString("email","");
SharedPreferences sharedPreferences = getSharedPreferences("seats_remaining", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
//deleting the cancelled ticket data from database
Set<String> oldSet = sharedPreferences.getStringSet("selectedSeatsSet"+title_text,new HashSet<>());
Set<String> newSet = new HashSet<>(Arrays.asList(selectedSeats));
oldSet.removeAll(newSet);
editor.putStringSet("selectedSeatsSet"+title_text,oldSet);
Set<String> tickets_ids = sharedPreferences.getStringSet("tickets_ids"+email,new HashSet<>());
Log.e("removing tid",title_text+" : "+selected_seats_text);
tickets_ids.remove(perfTitle);
editor.putStringSet("tickets_ids"+email,tickets_ids);
//updatin database
Log.e("title",title_text);
int totalSeats = sharedPreferences.getInt(title_text,39);
editor.putInt(title_text, Math.min(totalSeats + (selected_seats_text.length()/6), 39));
editor.apply();
//starting UserTickets activity
startActivity(new Intent(Ticket.this,UserTickets.class));
finish();
}
});
invalidateOptionsMenu();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//inflating options menu in this screen
boolean res = super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(true);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(true);
return res;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
\ No newline at end of file
package com.example.project58;
public class TicketsListItem {
//this is class that denoted a ticket list item
String title;
int amount;
public TicketsListItem(String title, int amount){
this.amount = amount;
this.title = title;
}
}
package com.example.project58;
import androidx.annotation.NonNull;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class UserTickets extends Home {
ArrayList<TicketsListItem> list = new ArrayList<>();
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_tickets);
//getting logged in user data and seating data from database
SharedPreferences emailPref = getSharedPreferences("logged_in_email",MODE_PRIVATE);
String email = emailPref.getString("email","");
SharedPreferences sharedPreferences = getSharedPreferences("seats_remaining", Context.MODE_PRIVATE);
String[] titles = sharedPreferences.getStringSet("tickets_ids"+email, new HashSet<>()).toArray(new String[0]);
Log.e("titles size", String.valueOf(titles.length));
//calculating tickets which were booked by current user
for(int i=0; i<titles.length; i++){
TicketsListItem item = new TicketsListItem(titles[i],titles.length*50);
list.add(item);
}
//showing list int he screen
ListAdapter listAdapter = new MyTicketsListAdapter(UserTickets.this,list);
listView = findViewById(R.id.listview);
listView.setAdapter(listAdapter);
listView.setClickable(true);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//when any list item is clicked
Intent i = new Intent(UserTickets.this,Ticket.class);
//putting extra data for Ticket activity like selected seats,cost etc
i.putExtra("perfTitle",titles[position]);
ArrayList<String> selectedSeats = new ArrayList<>();
Set<String> selectedButtons = sharedPreferences.getStringSet(titles[position],new HashSet<>());
for(String x : selectedButtons) {
selectedSeats.add(x);
}
//starting Ticket activity
i.putStringArrayListExtra("selectedSeats",selectedSeats );
startActivity(i);
// finish();
}
});
invalidateOptionsMenu();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//inflating options menu in this screen
boolean res = super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.findItem(R.id.nav_performances);
menuItem.setVisible(true);
MenuItem menuItem2 = menu.findItem(R.id.nav_myTickets);
menuItem2.setVisible(false);
return res;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
startActivity(new Intent(UserTickets.this, Home.class));
finish();
}
}
\ No newline at end of file
package com.example.project58;
public class databaseQueries {
//database query to create a new user
public static final String SQL_CREATE_USER =
"CREATE TABLE USER (Email text, Password text )";
//database query to delete a user from database
public static final String SQL_DELETE_USERS =
"DROP TABLE IF EXISTS USER ";
}
package com.example.project58;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import static android.content.ContentValues.TAG;
public class databaseValidateUserClass {
//this class check whether user is signed up already, same user exists, etc
private static SQLiteDatabase wdb = null;
private static userDB db = null;
public static SQLiteDatabase getWritable(Context context) {
if (db == null){
db = new userDB(context);
}
if (wdb == null)
wdb = db.getWritableDatabase();
return wdb;
}
public static boolean checkUser(String email,String password,String selectQuery) {
//checking whether user entered correct email password combination saved in the database
//if it does not exists then do not allow to login
Cursor cursor = wdb.rawQuery(selectQuery, null);
boolean res = false;
if (cursor.moveToFirst()) {
do {
String s1 = cursor.getString(0);
Log.e(TAG, "checkUser col 1: "+s1);
String s2 = cursor.getString(1);
Log.e(TAG, "checkUser col 2: "+s1);
if (s1.equals(email) && s2.equals(password)) // check if username and email already exist in DB
{
res = true;
break;
}
} while (cursor.moveToNext());
}
return res;
}
public static boolean isAlreadyRegistered (String email,String selectQuery) {
//checking whether user with this email already exists or not
//if it does not exists then creating a new user in the database
Cursor cursor = wdb.rawQuery(selectQuery, null);
boolean res = false;
if (cursor.moveToFirst()) {
do {
String s1 = cursor.getString(0);
Log.e("columns", "checkUser1 col1: " + s1);
if (s1.equals(email))
{
res = true;
break;
}
} while (cursor.moveToNext());
}
return res;
}
// close database connection
public static void close() {
if (db != null)
db.close();
}
}
package com.example.project58;
public class performancesListItem {
//this is a class that denotes an performance list item
String title;
int image;
public performancesListItem(String title, int image){
this.title = title;
this.image = image;
}
}
package com.example.project58;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
//this class is for storing and getting data from sqlite database
public class userDB extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 7;
public static final String DATABASE_NAME = "userDB.db";
public userDB(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
if (!db.isReadOnly()) {
// Enable foreign key constraints
db.execSQL("PRAGMA foreign_keys=ON;");
}
}
//this will execute when database is created for first time
public void onCreate(SQLiteDatabase db) {
Log.e("TABLE Creating","onCreate******************************************");
//creating a new user
db.execSQL(com.example.project58.databaseQueries.SQL_CREATE_USER);
Log.e("TABLE CREATED","onCreate******************************************");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//this method is required for SQLiteOpenHelper
// but this is not needed in the app
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="15dp"/>
<solid android:color="#ffffff"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="15dp"/>
<solid android:color="#00FFFFFF"/>
<stroke android:color="#ffffff" android:width="1dp"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient android:angle="90" android:startColor="#f2a02b" android:endColor="#df6f56"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@color/pressed_color" />
<item android:drawable="@color/default_color" />
<item android:drawable="@color/color_focus"
android:state_pressed="true" />
<item android:drawable="@color/color_focus"
android:state_focused="true" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#f19d2c" />
<corners android:radius="15dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/default_color" />
<item android:drawable="@color/color_focus"
android:state_pressed="true" />
<item android:drawable="@color/color_focus"
android:state_focused="true" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#e1e1e1"/>
<corners android:radius="15dp"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment