diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..b5e0bed
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ compileSdk 32
+
+ defaultConfig {
+ applicationId "pl.krzysiek.simplesocial"
+ minSdk 26
+ targetSdk 32
+ versionCode 12
+ versionName "1.09"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility mysqlConnectorJavaVersion
+ targetCompatibility mysqlConnectorJavaVersion
+ }
+ compileSdkVersion 32
+ buildToolsVersion '32.0.0'
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ implementation "mysql:mysql-connector-java:5.1.49"
+ // implementation "mysql:mysql-connector-java:8.0.20"
+ implementation "commons-io:commons-io:2.11.0"
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/app/debug/app-debug.aab b/app/debug/app-debug.aab
new file mode 100644
index 0000000..0c68347
Binary files /dev/null and b/app/debug/app-debug.aab differ
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -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
\ No newline at end of file
diff --git a/app/release/app-release.aab b/app/release/app-release.aab
new file mode 100644
index 0000000..0021cc7
Binary files /dev/null and b/app/release/app-release.aab differ
diff --git a/app/src/androidTest/java/pl/krzysiek/simplesocial/ExampleInstrumentedTest.java b/app/src/androidTest/java/pl/krzysiek/simplesocial/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..c5a2887
--- /dev/null
+++ b/app/src/androidTest/java/pl/krzysiek/simplesocial/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package pl.krzysiek.simplesocial;
+
+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 Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("pl.krzysiek.simplesocial", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..052a4c7
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/CommentsManagement.java b/app/src/main/java/pl/krzysiek/simplesocial/CommentsManagement.java
new file mode 100644
index 0000000..6cfb6dd
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/CommentsManagement.java
@@ -0,0 +1,187 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.text.util.Linkify;
+import android.view.ContextThemeWrapper;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+
+public class CommentsManagement extends AppCompatActivity {
+
+ Server server;
+ LinearLayout commentsList;
+ static int id;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_comments_management);
+ onLoad();
+ }
+
+ public void quit(View v){
+ Intent homepage = new Intent(this, Homepage.class);
+ startActivity(homepage);
+ finish();
+ }
+
+ public void onLoad(){
+ Bundle data = getIntent().getExtras();
+ id = data.getInt("user");
+ commentsList = findViewById(R.id.commentsList);
+ server = new Server();
+
+ refreshComments();
+ }
+
+ void refreshComments(){
+ ResultSet rs = server.query("*", "comments", "id_author = " + id);
+ try{
+ while(rs.next()) {
+ generateComment(
+ rs.getInt(1),
+ rs.getInt(2),
+ rs.getInt(3),
+ rs.getString(4),
+ rs.getString(5)
+ );
+ }
+ } catch (SQLException ex) { ex.printStackTrace(); }
+ }
+
+ @SuppressLint("SetTextI18n")
+ void generateComment(int id_comment, int id_post, int id_author, String dataUtworzenia, String tresc){
+ LinearLayout comment = new LinearLayout(commentsList.getContext());
+ LinearLayout.LayoutParams commentParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ commentParams.setMargins(0,4,8,4);
+ comment.setLayoutParams(commentParams);
+ comment.setId(View.generateViewId());
+ comment.setOrientation(LinearLayout.HORIZONTAL);
+
+ LinearLayout buttonGroup = new LinearLayout(comment.getContext());
+ LinearLayout.LayoutParams btnGroupParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ buttonGroup.setLayoutParams(btnGroupParams);
+ buttonGroup.setId(View.generateViewId());
+ buttonGroup.setOrientation(LinearLayout.VERTICAL);
+ buttonGroup.setGravity(Gravity.CENTER);
+
+ LinearLayout commentContent = new LinearLayout(comment.getContext());
+ LinearLayout.LayoutParams commentsParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ commentContent.setLayoutParams(commentsParams);
+ commentContent.setId(View.generateViewId());
+ commentContent.setOrientation(LinearLayout.VERTICAL);
+
+ ContextThemeWrapper theme = new ContextThemeWrapper(buttonGroup.getContext(), R.style.Widget_MaterialComponents_Button);
+ LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ buttonParams.setMargins(8,2,8,2);
+
+ Button editButton = new Button(theme);
+ editButton.setLayoutParams(buttonParams);
+ editButton.setId(View.generateViewId());
+ editButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.description_icon, 0,0,0);
+ editButton.setOnClickListener(view -> {
+ Intent intent = new Intent(this, EditComments.class);
+ intent.putExtra("comment", id_comment);
+ intent.putExtra("user", id);
+ startActivity(intent);
+ finish();
+ });
+
+ Button deleteButton = new Button(theme);
+ deleteButton.setLayoutParams(buttonParams);
+ deleteButton.setId(View.generateViewId());
+ deleteButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.delete_icon,0,0,0);
+ deleteButton.setOnClickListener(view -> {
+ AlertDialog.Builder alert = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener alertDialog = (dialog, which) -> {
+ switch (which) {
+ case DialogInterface.BUTTON_POSITIVE:
+ server.delete("comments", "id_comment = " + id_comment);
+ Toast.makeText(this, "Komentarz został usunięty", Toast.LENGTH_SHORT).show();
+ commentsList.removeAllViewsInLayout();
+ refreshComments();
+ break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ break;
+ }
+ };
+
+ alert.setMessage("Czy na pewno chcesz usunąć ten komentarz?").setPositiveButton("Tak", alertDialog).setNegativeButton("Nie", alertDialog).show();
+ });
+
+ Button postButton = new Button(theme);
+ postButton.setLayoutParams(buttonParams);
+ postButton.setId(View.generateViewId());
+ postButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.gotopost_icon,0,0,0);
+ postButton.setOnClickListener(view -> {
+ Intent intent = new Intent(this, ThePost.class);
+ intent.putExtra("id_user", id);
+ intent.putExtra("id_post", id_post);
+ intent.putExtra("from", "comment");
+ startActivity(intent);
+ finish();
+ });
+
+ LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+
+ TextView commentToPost = new TextView(commentContent.getContext());
+ commentToPost.setId(View.generateViewId());
+ ResultSet rsPost = server.query("tytul", "posts", "id_post = " + id_post);
+ try{
+ while(rsPost.next())
+ commentToPost.setText("Komentarz do posta: \"" + rsPost.getString(1) + "\"");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+
+ TextView commentText = new TextView(commentContent.getContext());
+ commentText.setId(View.generateViewId());
+ commentText.setTextAppearance(R.style.TextAppearance_AppCompat_Medium);
+ commentText.setText(tresc);
+
+ TextView addedText = new TextView(commentContent.getContext());
+ addedText.setId(View.generateViewId());
+ addedText.setTextAppearance(R.style.TextAppearance_AppCompat_Body2);
+ addedText.setText(dataUtworzenia);
+
+ View divider = new View(commentsList.getContext());
+ TableRow.LayoutParams dividerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) getResources().getDisplayMetrics().density);
+ dividerParams.setMargins(32, 32, 32, 32);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(getColor(R.color.gray_400));
+
+ buttonGroup.addView(editButton);
+ buttonGroup.addView(postButton);
+ buttonGroup.addView(deleteButton);
+ commentContent.addView(commentToPost);
+ commentContent.addView(commentText);
+ commentContent.addView(addedText);
+
+ comment.addView(buttonGroup);
+ comment.addView(commentContent);
+
+ commentsList.addView(comment);
+ commentsList.addView(divider);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/EditComments.java b/app/src/main/java/pl/krzysiek/simplesocial/EditComments.java
new file mode 100644
index 0000000..62902a5
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/EditComments.java
@@ -0,0 +1,88 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class EditComments extends AppCompatActivity {
+
+ Server server;
+ Helpers helper;
+
+ EditText commentBox;
+ TextView postAuthor, postTitle, postText, postDate;
+ ImageView postImage;
+
+ int id_comment, id_post, id;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_comments);
+
+ onLoad();
+ }
+
+ public void onLoad(){
+ server = new Server();
+ helper = new Helpers();
+
+ commentBox = findViewById(R.id.commentBox);
+ postAuthor = findViewById(R.id.postAuthor);
+ postTitle = findViewById(R.id.postTitle);
+ postText = findViewById(R.id.postText);
+ postDate = findViewById(R.id.postDate);
+
+ postImage = findViewById(R.id.postImage);
+
+ Bundle datas = getIntent().getExtras();
+ id_comment = datas.getInt("comment");
+ id = datas.getInt("user");
+
+ ResultSet rs = server.query("posts.id_post, comments.tresc, users.username, posts.tytul, posts.tresc, posts.typPosta, posts.dataDodania", "comments, posts, users", "id_comment = " + id_comment + " AND posts.id_post = comments.id_post AND users.id = posts.id_autor");
+ try{
+ while(rs.next()){
+ id_post = rs.getInt(1);
+ commentBox.setText(rs.getString(2));
+ postAuthor.setText("Post użytkownika " + rs.getString(3));
+ postTitle.setText(rs.getString(4));
+ postText.setText(rs.getString(5));
+ if(rs.getInt(6) > 0){
+ ResultSet rsImage = server.query("picture", "pictures", "id_post = " + id_post);
+ while(rsImage.next())
+ postImage.setImageBitmap(helper.convertToBitmap(rsImage.getString(1)));
+ }
+ postDate.setText("Dodano " + rs.getString(7));
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void updateComment(View v){
+ server.update("comments", "tresc = '" + commentBox.getText() + "'", "id_comment = " + id_comment);
+ Toast.makeText(this, "Komentarz został zaktualizowany", Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(this, ThePost.class);
+ intent.putExtra("id_user", id);
+ intent.putExtra("id_post", id_post);
+ intent.putExtra("from", "comment");
+ startActivity(intent);
+ finish();
+ }
+
+ public void quit(View v){
+ Intent intent = new Intent(this, CommentsManagement.class);
+ intent.putExtra("user", id);
+ startActivity(intent);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/EditPost.java b/app/src/main/java/pl/krzysiek/simplesocial/EditPost.java
new file mode 100644
index 0000000..9ddcbf3
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/EditPost.java
@@ -0,0 +1,80 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Debug;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class EditPost extends AppCompatActivity {
+
+ static Server server;
+ static Helpers helper;
+ static int id;
+ static int id_post;
+ boolean changePic;
+
+ EditText title, text;
+ ImageView img;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_post);
+ onLoad();
+ }
+
+ public void onLoad(){
+ getIds();
+ server = new Server();
+ helper = new Helpers();
+ setObjects();
+ fillFields();
+ }
+
+ public void setObjects(){
+ title = findViewById(R.id.postTitle);
+ text = findViewById(R.id.postText);
+ img = findViewById(R.id.postImage);
+ }
+
+ public void getIds(){
+ Bundle datas = getIntent().getExtras();
+ id_post = datas.getInt("post");
+ id = datas.getInt("user");
+ }
+
+ public void fillFields(){
+ ResultSet rs = server.query("tytul, tresc, typPosta", "posts", "id_post = " + id_post);
+ try{
+ while(rs.next()){
+ title.setText(rs.getString(1));
+ text.setText(rs.getString(2));
+ if(rs.getInt(3) > 0){
+ ResultSet picRs = server.query("picture", "pictures", "pictures.id_post = " + id_post);
+ while(picRs.next()){
+ img.setImageBitmap(helper.convertToBitmap(picRs.getString(1)));
+ }
+ }
+ }
+ } catch (SQLException ex) { ex.printStackTrace(); }
+ }
+
+ public void quit(View v){
+ Intent intent = new Intent(this, PostsManagement.class);
+ intent.putExtra("user", id);
+ startActivity(intent);
+ finish();
+ }
+
+ public void saveChanges(View v) {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/EditProfile.java b/app/src/main/java/pl/krzysiek/simplesocial/EditProfile.java
new file mode 100644
index 0000000..3961005
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/EditProfile.java
@@ -0,0 +1,175 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
+import android.app.DatePickerDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.*;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Calendar;
+
+public class EditProfile extends AppCompatActivity {
+
+ static int id_user;
+ Server server;
+
+ TextView username, birthdateBox;
+ EditText nameBox, emailBox, phoneBox, actualPassBox, newPassBox, rpPassBox;
+ RadioButton maleBox, femaleBox;
+ Button deleteBtn;
+
+ DatePickerDialog.OnDateSetListener dateSetListener;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_profile);
+ onLoad();
+ }
+
+ void onLoad(){
+ Bundle fromIntent = getIntent().getExtras();
+ server = new Server();
+
+ id_user = fromIntent.getInt("id_user");
+
+ loadObjects();
+ fillItAll();
+ }
+
+ @SuppressLint("SetTextI18n")
+ void loadObjects(){
+ username = findViewById(R.id.verifiedIcon);
+ nameBox = findViewById(R.id.nameBox);
+ emailBox = findViewById(R.id.emailBox);
+ phoneBox = findViewById(R.id.phoneBox);
+ actualPassBox = findViewById(R.id.actualPassBox);
+ newPassBox = findViewById(R.id.newPassBox);
+ rpPassBox = findViewById(R.id.rpPassBox);
+ birthdateBox = findViewById(R.id.birthdateBox);
+
+ maleBox = findViewById(R.id.maleBtn);
+ femaleBox = findViewById(R.id.femaleBtn);
+
+ deleteBtn = findViewById(R.id.deleteBtn);
+
+ dateSetListener = (datePicker, i, i1, i2) -> {
+ String year, month, day;
+ i1++;
+ month = (i1 < 10 ? "0" + i1 : Integer.toString(i1));
+ day = (i2 < 10 ? "0" + i2 : Integer.toString(i2));
+ year = Integer.toString(i);
+
+ birthdateBox.setText(year + "/" + month + "/" + day);
+ };
+ }
+
+ public void pickADate(View v){
+ Calendar cal = Calendar.getInstance();
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+
+ DatePickerDialog dialog = new DatePickerDialog(this, android.app.AlertDialog.THEME_HOLO_DARK, dateSetListener, year, month, day);
+ dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ dialog.show();
+ }
+
+ void fillItAll(){
+ try{
+ ResultSet rs = server.query("username, nazwaWyswietlana, email, numerTelefonu, dataUrodzenia, plec", "users", "id = " + id_user);
+ while(rs.next()){
+ username.setText(rs.getString(1));
+ nameBox.setText(rs.getString(2));
+ emailBox.setText(rs.getString(3));
+ phoneBox.setText(rs.getString(4));
+ birthdateBox.setText(rs.getString(5));
+
+ if(rs.getBoolean(6))
+ maleBox.setChecked(true);
+ else
+ femaleBox.setChecked(true);
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void exitEdit(View v){
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed(){
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+
+ public void updateProfile(View v){
+ try{
+ ResultSet rs = server.query("id", "users", "password = PASSWORD('" + actualPassBox.getText() + "') AND id = " + id_user);
+ if(!actualPassBox.getText().equals("")) {
+ while (rs.next()) {
+ if (rs.getInt(1) == id_user) {
+ server.update("users", "nazwaWyswietlana = '" + nameBox.getText() + "', email = '" + emailBox.getText() + "', numerTelefonu = '" + phoneBox.getText() + "', dataUrodzenia = '" + birthdateBox.getText() + "'", "id = " + id_user);
+
+ if(maleBox.isChecked())
+ server.update("users", "plec = 1", "id = " + id_user);
+ else
+ server.update("users", "plec = 0", "id = " + id_user);
+
+ Toast.makeText(this, "Profil został zaktualizowany!", Toast.LENGTH_SHORT).show();
+ if (newPassBox.getText() == rpPassBox.getText()) {
+ server.update("users", "password = PASSWORD('" + newPassBox.getText() + "')", "id = " + id_user);
+ Toast.makeText(this, "Hasło zostało zaktualizowane!", Toast.LENGTH_SHORT).show();
+ }
+ finish();
+ } else
+ Toast.makeText(this, "Wpisz swoje obecne hasło, aby zaktualizować swój profil!", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(this, "Wpisz swoje obecne hasło, aby zaktualizować swój profil!", Toast.LENGTH_SHORT).show();
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void deleteBtnAction(View v){
+ areYouSure();
+ }
+
+ void areYouSure(){
+ AlertDialog.Builder builder = new AlertDialog.Builder(deleteBtn.getContext());
+ DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
+ switch (which){
+ case DialogInterface.BUTTON_POSITIVE:
+ server.delete("posts", "id_autor = " + id_user);
+ server.delete("comments", "id_author = " + id_user);
+ Toast.makeText(deleteBtn.getContext(), "Konto zostało usunięte :(", Toast.LENGTH_SHORT).show();
+ server.delete("users", "id = " + id_user);
+ Intent intent = new Intent(deleteBtn.getContext(), Main.class);
+ finish();
+ startActivity(intent);
+ break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ Toast.makeText(deleteBtn.getContext(), "Uff... Fajnie, że zostajesz z nami :D", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ };
+
+ builder.setMessage("Czy na pewno chcesz usunąć konto? Wszystkie Twoje posty, komentarze oraz inne ślady znikną z serwisu. :/").setPositiveButton("Tak", dialogClickListener).setNegativeButton("Nie", dialogClickListener).show();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/GetEveryData.java b/app/src/main/java/pl/krzysiek/simplesocial/GetEveryData.java
new file mode 100644
index 0000000..208f4ec
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/GetEveryData.java
@@ -0,0 +1,39 @@
+package pl.krzysiek.simplesocial;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.os.AsyncTask;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class GetEveryData extends AsyncTask {
+ Helpers helper;
+ Server server;
+ public GetEveryData(Helpers help, Server srv){
+ helper = help;
+ server = srv;
+ }
+
+ @Override
+ protected String[][] doInBackground(Integer[] params){
+ String[][] table = new String[params.length][5];
+ for(int i = 0; i < params.length; i++){
+ ResultSet rs = server.query("posts.id_post, users.username, posts.tresc, posts.dataDodania, posts.tytul", "posts, users", "posts.id_post = " + params[i] + " AND users.id = posts.id_autor");
+ try{
+ while(rs.next()){
+ for(int j = 0; j < 5; j++){
+ table[i][j] = rs.getString(j + 1);
+ }
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+ return table;
+ }
+
+ @Override
+ protected void onPostExecute(String[][] table){
+ super.onPostExecute(table);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/GetMeImage.java b/app/src/main/java/pl/krzysiek/simplesocial/GetMeImage.java
new file mode 100644
index 0000000..abacbab
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/GetMeImage.java
@@ -0,0 +1,41 @@
+package pl.krzysiek.simplesocial;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.media.Image;
+import android.os.AsyncTask;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class GetMeImage extends AsyncTask {
+ private final ImageView img;
+ Helpers helpers;
+ Server server;
+ public GetMeImage(ImageView image, Helpers helper, Server srv){
+ img = image;
+ helpers = helper;
+ server = srv;
+ }
+ @Override
+ protected Bitmap doInBackground(String... id_post){
+ Bitmap bmp = null;
+ try {
+ ResultSet rs = server.query("picture", "posts_pictures", "id_post = " + id_post[0]);
+ while(rs.next()){
+ bmp = helpers.convertToBitmap(rs.getString(1));
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ return bmp;
+ }
+
+ @Override
+ protected void onPostExecute(Bitmap result){
+ super.onPostExecute(result);
+ img.setImageBitmap(result);
+ }
+}
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Group.java b/app/src/main/java/pl/krzysiek/simplesocial/Group.java
new file mode 100644
index 0000000..f5d7f38
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Group.java
@@ -0,0 +1,14 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+public class Group extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_group);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Helpers.java b/app/src/main/java/pl/krzysiek/simplesocial/Helpers.java
new file mode 100644
index 0000000..e93193f
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Helpers.java
@@ -0,0 +1,401 @@
+package pl.krzysiek.simplesocial;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.provider.MediaStore;
+import android.text.method.LinkMovementMethod;
+import android.text.util.Linkify;
+import android.view.ContextThemeWrapper;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.motion.widget.Debug;
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.lang.ref.WeakReference;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+import java.util.Base64;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Helpers extends AppCompatActivity {
+
+ final Server server = new Server();
+ Bitmap bmp;
+
+ public Bitmap convertToBitmap(String base64) {
+ byte[] decodedBytes = Base64.getDecoder().decode(base64);
+ return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
+ }
+
+ public String getThatPath(Uri uri, Context activity){
+ String[] filePathColumn = {MediaStore.Images.Media.DATA};
+ String yourRealPath = null;
+ Cursor cursor = activity.getContentResolver().query(uri, filePathColumn, null, null, null);
+ if(cursor.moveToFirst()){
+ int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
+ yourRealPath = cursor.getString(columnIndex);
+ } else
+ Debug.logStack("Błąd!", "Coś wyszło nie tak przy getThatPath. Linia 30 w Helpers", 1);
+
+ cursor.close();
+ return yourRealPath;
+ }
+
+ public String convertToBase64(Intent data, Context activity) {
+ String x = "";
+ try {
+ byte[] fileContent = org.apache.commons.io.FileUtils.readFileToByteArray(new File(getThatPath(data.getData(), activity)));
+ x = Base64.getEncoder().encodeToString(fileContent);
+ } catch (IOException ex){
+ ex.printStackTrace();
+ }
+ return x;
+ }
+
+ public String GetDate(){
+ LocalDateTime dateTime = LocalDateTime.now();
+ return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ }
+
+ @SuppressLint({"SetTextI18n", "ResourceAsColor", "UseCompatLoadingForDrawables", "StaticFieldLeak"})
+ public void GeneratePosts(LinearLayout postsList, int id_user, Activity activity, Context context, String from, String id_post, String autor, String text, String title, String datetime){
+ boolean nsfw = false;
+
+ TableLayout table = new TableLayout(postsList.getContext());
+ TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT);
+ table.setId(View.generateViewId());
+ table.setLayoutParams(tableParams);
+
+ TableRow authorRow = new TableRow(table.getContext());
+ authorRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ TextView authorLabel = new TextView(authorRow.getContext());
+ authorLabel.setPadding(16,16,16,16);
+ authorLabel.setText(autor + " \nDodano: " + datetime);
+
+ /* */
+
+ TableRow titleRow = new TableRow(table.getContext());
+ titleRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ TextView titleLabel = new TextView(titleRow.getContext());
+ titleLabel.setPadding(16,16,16,4);
+ titleLabel.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ titleLabel.setTextAppearance(R.style.TextAppearance_AppCompat_Large);
+ titleLabel.setMaxLines(2);
+ titleLabel.setTextSize(20f);
+ titleLabel.setText(title);
+ titleLabel.setOnClickListener(view -> {
+ Intent thePostIntent = new Intent(context, ThePost.class);
+ thePostIntent.putExtra("id_user", id_user);
+ thePostIntent.putExtra("id_post", id_post);
+ thePostIntent.putExtra("from", from);
+ activity.startActivity(thePostIntent);
+ });
+
+ /* */
+
+ TableRow textRow = new TableRow(table.getContext());
+ textRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ TextView textLabel = new TextView(textRow.getContext());
+ textLabel.setPadding(16,4,16,16);
+ textLabel.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ textLabel.setMaxLines(5);
+ textLabel.setTextSize(20f);
+ textLabel.setText(text);
+ textLabel.setOnClickListener(view -> {
+ Intent thePostIntent = new Intent(context, ThePost.class);
+ thePostIntent.putExtra("id_user", id_user);
+ thePostIntent.putExtra("id_post", id_post);
+ thePostIntent.putExtra("from", from);
+ activity.startActivity(thePostIntent);
+ });
+
+ ImageView image = new ImageView(table.getContext());
+ try{
+ ResultSet haveImage = server.query("typPosta", "posts", "id_post = " + id_post);
+ while(haveImage.next()){
+ if(haveImage.getBoolean(1)){
+ TableLayout.LayoutParams layout = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
+ layout.setMargins(0, 16, 0, 32);
+ image.setLayoutParams(layout);
+ image.setAdjustViewBounds(true);
+ image.setId(View.generateViewId());
+ image.setMaxHeight(1920);
+ GetMeImage gmi = new GetMeImage(image, this, server);
+ gmi.doInBackground(id_post);
+ WeakReference imageViewWeakReference = new WeakReference<>(image);
+ new AsyncTask(){
+ @Override
+ protected Bitmap doInBackground(String... strings){
+ Bitmap bitmap = null;
+ try {
+ ResultSet rs = server.query("picture", "posts_pictures", "id_post = " + id_post);
+ while(rs.next()){
+ bitmap = convertToBitmap(rs.getString(1));
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ return bitmap;
+ }
+
+ @Override
+ protected void onPostExecute(Bitmap bitmap){
+ super.onPostExecute(bitmap);
+ if(bitmap != null){
+ ImageView weak = imageViewWeakReference.get();
+ if(weak != null)
+ weak.setImageBitmap(bitmap);
+ }
+ }
+ }.execute();
+ /*ResultSet getImage = server.query("picture", "posts_pictures", "id_post = " + id_post);
+ while (getImage.next()) {
+ image.setImageBitmap(convertToBitmap(getImage.getString(1)));*/
+
+ }
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+
+ TableRow nsfwTag = new TableRow(table.getContext());
+ nsfwTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
+ nsfwTag.setGravity(Gravity.START);
+
+ ImageView nsfwIcon = new ImageView(nsfwTag.getContext());
+ nsfwIcon.setImageDrawable(context.getDrawable(R.drawable.warning));
+ nsfwIcon.setId(View.generateViewId());
+ TableRow.LayoutParams iconLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
+ iconLayout.setMargins(16,16,4,16);
+ nsfwIcon.setLayoutParams(iconLayout);
+ nsfwIcon.setBackgroundColor(Color.BLACK);
+ nsfwIcon.setMaxWidth(32);
+
+ TextView nsfwText = new TextView(nsfwTag.getContext());
+ nsfwText.setText("NSFW");
+ TableRow.LayoutParams textLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
+ textLayout.setMargins(4,16,16,16);
+ nsfwText.setLayoutParams(textLayout);
+
+ nsfwTag.addView(nsfwIcon);
+ nsfwTag.addView(nsfwText);
+
+ /* */
+
+ TableRow likesRow = new TableRow(table.getContext());
+ likesRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
+
+ ConstraintLayout inLikesRow = new ConstraintLayout(likesRow.getContext());
+ inLikesRow.setId(View.generateViewId());
+ TableRow.LayoutParams inLikesRowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1.0f);
+ inLikesRow.setLayoutParams(inLikesRowParams);
+
+ ContextThemeWrapper newContext = new ContextThemeWrapper(context, R.style.Widget_MaterialComponents_Button);
+
+ Button likesBtn = new Button(newContext);
+ likesBtn.setId(View.generateViewId());
+ ConstraintLayout.LayoutParams likeParams = new ConstraintLayout.LayoutParams((int) context.getResources().getDisplayMetrics().density * 70, ConstraintLayout.LayoutParams.WRAP_CONTENT);
+ likeParams.setMarginStart(8);
+ likeParams.startToStart = 0;
+ likeParams.topToTop = 0;
+ likeParams.bottomToBottom = 0;
+ likesBtn.setGravity(Gravity.CENTER);
+
+ TextView likesCount = new TextView(inLikesRow.getContext());
+ ConstraintLayout.LayoutParams likesCountParams = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
+ likesCountParams.startToEnd = likesBtn.getId();
+ likesCountParams.bottomToBottom = 0;
+ likesCountParams.topToTop = 0;
+ likesCountParams.setMarginStart(8);
+ likesCount.setGravity(Gravity.CENTER);
+ likesCount.setTextAppearance(R.style.TextAppearance_AppCompat_Large);
+ likesCount.setId(View.generateViewId());
+ likesCount.setLayoutParams(likesCountParams);
+ try {
+ ResultSet rs = server.query("COUNT(*)", "posts_likes", "id_post = " + id_post);
+ while(rs.next())
+ likesCount.setText(rs.getString(1));
+
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+
+ likesBtn.setLayoutParams(likeParams);
+ try{
+ ResultSet rs = server.query("id_like", "posts_likes", "id_post = " + id_post + " AND id_user = " + id_user);
+ if(!rs.isBeforeFirst())
+ likesBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.like_icon, 0, 0, 0);
+ else
+ likesBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.liked_icon, 0,0,0);
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ likesBtn.setOnClickListener(view -> {
+ try{
+ ResultSet rs = server.query("id_like", "posts_likes", "id_post = " + id_post + " AND id_user = " + id_user);
+ if(!rs.isBeforeFirst()) {
+ server.insert("posts_likes", "NULL, " + id_post + ", " + id_user + ", '" + GetDate() + "'");
+ likesBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.liked_icon, 0,0,0);
+ } else {
+ server.delete("posts_likes", "id_post = " + id_post + " AND id_user = " + id_user);
+ likesBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.like_icon, 0, 0, 0);
+ }
+ ResultSet rsLikes = server.query("COUNT(*)", "posts_likes", "id_post = " + id_post);
+ while(rsLikes.next())
+ likesCount.setText(rsLikes.getString(1));
+
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ });
+
+ View divider = new View(inLikesRow.getContext());
+ divider.setId(View.generateViewId());
+ ConstraintLayout.LayoutParams dividerParams = new ConstraintLayout.LayoutParams((int) context.getResources().getDisplayMetrics().density, ConstraintLayout.LayoutParams.MATCH_PARENT);
+ dividerParams.startToEnd = likesCount.getId();
+ dividerParams.topToTop = 0;
+ dividerParams.bottomToBottom = 0;
+ dividerParams.setMargins(16, 0, 0, 0);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(context.getColor(R.color.gray_600));
+
+ Button commentsBtn = new Button(newContext);
+ commentsBtn.setId(View.generateViewId());
+ ConstraintLayout.LayoutParams commentsParams = new ConstraintLayout.LayoutParams((int) context.getResources().getDisplayMetrics().density * 70, ConstraintLayout.LayoutParams.WRAP_CONTENT);
+ commentsParams.setMarginStart(16);
+ commentsParams.startToEnd = divider.getId();
+ commentsParams.topToTop = 0;
+ commentsParams.bottomToBottom = 0;
+ commentsBtn.setGravity(Gravity.CENTER);
+ commentsBtn.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.comment_icon,0);
+ commentsBtn.setLayoutParams(commentsParams);
+ commentsBtn.setOnClickListener(view ->{
+ Intent thePostIntent = new Intent(context, ThePost.class);
+ thePostIntent.putExtra("id_user", id_user);
+ thePostIntent.putExtra("id_post", id_post);
+ thePostIntent.putExtra("from", from);
+ activity.startActivity(thePostIntent);
+ });
+
+ View divider2 = new View(postsList.getContext());
+ TableRow.LayoutParams divider2Params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) context.getResources().getDisplayMetrics().density);
+ divider2Params.setMargins(32, 32, 32, 32);
+ divider2.setLayoutParams(divider2Params);
+ divider2.setBackgroundColor(context.getColor(R.color.gray_400));
+
+ try{
+ ResultSet checkNsfw = server.query("nsfw", "posts", "id_post = " + id_post);
+ while(checkNsfw.next()){
+ nsfw = checkNsfw.getBoolean(1);
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+
+ titleRow.addView(titleLabel);
+ inLikesRow.addView(likesBtn);
+ inLikesRow.addView(likesCount);
+ inLikesRow.addView(divider);
+ inLikesRow.addView(commentsBtn);
+ likesRow.addView(inLikesRow);
+ textRow.addView(textLabel);
+ authorRow.addView(authorLabel);
+
+ table.addView(authorRow);
+ table.addView(titleRow);
+
+ if(!nsfw) {
+ table.addView(textRow);
+ table.addView(image);
+ } else {
+ table.addView(nsfwTag);
+ }
+ table.addView(likesRow);
+ postsList.addView(table);
+ postsList.addView(divider2);
+ }
+
+ @SuppressLint("SetTextI18n")
+ void GenerateComments(LinearLayout commentList, String autor, Context context, String tresc, String dataUtworzenia, TextView author){
+ LinearLayout comment = new LinearLayout(commentList.getContext());
+ LinearLayout.LayoutParams linParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ comment.setOrientation(LinearLayout.VERTICAL);
+ comment.setId(View.generateViewId());
+ comment.setLayoutParams(linParams);
+
+ TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
+ TableRow authorRow = new TableRow(comment.getContext());
+ authorRow.setId(View.generateViewId());
+ authorRow.setLayoutParams(rowParams);
+
+ TextView authorText = new TextView(authorRow.getContext());
+ authorText.setId(View.generateViewId());
+ authorText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ authorText.setPadding(16, 16, 16, 4);
+ authorText.setText(autor + " odpowiedział " + author.getText());
+
+ TableRow content = new TableRow(comment.getContext());
+ content.setId(View.generateViewId());
+ content.setLayoutParams(rowParams);
+
+ TextView contentText = new TextView(author.getContext());
+ contentText.setId(View.generateViewId());
+ contentText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ contentText.setPadding(16, 4, 16, 4);
+ contentText.setAutoLinkMask(Linkify.ALL);
+ contentText.setMovementMethod(LinkMovementMethod.getInstance());
+ contentText.setText(tresc);
+
+ TableRow added = new TableRow(comment.getContext());
+ added.setId(View.generateViewId());
+ added.setLayoutParams(rowParams);
+
+ TextView addedText = new TextView(author.getContext());
+ addedText.setId(View.generateViewId());
+ addedText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ addedText.setPadding(16, 4, 16, 16);
+ addedText.setText("Dodano " + dataUtworzenia);
+
+ View divider = new View(commentList.getContext());
+ TableRow.LayoutParams dividerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) context.getResources().getDisplayMetrics().density);
+ dividerParams.setMargins(32, 32, 32, 32);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(context.getColor(R.color.gray_400));
+
+ authorRow.addView(authorText);
+ content.addView(contentText);
+ added.addView(addedText);
+
+ comment.addView(authorRow);
+ comment.addView(content);
+ comment.addView(added);
+
+ commentList.addView(comment);
+ commentList.addView(divider);
+ }
+}
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Homepage.java b/app/src/main/java/pl/krzysiek/simplesocial/Homepage.java
new file mode 100644
index 0000000..14c8d09
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Homepage.java
@@ -0,0 +1,473 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Icon;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.MediaStore;
+import android.text.InputFilter;
+import android.view.*;
+import android.widget.*;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.tabs.*;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.concurrent.ExecutionException;
+
+public class Homepage extends AppCompatActivity implements Serializable {
+
+ public static int id;
+
+ TextView loggedAs;
+ FloatingActionButton newPostBtn;
+ Button refreshBtn;
+
+ ScrollView homeView, menuView, searchView;
+ TabLayout navigationTab;
+ LinearLayout postsList, searchResults;
+ int posts = 0;
+
+ EditText searchBar;
+ ImageView avatarUser;
+ SharedPreferences settings;
+ SharedPreferences.Editor editor;
+ Server server;
+ Helpers helper;
+ Activity activity = this;
+ Intent imageData;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.homepage);
+ GetFromMain();
+ onLoad();
+ refreshHomepage();
+ changeTab();
+ }
+
+ void GetFromMain(){
+ id = Main.id;
+ settings = Main.settings;
+ editor = Main.editor;
+ }
+
+ public void AddNewPost(View v){
+ Intent intent = new Intent(this, NewPost.class);
+ startActivity(intent);
+ finish();
+ }
+
+ @SuppressLint("SetTextI18n")
+ public void onLoad(){
+ postsList = findViewById(R.id.postsList);
+ server = new Server();
+ helper = new Helpers();
+ loggedAs = findViewById(R.id.loggedAsText);
+ newPostBtn = findViewById(R.id.button);
+ refreshBtn = findViewById(R.id.refreshHomepage);
+ avatarUser = findViewById(R.id.avatarUser);
+
+ searchBar = findViewById(R.id.searchET);
+ navigationTab = findViewById(R.id.navigationTab);
+ searchView = findViewById(R.id.searchView);
+ homeView = findViewById(R.id.homeView);
+ menuView = findViewById(R.id.menuView);
+
+ searchResults = findViewById(R.id.searchResults);
+
+ ResultSet rs = server.query("username, nazwaWyswietlana, avatar", "users", "id = " + id);
+ try {
+ while(rs.next()) {
+ if(rs.getString(2).matches(""))
+ loggedAs.setText("Witaj,\n" + rs.getString(1));
+ else
+ loggedAs.setText("Witaj,\n" + rs.getString(2));
+
+ if(rs.getString(3) != null) {
+ if (!rs.getString(3).matches(""))
+ avatarUser.setImageBitmap(helper.convertToBitmap(rs.getString(3)));
+ else
+ avatarUser.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ } else
+ avatarUser.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ }
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void addMore(View v){
+ refreshHomepage();
+ }
+
+ public void refresh(View v){
+ postsList.removeAllViewsInLayout();
+ posts = 0;
+ refreshHomepage();
+ }
+
+ public void changeAvatar(View v){
+ imgAdd();
+ }
+
+ private final ActivityResultLauncher requestPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { if (isGranted) { imgAdd(); } else { Toast.makeText(this, "Nie możesz dodać zdjęcia do postu, ponieważ nie zezwoliłeś aplikacji na dostęp do plików.", Toast.LENGTH_LONG).show(); } });
+
+ @SuppressLint("IntentReset")
+ public void imgAdd(){
+ if(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
+ pickIntent.setType("image/*");
+ startActivityForResult(pickIntent, 1);
+ } else {
+ requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
+ }
+ }
+
+ @SuppressLint("StaticFieldLeak")
+ public void refreshHomepage(){
+ /*String[][] publicTable = null;
+ new Thread(() -> {
+ int size = 0;
+ String[][] table = null;
+ try {
+ ResultSet rs1 = server.query("posts.id_post", "posts");
+ if (rs1 != null) {
+ rs1.last();
+ size = rs1.getRow();
+ }
+ int[] id_posts = new int[size];
+
+ ResultSet rs2 = server.query("posts.id_post", "posts");
+ while (rs2.next()) {
+ for (int i = 0; i < size; i++) {
+ rs2.absolute(i + 1);
+ id_posts[i] = rs2.getInt(1);
+ }
+ }
+
+ table = new String[size][5];
+ for (int i = 0; i < size; i++) {
+ String[][] finalTable = table;
+ int x = i;
+ new Thread(() ->{
+ GetEveryData data = new GetEveryData(id_posts[x], server);
+ finalTable[x][0] = data.giveData()[0];
+ finalTable[x][1] = data.giveData()[1];
+ finalTable[x][2] = data.giveData()[2];
+ finalTable[x][3] = data.giveData()[3];
+ finalTable[x][4] = data.giveData()[4];
+ }).start();
+ runOnUiThread(() -> {
+ helper.GeneratePosts(
+ postsList,
+ id,
+ activity,
+ getBaseContext(),
+ "homepage",
+ finalTable[x][0],
+ finalTable[x][1],
+ finalTable[x][2],
+ finalTable[x][4],
+ finalTable[x][3]
+ );
+ });
+ }
+ publicTable = table;
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ }).start();*/
+ ResultSet rs = server.query("posts.id_post, users.username, posts.tresc, posts.dataDodania, posts.tytul", "posts, users", "users.id = posts.id_autor", "ORDER BY id_post DESC LIMIT " + posts + ",5");
+ new AsyncTask(){
+ @Override
+ protected String doInBackground(ResultSet... params){
+ runOnUiThread(() -> {
+ try {
+ while (rs.next()) {
+ helper.GeneratePosts(
+ postsList,
+ id,
+ activity,
+ getBaseContext(),
+ "homepage",
+ params[0].getString(1),
+ params[0].getString(2),
+ params[0].getString(3),
+ params[0].getString(5),
+ params[0].getString(4)
+ );
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ });
+ return "";
+ }
+ }.execute(rs);
+
+ Toast.makeText(this, "Pomyślnie zaktualizowano!", Toast.LENGTH_SHORT).show();
+ posts += 5;
+ }
+
+ public String[] con(String[] to){ return to;}
+
+ public void goToProfile(View v){
+ Intent intent = new Intent(this, Profile.class);
+ intent.putExtra("id_user", id);
+ startActivity(intent);
+ finish();
+ }
+
+ public void changeTab(){
+ navigationTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+ @Override
+ public void onTabSelected(TabLayout.Tab tab) {
+ switch(tab.getPosition()){
+ case 0:
+ homeView.setVisibility(View.VISIBLE);
+ refreshBtn.setVisibility(View.VISIBLE);
+ newPostBtn.setVisibility(View.VISIBLE);
+ break;
+ case 1:
+
+ break;
+ case 2:
+ searchView.setVisibility(View.VISIBLE);
+ break;
+ case 3:
+ menuView.setVisibility(View.VISIBLE);
+ break;
+ }
+ }
+
+ @Override
+ public void onTabUnselected(TabLayout.Tab tab) {
+ switch(tab.getPosition()){
+ case 0:
+ homeView.setVisibility(View.GONE);
+ refreshBtn.setVisibility(View.GONE);
+ newPostBtn.setVisibility(View.GONE);
+ break;
+ case 1:
+
+ break;
+ case 2:
+ searchView.setVisibility(View.GONE);
+ break;
+ case 3:
+ menuView.setVisibility(View.GONE);
+ break;
+ }
+ }
+
+ @Override
+ public void onTabReselected(TabLayout.Tab tab) {
+
+ }
+ });
+ }
+
+ public void logOff(View v){
+ editor.putInt("userID", 0);
+ editor.apply();
+ Intent intent = new Intent(this, Main.class);
+ startActivity(intent);
+ finish();
+ }
+
+ public void editProfile(View v){
+ Intent intent = new Intent(this, EditProfile.class);
+ intent.putExtra("id_user", id);
+ startActivity(intent);
+ finish();
+ }
+
+ public void editDescription(View v){
+ EditText descriptionText = new EditText(this);
+ TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
+ params.setMargins(4,4,4,4);
+ descriptionText.setLayoutParams(params);
+ descriptionText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(200)});
+ AlertDialog.Builder alert = new AlertDialog.Builder(this);
+
+ try{
+ ResultSet rs = server.query("opis", "users", "id = " + id);
+
+ while(rs.next()){
+ descriptionText.setText(rs.getString(1));
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+
+ alert.setTitle("Twój opis");
+ alert.setView(descriptionText);
+
+ alert.setPositiveButton("Zapisz", (dialogInterface, i) -> {
+ server.update("users", "opis = '" + descriptionText.getText().toString() + "'", "id = " + id);
+ Toast.makeText(alert.getContext(), "Opis został zmieniony", Toast.LENGTH_SHORT).show();
+ });
+
+ alert.setNegativeButton("Anuluj", (dialogInterface, i) -> {
+ });
+
+ alert.show();
+ }
+
+ public void search(View v){
+ searchResults.removeAllViewsInLayout();
+ findInAll(searchBar.getText().toString());
+ }
+
+ public void findInAll(String phrase){
+ try {
+ // Uzytkownicy
+ ResultSet usersRS = server.query("username, opis, nazwaWyswietlana, zweryfikowany, avatar, id", "users", "username LIKE '%" + phrase + "%' OR nazwaWyswietlana LIKE '%" + phrase + "%' OR opis LIKE '%" + phrase + "%' LIMIT 3");
+ if(usersRS.isBeforeFirst()){
+ TextView textOne = new TextView(searchResults.getContext());
+ textOne.setId(View.generateViewId());
+ LinearLayout.LayoutParams textOneParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ textOne.setPadding(8, 8, 8, 8);
+ textOne.setLayoutParams(textOneParams);
+ textOne.setTextAppearance(R.style.TextAppearance_AppCompat_Medium);
+ textOne.setText("Użytkownicy");
+ searchResults.addView(textOne);
+
+ while (usersRS.next()) {
+ int id_user = usersRS.getInt(6);
+
+ TableRow userRow = new TableRow(searchResults.getContext());
+ userRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
+ userRow.setId(View.generateViewId());
+ userRow.setPadding(8,8,8,8);
+
+ ImageView avatarUser = new ImageView(userRow.getContext());
+ avatarUser.setId(View.generateViewId());
+ TableRow.LayoutParams avatarParams = new TableRow.LayoutParams((int) getResources().getDisplayMetrics().density * 64, (int) getResources().getDisplayMetrics().density * 64);
+ avatarParams.setMargins(8, 8, 4, 8);
+ avatarUser.setLayoutParams(avatarParams);
+ avatarUser.setAdjustViewBounds(true);
+ avatarUser.setScaleType(ImageView.ScaleType.CENTER_CROP);
+
+ if (usersRS.getString(5) != null) {
+ avatarUser.setImageBitmap(helper.convertToBitmap(usersRS.getString(5)));
+ } else {
+ avatarUser.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ }
+
+ avatarUser.setOnClickListener(view -> {
+ Intent intent = new Intent(this, Profile.class);
+ intent.putExtra("id_user", id_user);
+ startActivity(intent);
+ finish();
+ });
+ userRow.addView(avatarUser);
+
+ LinearLayout otherData = new LinearLayout(userRow.getContext());
+ otherData.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
+ otherData.setOrientation(LinearLayout.VERTICAL);
+ otherData.setId(View.generateViewId());
+
+ TableRow usernameRow = new TableRow(otherData.getContext());
+ usernameRow.setId(View.generateViewId());
+ usernameRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
+
+ if (usersRS.getBoolean(4)) {
+ ImageView verifiedIcon = new ImageView(usernameRow.getContext());
+ verifiedIcon.setId(View.generateViewId());
+ TableRow.LayoutParams verifiedParam = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.MATCH_PARENT);
+ verifiedParam.setMargins(8, 8, 4, 4);
+ verifiedIcon.setLayoutParams(verifiedParam);
+ verifiedIcon.setImageIcon(Icon.createWithResource(this, R.drawable.verified_icon));
+ usernameRow.addView(verifiedIcon);
+ }
+
+ TextView username = new TextView(usernameRow.getContext());
+ username.setId(View.generateViewId());
+ TableRow.LayoutParams usernameParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
+ usernameParams.setMargins(4, 8, 8, 4);
+ username.setLayoutParams(usernameParams);
+ username.setText(usersRS.getString(1));
+ username.setOnClickListener(view -> {
+ Intent intent = new Intent(this, Profile.class);
+ intent.putExtra("id_user", id_user);
+ startActivity(intent);
+ finish();
+ });
+
+ TextView description = new TextView(otherData.getContext());
+ description.setId(View.generateViewId());
+ TableRow.LayoutParams descriptionParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
+ descriptionParams.setMargins(8, 4, 8, 8);
+ description.setLayoutParams(descriptionParams);
+ description.setText(usersRS.getString(2));
+ description.setOnClickListener(view -> {
+ Intent intent = new Intent(this, Profile.class);
+ intent.putExtra("id_user", id_user);
+ startActivity(intent);
+ finish();
+ });
+
+ usernameRow.addView(username);
+ otherData.addView(usernameRow);
+ otherData.addView(description);
+ userRow.addView(otherData);
+
+ searchResults.addView(userRow);
+ }
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void postManagement(View v) {
+ Intent intent = new Intent(this, PostsManagement.class);
+ startActivity(intent);
+ finish();
+ }
+
+ public void commentManagement(View v){
+ Intent intent = new Intent(this, CommentsManagement.class);
+ intent.putExtra("user", id);
+ startActivity(intent);
+ finish();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data){
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == 1 && resultCode == RESULT_OK) {
+ Bitmap bitmap = null;
+ if(data != null){
+ try{
+ imageData = data;
+ bitmap = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), imageData.getData());
+ Toast.makeText(this, helper.getThatPath(data.getData(), this), Toast.LENGTH_SHORT).show();
+ server.update("users", "avatar = '" + helper.convertToBase64(imageData, this) + "'", "id = " + id);
+ } catch (IOException ex){
+ ex.printStackTrace();
+ }
+ }
+ avatarUser.setImageBitmap(bitmap);
+ Toast.makeText(this, "Zmieniono", Toast.LENGTH_SHORT).show();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Main.java b/app/src/main/java/pl/krzysiek/simplesocial/Main.java
new file mode 100644
index 0000000..8af2655
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Main.java
@@ -0,0 +1,162 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.StrictMode;
+import android.text.InputType;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.Switch;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class Main extends AppCompatActivity {
+
+ public static int id;
+ boolean automaticLogIn = false;
+
+ EditText usernameText;
+ EditText passwordText;
+ Switch showPassword;
+ public static Server server;
+
+ public static SharedPreferences settings;
+ public static SharedPreferences.Editor editor;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ onLoad();
+ passwordText.setOnEditorActionListener((v, actionId, event) -> {
+ if(actionId == EditorInfo.IME_ACTION_GO){
+ if(!usernameText.getText().toString().matches("") && !passwordText.getText().toString().matches(""))
+ LogIn();
+ else
+ Toast.makeText(this, "Nie możesz się zalogować bez podania danych do logowania!", Toast.LENGTH_LONG).show();
+ }
+
+ return true;
+ });
+
+ showPassword.setOnCheckedChangeListener((compoundButton, b) -> {
+ if(b)
+ passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
+ else {
+ passwordText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ }
+ });
+ }
+
+ public void onLoad(){
+ setObjects();
+ policySet();
+ server = new Server();
+ showPassword = findViewById(R.id.showPassword);
+
+ settings = getApplicationContext().getSharedPreferences("userID", MODE_PRIVATE);
+ editor = settings.edit();
+
+ if(settings.getInt("userID", MODE_PRIVATE) == 0) {
+ automaticLogIn = false;
+ }else{
+ automaticLogIn = true;
+ LogIn();
+ }
+ }
+
+ @Override
+ public void onBackPressed(){
+ server.close();
+ finish();
+ }
+
+ void setObjects(){
+ usernameText = findViewById(R.id.usernameBar);
+ passwordText = findViewById(R.id.passwordBar);
+ }
+
+ // Wymagane, aby mógł się połączyć z siecią
+ public void policySet(){
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
+ StrictMode.setThreadPolicy(policy);
+ }
+
+ public void AddToTable(View v){
+ Intent intent = new Intent(this, Registration.class);
+ startActivity(intent);
+ }
+
+ public void LogInBtn(View v){
+ if(!usernameText.getText().toString().matches("") && !passwordText.getText().toString().matches(""))
+ LogIn();
+ else
+ Toast.makeText(this, "Nie możesz się zalogować bez podania danych do logowania!", Toast.LENGTH_LONG).show();
+ }
+
+ void LogIn(){
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener dialogClickListener;
+ try{
+ if(!automaticLogIn){
+ ResultSet rs = server.query("id, username, nazwaWyswietlana", "users", "username = '" + usernameText.getText() + "' OR numerTelefonu = '" + usernameText.getText() + "' OR email = '" + usernameText.getText() + "' AND password = PASSWORD('" + passwordText.getText() + "')");
+
+ if(rs.isBeforeFirst()){
+ while (rs.next()) {
+ id = rs.getInt(1);
+ String username = rs.getString(2);
+ String displayname = rs.getString(3);
+ dialogClickListener = (dialogInterface, i) -> {
+ switch (i) {
+ case DialogInterface.BUTTON_POSITIVE:
+ editor.putInt("userID", id);
+ editor.apply();
+ TheThirdLogIn(username, displayname);
+ break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ TheThirdLogIn(username, displayname);
+ break;
+ }
+ };
+ builder.setMessage("Czy chcesz zachować zalogowane konto na urządzeniu?").setPositiveButton("Tak", dialogClickListener).setNegativeButton("Nie", dialogClickListener).show();
+ }
+ } else {
+ Toast.makeText(this, "Nie poprawne dane logowania", Toast.LENGTH_LONG).show();
+ }
+ } else {
+ id = settings.getInt("userID", 0);
+ ResultSet rs = server.query("username, nazwaWyswietlana", "users", "id = " + id);
+
+ while(rs.next()){
+ TheThirdLogIn(rs.getString(1), rs.getString(2));
+ }
+ }
+ } catch(SQLException ex){
+ Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ public void GoToHomepage(){
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+
+ void TheThirdLogIn(String username, String displayname){
+ if (displayname == null)
+ Toast.makeText(Main.this, "Witaj ponownie, " + username + "!", Toast.LENGTH_LONG).show();
+ else
+ Toast.makeText(Main.this, "Witaj ponownie, " + displayname + "!", Toast.LENGTH_LONG).show();
+ GoToHomepage();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/NewPost.java b/app/src/main/java/pl/krzysiek/simplesocial/NewPost.java
new file mode 100644
index 0000000..b968cb7
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/NewPost.java
@@ -0,0 +1,134 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.provider.MediaStore;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import java.io.IOException;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+public class NewPost extends AppCompatActivity {
+
+ static int id;
+ Server server;
+ Helpers helper;
+ EditText text, title;
+ CheckBox nsfwTag;
+ ImageView imageToPost;
+ Intent imageData;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_new_post);
+
+ onLoad();
+ }
+
+ void onLoad(){
+ server = new Server();
+ helper = new Helpers();
+
+ id = Homepage.id;
+ text = findViewById(R.id.postTextBox);
+ title = findViewById(R.id.titleBox);
+ imageToPost = findViewById(R.id.imageToPost);
+ nsfwTag = findViewById(R.id.nsfwTag);
+ }
+
+ public void addPost(View v){
+ if(!title.getText().toString().matches("")) {
+ String date = helper.GetDate();
+ String nsfw = "";
+
+ if (nsfwTag.isChecked())
+ nsfw = "1";
+ else
+ nsfw = "0";
+
+ try {
+ int id_post = 0;
+ if (imageData != null) {
+ server.insert("posts", "id_autor, dataDodania, tytul, tresc, typPosta, nsfw", id + ", NOW(), \"" + title.getText() + "\", \"" + text.getText() + "\", 1, " + nsfw);
+ ResultSet rsNew = server.query("id_post", "posts", "id_autor = '" + id + "' AND tytul = '" + title.getText() + "' AND tresc = '" + text.getText() + "' AND typPosta = '1';");
+ while (rsNew.next()) {
+ id_post = rsNew.getInt(1);
+ }
+ uploadImage(id, id_post, date, imageData);
+ } else
+ server.insert("posts", "id_autor, dataDodania, tytul, tresc, typPosta, nsfw", id + ", \"" + date + "\", \"" + title.getText() + "\", \"" + text.getText() + "\", 0, " + nsfw);
+
+ Toast.makeText(this, "Post został utworzony", Toast.LENGTH_LONG).show();
+ Intent intent = new Intent(this, ThePost.class);
+ intent.putExtra("id_post", id_post);
+ intent.putExtra("id_user", id);
+ intent.putExtra("from", "homepage");
+ startActivity(intent);
+ finish();
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ Toast.makeText(this, "Post musi zawierać tytuł!", Toast.LENGTH_LONG).show();
+ }
+ }
+
+ @SuppressLint("RestrictedApi")
+ public void addImage(View v){
+ imgAdd();
+ }
+
+ private final ActivityResultLauncher requestPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { if (isGranted) { imgAdd(); } else { Toast.makeText(this, "Nie możesz dodać zdjęcia do postu, ponieważ nie zezwoliłeś aplikacji na dostęp do plików.", Toast.LENGTH_LONG).show(); } });
+
+ @SuppressLint("IntentReset")
+ public void imgAdd(){
+ if(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
+ pickIntent.setType("image/*");
+
+ startActivityForResult(pickIntent, 1);
+ } else {
+ requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == 1 && resultCode == RESULT_OK) {
+ Bitmap bitmap = null;
+ if(data != null){
+ try{
+ imageData = data;
+ bitmap = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), imageData.getData());
+ Toast.makeText(this, helper.getThatPath(data.getData(), this), Toast.LENGTH_SHORT).show();
+ } catch (IOException ex){
+ ex.printStackTrace();
+ }
+ }
+ imageToPost.setImageBitmap(bitmap);
+ Toast.makeText(this, "Dodałem się", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ void uploadImage(int id_autor, int id_post, String dataDodania, Intent data) {
+ server.insert("posts_pictures", "NULL, '" + id_autor + "', '" + id_post + "', '" + helper.convertToBase64(data, this) + "', '" + dataDodania + "'");
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/PostsManagement.java b/app/src/main/java/pl/krzysiek/simplesocial/PostsManagement.java
new file mode 100644
index 0000000..c31c6f7
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/PostsManagement.java
@@ -0,0 +1,184 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.core.content.ContextCompat;
+
+import android.annotation.SuppressLint;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.ContextThemeWrapper;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class PostsManagement extends AppCompatActivity {
+
+ LinearLayout postsList;
+ Server server;
+ public static int id;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_posts_management);
+ server = new Server();
+
+ onLoad();
+ }
+
+ void onLoad(){
+ postsList = findViewById(R.id.postList);
+ id = Homepage.id;
+ refreshPosts();
+ }
+
+ void refreshPosts(){
+ ResultSet res = server.query("id_post, tresc, tytul, dataDodania", "posts", "id_autor = " + id, "ORDER BY id_post DESC");
+ try{
+ while(res.next()){
+ showPosts(
+ res.getInt(1),
+ res.getString(2),
+ res.getString(3),
+ res.getString(4)
+ );
+ }
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @SuppressLint({"SetTextI18n", "ResourceAsColor"})
+ public void showPosts(int id_post, String tresc, String title, String dataUtworzenia){
+ LinearLayout post = new LinearLayout(postsList.getContext());
+ LinearLayout.LayoutParams commentParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ commentParams.setMargins(0,4,8,4);
+ post.setLayoutParams(commentParams);
+ post.setId(View.generateViewId());
+ post.setOrientation(LinearLayout.HORIZONTAL);
+
+ LinearLayout buttonGroup = new LinearLayout(post.getContext());
+ LinearLayout.LayoutParams btnGroupParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ buttonGroup.setLayoutParams(btnGroupParams);
+ buttonGroup.setId(View.generateViewId());
+ buttonGroup.setOrientation(LinearLayout.VERTICAL);
+ buttonGroup.setGravity(Gravity.CENTER);
+
+ LinearLayout postContent = new LinearLayout(post.getContext());
+ LinearLayout.LayoutParams commentsParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ postContent.setLayoutParams(commentsParams);
+ postContent.setId(View.generateViewId());
+ postContent.setOrientation(LinearLayout.VERTICAL);
+
+ ContextThemeWrapper theme = new ContextThemeWrapper(buttonGroup.getContext(), R.style.Widget_MaterialComponents_Button);
+ LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ buttonParams.setMargins(8,2,8,2);
+
+ Button editButton = new Button(theme);
+ editButton.setLayoutParams(buttonParams);
+ editButton.setId(View.generateViewId());
+ editButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.description_icon, 0,0,0);
+ editButton.setOnClickListener(view -> {
+ Intent intent = new Intent(this, EditPost.class);
+ intent.putExtra("post", id_post);
+ intent.putExtra("user", id);
+ startActivity(intent);
+ finish();
+ });
+
+ Button deleteButton = new Button(theme);
+ deleteButton.setLayoutParams(buttonParams);
+ deleteButton.setId(View.generateViewId());
+ deleteButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.delete_icon,0,0,0);
+ deleteButton.setOnClickListener(view -> {
+ AlertDialog.Builder alert = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener alertDialog = (dialog, which) -> {
+ switch (which) {
+ case DialogInterface.BUTTON_POSITIVE:
+ server.delete("comments", "id_post = " + id_post);
+ server.delete("posts_likes", "id_post = " + id_post);
+ server.delete("posts_pictures", "id_post = " + id_post);
+ server.delete("posts", "id_post = " + id_post);
+ Toast.makeText(this, "Post został usunięty", Toast.LENGTH_SHORT).show();
+ postsList.removeAllViewsInLayout();
+ refreshPosts();
+ break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ break;
+ }
+ };
+
+ alert.setMessage("Czy na pewno chcesz usunąć ten post?").setPositiveButton("Tak", alertDialog).setNegativeButton("Nie", alertDialog).show();
+ });
+
+ Button postButton = new Button(theme);
+ postButton.setLayoutParams(buttonParams);
+ postButton.setId(View.generateViewId());
+ postButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.gotopost_icon,0,0,0);
+ postButton.setOnClickListener(view -> {
+ Intent intent = new Intent(this, ThePost.class);
+ intent.putExtra("id_user", id);
+ intent.putExtra("id_post", id_post);
+ intent.putExtra("from", "edit");
+ startActivity(intent);
+ finish();
+ });
+
+ TextView postTitle = new TextView(postContent.getContext());
+ postTitle.setId(View.generateViewId());
+ postTitle.setText(title);
+
+ TextView postText = new TextView(postContent.getContext());
+ postText.setId(View.generateViewId());
+ postText.setTextAppearance(R.style.TextAppearance_AppCompat_Medium);
+ postText.setText(tresc);
+
+ TextView addedText = new TextView(postContent.getContext());
+ addedText.setId(View.generateViewId());
+ addedText.setTextAppearance(R.style.TextAppearance_AppCompat_Body2);
+ addedText.setText(dataUtworzenia);
+
+ View divider = new View(postsList.getContext());
+ TableRow.LayoutParams dividerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) getResources().getDisplayMetrics().density);
+ dividerParams.setMargins(32, 24, 32, 24);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(getColor(R.color.gray_400));
+
+ buttonGroup.addView(editButton);
+ buttonGroup.addView(postButton);
+ buttonGroup.addView(deleteButton);
+ postContent.addView(postTitle);
+ postContent.addView(postText);
+ postContent.addView(addedText);
+
+ post.addView(buttonGroup);
+ post.addView(postContent);
+
+ postsList.addView(post);
+ postsList.addView(divider);
+ }
+
+ public void quit(View v){
+ Intent homepage = new Intent(this, Homepage.class);
+ startActivity(homepage);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed(){
+ Intent homepage = new Intent(this, Homepage.class);
+ startActivity(homepage);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Profile.java b/app/src/main/java/pl/krzysiek/simplesocial/Profile.java
new file mode 100644
index 0000000..32d9c03
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Profile.java
@@ -0,0 +1,354 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.Icon;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.text.util.Linkify;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.google.android.material.tabs.TabLayout;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class Profile extends AppCompatActivity {
+
+ int id;
+ int id_user;
+ Server server;
+ Helpers helper;
+ TextView nameText, usernameText, observedByText, descriptionText;
+ ImageView verifiedIcon, avatarImage;
+ Button observationBtn;
+ TabLayout navigationTab;
+
+ LinearLayout posts, comments;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_profile);
+ onLoad();
+ changeTab();
+ }
+
+ void onLoad(){
+ nameText = findViewById(R.id.nameText);
+ usernameText = findViewById(R.id.usernameText);
+ observedByText = findViewById(R.id.observedByText);
+ verifiedIcon = findViewById(R.id.verifiedIcon);
+ observationBtn = findViewById(R.id.observationBtn);
+ navigationTab = findViewById(R.id.navigationTab);
+ descriptionText = findViewById(R.id.descriptionText);
+ avatarImage = findViewById(R.id.avatarImage);
+
+ comments = findViewById(R.id.comments);
+ posts = findViewById(R.id.posts);
+
+ id = Homepage.id;
+ server = new Server();
+ helper = new Helpers();
+
+ Bundle fromSomewhere = getIntent().getExtras();
+ id_user = fromSomewhere.getInt("id_user");
+
+ giveMeAll();
+ }
+
+ public void quitTheProfile(View v){
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed(){
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+
+ public void changeTab(){
+ navigationTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+ @Override
+ public void onTabSelected(TabLayout.Tab tab) {
+ switch(tab.getPosition()){
+ case 0:
+ posts.setVisibility(View.VISIBLE);
+ break;
+ case 1:
+ comments.setVisibility(View.VISIBLE);
+ break;
+ }
+ }
+
+ @Override
+ public void onTabUnselected(TabLayout.Tab tab) {
+ switch(tab.getPosition()){
+ case 0:
+ posts.setVisibility(View.GONE);
+ break;
+ case 1:
+ comments.setVisibility(View.GONE);
+ break;
+ }
+ }
+
+ @Override
+ public void onTabReselected(TabLayout.Tab tab) {
+
+ }
+ });
+ }
+
+ @SuppressLint("SetTextI18n")
+ void giveMeAll(){
+ try{
+ ResultSet rsComments = server.query("DISTINCT users.username, comments.tresc, comments.dataUtworzenia, comments.id_post, posts.id_autor, comments.id_post", "comments, users, posts", "comments.id_author = " + id_user + " AND users.id = comments.id_author AND comments.id_post = posts.id_post", "ORDER BY comments.dataUtworzenia DESC");
+ while(rsComments.next()) {
+ String username = rsComments.getString(1);
+ String tresc = rsComments.getString(2);
+ String dataUtworzenia = rsComments.getString(3);
+ int id_post = rsComments.getInt(4);
+ ResultSet rsAuthor = server.query("users.username", "users", "users.id = " + rsComments.getInt(5));
+ while(rsAuthor.next())
+ showComments(
+ id_post,
+ username,
+ tresc,
+ dataUtworzenia,
+ rsAuthor.getString(1)
+ );
+ }
+ ResultSet rsPost = server.query("posts.id_post, users.username, posts.tresc, posts.dataDodania", "posts, users", "users.id = posts.id_autor AND posts.id_autor = " + id_user, "ORDER BY id_post DESC");
+
+ while(rsPost.next())
+ showPosts(
+ Integer.parseInt(rsPost.getString(1)),
+ rsPost.getString(2),
+ rsPost.getString(3),
+ rsPost.getString(4)
+ );
+
+ ResultSet rsUser = server.query("username, nazwaWyswietlana, zweryfikowany, opis, avatar", "users", "id = " + id_user);
+
+ while(rsUser.next()){
+ usernameText.setText(rsUser.getString(1));
+ nameText.setText(rsUser.getString(2));
+ descriptionText.setText(rsUser.getString(4));
+ if(rsUser.getInt(3) == 1)
+ verifiedIcon.setImageIcon(Icon.createWithResource(this, R.drawable.verified_icon));
+ else
+ verifiedIcon.setImageIcon(Icon.createWithResource(this, R.drawable.normaluser_icon));
+
+ if(rsUser.getString(5) != null) {
+ if(!rsUser.getString(5).matches(""))
+ avatarImage.setImageBitmap(helper.convertToBitmap(rsUser.getString(5)));
+ else
+ avatarImage.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ }else
+ avatarImage.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ }
+
+ ResultSet rsFollowers = server.query("COUNT(*)", "users_observations", "id_observedProfile = " + id_user);
+ while(rsFollowers.next())
+ observedByText.setText(rsFollowers.getInt(1) + " obserwujących");
+
+ if(id_user == id)
+ observationBtn.setVisibility(View.GONE);
+ else {
+ ResultSet rsObs = server.query("id_observation", "users_observations", "id_observedProfile = " + id_user + " AND id_observedBy = " + id);
+
+ if (rsObs.next()){
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observed_icon, 0,0,0);
+ } else
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observe_icon, 0,0,0);
+ }
+ }
+ catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void observation(View v){
+ try{
+ ResultSet rs = server.query("id_observation", "users_observations", "id_observedProfile = " + id_user + " AND id_observedBy = " + id);
+
+ if(!rs.isBeforeFirst()){
+ server.insert("users_observations", "NULL, " + id_user + ", " + id_user + ", '" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'");
+ Toast.makeText(this, "Zaobserwowano profil", Toast.LENGTH_SHORT).show();
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observed_icon, 0,0,0);
+
+ ResultSet rsFollowers = server.query("COUNT(*)", "users_observations", "id_observedProfile = " + id_user);
+ while(rsFollowers.next())
+ observedByText.setText(rsFollowers.getInt(1) + " obserwujących");
+ } else {
+ server.delete("users_observations", "id_observedProfile = " + id_user + " AND id_observedBy = " + id);
+ Toast.makeText(this, "Już nie obserwujesz tego profilu", Toast.LENGTH_SHORT).show();
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observe_icon, 0,0,0);
+
+ ResultSet rsFollowers = server.query("COUNT(*)", "users_observations", "id_observedProfile = " + id_user);
+ while(rsFollowers.next())
+ observedByText.setText(rsFollowers.getInt(1) + " obserwujących");
+ }
+ } catch(SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @SuppressLint({"SetTextI18n", "ResourceAsColor"})
+ public void showPosts(int id_post, String autor, String text, String datetime){
+ TableLayout table = new TableLayout(posts.getContext());
+ TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT);
+ table.setId(View.generateViewId());
+ table.setLayoutParams(tableParams);
+
+ TableRow authorRow = new TableRow(table.getContext());
+ authorRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ TextView authorLabel = new TextView(authorRow.getContext());
+ authorLabel.setPadding(16,16,16,16);
+ authorLabel.setText(autor + " \nDodano: " + datetime);
+
+ /* */
+
+ TableRow textRow = new TableRow(table.getContext());
+ textRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ TextView textLabel = new TextView(textRow.getContext());
+ textLabel.setPadding(16,16,16,16);
+ textLabel.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ textLabel.setMaxLines(5);
+ textLabel.setTextSize(20f);
+ textLabel.setText(text);
+
+ /* */
+
+ TableRow likesRow = new TableRow(table.getContext());
+ likesRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.MATCH_PARENT));
+
+ Button goToPost = new Button(likesRow.getContext());
+ goToPost.setId(View.generateViewId());
+ TableRow.LayoutParams redirectParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 96, 1f);
+ redirectParams.setMargins(16, 4, 16, 4);
+ goToPost.setBackgroundColor(ContextCompat.getColor(this, R.color.purple_500));
+ goToPost.setTextColor(Color.WHITE);
+ goToPost.setLayoutParams(redirectParams);
+ goToPost.setText("Pokaż cały post");
+ goToPost.setOnClickListener(
+ view -> {
+ Intent thePostIntent = new Intent(this, ThePost.class);
+ thePostIntent.putExtra("id_user", id);
+ thePostIntent.putExtra("id_post", id_post);
+ startActivity(thePostIntent);
+ }
+ );
+
+ View divider = new View(posts.getContext());
+ TableRow.LayoutParams dividerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) getResources().getDisplayMetrics().density);
+ dividerParams.setMargins(32, 32, 32, 32);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(ContextCompat.getColor(this, R.color.gray_400));
+
+ likesRow.addView(goToPost);
+ textRow.addView(textLabel);
+ authorRow.addView(authorLabel);
+
+ table.addView(authorRow);
+ table.addView(textRow);
+ table.addView(likesRow);
+ posts.addView(table);
+ posts.addView(divider);
+ }
+
+ @SuppressLint("SetTextI18n")
+ void showComments(int id_post, String autor, String tresc, String dataUtworzenia, String autorPosta){
+ LinearLayout comment = new LinearLayout(comments.getContext());
+ LinearLayout.LayoutParams linParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+ comment.setOrientation(LinearLayout.VERTICAL);
+ comment.setId(View.generateViewId());
+ comment.setLayoutParams(linParams);
+
+ TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
+ TableRow authorRow = new TableRow(comment.getContext());
+ authorRow.setId(View.generateViewId());
+ authorRow.setLayoutParams(rowParams);
+
+ TextView authorText = new TextView(authorRow.getContext());
+ authorText.setId(View.generateViewId());
+ authorText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ authorText.setPadding(16, 16, 16, 4);
+ authorText.setText(autor + " odpowiedział " + autorPosta);
+
+ TableRow content = new TableRow(comment.getContext());
+ content.setId(View.generateViewId());
+ content.setLayoutParams(rowParams);
+
+ TextView contentText = new TextView(authorRow.getContext());
+ contentText.setId(View.generateViewId());
+ contentText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ contentText.setPadding(16, 4, 16, 4);
+ contentText.setAutoLinkMask(Linkify.ALL);
+ contentText.setMovementMethod(LinkMovementMethod.getInstance());
+ contentText.setText(tresc);
+
+ TableRow added = new TableRow(comment.getContext());
+ added.setId(View.generateViewId());
+ added.setLayoutParams(rowParams);
+
+ TextView addedText = new TextView(authorRow.getContext());
+ addedText.setId(View.generateViewId());
+ addedText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
+ addedText.setPadding(16, 4, 16, 16);
+ addedText.setText("Dodano " + dataUtworzenia);
+
+ Button goToPost = new Button(comments.getContext());
+ goToPost.setId(View.generateViewId());
+ TableRow.LayoutParams redirectParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 96, 1f);
+ redirectParams.setMargins(16, 4, 16, 4);
+ goToPost.setBackgroundColor(ContextCompat.getColor(this, R.color.purple_500));
+ goToPost.setTextColor(Color.WHITE);
+ goToPost.setLayoutParams(redirectParams);
+ goToPost.setText("Pokaż cały post");
+ goToPost.setOnClickListener(
+ view -> {
+ Intent thePostIntent = new Intent(this, ThePost.class);
+ thePostIntent.putExtra("id_user", id);
+ thePostIntent.putExtra("id_post", id_post);
+ startActivity(thePostIntent);
+ }
+ );
+
+ View divider = new View(comments.getContext());
+ TableRow.LayoutParams dividerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, (int) getResources().getDisplayMetrics().density);
+ dividerParams.setMargins(32, 32, 32, 32);
+ divider.setLayoutParams(dividerParams);
+ divider.setBackgroundColor(ContextCompat.getColor(this, R.color.gray_400));
+
+ authorRow.addView(authorText);
+ content.addView(contentText);
+ added.addView(addedText);
+
+ comment.addView(authorRow);
+ comment.addView(content);
+ comment.addView(added);
+
+ comments.addView(comment);
+ comments.addView(goToPost);
+ comments.addView(divider);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Registration.java b/app/src/main/java/pl/krzysiek/simplesocial/Registration.java
new file mode 100644
index 0000000..57d77ca
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Registration.java
@@ -0,0 +1,153 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.app.DatePickerDialog;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.view.View;
+import java.sql.*;
+import java.util.Calendar;
+import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import android.widget.*;
+
+public class Registration extends AppCompatActivity {
+
+ EditText nicknameBox, passwordBox, rpPasswordBox, nameBox, emailBox, phoneBox;
+ RadioButton maleBox, femaleBox;
+ TextView passwordIdentityText, birthdateBox, tosLink;
+ CheckBox acceptToS;
+ Button registerBtn;
+
+ String[] firstPartMale = {"Ambitny", "Zabawny", "Kreatywny", "Śmierdzacy", "Stanowczy", "Lojalny", "Dziwny", "Przyzwoity", "Przemądrzały", "Optymistyczny", "Pesymistyczny", "Zwariowany", "Zmarnowany", "Towarzyski", "Szczery", "Latający", "Aktywny", "Bezużyteczny", "Nieśmieszny"};
+ String[] secondPartMale = {"Dinozaur", "Robot", "Odkurzacz", "Tygrys", "Nerd", "Gracz", "Przegryw", "Król", "Kujon", "Kierowca", "Drifter", "Aparaciarz", "Zgredek"};
+ String[] firstPartFemale = {"Ambitna", "Zabawna", "Kreatywna", "Śmierdzaca", "Stanowcza", "Lojalna", "Dziwna", "Przyzwoita", "Przemądrzała", "Optymistyczna", "Pesymistyczna", "Zwariowana", "Zmarnowana", "Towarzyska", "Szczera", "Latająca", "Aktywna", "Bezużyteczna", "Nieśmieszna"};
+ String[] secondPartFemale = {"Dinozaur", "Robot", "Tygrysica", "Nerdini", "Graczka", "Przegrywka", "Królowa", "Kujonka", "Kierowczyni", "Drifterka", "Aparatka", "Zgredka"};
+
+ DatePickerDialog.OnDateSetListener dateSetListener;
+ Server server;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_registration);
+
+ onLoad();
+ }
+
+ @SuppressLint("SetTextI18n")
+ void onLoad(){
+ nicknameBox = findViewById(R.id.usernameBar);
+ birthdateBox = findViewById(R.id.birthdateBox);
+ passwordBox = findViewById(R.id.passwordBox);
+ rpPasswordBox = findViewById(R.id.rpPasswordBox);
+ nameBox = findViewById(R.id.nameBox);
+ emailBox = findViewById(R.id.emailBox);
+ phoneBox = findViewById(R.id.phoneBox);
+ tosLink = findViewById(R.id.tosLink);
+
+ tosLink.setMovementMethod(LinkMovementMethod.getInstance());
+
+ server = new Server();
+
+ maleBox = findViewById(R.id.maleBtn);
+ femaleBox = findViewById(R.id.femaleBtn);
+
+ passwordIdentityText = findViewById(R.id.identityLogText);
+ registerBtn = findViewById(R.id.registerBtn);
+
+ acceptToS = findViewById(R.id.acceptToS);
+
+ dateSetListener = (datePicker, i, i1, i2) -> {
+ String year, month, day;
+ i1++;
+ month = (i1 < 10 ? "0" + i1 : Integer.toString(i1));
+ day = (i2 < 10 ? "0" + i2 : Integer.toString(i2));
+ year = Integer.toString(i);
+
+ birthdateBox.setText(year + "/" + month + "/" + day);
+ };
+ }
+
+ public void birthdateEvent(View v){
+ Calendar cal = Calendar.getInstance();
+
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+
+ DatePickerDialog dialog = new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT, dateSetListener, year, month, day);
+ dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ dialog.show();
+ }
+
+ public void randomMeNickname(View v){
+ Random random = new Random();
+ StringBuilder x = new StringBuilder();
+
+ if(maleBox.isChecked()) {
+ x.append(firstPartMale[random.nextInt(firstPartMale.length)]);
+ x.append(secondPartMale[random.nextInt(secondPartMale.length)]);
+ } else {
+ x.append(firstPartFemale[random.nextInt(firstPartFemale.length)]);
+ x.append(secondPartFemale[random.nextInt(secondPartFemale.length)]);
+ }
+ x.append(random.nextInt(999));
+
+ nicknameBox.setText(x);
+ }
+
+ public void registerMe(View v){
+ int plec;
+
+ if(maleBox.isChecked())
+ plec = 1;
+ else
+ plec = 0;
+
+ Pattern p = Pattern.compile("[^A-Za-z0-9]", Pattern.CASE_INSENSITIVE);
+ Matcher m = p.matcher(nicknameBox.getText());
+
+ if(acceptToS.isChecked()) {
+ if(!m.find()) {
+ if (passwordBox.getText().toString().equals(rpPasswordBox.getText().toString())) {
+ if (!nicknameBox.getText().equals("") && !birthdateBox.getText().equals("")) {
+ if (nicknameBox.getText().length() > 3) {
+ try {
+ server.insert("users", "username, password, nazwaWyswietlana, email, numerTelefonu, dataUrodzenia, plec",
+ "'" + nicknameBox.getText() + "', PASSWORD('" + passwordBox.getText() + "'), '" + nameBox.getText() + "', '" + emailBox.getText() + "', '" + phoneBox.getText() + "', '" + birthdateBox.getText() + "', " + plec);
+ if (!nameBox.getText().equals("")) {
+ Toast.makeText(this, "Konto zostało utworzone. Witaj na pokładzie, " + nameBox.getText() + "!", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(this, "Konto zostało utworzone. Witaj na pokładzie, " + nicknameBox.getText() + "!", Toast.LENGTH_SHORT).show();
+ }
+
+ ResultSet rs = server.query("id", "users", "username = '" + nicknameBox.getText() + "'");
+ while (rs.next()) {
+ Main.id = rs.getInt(1);
+ Intent intent = new Intent(this, Homepage.class);
+ startActivity(intent);
+ finish();
+ }
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ } else Toast.makeText(this, "Za krótka nazwa użytkownika! Minimalnie 4 znaki.", Toast.LENGTH_LONG).show();
+ } else Toast.makeText(this, "Nazwa użytkownika jest wymagana! Jeżeli nie masz pomysłu, to wygeneruj sobie.", Toast.LENGTH_LONG).show();
+ } else Toast.makeText(this, "Wpisane hasła nie są identyczne, for blyat sake!", Toast.LENGTH_LONG).show();
+ } else Toast.makeText(this, "Nazwa użytkownika nie może zawierać znaków specjalnych. Jedynie litery oraz cyfry zezwolone!", Toast.LENGTH_LONG).show();
+ } else Toast.makeText(this, "Aby korzystać z serwisu musisz zakceptować regulamin!", Toast.LENGTH_LONG).show();
+ }
+
+ public void cancelRegistration(View v){
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/Server.java b/app/src/main/java/pl/krzysiek/simplesocial/Server.java
new file mode 100644
index 0000000..491152f
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/Server.java
@@ -0,0 +1,109 @@
+package pl.krzysiek.simplesocial;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class Server {
+ String username = "";
+ String password = "";
+ String url = "jdbc:mysql://";
+ Connection conn;
+
+ public Connection connection(){
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ conn = DriverManager.getConnection(url, username, password);
+ } catch (SQLException | ClassNotFoundException ex) {
+ ex.printStackTrace();
+ }
+ return conn;
+ }
+
+ public Statement stmt() {
+ Statement stmt = null;
+ try{ stmt = connection().createStatement(); } catch (SQLException ex) { ex.printStackTrace(); }
+ return stmt;
+ }
+
+ public ResultSet query(String columns, String from, String type, String table, String joinOn, String where, String args) {
+ ResultSet res = null;
+ try {
+ res = stmt().executeQuery("SELECT " + columns + " FROM " + from + " " + type + " JOIN " + table + " ON " + joinOn + " WHERE " + where + " " + args + ";");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ close();
+ return res;
+ }
+
+ public ResultSet query(String columns, String from, String type, String table, String joinOn, String where) {
+ ResultSet res = null;
+ try {
+ res = stmt().executeQuery("SELECT " + columns + " FROM " + from + " " + type + " JOIN " + table + " ON " + joinOn + " WHERE " + where + ";");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ close();
+ return res;
+ }
+
+ public ResultSet query(String columns, String from, String where, String args) {
+ ResultSet res = null;
+ try {
+ res = stmt().executeQuery("SELECT " + columns + " FROM " + from + " WHERE " + where + " " + args + ";");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ close();
+ return res;
+ }
+
+ public ResultSet query(String columns, String from, String where) {
+ ResultSet res = null;
+ try {
+ res = stmt().executeQuery("SELECT " + columns + " FROM " + from + " WHERE " + where + ";");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ close();
+ return res;
+ }
+
+ public ResultSet query(String columns, String from) {
+ ResultSet res = null;
+ try {
+ res = stmt().executeQuery("SELECT " + columns + " FROM " + from + ";");
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ close();
+ return res;
+ }
+
+ public void update(String table, String changes, String where) {
+ try {stmt().executeUpdate("UPDATE " + table + " SET " + changes + " WHERE " + where + ";"); } catch (SQLException ex) { ex.printStackTrace(); }
+ close();
+ }
+
+ public void delete(String from, String where){
+ try { stmt().executeUpdate("DELETE FROM " + from + " WHERE " + where + ";"); } catch (SQLException ex) { ex.printStackTrace(); }
+ close();
+ }
+
+ public void insert(String table, String columns, String values){
+ try {stmt().executeUpdate("INSERT INTO " + table + "(" + columns + ") VALUES(" + values + ");"); } catch (SQLException ex) { ex.printStackTrace(); }
+ close();
+ }
+
+ public void insert(String table, String values){
+ try {stmt().executeUpdate("INSERT INTO " + table + " VALUES(" + values + ");"); } catch (SQLException ex) { ex.printStackTrace(); }
+ close();
+ }
+
+ public void close(){
+ try{ connection().close(); } catch (SQLException ex) { ex.printStackTrace(); }
+ }
+}
diff --git a/app/src/main/java/pl/krzysiek/simplesocial/ThePost.java b/app/src/main/java/pl/krzysiek/simplesocial/ThePost.java
new file mode 100644
index 0000000..d8792a3
--- /dev/null
+++ b/app/src/main/java/pl/krzysiek/simplesocial/ThePost.java
@@ -0,0 +1,235 @@
+package pl.krzysiek.simplesocial;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.graphics.drawable.Icon;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.text.util.Linkify;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+import java.sql.*;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class ThePost extends AppCompatActivity {
+
+ int id_user;
+ int id_post;
+
+ int id_author;
+ String from;
+
+ ImageView postImage, avatarView;
+ Server server;
+ Helpers helper;
+
+ TextView author, createDate, contentOfPost, likes, title;
+ EditText commentBox;
+ Button likeBtn, observationBtn;
+
+ LinearLayout linearLayout;
+ LinearLayout comments;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.thepost);
+ onLoad();
+ updateThePost();
+ refreshComments();
+ }
+
+ void onLoad(){
+ Bundle homepage = getIntent().getExtras();
+ id_user = homepage.getInt("id_user");
+ id_post = homepage.getInt("id_post");
+ from = homepage.getString("from");
+ server = new Server();
+ helper = new Helpers();
+
+ author = findViewById(R.id.userText);
+ createDate = findViewById(R.id.createDateText);
+ observationBtn = findViewById(R.id.observeBtn);
+
+ postImage = findViewById(R.id.postImage);
+
+ contentOfPost = findViewById(R.id.contentText);
+ contentOfPost.setMovementMethod(LinkMovementMethod.getInstance());
+ title = findViewById(R.id.titleText);
+ avatarView = findViewById(R.id.avatarView);
+
+ likes = findViewById(R.id.likesText);
+ likeBtn = findViewById(R.id.likeBtn);
+ commentBox = findViewById(R.id.commentBox);
+ comments = findViewById(R.id.comments);
+ linearLayout = findViewById(R.id.postLayout);
+ }
+
+ @SuppressLint("SetTextI18n")
+ void updateThePost(){
+ int typ = 0;
+ try{
+ ResultSet rsPost = server.query("users.username, posts.dataDodania, posts.tresc, posts.id_autor, posts.tytul, posts.typPosta, users.avatar", "posts, users", "posts.id_post = " + id_post + " AND users.id = posts.id_autor");
+
+ while(rsPost.next()){
+ author.setText(rsPost.getString(1));
+ createDate.setText("Dodano " + rsPost.getString(2));
+ contentOfPost.setText(rsPost.getString(3));
+ id_author = rsPost.getInt(4);
+ title.setText(rsPost.getString(5));
+ typ = rsPost.getInt(6);
+
+ if(rsPost.getString(7) != null) {
+ if(!rsPost.getString(7).matches(""))
+ avatarView.setImageBitmap(helper.convertToBitmap(rsPost.getString(7)));
+ else
+ avatarView.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ } else
+ avatarView.setImageIcon(Icon.createWithResource(this, R.drawable.default_avatar));
+ }
+
+ ResultSet rsLikes = server.query("COUNT(*)", "posts_likes", "id_post = " + id_post);
+ while(rsLikes.next()){
+ likes.setText(rsLikes.getString(1));
+ }
+
+ if(typ > 0){
+ ResultSet rsImage = server.query("picture", "posts_pictures", "id_post = " + id_post + " AND id_autor = " + id_author);
+ while(rsImage.next()) {
+ postImage.setImageBitmap(helper.convertToBitmap(rsImage.getString(1)));
+ }
+ }
+
+ if(id_author == id_user)
+ observationBtn.setVisibility(View.GONE);
+ else {
+ ResultSet rsObs = server.query("id_observation", "users_observations", "id_observedProfile = " + id_author + " AND id_observedBy = " + id_user);
+
+ if(!rsObs.isBeforeFirst())
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observe_icon, 0,0,0);
+ else
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observed_icon, 0,0,0);
+ }
+
+ ResultSet rs = server.query("id_like", "posts_likes", "id_post = " + id_post + " AND id_user = " + id_user + ";");
+
+ if(!rs.next())
+ likeBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.like_icon, 0, 0, 0);
+ else
+ likeBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.liked_icon, 0, 0, 0);
+
+ } catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void goToProfile(View v){
+ Intent intent = new Intent(this, Profile.class);
+ intent.putExtra("id_user", id_author);
+ startActivity(intent);
+ }
+
+ public void giveAComment(View v){
+ if(!title.getText().toString().matches("")) {
+ server.insert("comments", "NULL, " + id_post + ", " + id_user + ", NOW(), '" + commentBox.getText() + "', 0");
+ commentBox.setText("");
+ refreshComments();
+ Toast.makeText(this, "Komentarz dodany!", Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(this, "Nie można dodawać pustych komentarzy", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ void refreshComments(){
+ try{
+ ResultSet rs = server.query("users.username, comments.tresc, comments.dataUtworzenia", "comments, users", "comments.id_post = " + id_post + " AND users.id = comments.id_author", "ORDER BY comments.dataUtworzenia DESC");
+ comments.removeAllViewsInLayout();
+ while(rs.next())
+ helper.GenerateComments(
+ comments,
+ rs.getString(1),
+ getBaseContext(),
+ rs.getString(2),
+ rs.getString(3),
+ author
+ );
+ Toast.makeText(this, "Pomyślnie zaktualizowano!", Toast.LENGTH_SHORT).show();
+ }
+ catch (SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void giveALike(View v){
+ try{
+ ResultSet rs = server.query("id_like", "posts_likes", "id_post = " + id_post + " AND id_user = " + id_user);
+
+ if(!rs.isBeforeFirst()){
+ server.insert("posts_likes", "NULL, " + id_post + ", " + id_user + ", '" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'");
+ likeBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.liked_icon, 0, 0, 0);
+ } else {
+ server.delete("posts_likes", "id_post = " + id_post + " AND id_user = " + id_user + ";");
+ likeBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.like_icon, 0, 0, 0);
+ }
+
+ ResultSet rsLikes = server.query("COUNT(*)", "posts_likes", "id_post = " + id_post);
+ while(rsLikes.next()){
+ likes.setText(rsLikes.getString(1));
+ }
+ }
+ catch(SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void observation(View v){
+ try{
+ ResultSet rs = server.query("id_observation", "users_observations", "id_observedProfile = " + id_author + " AND id_observedBy = " + id_user);
+
+ if(!rs.isBeforeFirst()){
+ server.insert("users_observations", "NULL, " + id_author + ", " + id_user + ", '" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'");
+ Toast.makeText(this, "Zaobserwowano profil", Toast.LENGTH_SHORT).show();
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observed_icon, 0,0,0);
+ } else {
+ server.delete("users_observations", "id_observedProfile = " + id_author + " AND id_observedBy = " + id_user);
+ Toast.makeText(this, "Już nie obserwujesz tego profilu", Toast.LENGTH_SHORT).show();
+ observationBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.observe_icon, 0,0,0);
+ }
+ } catch(SQLException ex){
+ ex.printStackTrace();
+ }
+ }
+
+ public void exitPost(View v){
+ Intent parent = null;
+ switch (from) {
+ case "homepage":
+ parent = new Intent(this, Homepage.class);
+ break;
+ case "user":
+ parent = new Intent(this, Profile.class);
+ parent.putExtra("id_user", id_author);
+ break;
+ case "edit":
+ parent = new Intent(this, PostsManagement.class);
+ break;
+ case "comment":
+ parent = new Intent(this, CommentsManagement.class);
+ parent.putExtra("user", id_user);
+ break;
+ }
+
+ startActivity(parent);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-anydpi/add_icon.xml b/app/src/main/res/drawable-anydpi/add_icon.xml
new file mode 100644
index 0000000..f48ea94
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/add_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/addimage_icon.xml b/app/src/main/res/drawable-anydpi/addimage_icon.xml
new file mode 100644
index 0000000..232634f
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/addimage_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/avatar_icon.xml b/app/src/main/res/drawable-anydpi/avatar_icon.xml
new file mode 100644
index 0000000..192adbd
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/avatar_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/comment_icon.xml b/app/src/main/res/drawable-anydpi/comment_icon.xml
new file mode 100644
index 0000000..36a4c53
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/comment_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/delete_icon.xml b/app/src/main/res/drawable-anydpi/delete_icon.xml
new file mode 100644
index 0000000..ed06cd4
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/delete_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/description_icon.xml b/app/src/main/res/drawable-anydpi/description_icon.xml
new file mode 100644
index 0000000..dccaf48
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/description_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/goback_icon.xml b/app/src/main/res/drawable-anydpi/goback_icon.xml
new file mode 100644
index 0000000..a1a703a
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/goback_icon.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/gotopost_icon.xml b/app/src/main/res/drawable-anydpi/gotopost_icon.xml
new file mode 100644
index 0000000..e5bb334
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/gotopost_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/home_icon.xml b/app/src/main/res/drawable-anydpi/home_icon.xml
new file mode 100644
index 0000000..39d6e1f
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/home_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/like_icon.xml b/app/src/main/res/drawable-anydpi/like_icon.xml
new file mode 100644
index 0000000..120375c
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/like_icon.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/liked_icon.xml b/app/src/main/res/drawable-anydpi/liked_icon.xml
new file mode 100644
index 0000000..dd9c818
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/liked_icon.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/logout_icon.xml b/app/src/main/res/drawable-anydpi/logout_icon.xml
new file mode 100644
index 0000000..006ccf3
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/logout_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/menu_icon.xml b/app/src/main/res/drawable-anydpi/menu_icon.xml
new file mode 100644
index 0000000..4f3d7e5
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/menu_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/normaluser_icon.xml b/app/src/main/res/drawable-anydpi/normaluser_icon.xml
new file mode 100644
index 0000000..59fb629
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/normaluser_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/observe_icon.xml b/app/src/main/res/drawable-anydpi/observe_icon.xml
new file mode 100644
index 0000000..9aad48d
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/observe_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/observed_icon.xml b/app/src/main/res/drawable-anydpi/observed_icon.xml
new file mode 100644
index 0000000..fc38e81
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/observed_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/post_icon.xml b/app/src/main/res/drawable-anydpi/post_icon.xml
new file mode 100644
index 0000000..bef6a2c
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/post_icon.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/refresh.xml b/app/src/main/res/drawable-anydpi/refresh.xml
new file mode 100644
index 0000000..2d5f892
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/refresh.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/search_icon.xml b/app/src/main/res/drawable-anydpi/search_icon.xml
new file mode 100644
index 0000000..6796805
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/search_icon.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/send_icon.xml b/app/src/main/res/drawable-anydpi/send_icon.xml
new file mode 100644
index 0000000..ba42f51
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/send_icon.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/verified_icon.xml b/app/src/main/res/drawable-anydpi/verified_icon.xml
new file mode 100644
index 0000000..827d644
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/verified_icon.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-anydpi/warning.xml b/app/src/main/res/drawable-anydpi/warning.xml
new file mode 100644
index 0000000..4affde5
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/warning.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/drawable-hdpi/add_icon.png b/app/src/main/res/drawable-hdpi/add_icon.png
new file mode 100644
index 0000000..79fba7f
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/add_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/addimage_icon.png b/app/src/main/res/drawable-hdpi/addimage_icon.png
new file mode 100644
index 0000000..f14d404
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/addimage_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/avatar_icon.png b/app/src/main/res/drawable-hdpi/avatar_icon.png
new file mode 100644
index 0000000..49444ae
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/avatar_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/comment_icon.png b/app/src/main/res/drawable-hdpi/comment_icon.png
new file mode 100644
index 0000000..e84ec3b
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/comment_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/delete_icon.png b/app/src/main/res/drawable-hdpi/delete_icon.png
new file mode 100644
index 0000000..566c2c7
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/delete_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/description_icon.png b/app/src/main/res/drawable-hdpi/description_icon.png
new file mode 100644
index 0000000..65f9fb3
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/description_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/goback_icon.png b/app/src/main/res/drawable-hdpi/goback_icon.png
new file mode 100644
index 0000000..1f149e0
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/goback_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/gotopost_icon.png b/app/src/main/res/drawable-hdpi/gotopost_icon.png
new file mode 100644
index 0000000..2b47aed
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/gotopost_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/home_icon.png b/app/src/main/res/drawable-hdpi/home_icon.png
new file mode 100644
index 0000000..604cacc
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/home_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/like_icon.png b/app/src/main/res/drawable-hdpi/like_icon.png
new file mode 100644
index 0000000..62e851b
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/like_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/liked_icon.png b/app/src/main/res/drawable-hdpi/liked_icon.png
new file mode 100644
index 0000000..8e364fb
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/liked_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/logout_icon.png b/app/src/main/res/drawable-hdpi/logout_icon.png
new file mode 100644
index 0000000..8879781
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/logout_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/menu_icon.png b/app/src/main/res/drawable-hdpi/menu_icon.png
new file mode 100644
index 0000000..f88a234
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/menu_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/normaluser_icon.png b/app/src/main/res/drawable-hdpi/normaluser_icon.png
new file mode 100644
index 0000000..7d5ec1e
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/normaluser_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/observe_icon.png b/app/src/main/res/drawable-hdpi/observe_icon.png
new file mode 100644
index 0000000..d1ef56a
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/observe_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/observed_icon.png b/app/src/main/res/drawable-hdpi/observed_icon.png
new file mode 100644
index 0000000..79d8b98
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/observed_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/post_icon.png b/app/src/main/res/drawable-hdpi/post_icon.png
new file mode 100644
index 0000000..b6df773
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/post_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/refresh.png b/app/src/main/res/drawable-hdpi/refresh.png
new file mode 100644
index 0000000..52f92d4
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/refresh.png differ
diff --git a/app/src/main/res/drawable-hdpi/search_icon.png b/app/src/main/res/drawable-hdpi/search_icon.png
new file mode 100644
index 0000000..f1a4feb
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/search_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/send_icon.png b/app/src/main/res/drawable-hdpi/send_icon.png
new file mode 100644
index 0000000..0a3b81e
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/send_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/verified_icon.png b/app/src/main/res/drawable-hdpi/verified_icon.png
new file mode 100644
index 0000000..cba6605
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/verified_icon.png differ
diff --git a/app/src/main/res/drawable-hdpi/warning.png b/app/src/main/res/drawable-hdpi/warning.png
new file mode 100644
index 0000000..f057f3e
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/warning.png differ
diff --git a/app/src/main/res/drawable-mdpi/add_icon.png b/app/src/main/res/drawable-mdpi/add_icon.png
new file mode 100644
index 0000000..670a4ad
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/add_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/addimage_icon.png b/app/src/main/res/drawable-mdpi/addimage_icon.png
new file mode 100644
index 0000000..655b4f5
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/addimage_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/avatar_icon.png b/app/src/main/res/drawable-mdpi/avatar_icon.png
new file mode 100644
index 0000000..c506747
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/avatar_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/comment_icon.png b/app/src/main/res/drawable-mdpi/comment_icon.png
new file mode 100644
index 0000000..d87dc2b
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/comment_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/delete_icon.png b/app/src/main/res/drawable-mdpi/delete_icon.png
new file mode 100644
index 0000000..7ca71bf
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/delete_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/description_icon.png b/app/src/main/res/drawable-mdpi/description_icon.png
new file mode 100644
index 0000000..1862b3a
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/description_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/goback_icon.png b/app/src/main/res/drawable-mdpi/goback_icon.png
new file mode 100644
index 0000000..ad82552
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/goback_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/gotopost_icon.png b/app/src/main/res/drawable-mdpi/gotopost_icon.png
new file mode 100644
index 0000000..dc9a3ba
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/gotopost_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/home_icon.png b/app/src/main/res/drawable-mdpi/home_icon.png
new file mode 100644
index 0000000..fe6de69
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/home_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/like_icon.png b/app/src/main/res/drawable-mdpi/like_icon.png
new file mode 100644
index 0000000..6bdf750
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/like_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/liked_icon.png b/app/src/main/res/drawable-mdpi/liked_icon.png
new file mode 100644
index 0000000..11b9d71
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/liked_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/logout_icon.png b/app/src/main/res/drawable-mdpi/logout_icon.png
new file mode 100644
index 0000000..49177b7
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/logout_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/menu_icon.png b/app/src/main/res/drawable-mdpi/menu_icon.png
new file mode 100644
index 0000000..cfbaa4d
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/menu_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/normaluser_icon.png b/app/src/main/res/drawable-mdpi/normaluser_icon.png
new file mode 100644
index 0000000..8780cd3
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/normaluser_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/observe_icon.png b/app/src/main/res/drawable-mdpi/observe_icon.png
new file mode 100644
index 0000000..14655ce
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/observe_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/observed_icon.png b/app/src/main/res/drawable-mdpi/observed_icon.png
new file mode 100644
index 0000000..fcfabe0
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/observed_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/post_icon.png b/app/src/main/res/drawable-mdpi/post_icon.png
new file mode 100644
index 0000000..142559c
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/post_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/refresh.png b/app/src/main/res/drawable-mdpi/refresh.png
new file mode 100644
index 0000000..a0c52c8
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/refresh.png differ
diff --git a/app/src/main/res/drawable-mdpi/search_icon.png b/app/src/main/res/drawable-mdpi/search_icon.png
new file mode 100644
index 0000000..d1629dc
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/search_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/send_icon.png b/app/src/main/res/drawable-mdpi/send_icon.png
new file mode 100644
index 0000000..951da13
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/send_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/verified_icon.png b/app/src/main/res/drawable-mdpi/verified_icon.png
new file mode 100644
index 0000000..bfe4f0c
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/verified_icon.png differ
diff --git a/app/src/main/res/drawable-mdpi/warning.png b/app/src/main/res/drawable-mdpi/warning.png
new file mode 100644
index 0000000..7aef13f
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/warning.png differ
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-xhdpi/add_icon.png b/app/src/main/res/drawable-xhdpi/add_icon.png
new file mode 100644
index 0000000..344277f
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/add_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/addimage_icon.png b/app/src/main/res/drawable-xhdpi/addimage_icon.png
new file mode 100644
index 0000000..64c7cf6
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/addimage_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/avatar_icon.png b/app/src/main/res/drawable-xhdpi/avatar_icon.png
new file mode 100644
index 0000000..cb8f052
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/avatar_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/comment_icon.png b/app/src/main/res/drawable-xhdpi/comment_icon.png
new file mode 100644
index 0000000..f1390bd
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/comment_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/delete_icon.png b/app/src/main/res/drawable-xhdpi/delete_icon.png
new file mode 100644
index 0000000..a844b55
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/delete_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/description_icon.png b/app/src/main/res/drawable-xhdpi/description_icon.png
new file mode 100644
index 0000000..e98703e
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/description_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/goback_icon.png b/app/src/main/res/drawable-xhdpi/goback_icon.png
new file mode 100644
index 0000000..0c26bdd
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/goback_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/gotopost_icon.png b/app/src/main/res/drawable-xhdpi/gotopost_icon.png
new file mode 100644
index 0000000..9a4ba25
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/gotopost_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/home_icon.png b/app/src/main/res/drawable-xhdpi/home_icon.png
new file mode 100644
index 0000000..0d3371c
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/home_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/like_icon.png b/app/src/main/res/drawable-xhdpi/like_icon.png
new file mode 100644
index 0000000..6a64e44
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/like_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/liked_icon.png b/app/src/main/res/drawable-xhdpi/liked_icon.png
new file mode 100644
index 0000000..c2e4844
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/liked_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/logout_icon.png b/app/src/main/res/drawable-xhdpi/logout_icon.png
new file mode 100644
index 0000000..4e022bd
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/logout_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/menu_icon.png b/app/src/main/res/drawable-xhdpi/menu_icon.png
new file mode 100644
index 0000000..33a29fa
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/menu_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/normaluser_icon.png b/app/src/main/res/drawable-xhdpi/normaluser_icon.png
new file mode 100644
index 0000000..7162c7b
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/normaluser_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/observe_icon.png b/app/src/main/res/drawable-xhdpi/observe_icon.png
new file mode 100644
index 0000000..3a34c60
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/observe_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/observed_icon.png b/app/src/main/res/drawable-xhdpi/observed_icon.png
new file mode 100644
index 0000000..f7cb7f1
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/observed_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/post_icon.png b/app/src/main/res/drawable-xhdpi/post_icon.png
new file mode 100644
index 0000000..4087b6c
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/post_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/refresh.png b/app/src/main/res/drawable-xhdpi/refresh.png
new file mode 100644
index 0000000..ce9dfbe
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/refresh.png differ
diff --git a/app/src/main/res/drawable-xhdpi/search_icon.png b/app/src/main/res/drawable-xhdpi/search_icon.png
new file mode 100644
index 0000000..9aab126
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/search_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/send_icon.png b/app/src/main/res/drawable-xhdpi/send_icon.png
new file mode 100644
index 0000000..bb0e2f1
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/send_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/verified_icon.png b/app/src/main/res/drawable-xhdpi/verified_icon.png
new file mode 100644
index 0000000..9a896e9
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/verified_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/warning.png b/app/src/main/res/drawable-xhdpi/warning.png
new file mode 100644
index 0000000..7b2f904
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/warning.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/add_icon.png b/app/src/main/res/drawable-xxhdpi/add_icon.png
new file mode 100644
index 0000000..07ff961
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/add_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/addimage_icon.png b/app/src/main/res/drawable-xxhdpi/addimage_icon.png
new file mode 100644
index 0000000..a216014
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/addimage_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/avatar_icon.png b/app/src/main/res/drawable-xxhdpi/avatar_icon.png
new file mode 100644
index 0000000..a3640e3
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/avatar_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/comment_icon.png b/app/src/main/res/drawable-xxhdpi/comment_icon.png
new file mode 100644
index 0000000..d3d574c
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/comment_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/delete_icon.png b/app/src/main/res/drawable-xxhdpi/delete_icon.png
new file mode 100644
index 0000000..906e3e1
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/delete_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/description_icon.png b/app/src/main/res/drawable-xxhdpi/description_icon.png
new file mode 100644
index 0000000..4ad5c19
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/description_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/goback_icon.png b/app/src/main/res/drawable-xxhdpi/goback_icon.png
new file mode 100644
index 0000000..9e3c10f
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/goback_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/gotopost_icon.png b/app/src/main/res/drawable-xxhdpi/gotopost_icon.png
new file mode 100644
index 0000000..a2a2cfc
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/gotopost_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/home_icon.png b/app/src/main/res/drawable-xxhdpi/home_icon.png
new file mode 100644
index 0000000..50efa6f
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/home_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/like_icon.png b/app/src/main/res/drawable-xxhdpi/like_icon.png
new file mode 100644
index 0000000..fae340e
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/like_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/liked_icon.png b/app/src/main/res/drawable-xxhdpi/liked_icon.png
new file mode 100644
index 0000000..ba92819
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/liked_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/logout_icon.png b/app/src/main/res/drawable-xxhdpi/logout_icon.png
new file mode 100644
index 0000000..75fe6d2
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/logout_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/menu_icon.png b/app/src/main/res/drawable-xxhdpi/menu_icon.png
new file mode 100644
index 0000000..a7e0f0f
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/menu_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/normaluser_icon.png b/app/src/main/res/drawable-xxhdpi/normaluser_icon.png
new file mode 100644
index 0000000..3d69a62
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/normaluser_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/observe_icon.png b/app/src/main/res/drawable-xxhdpi/observe_icon.png
new file mode 100644
index 0000000..42f4636
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/observe_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/observed_icon.png b/app/src/main/res/drawable-xxhdpi/observed_icon.png
new file mode 100644
index 0000000..57feba0
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/observed_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/post_icon.png b/app/src/main/res/drawable-xxhdpi/post_icon.png
new file mode 100644
index 0000000..10b5bc2
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/post_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/refresh.png b/app/src/main/res/drawable-xxhdpi/refresh.png
new file mode 100644
index 0000000..c63b765
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/refresh.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/search_icon.png b/app/src/main/res/drawable-xxhdpi/search_icon.png
new file mode 100644
index 0000000..d0932ee
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/search_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/send_icon.png b/app/src/main/res/drawable-xxhdpi/send_icon.png
new file mode 100644
index 0000000..fc84d6e
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/send_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/verified_icon.png b/app/src/main/res/drawable-xxhdpi/verified_icon.png
new file mode 100644
index 0000000..4a3499e
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/verified_icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/warning.png b/app/src/main/res/drawable-xxhdpi/warning.png
new file mode 100644
index 0000000..ebe3c01
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/warning.png differ
diff --git a/app/src/main/res/drawable/default_avatar.png b/app/src/main/res/drawable/default_avatar.png
new file mode 100644
index 0000000..0eaf3c6
Binary files /dev/null and b/app/src/main/res/drawable/default_avatar.png differ
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_comments_management.xml b/app/src/main/res/layout/activity_comments_management.xml
new file mode 100644
index 0000000..bb01e26
--- /dev/null
+++ b/app/src/main/res/layout/activity_comments_management.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_comments.xml b/app/src/main/res/layout/activity_edit_comments.xml
new file mode 100644
index 0000000..169111f
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_comments.xml
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_post.xml b/app/src/main/res/layout/activity_edit_post.xml
new file mode 100644
index 0000000..27cdc61
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_post.xml
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml
new file mode 100644
index 0000000..fb5aa6d
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_profile.xml
@@ -0,0 +1,345 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_group.xml b/app/src/main/res/layout/activity_group.xml
new file mode 100644
index 0000000..81b1fee
--- /dev/null
+++ b/app/src/main/res/layout/activity_group.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..7ff080c
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_new_post.xml b/app/src/main/res/layout/activity_new_post.xml
new file mode 100644
index 0000000..12d8b5b
--- /dev/null
+++ b/app/src/main/res/layout/activity_new_post.xml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_posts_management.xml b/app/src/main/res/layout/activity_posts_management.xml
new file mode 100644
index 0000000..15610b0
--- /dev/null
+++ b/app/src/main/res/layout/activity_posts_management.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml
new file mode 100644
index 0000000..2aa1049
--- /dev/null
+++ b/app/src/main/res/layout/activity_profile.xml
@@ -0,0 +1,210 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_registration.xml b/app/src/main/res/layout/activity_registration.xml
new file mode 100644
index 0000000..b1ee4a6
--- /dev/null
+++ b/app/src/main/res/layout/activity_registration.xml
@@ -0,0 +1,344 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/homepage.xml b/app/src/main/res/layout/homepage.xml
new file mode 100644
index 0000000..898055b
--- /dev/null
+++ b/app/src/main/res/layout/homepage.xml
@@ -0,0 +1,365 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/thepost.xml b/app/src/main/res/layout/thepost.xml
new file mode 100644
index 0000000..23a4064
--- /dev/null
+++ b/app/src/main/res/layout/thepost.xml
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..205d72e
--- /dev/null
+++ b/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..fb20784
--- /dev/null
+++ b/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs_layout_main.xml b/app/src/main/res/values/attrs_layout_main.xml
new file mode 100644
index 0000000..818345b
--- /dev/null
+++ b/app/src/main/res/values/attrs_layout_main.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..66e3f6c
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,14 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+ #FF29B6F6
+ #FF039BE5
+ #FFBDBDBD
+ #FF757575
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..2679198
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,9 @@
+
+ SimpleSocial
+ Hasło
+ Zarejestruj
+ Zaloguj
+ Nazwa użytkownika
+ Połączenie z bazą danych
+ Aby zobaczyć regulamin serwisu SimpleSocial naciśnij tutaj
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..49b8bc7
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..f3ff51d
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml
new file mode 100644
index 0000000..773ec55
--- /dev/null
+++ b/app/src/main/res/xml/network_security_config.xml
@@ -0,0 +1,6 @@
+
+
+
+ 31.42.6.165
+
+
\ No newline at end of file
diff --git a/app/src/test/java/pl/krzysiek/simplesocial/ExampleUnitTest.java b/app/src/test/java/pl/krzysiek/simplesocial/ExampleUnitTest.java
new file mode 100644
index 0000000..2a0fd6f
--- /dev/null
+++ b/app/src/test/java/pl/krzysiek/simplesocial/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package pl.krzysiek.simplesocial;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..61eee3e
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,19 @@
+ext {
+ mysqlConnectorJavaVersion = '8.0.27'
+}// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.1.1'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..ed9a6d4
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,20 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+android.suppressUnsupportedCompileSdk=29
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..8de5e3d
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 20 19:43:23 CET 2021
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..4f906e0
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml
new file mode 100644
index 0000000..8c83010
--- /dev/null
+++ b/projectFilesBackup/.idea/workspace.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1640025785057
+
+
+ 1640025785057
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projectFilesBackup1/.idea/workspace.xml b/projectFilesBackup1/.idea/workspace.xml
new file mode 100644
index 0000000..8c83010
--- /dev/null
+++ b/projectFilesBackup1/.idea/workspace.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1640025785057
+
+
+ 1640025785057
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projectFilesBackup2/.idea/workspace.xml b/projectFilesBackup2/.idea/workspace.xml
new file mode 100644
index 0000000..85d5d7c
--- /dev/null
+++ b/projectFilesBackup2/.idea/workspace.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1640025785057
+
+
+ 1640025785057
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projectFilesBackup3/.idea/workspace.xml b/projectFilesBackup3/.idea/workspace.xml
new file mode 100644
index 0000000..fbcce1e
--- /dev/null
+++ b/projectFilesBackup3/.idea/workspace.xml
@@ -0,0 +1,389 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1640025785057
+
+
+ 1640025785057
+
+
+ 1643497221886
+
+
+
+ 1643497221886
+
+
+ 1644183847154
+
+
+
+ 1644183847154
+
+
+ 1644184966720
+
+
+
+ 1644184966720
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..c8eb77f
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,10 @@
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ jcenter() // Warning: this repository is going to shut down soon
+ }
+}
+rootProject.name = "SimpleSocial"
+include ':app'