Skip to content

Commit

Permalink
Final Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IakMastro committed Jun 14, 2021
1 parent d2c7293 commit dca6473
Show file tree
Hide file tree
Showing 63 changed files with 2,478 additions and 239 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ __pycache__
node_modules
data
client/package-lock.json
client/yarn.lock
client/yarn.lock
Tinder-Clone.pdf
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
Tinder-Clone
# Tinder-Clone

Αυτό το repository είναι περιέχει την δεύτερη εργασία που πραγματοποίηθηκε για το μάθημα <<Ηλεκτρονικό Εμπόριο>>, όπως και το εργαστηριακό μέρος του μαθήματος <<Προγραμματισμός Κινητών>>.
Ο σκοπός της εργασίας ητάν η δημιουργία μίας ιστοσελίδας με σκόπο γνωριμίων (σαν το Tinder), όπως και την αντιστοίχη Android εφαρμογή του.

## Απαραίτητα προγραμμάτα

Για την εκτέλεση της εφαρμογής, χρείαζεται να υπάρχει εγκαταστημένο Docker. Κατα προτίμησης, έχει δοκιμαστεί πλήρως σε Linux σύστημα και θα έπρεπε να δουλεύει το ίδιο καλά και σε MacOS. Σε Windows, όμως, είναι αβέβαιο εάν δουλεύει. Για την εγκατάσταση του Docker, έχει φτιαχτεί αυτομάτο scriptακη που δουλεύει σε [Debian](https://www.debian.org/distrib/) συστήματα (όπως [Ubuntu](https://ubuntu.com/download/desktop), [Kali](https://www.kali.org/get-kali/) κτλ), όπως και σε [Arch](https://archlinux.org/download/) συστήματα (όπως [Manjaro](https://manjaro.org/download/)).
Επιπρόσθετα, για την Android εφαρμογή θα πρέπει να υπάρχει και το [AndroidStudio](https://developer.android.com/studio) κατεβασμένο.

## Επιπλέον πληροφορίες

Για επιπλέον πληροφορίες, πατήστε [εδώ](Tinder-Clone.adoc).
15 changes: 15 additions & 0 deletions Tinder-Clone-Android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions Tinder-Clone-Android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions Tinder-Clone-Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.tinder_clone_android"
minSdkVersion 27
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}
21 changes: 21 additions & 0 deletions Tinder-Clone-Android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.tinder_clone_android;

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.tinder_clone_android", appContext.getPackageName());
}
}
23 changes: 23 additions & 0 deletions Tinder-Clone-Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tinder_clone_android">

<uses-permission android:name="android.permission.INTERNET" />

<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.TinderCloneAndroid"
android:usesCleartextTraffic="true">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.example;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tinder_clone_android.R;
import com.example.tinder_clone_android.json_api.User;
import com.squareup.picasso.Picasso;

import org.jetbrains.annotations.NotNull;

import java.time.LocalDate;
import java.time.Period;
import java.util.ArrayList;

public class TinderCloneAdapter extends RecyclerView.Adapter<TinderCloneAdapter.ViewHolder> {
private final ArrayList<User> localDataSet;

public TinderCloneAdapter(ArrayList<User> localDataSet) {
this.localDataSet = localDataSet;
}

@NonNull
@NotNull
@Override
public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item, parent, false);

return new ViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) {
holder.bind(localDataSet.get(position));
}

@Override
public int getItemCount() {
return localDataSet.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
private ImageView imageView;
private TextView name;
private TextView surname;
private TextView age;
private TextView height;
private TextView weight;
private TextView eyes;
private TextView hair;

@SuppressLint("SetTextI18n")
public void bind(User user) {

Picasso.get()
.load("http://192.168.1.3:5000/img/".concat(user.getPfp()))
.error(R.drawable.ic_launcher_background).into(imageView);

name.setText(user.getName());
surname.setText(user.getSurname());
age.setText(Period.between(LocalDate
.parse(user.getBirthday()), LocalDate.now()).getYears() + " years old");
height.setText(user.getHeight() + "cm");
weight.setText(user.getWeight() + "kg");
eyes.setText(user.getEyeColour() + " eyes, ");
hair.setText(user.getHairColour() + " hair");
}

public ViewHolder(@NonNull @NotNull View itemView) {
super(itemView);
setReferences(itemView);
}

private void setReferences(View itemView) {
imageView = itemView.findViewById(R.id.profile_pic);
name = itemView.findViewById(R.id.name);
surname = itemView.findViewById(R.id.surname);
age = itemView.findViewById(R.id.age);
height = itemView.findViewById(R.id.height);
weight = itemView.findViewById(R.id.weight);
eyes = itemView.findViewById(R.id.eyes);
hair = itemView.findViewById(R.id.hair);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.example.tinder_clone_android;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.example.TinderCloneAdapter;
import com.example.tinder_clone_android.json_api.RestApi;
import com.example.tinder_clone_android.json_api.User;
import com.example.tinder_clone_android.json_api.UserList;
import com.squareup.picasso.Picasso;

import java.time.LocalDate;
import java.time.Period;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
public static MainActivity Instance;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Instance = this;

Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.1.3:5000/")
.addConverterFactory(GsonConverterFactory.create())
.build();

RestApi restApi = retrofit.create(RestApi.class);

Call<UserList> call = restApi.getUsers();

call.enqueue(new Callback<UserList>() {
@SuppressLint("SetTextI18n")
@Override
public void onResponse(Call<UserList> call, Response<UserList> response) {
if (!response.isSuccessful()) {
System.err.printf("*** Code: %s\n", response.code());
return;
}

UserList userList = response.body();
assert userList != null;

RecyclerView recyclerView = findViewById(R.id.recycler_view);
TinderCloneAdapter tinderCloneAdapter =
new TinderCloneAdapter(userList.getUserList());
recyclerView.setAdapter(tinderCloneAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.Instance));
}

@Override
public void onFailure(Call<UserList> call, Throwable t) {
System.err.printf("*** %s\n", t.getMessage());
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.tinder_clone_android.json_api;

public class Ping {
private String text;

public String getText() {
return text;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.tinder_clone_android.json_api;

import retrofit2.Call;
import retrofit2.http.GET;

public interface RestApi {
@GET("ping")
Call<Ping> getPing();

@GET("/")
Call<UserList> getUsers();
}
Loading

0 comments on commit dca6473

Please sign in to comment.