浏览代码

meged Database

Simon Hammer 3 年之前
父节点
当前提交
6809b2449d
共有 48 个文件被更改,包括 1719 次插入248 次删除
  1. 17 4
      app/build.gradle
  2. 88 0
      app/schemas/com.noahvogt.miniprojekt.ui.DataBase.EmailRoomDatabase/1.json
  3. 1 0
      app/src/main/AndroidManifest.xml
  4. 108 22
      app/src/main/java/com/noahvogt/miniprojekt/MainActivity.java
  5. 39 0
      app/src/main/java/com/noahvogt/miniprojekt/NewDraftMessageActivity.java
  6. 72 14
      app/src/main/java/com/noahvogt/miniprojekt/messageCreateFragment.java
  7. 84 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/EmailRepository.java
  8. 112 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/EmailRoomDatabase.java
  9. 92 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/Message.java
  10. 88 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/MessageDao.java
  11. 67 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/archive/ArchiveFragment.java
  12. 19 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/archive/ArchiveViewModel.java
  13. 31 1
      app/src/main/java/com/noahvogt/miniprojekt/ui/gallery/GalleryFragment.java
  14. 28 81
      app/src/main/java/com/noahvogt/miniprojekt/ui/home/CustomAdapter.java
  15. 0 42
      app/src/main/java/com/noahvogt/miniprojekt/ui/home/Data.java
  16. 30 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/home/HomeFragment.java
  17. 142 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/show/MessageShowFragment.java
  18. 19 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/show/MessageShowViewModel.java
  19. 67 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/DraftFragment.java
  20. 2 2
      app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/DraftViewModel.java
  21. 120 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/EmailViewHolder.java
  22. 50 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/EmailViewModel.java
  23. 0 35
      app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/SlideshowFragment.java
  24. 66 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/spam/SpamFragment.java
  25. 19 0
      app/src/main/java/com/noahvogt/miniprojekt/ui/spam/SpamViewModel.java
  26. 11 0
      app/src/main/res/drawable-anydpi/archive_icon.xml
  27. 11 0
      app/src/main/res/drawable-anydpi/spam_icon.xml
  28. 二进制
      app/src/main/res/drawable-hdpi/archive_icon.png
  29. 二进制
      app/src/main/res/drawable-hdpi/spam_icon.png
  30. 二进制
      app/src/main/res/drawable-mdpi/archive_icon.png
  31. 二进制
      app/src/main/res/drawable-mdpi/spam_icon.png
  32. 二进制
      app/src/main/res/drawable-xhdpi/archive_icon.png
  33. 二进制
      app/src/main/res/drawable-xhdpi/spam_icon.png
  34. 二进制
      app/src/main/res/drawable-xxhdpi/archive_icon.png
  35. 二进制
      app/src/main/res/drawable-xxhdpi/spam_icon.png
  36. 10 0
      app/src/main/res/drawable/ic_baseline_add_24.xml
  37. 7 10
      app/src/main/res/layout/activity_main.xml
  38. 13 22
      app/src/main/res/layout/content_main.xml
  39. 23 0
      app/src/main/res/layout/fragment_archive.xml
  40. 7 3
      app/src/main/res/layout/fragment_home.xml
  41. 1 1
      app/src/main/res/layout/fragment_slideshow.xml
  42. 23 0
      app/src/main/res/layout/fragment_spam.xml
  43. 199 0
      app/src/main/res/layout/message_show_fragment.xml
  44. 10 0
      app/src/main/res/menu/activity_main_drawer.xml
  45. 9 10
      app/src/main/res/menu/create_message_options_menu.xml
  46. 15 1
      app/src/main/res/navigation/mobile_navigation.xml
  47. 16 0
      app/src/main/res/values/strings.xml
  48. 3 0
      build.gradle

+ 17 - 4
app/build.gradle

@@ -29,6 +29,14 @@ android {
         }
     packagingOptions {
         exclude 'META-INF/NOTICE.md'
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+
+        javaCompileOptions {
+            annotationProcessorOptions {
+                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
+            }
+        }
     }
 
 
@@ -49,10 +57,6 @@ android {
 
 dependencies {
 
-    //implementation 'com.android.support:cardview-v7:28.0.0'
-    //implementation 'com.android.support:appcompat-v7:28.0.0'
-    //implementation 'com.android.support:appcompat-v7:18.0.+'
-
     implementation 'androidx.appcompat:appcompat:1.2.0'
     implementation 'com.google.android.material:material:1.3.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
@@ -61,8 +65,17 @@ dependencies {
 
     implementation 'androidx.navigation:navigation-fragment:2.3.5'
     implementation 'androidx.navigation:navigation-ui:2.3.5'
+
+    /* Room components */
+    implementation 'androidx.room:room-runtime:2.3.0'
+    annotationProcessor 'androidx.room:room-compiler:2.3.0'
+    androidTestImplementation 'androidx.room:room-testing:2.3.0'
+
+    /* lifecycle components */
     implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
+    implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
+
     implementation 'androidx.recyclerview:recyclerview:1.2.0'
     implementation 'androidx.preference:preference:1.1.1'
 

+ 88 - 0
app/schemas/com.noahvogt.miniprojekt.ui.DataBase.EmailRoomDatabase/1.json

@@ -0,0 +1,88 @@
+{
+  "formatVersion": 1,
+  "database": {
+    "version": 1,
+    "identityHash": "217605d4a5ec0067e9003ad5b099a303",
+    "entities": [
+      {
+        "tableName": "message_table",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `to` TEXT NOT NULL, `cc` TEXT, `bcc` TEXT, `fromEmail` TEXT NOT NULL, `date` TEXT NOT NULL, `subject` TEXT, `textContent` TEXT, `folder` TEXT NOT NULL, `seen` INTEGER NOT NULL)",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "mTo",
+            "columnName": "to",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "mCc",
+            "columnName": "cc",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "mBcc",
+            "columnName": "bcc",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "mFrom",
+            "columnName": "fromEmail",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "mDate",
+            "columnName": "date",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "mSubject",
+            "columnName": "subject",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "mTextContent",
+            "columnName": "textContent",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "mFolder",
+            "columnName": "folder",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "mSeen",
+            "columnName": "seen",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": []
+      }
+    ],
+    "views": [],
+    "setupQueries": [
+      "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '217605d4a5ec0067e9003ad5b099a303')"
+    ]
+  }
+}

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -10,6 +10,7 @@
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.MiniProjekt">
+        <activity android:name=".NewDraftMessageActivity"></activity>
         <activity
             android:name=".MainActivity"
             android:label="@string/app_name"

+ 108 - 22
app/src/main/java/com/noahvogt/miniprojekt/MainActivity.java

@@ -6,7 +6,6 @@ import android.view.Menu;
 import android.view.View;
 import android.widget.Button;
 import android.widget.EditText;
-import android.widget.ImageButton;
 import android.widget.Toast;
 
 import androidx.appcompat.app.AlertDialog;
@@ -14,22 +13,34 @@ import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
 import androidx.drawerlayout.widget.DrawerLayout;
 import androidx.fragment.app.DialogFragment;
+
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.noahvogt.miniprojekt.ui.DataBase.Message;
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+
+import com.google.android.material.navigation.NavigationView;
+
 import androidx.navigation.NavController;
 import androidx.navigation.Navigation;
 import androidx.navigation.ui.AppBarConfiguration;
 import androidx.navigation.ui.NavigationUI;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
 
 import com.chaquo.python.Python;
 import com.chaquo.python.android.AndroidPlatform;
-import com.google.android.material.navigation.NavigationView;
 import com.google.android.material.snackbar.Snackbar;
-import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
-import com.noahvogt.miniprojekt.ui.home.Data;
 import com.noahvogt.miniprojekt.ui.home.SettingsActivity;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewModel;
 
-import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 import static com.noahvogt.miniprojekt.R.id.drawer_layout;
@@ -38,14 +49,36 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
 
     private AppBarConfiguration mAppBarConfiguration;
 
-    /* declare vars that should always be used / shown by default */
-    protected ArrayList<Data> data;
+    public static final int NEW_WORD_ACTIVITY_REQUEST_CODE = 1;
+    public static EmailViewModel mEmailViewModel;
+    public static RecyclerView recyclerView;
+
+    public static final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
     private AlertDialog dialog;
     private EditText newemail_name, newemail_email, newemail_password; /* may not be private */
 
     /* empty descriptor */
     public MainActivity() {}
 
+
+    public String getVisibleFragment(){
+        FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
+        List<Fragment> fragments = fragmentManager.getFragments();
+        if(fragments != null){
+            showToast("not null");
+            for(Fragment fragment : fragments){
+                showToast(fragment.toString());
+                if(fragment.isVisible())
+                    showToast("found visible fragment");
+                    return "is gallery";
+            }
+        } else {
+            showToast("null");}
+            return null;
+
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -61,12 +94,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
             }
         });
 
-        ImageButton message_create_button = (ImageButton) findViewById(R.id.messageButton);
-        message_create_button.setOnClickListener(new View.OnClickListener() {
+        /*creates accountmanager by clicking on profil */
+        View accountView = findViewById(R.id.accountView);
+        accountView.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                DialogFragment dialog = messageCreateFragment.newInstance();
-                dialog.show(getSupportFragmentManager(), "tag");
+                createNewEmailDialog();
             }
         });
 
@@ -82,22 +115,17 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
          menu should be considered as top level destinations.
         */
         mAppBarConfiguration = new AppBarConfiguration.Builder(
-                R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow)
+                R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow, R.id.nav_archive, R.id.nav_spam)
                 .setDrawerLayout(drawer)
                 .build();
         NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
         NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
         NavigationUI.setupWithNavController(navigationView, navController);
 
-        /* invoke recycleViewer */
-
-        //initDataset();
         /* Lookup the recyclerview in activity layout */
-        RecyclerView recyclerView = findViewById(R.id.recyclerView);
-        /* Initialize contacts */
-        data = Data.createContactsList(20);
-        /* Create adapter passing in the sample user data */
-        CustomAdapter adapter = new CustomAdapter(data);
+        recyclerView = findViewById(R.id.recyclerView);
+
+
         /* Attach the adapter to the recyclerview to populate items */
         recyclerView.setAdapter(adapter);
         recyclerView.setLayoutManager(new LinearLayoutManager(this));
@@ -111,9 +139,64 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                 startActivity(i);
             }
         });
+        /* get Inbox Messages in Recyclerviewer at begining is overwritten by Fragments but has to stay*/
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getInboxMessage().observe(this, messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
+
+        /* Start email Writer*/
+        FloatingActionButton message_create_button = findViewById(R.id.messageButton);
+        message_create_button.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                DialogFragment dialog = messageCreateFragment.newInstance();
+                dialog.show(getSupportFragmentManager(), "tag");
+
+            }
+        });
     }
 
 
+        /* gets the data from the Email writer and adds it to the Database */
+        public void onActivityResult(int requestCode, int resultCode, Intent data) {
+            super.onActivityResult(requestCode, resultCode, messageCreateFragment.replyIntent);
+
+            /* Creates class for the Date when Email is written */
+            Date dNow = new Date();
+            SimpleDateFormat ft =
+                    new SimpleDateFormat("dd.MM.yy");
+
+         //   if (requestCode == NEW_WORD_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
+                Message word = new Message(
+                        messageCreateFragment.replyIntent.getStringExtra(messageCreateFragment.EXTRA_TO),
+                        null,
+                        null,
+                        messageCreateFragment.replyIntent.getStringExtra(messageCreateFragment.EXTRA_FROM),
+                        ft.format(dNow),
+                        messageCreateFragment.replyIntent.getStringExtra(messageCreateFragment.EXTRA_SUBJECT),
+                        messageCreateFragment.replyIntent.getStringExtra(messageCreateFragment.EXTRA_MESSAGE),
+                        "Draft",false);
+                mEmailViewModel.insert(word);
+          //  } else {
+                Toast.makeText(
+                        getApplicationContext(),
+                        R.string.empty_not_saved,
+                        Toast.LENGTH_LONG).show();
+
+            Toast.makeText(
+                    getApplicationContext(),
+                    messageCreateFragment.replyIntent.getStringExtra(messageCreateFragment.EXTRA_FROM),
+                    Toast.LENGTH_LONG).show();
+          //  }
+
+
+        }
+
+
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
@@ -134,6 +217,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
     public void onClick(View view) { }
 
 
+
     public void createNewEmailDialog(){
         /* define View window */
         AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
@@ -163,6 +247,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
         newemail_save_button.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+
                 /* store user input (only needed for DEBUGGING) */
                 String name = newemail_name.getText().toString();
                 String email = newemail_email.getText().toString();
@@ -214,3 +299,4 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
 
 
 }
+

+ 39 - 0
app/src/main/java/com/noahvogt/miniprojekt/NewDraftMessageActivity.java

@@ -0,0 +1,39 @@
+package com.noahvogt.miniprojekt;
+
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.Toast;
+
+public class NewDraftMessageActivity extends AppCompatActivity {
+
+
+
+
+
+
+   @Override
+    public void onCreate(Bundle savedInstanceState){
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.fragment_home);
+
+       NewDraftMessageActivity.this.finish();
+
+
+
+
+
+
+
+
+        }
+    }
+
+
+

+ 72 - 14
app/src/main/java/com/noahvogt/miniprojekt/messageCreateFragment.java

@@ -1,7 +1,12 @@
 package com.noahvogt.miniprojekt;
 
+import android.app.Activity;
+
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.os.Bundle;
+import android.os.Message;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.MenuItem;
 import android.view.View;
@@ -16,13 +21,36 @@ import androidx.annotation.Nullable;
 import androidx.appcompat.app.AlertDialog;
 import androidx.fragment.app.DialogFragment;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
 public class messageCreateFragment extends DialogFragment implements PopupMenu.OnMenuItemClickListener {
 
+    public static final String EXTRA_TO = "com.example.android.namelistsql.NAME";
+    public static final String EXTRA_FROM = "com.example.android.namelistsql.FROM";
+    public static final String EXTRA_SUBJECT = "com.example.android.namelistsql.SUBJECT";
+    public static final String EXTRA_MESSAGE = "com.example.android.namelistsql.MESSAGE";
+    public static final String EXTRA_DATE = "com.example.android.namelistsql.DATE";
+
+    public EditText sendingAddressObject;
+    public EditText receivingAddressObject;
+    public EditText subjectObject;
+    public EditText messageBodyObject;
+
+    public static final int RESULT_CANCELED = 0;
+    public static final int RESULT_OK = -1;
+
+    public Activity activity = new Activity();
+    public static Intent replyIntent = new Intent();
+
     static messageCreateFragment newInstance() {
         return new messageCreateFragment();
     }
     private AlertDialog dialog;
 
+    private static final int NUMBER_OF_THREADS = 4;
+    static final ExecutorService databaseWriteExecutor =
+            Executors.newFixedThreadPool(NUMBER_OF_THREADS);
 
 
     /* set theming style */
@@ -42,23 +70,30 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
         /* init vars */
 
         ImageButton closeButton = view.findViewById(R.id.create_message_close_button);
-        ImageButton sendButton = view.findViewById(R.id.create_message_send_button);
+        final ImageButton sendButton = view.findViewById(R.id.create_message_send_button);
         ImageButton dotButton = view.findViewById(R.id.create_message_dots_button);
         ImageButton attachButton = view.findViewById(R.id.create_message_attach_button);
 
-        EditText sendingAddressObject = (EditText) view.findViewById(R.id.create_message_sending_address_text);
-        EditText receivingAddressObject = (EditText) view.findViewById(R.id.create_message_receiving_address_text);
-        EditText subjectObject = (EditText) view.findViewById(R.id.create_message_subject_text);
-        EditText messageBodyObject = (EditText) view.findViewById(R.id.create_message_body_text);
+         sendingAddressObject = (EditText) view.findViewById(R.id.create_message_sending_address_text);
+         receivingAddressObject = (EditText) view.findViewById(R.id.create_message_receiving_address_text);
+         subjectObject = (EditText) view.findViewById(R.id.create_message_subject_text);
+         messageBodyObject = (EditText) view.findViewById(R.id.create_message_body_text);
 
         /* get string vars, MAYBE NOT HERE */
         String sendingAddress = sendingAddressObject.getText().toString();
         String receivingAddress = receivingAddressObject.getText().toString();
-        String subject = subjectObject.getText().toString();
+        //String subject = subjectObject.getText().toString();
         String messageBody = messageBodyObject.getText().toString();
 
         /* TODO: add cc + bcc functionality */
 
+        /* dosen't wotk cause Activity is not extendet and used as variable */
+
+
+
+
+
+
         /* button listeners */
 
         closeButton.setOnClickListener(new View.OnClickListener() {
@@ -77,18 +112,41 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
                     AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
                     alertDialogBuilder.setTitle("Warning");
                     alertDialogBuilder
-                            .setMessage("Do you really want to cancel?")
+                            .setMessage("Do you want to save your Draft?")
                             .setCancelable(false)
                             .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog, int id) {
-                                    /* if this button is clicked, close the whole fragment */
+
+                                    activity.setResult(RESULT_CANCELED, replyIntent);
+
+                                    String from = sendingAddressObject.getText().toString();
+                                    String to = receivingAddressObject.getText().toString();
+                                    String subject = subjectObject.getText().toString();
+                                    String message = messageBodyObject.getText().toString();
+
+
+                                    replyIntent.putExtra(EXTRA_FROM, from);
+                                    replyIntent.putExtra(EXTRA_TO, to);
+                                    replyIntent.putExtra(EXTRA_SUBJECT, subject);
+                                    replyIntent.putExtra(EXTRA_MESSAGE, message);
+                                    activity.setResult(RESULT_OK, replyIntent);
+
+                                    activity.finish();
+
+                                    Toast.makeText(getContext(), "messageCreateFragmentReadIn", Toast.LENGTH_SHORT).show();
+                                    Toast.makeText(getContext(), replyIntent.getStringExtra(EXTRA_FROM), Toast.LENGTH_SHORT).show();
+
+                                    Intent intent = new Intent(getContext(), NewDraftMessageActivity.class);
+                                    startActivityForResult(intent, MainActivity.NEW_WORD_ACTIVITY_REQUEST_CODE);
+
+                                    /*if this button is clicked, close the whole fragment */
                                     dismiss();
                                 }
                             })
                             .setNegativeButton("No",new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog,int id) {
-                                    /* if this button is clicked, just close the dialog box */
-                                    dialog.cancel();
+                                    /* if this button is clicked, close the hole fragment */
+                                    dismiss();
                                 }
                             });
 
@@ -156,16 +214,16 @@ public class messageCreateFragment extends DialogFragment implements PopupMenu.O
     @Override
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
-            case R.id.create_message_item_1:
+            case R.id.create_message_delete:
                 Toast.makeText(getActivity(), "item 1 clicked", Toast.LENGTH_LONG).show();
                 return true;
-            case R.id.create_message_item_2:
+            case R.id.create_message_spam:
                 Toast.makeText(getActivity(), "item 2 clicked", Toast.LENGTH_LONG).show();
                 return true;
-            case R.id.create_message_item_3:
+            case R.id.create_message_move_to:
                 Toast.makeText(getActivity(), "item 3 clicked", Toast.LENGTH_LONG).show();
                 return true;
-            case R.id.create_message_item_4:
+            case R.id.create_message_sent_to:
                 Toast.makeText(getActivity(), "item 4 clicked", Toast.LENGTH_LONG).show();
                 return true;
             default: /* this case should never occur */

+ 84 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/EmailRepository.java

@@ -0,0 +1,84 @@
+package com.noahvogt.miniprojekt.ui.DataBase;
+
+import android.app.Application;
+import android.os.AsyncTask;
+
+import androidx.lifecycle.LiveData;
+
+import java.util.List;
+
+public class EmailRepository {
+
+    private MessageDao messageDao;
+    private final LiveData<List<Message>> mDraftMessage;
+    private LiveData<List<Message>> mInboxMessage;
+    private LiveData<List<Message>> mSentMessage;
+    private LiveData<List<Message>> mArchiveMessage;
+    private LiveData<List<Message>> mSpamMessage;
+
+
+    // Note that in order to unit test the WordRepository, you have to remove the Application
+    // dependency. This adds complexity and much more code, and this sample is not about testing.
+    // See the BasicSample in the android-architecture-components repository at
+    // https://github.com/googlesamples
+    /*get all messages sorted by date out of Database*/
+    public EmailRepository(Application application) {
+        EmailRoomDatabase db = EmailRoomDatabase.getDatabase(application);
+        messageDao = db.messageDao();
+        mDraftMessage = messageDao.getDraftMessages();
+        mArchiveMessage = messageDao.getArchiveMessages();
+        mInboxMessage = messageDao.getInboxMessages();
+        mSentMessage = messageDao.getSentMessages();
+        mSpamMessage = messageDao.getSpamMessages();
+    }
+
+    // Room executes all queries on a separate thread.
+    // Observed LiveData will notify the observer when the data has changed.
+    /* returns all messages of with tag Draft */
+    public LiveData<List<Message>> getDraftMessages() {
+        return mDraftMessage;
+    }
+
+    public LiveData<List<Message>> getSpamMessage(){return mSpamMessage;}
+
+    public LiveData<List<Message>> getInboxMessages() {
+        return mInboxMessage;
+    }
+
+    public LiveData<List<Message>> getSentMessages() {
+        return mSentMessage;
+    }
+
+    public LiveData<List<Message>> getArchiveMessages() {
+        return mArchiveMessage;
+    }
+
+    // You must call this on a non-UI thread or your app will throw an exception. Room ensures
+    // that you're not doing any long running operations on the main thread, blocking the UI.
+    public void insert(Message message) {
+        EmailRoomDatabase.databaseWriteExecutor.execute(() -> {
+            messageDao.insert(message);
+        });
+    }
+
+    public void deleteMessage(final Message message){
+       /* new AsyncTask<Void, Void, Void>() {
+            @Override
+            protected Void doInBackground(Void... voids) {
+                db.MessageDao().deleteMessage(message);
+                return null;
+            }
+        }.execute();
+
+        */
+        EmailRoomDatabase.databaseWriteExecutor.execute(() -> {
+            messageDao.delete(message);
+        });
+    }
+
+    public void updateMessage(final Message message){
+        EmailRoomDatabase.databaseWriteExecutor.execute(() -> {
+            messageDao.updateMessage(message);
+        });
+    }
+}

+ 112 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/EmailRoomDatabase.java

@@ -0,0 +1,112 @@
+package com.noahvogt.miniprojekt.ui.DataBase;
+
+import android.content.Context;
+import android.icu.util.Measure;
+
+import androidx.annotation.NonNull;
+import androidx.room.Database;
+import androidx.room.Room;
+import androidx.room.RoomDatabase;
+import androidx.room.migration.Migration;
+import androidx.sqlite.db.SupportSQLiteDatabase;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Database(entities = {Message.class}, version = 1, exportSchema = true)
+public abstract class EmailRoomDatabase extends RoomDatabase{
+
+    public abstract MessageDao messageDao();
+
+    /* the INSTANCE can be used by different threads at the same time */
+    private static volatile EmailRoomDatabase INSTANCE;
+
+    /* tells room the schema is changed from the version tha is istallend in device
+     * is not used */
+    static final Migration MIGRATION_2_3 = new Migration(2, 3) {
+        @Override
+        public void migrate(SupportSQLiteDatabase database) {
+            database.execSQL("ALTER TABLE word_table "
+                    + "ADD COLUMN last_update INTEGER ");
+        }
+    };
+
+    /* creating 4 threads */
+    private static final int NUMBER_OF_THREADS = 4;
+    static final ExecutorService databaseWriteExecutor =
+            Executors.newFixedThreadPool(NUMBER_OF_THREADS);
+
+    static EmailRoomDatabase getDatabase(final Context context) {
+        if (INSTANCE == null) {
+            /* synchronize all threads of WordRoomDatabase */
+            synchronized (EmailRoomDatabase.class) {
+                if (INSTANCE == null) {
+                    /* passes the interface in the Room and deletes old data/schema from device*/
+                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
+                            EmailRoomDatabase.class, "message_database")
+                            .addCallback(sRoomDatabaseCallback)
+                            .fallbackToDestructiveMigration()
+                            .build();
+                }
+            }
+        }
+        return INSTANCE;
+    }
+
+    private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback() {
+        @Override
+        public void onCreate(@NonNull SupportSQLiteDatabase db) {
+            super.onCreate(db);
+
+            // If you want to keep data through app restarts,
+            // comment out the following block
+            databaseWriteExecutor.execute(() -> {
+                // Populate the database in the background.
+                // If you want to start with more words, just add them.
+                MessageDao dao = INSTANCE.messageDao();
+                dao.deleteAll();
+
+
+                Message word = new Message("Noah", null , null,
+                        "Samuel", "31.9.21", "inboxTest", "I Try my best", "Inbox",
+                        true);
+               dao.insert(word);
+
+               word = new Message("Noah", null, null,
+                       "arldemeier", "bobo", "sentTest", "i could cry", "Sent",
+                       true);
+               dao.insert(word);
+
+               for (int n = 1; n < 20; n++) {
+                   word = new Message("Simon", null, null,
+                           "stefan", "tomorrow", "sent20", "lets goo","Sent",
+                           true);
+                   dao.insert(word);
+               }
+
+               for (int i = 1; i < 20; i++){
+                   word = new Message("Simon", null, null,
+                           "Hans", "tomorrow", "inbox20", "lets goo","Inbox",
+                           true);
+                   dao.insert(word);
+               }
+
+
+                word = new Message("Simon", null, null,
+                        "Maurice", "yesterday", "ArchiveTest", "lets goo","Archive",
+                        true);
+                dao.insert(word);
+
+                word = new Message("Simon", null, null,
+                        "Lenny", "tomorrow", "SpamTest", "lets goo","Spam",
+                        true);
+                dao.insert(word);
+
+
+            });
+        }
+    };
+
+}
+
+

+ 92 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/Message.java

@@ -0,0 +1,92 @@
+package com.noahvogt.miniprojekt.ui.DataBase;
+
+import androidx.annotation.NonNull;
+import androidx.room.ColumnInfo;
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+
+/* @Embedded to express entitys together
+ *  https://developer.android.com/training/data-storage/room/relationships
+ * to learn more */
+
+@Entity(tableName = "message_table")
+public class Message {
+
+    @PrimaryKey (autoGenerate = true)
+    public int id;
+
+    /* name of Columm */
+    @NonNull
+    @ColumnInfo(name = "to")
+    private String mTo ;
+
+
+    @ColumnInfo(name = "cc")
+    private String mCc;
+
+    @ColumnInfo(name = "bcc")
+    private String mBcc; //blind carpet copy, not see who sees mails
+
+    @NonNull
+    @ColumnInfo(name = "fromEmail")
+    private String mFrom;
+
+    @NonNull
+    @ColumnInfo(name = "date")
+    private String mDate;
+
+    @ColumnInfo(name = "subject")
+    private String mSubject;
+
+    @ColumnInfo(name = "textContent")
+    private String mTextContent;
+
+    @NonNull
+    @ColumnInfo(name = "folder")
+    private String mFolder;
+
+    @ColumnInfo(name = "seen")
+    private boolean mSeen;
+
+    public String getTo(){return this.mTo;}
+
+    public String getFrom(){return this.mFrom;}
+
+    public String getCc(){return this.mCc;}
+
+    public String getBcc(){return this.mBcc;}
+
+    public String getDate(){return this.mDate;}
+
+    public String getSubject(){return this.mSubject;}
+
+    public String getTextContent(){return this.mTextContent;}
+
+    public String getFolder(){return this.mFolder;}
+
+    public int getId(){return this.id;}
+
+    public boolean isSeen() {return this.mSeen;}
+
+    public Message(
+            @NonNull String to,
+            String cc,
+            String bcc,
+            @NonNull String from,
+            @NonNull String date,
+            String subject,
+            String textContent,
+            @NonNull String folder,
+            @NonNull boolean seen) {
+        this.mTo = to;
+        this.mFrom = from;
+        this.mCc = cc;
+        this.mBcc = bcc;
+        this.mDate = date;
+        this.mSubject = subject;
+        this.mTextContent = textContent;
+        this.mFolder = folder;
+        this.mSeen = seen;
+    }
+
+}

+ 88 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/DataBase/MessageDao.java

@@ -0,0 +1,88 @@
+package com.noahvogt.miniprojekt.ui.DataBase;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import java.util.List;
+
+@Dao
+public interface MessageDao {
+
+    /*
+
+    WordDao is an interface; DAOs must either be interfaces or abstract classes.
+    The @Dao annotation identifies it as a DAO class for Room.
+    void insert(Word word); Declares a method to insert one word:
+    The @Insert annotation is a special DAO method annotation where you don't have to provide any SQL! (There are also @Delete and @Update annotations for deleting and updating rows, but you are not using them in this app.)
+    onConflict = OnConflictStrategy.IGNORE: The selected on conflict strategy ignores a new word if it's exactly the same as one already in the list. To know more about the available conflict strategies, check out the documentation.
+    deleteAll(): declares a method to delete all the words.
+    There is no convenience annotation for deleting multiple entities, so it's annotated with the generic @Query.
+    @Query("DELETE FROM word_table"): @Query requires that you provide a SQL query as a string parameter to the annotation.
+    List<Word> getAlphabetizedWords(): A method to get all the words and have it return a List of Words.
+    @Query("SELECT * FROM word_table ORDER BY word ASC"): Returns a list of words sorted in ascending order.
+
+     */
+
+    // allowing the insert of the same word multiple times by passing a
+    // conflict resolution strategy
+    @Insert(onConflict = OnConflictStrategy.IGNORE)
+    void insert(Message message);
+
+    @Query("DELETE FROM message_table")
+    void deleteAll();
+
+    @Delete(entity = Message.class)
+    void delete(Message message);
+
+    @Update(entity = Message.class)
+    void updateMessage(Message message);
+
+    @Query("DELETE FROM message_table WHERE subject='DELETE'")
+    void deleteNewMessage();
+
+
+    @Query("SELECT * FROM message_table")
+    LiveData<List<Message>> getAllMessages();
+
+    /*gets messages all messages ordered by date
+    * !IMPORTANT I don't know in which direction */
+    @Query("SELECT * FROM message_table ORDER BY date ASC")
+    LiveData<List<Message>> getDateMessages();
+
+    /* get Draft messages*/
+    @Query("SELECT * FROM message_table WHERE folder LIKE 'Draft' ORDER BY date ASC")
+    LiveData<List<Message>> getDraftMessages();
+
+    /* get Inbox messages*/
+    @Query("SELECT * FROM message_table WHERE folder LIKE 'Inbox' ORDER BY date ASC")
+    LiveData<List<Message>> getInboxMessages();
+
+    /* get Sent messages*/
+    @Query("SELECT * FROM message_table WHERE folder LIKE 'Sent' ORDER BY date ASC")
+    LiveData<List<Message>> getSentMessages();
+
+    /* get Archive messages*/
+    @Query("SELECT * FROM message_table WHERE folder LIKE 'Archive' ORDER BY date ASC")
+    LiveData<List<Message>> getArchiveMessages();
+
+    /* get Spam messages*/
+    @Query("SELECT * FROM message_table WHERE folder LIKE 'Spam' ORDER BY date ASC")
+    LiveData<List<Message>> getSpamMessages();
+
+
+
+
+
+
+    /* selects just from, subject and date from word_table */
+
+    /* @Query("SELECT fromEmail, date, subject, textContent FROM message_table")
+    LiveData<List<Message>> getRecyclerviewData();
+     */
+
+}

+ 67 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/archive/ArchiveFragment.java

@@ -0,0 +1,67 @@
+package com.noahvogt.miniprojekt.ui.archive;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.noahvogt.miniprojekt.MainActivity;
+import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewModel;
+
+public class ArchiveFragment extends Fragment {
+
+    private ArchiveViewModel archiveViewModel;
+    EmailViewModel mEmailViewModel;
+    RecyclerView recyclerView;
+
+    public View onCreateView(@NonNull LayoutInflater inflater,
+                             ViewGroup container, Bundle savedInstanceState) {
+
+
+
+        recyclerView = MainActivity.recyclerView.findViewById(R.id.recyclerView);
+
+        final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
+        /* Attach the adapter to the recyclerview to populate items */
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+        //mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getArchiveMessage().observe(getViewLifecycleOwner(), messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
+
+        archiveViewModel =
+                new ViewModelProvider(this).get(ArchiveViewModel.class);
+        View root = inflater.inflate(R.layout.fragment_archive, container, false);
+        final TextView textView = root.findViewById(R.id.text_archive);
+        archiveViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
+            @Override
+            public void onChanged(@Nullable String s) {
+                textView.setText(s);
+            }
+        });
+        return root;
+
+
+
+
+    }
+
+
+}

+ 19 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/archive/ArchiveViewModel.java

@@ -0,0 +1,19 @@
+package com.noahvogt.miniprojekt.ui.archive;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class ArchiveViewModel extends ViewModel {
+
+    private MutableLiveData<String> mText;
+
+    public ArchiveViewModel() {
+        mText = new MutableLiveData<>();
+        mText.setValue("This is archive fragment");
+    }
+
+    public LiveData<String> getText() {
+        return mText;
+    }
+}

+ 31 - 1
app/src/main/java/com/noahvogt/miniprojekt/ui/gallery/GalleryFragment.java

@@ -11,15 +11,27 @@ import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
 import androidx.lifecycle.Observer;
 import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
 
+import com.noahvogt.miniprojekt.MainActivity;
 import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewModel;
 
-public class GalleryFragment extends Fragment {
+public class GalleryFragment extends Fragment{
 
     private GalleryViewModel galleryViewModel;
+    EmailViewModel mEmailViewModel;
+    RecyclerView recyclerView;
 
     public View onCreateView(@NonNull LayoutInflater inflater,
                              ViewGroup container, Bundle savedInstanceState) {
+
+
+
+       // mEmailViewModel.deleteNewMessage();
+
         galleryViewModel =
                 new ViewModelProvider(this).get(GalleryViewModel.class);
         View root = inflater.inflate(R.layout.fragment_gallery, container, false);
@@ -30,6 +42,24 @@ public class GalleryFragment extends Fragment {
                 textView.setText(s);
             }
         });
+
+        recyclerView = MainActivity.recyclerView.findViewById(R.id.recyclerView);
+
+        final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
+        /* Attach the adapter to the recyclerview to populate items */
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getSentMessage().observe(getViewLifecycleOwner(), messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
         return root;
+
     }
+
+
 }

+ 28 - 81
app/src/main/java/com/noahvogt/miniprojekt/ui/home/CustomAdapter.java

@@ -1,107 +1,54 @@
 package com.noahvogt.miniprojekt.ui.home;
 
 
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
+import android.os.Build;
 import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.TextView;
 
 
-import androidx.recyclerview.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+import androidx.recyclerview.widget.DiffUtil;
+import androidx.recyclerview.widget.ListAdapter;
 
-import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.DataBase.Message;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewHolder;
 
-import org.w3c.dom.Text;
 
-import java.util.List;
+import java.util.Objects;
 
-public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> {
+public class CustomAdapter extends ListAdapter<Message, EmailViewHolder> {
 
-    private List<Data> localDataSet;
 
-    /**
-     * Provide a reference to the type of views that you are using
-     * (custom ViewHolder).
-     */
-    public class ViewHolder extends RecyclerView.ViewHolder {
-        private TextView name;
-        private TextView betreff;
-        private TextView date;
-        private TextView begin;
 
-        public ViewHolder(View view) {
-            super(view);
-            // Define click listener for the ViewHolder's View
-
-            name = (TextView) view.findViewById(R.id.textView);
-            betreff = (TextView) view.findViewById(R.id.betreff);
-            date = (TextView) view.findViewById(R.id.date);
-            begin = (TextView) view.findViewById(R.id.begin);
-        }
-
-        //public TextView getTextView() {
-            //return textView;
-        //}
-    }
-
-    /**
-     * Initialize the dataset of the Adapter.
-     *
-     * @param dataSet String[] containing the data to populate views to be used
-     * by RecyclerView.
-     */
-    public CustomAdapter(List<Data> dataSet) {
-        localDataSet = dataSet;
+    public CustomAdapter(@NonNull DiffUtil.ItemCallback<Message> diffCallback) {
+        super(diffCallback);
     }
 
-    // Create new views (invoked by the layout manager)
     @Override
-    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
-        // Create a new view, which defines the UI of the list item
-        //View view = LayoutInflater.from(viewGroup.getContext())
-                //.inflate(R.layout.text_row_item, viewGroup, false);
-
-        Context context = viewGroup.getContext();
-        LayoutInflater inflater = LayoutInflater.from(context);
-
-        // Inflate the custom layout
-        View contactView = inflater.inflate(R.layout.fragment_home, viewGroup, false); //fragment_home is just for no errors idk if it is the right file
-
-        // Return a new holder instance
-        ViewHolder view = new ViewHolder(contactView);
-        return view;
+    public EmailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        return EmailViewHolder.create(parent);
     }
 
-    // Replace the contents of a view (invoked by the layout manager)
+    /* bind data to View*/
     @Override
-    public void onBindViewHolder(ViewHolder viewHolder, int position) {
-
-        // Get element from your dataset at this position and replace the
-        // contents of the view with that element
-        //viewHolder.getTextView().setText(localDataSet[position]);
-        // Get the data model based on position
-        Data contact = localDataSet.get(position);
-
-        // Set item views based on your views and data model
-        TextView nameView = viewHolder.name;
-        TextView betreffView = viewHolder.betreff;
-        TextView dateView = viewHolder.date;
-        TextView beginView = viewHolder.begin;
+    public void onBindViewHolder(EmailViewHolder holder, int position) {
+        Message current = getItem(position);
+        holder.bind(current.getFrom(),current.getSubject(), current.getDate() ,current.getTextContent());
+    }
 
-        nameView.setText(contact.getName());
-        betreffView.setText(contact.getBetreff());
-        dateView.setText(contact.getDate());
-        beginView.setText(contact.getBegin());
+    public static class EmailDiff extends DiffUtil.ItemCallback<Message> {
 
+        @Override
+        public boolean areItemsTheSame(@NonNull Message oldItem, @NonNull Message newItem) {
+            return oldItem == newItem;
+        }
 
+        @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+        @Override
+        public boolean areContentsTheSame(@NonNull Message oldItem, @NonNull Message newItem) {
+            return Objects.equals(oldItem.getId(), newItem.getId());
+        }
     }
 
-    // Return the size of your dataset (invoked by the layout manager)
-    @Override
-    public int getItemCount() {
-        return localDataSet.size();
-    }
 }
 

+ 0 - 42
app/src/main/java/com/noahvogt/miniprojekt/ui/home/Data.java

@@ -1,42 +0,0 @@
-package com.noahvogt.miniprojekt.ui.home;
-
-import java.util.ArrayList;
-
-public class Data {
-    private String mName;
-    private String mdate;
-    private String mBetreff;
-    private String mBegin;
-
-
-    public Data(String name, String date, String begin, String betreff) {
-        mName = name;
-        mdate = date;
-        mBegin = begin;
-        mBetreff = betreff;
-
-
-    }
-
-    public String getName() {
-        return mName;
-    }
-    public String getDate(){return mdate;}
-    public String getBetreff(){return mBetreff;}
-    public String getBegin(){return mBegin;}
-
-
-
-    private static int lastContactId = 0;
-
-    public static ArrayList<Data> createContactsList(int numContacts) {
-        ArrayList<Data> contacts = new ArrayList<Data>();
-
-        for (int i = 1; i <= numContacts; i++) {
-            contacts.add(new Data("Person " + ++lastContactId, "14.04.2021", "This email begins with..",
-                    "My Betreff is no that god"));
-        }
-
-        return contacts;
-    }
-}

+ 30 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/home/HomeFragment.java

@@ -12,15 +12,41 @@ import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
 import androidx.lifecycle.Observer;
 import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
 
+import com.noahvogt.miniprojekt.MainActivity;
 import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewModel;
 
 public class HomeFragment extends Fragment {
 
     private HomeViewModel homeViewModel;
+    EmailViewModel mEmailViewModel;
+    RecyclerView recyclerView;
 
     public View onCreateView(@NonNull LayoutInflater inflater,
                              ViewGroup container, Bundle savedInstanceState) {
+
+
+
+        recyclerView = MainActivity.recyclerView.findViewById(R.id.recyclerView);
+
+        final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
+        /* Attach the adapter to the recyclerview to populate items */
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+        //mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getInboxMessage().observe(getViewLifecycleOwner(), messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
+
+
         homeViewModel =
                 new ViewModelProvider(this).get(HomeViewModel.class);
         View root = inflater.inflate(R.layout.fragment_home, container, false);
@@ -33,4 +59,8 @@ public class HomeFragment extends Fragment {
         });
         return root;
     }
+
+
+
+
 }

+ 142 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/show/MessageShowFragment.java

@@ -0,0 +1,142 @@
+package com.noahvogt.miniprojekt.ui.show;
+
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.PopupMenu;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProvider;
+
+import com.noahvogt.miniprojekt.R;
+
+
+public class MessageShowFragment extends Fragment implements PopupMenu.OnMenuItemClickListener {
+
+
+    public TextView sendingAddressObject;
+    public TextView receivingAddressObject;
+    public TextView subjectObject;
+    public TextView messageBodyObject;
+
+    private MessageShowViewModel messageShowViewModel;
+
+
+
+
+    // set theming style
+    /*@Override
+    public void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setStyle(DialogFragment.STYLE_NORMAL, R.style.messageCreateTheme);
+    }
+
+     */
+
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        // set and inflate layout
+        View view = inflater.inflate(R.layout.message_show_fragment, container, false);
+
+        // init vars
+
+        messageShowViewModel =
+                new ViewModelProvider(this).get(MessageShowViewModel.class);
+        View root = inflater.inflate(R.layout.message_show_fragment, container, false);
+        final TextView textView = root.findViewById(R.id.show_message_receiving_address_layout);
+        messageShowViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
+            @Override
+            public void onChanged(@Nullable String s) {
+                textView.setText(s);
+            }
+        });
+
+
+        ImageButton closeButton = view.findViewById(R.id.show_message_close_button);
+        ImageButton dotButton = view.findViewById(R.id.show_message_dots_button);
+        ImageButton attachButton = view.findViewById(R.id.show_message_attach_button);
+
+        sendingAddressObject = (EditText) view.findViewById(R.id.create_message_sending_address_text);
+        receivingAddressObject = (EditText) view.findViewById(R.id.create_message_receiving_address_text);
+        subjectObject = (EditText) view.findViewById(R.id.create_message_subject_text);
+        messageBodyObject = (EditText) view.findViewById(R.id.create_message_body_text);
+
+        // get string vars, MAYBE NOT HERE
+        String sendingAddress = sendingAddressObject.getText().toString();
+        String receivingAddress = receivingAddressObject.getText().toString();
+        //String subject = subjectObject.getText().toString();
+        String messageBody = messageBodyObject.getText().toString();
+
+
+        /* dosen't wotk cause Activity is not extendet and used as variable */
+
+
+
+
+
+
+        // TODO: add cc + bcc functionality
+
+        // button listeners
+
+        closeButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+            }
+
+        });
+
+        attachButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                // TODO: add file attachment functionality
+            }
+        });
+
+        dotButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                PopupMenu popupMenu = new PopupMenu(getActivity(), v);
+                popupMenu.setOnMenuItemClickListener(MessageShowFragment.this::onMenuItemClick);
+                popupMenu.inflate(R.menu.create_message_options_menu);
+                popupMenu.show();
+            }
+        });
+
+        return root;
+    }
+
+
+    @Override
+    public boolean onMenuItemClick(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.create_message_delete:
+                Toast.makeText(getActivity(), "item delete clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_spam:
+                Toast.makeText(getActivity(), "item spam clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_sent_to:
+                Toast.makeText(getActivity(), "item sent to clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_move_to:
+                Toast.makeText(getActivity(), "item move to clicked", Toast.LENGTH_LONG).show();
+                return true;
+            default: // this case should never occur
+                return false;
+        }
+    }
+}

+ 19 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/show/MessageShowViewModel.java

@@ -0,0 +1,19 @@
+package com.noahvogt.miniprojekt.ui.show;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class MessageShowViewModel extends ViewModel {
+
+    private MutableLiveData<String> mText;
+
+    public MessageShowViewModel() {
+        mText = new MutableLiveData<>();
+        mText.setValue("This is from Simon");
+    }
+
+    public LiveData<String> getText() {
+        return mText;
+    }
+}

+ 67 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/DraftFragment.java

@@ -0,0 +1,67 @@
+package com.noahvogt.miniprojekt.ui.slideshow;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.noahvogt.miniprojekt.MainActivity;
+import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
+
+public class DraftFragment extends Fragment {
+
+   private DraftViewModel draftViewModel;
+   EmailViewModel mEmailViewModel;
+   RecyclerView recyclerView;
+
+
+    public View onCreateView(@NonNull LayoutInflater inflater,
+                             ViewGroup container, Bundle savedInstanceState) {
+
+
+
+        recyclerView = MainActivity.recyclerView.findViewById(R.id.recyclerView);
+
+        final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
+        /* Attach the adapter to the recyclerview to populate items */
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+        //mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getDraftMessage().observe(getViewLifecycleOwner(), messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
+        draftViewModel =
+                new ViewModelProvider(this).get(DraftViewModel.class);
+        View root = inflater.inflate(R.layout.fragment_slideshow, container, false);
+        final TextView textView = root.findViewById(R.id.text_slideshow);
+        draftViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
+            @Override
+            public void onChanged(@Nullable String s) {
+                textView.setText(s);
+            }
+        });
+        return root;
+    }
+
+
+
+
+
+
+}
+

+ 2 - 2
app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/SlideshowViewModel.java → app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/DraftViewModel.java

@@ -4,11 +4,11 @@ import androidx.lifecycle.LiveData;
 import androidx.lifecycle.MutableLiveData;
 import androidx.lifecycle.ViewModel;
 
-public class SlideshowViewModel extends ViewModel {
+public class DraftViewModel extends ViewModel {
 
     private MutableLiveData<String> mText;
 
-    public SlideshowViewModel() {
+    public DraftViewModel() {
         mText = new MutableLiveData<>();
         mText.setValue("This is slideshow fragment");
     }

+ 120 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/EmailViewHolder.java

@@ -0,0 +1,120 @@
+package com.noahvogt.miniprojekt.ui.slideshow;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.noahvogt.miniprojekt.MainActivity;
+import com.noahvogt.miniprojekt.ui.show.MessageShowFragment;
+import com.noahvogt.miniprojekt.R;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.drawerlayout.widget.DrawerLayout;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.navigation.Navigation;
+import androidx.navigation.ui.AppBarConfiguration;
+import androidx.recyclerview.widget.RecyclerView;
+
+/* adds the content to the View of RecyclerView*/
+public class EmailViewHolder extends RecyclerView.ViewHolder {
+    private final TextView fromItemView;
+    private final TextView subjectItemView;
+    private final TextView dateItemView;
+    public final TextView messageItemView;
+
+    private AppBarConfiguration mAppBarConfiguration;
+
+
+    private EmailViewHolder(View itemView, ViewGroup parent) {
+        super(itemView);
+        fromItemView = itemView.findViewById(R.id.textView);
+        subjectItemView = itemView.findViewById(R.id.subject);
+        dateItemView = itemView.findViewById(R.id.date);
+        messageItemView = itemView.findViewById(R.id.message);
+        itemView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Toast.makeText(v.getContext(), "clicked ViewHolder ", Toast.LENGTH_LONG).show();
+              /*  Fragment fragment = new MessageShowFragment();
+                if (!fragment.isAdded()){
+                    Toast.makeText(v.getContext(), "is not Added ", Toast.LENGTH_LONG).show();
+
+                    FragmentManager fragmentManager = fragment.getParentFragmentManager();
+                    fragmentManager.beginTransaction()
+                        .add(R.id.nav_show, MessageShowFragment.class, null)
+                        .commit();
+                }
+
+               */
+            }
+        });
+    }
+
+    public void bind(String from, String subject, String date, String message) {
+        fromItemView.setText(from);
+        subjectItemView.setText(subject);
+        dateItemView.setText(date);
+        messageItemView.setText(message);
+    }
+
+    public static EmailViewHolder create(ViewGroup parent) {
+        View view = LayoutInflater.from(parent.getContext())
+                .inflate(R.layout.fragment_home, parent, false);
+        return new EmailViewHolder(view, parent);
+    }
+
+
+
+   /* public void createNewEmailDialog(){
+        // define View window
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(itemView.getContext());
+
+        // init text field variables
+        newemail_name = emailPopupView.findViewById(R.id.popup_material_name_asking_text);
+        newemail_email = emailPopupView.findViewById(R.id.popup_material_email_asking_text);
+        newemail_password = emailPopupView.findViewById(R.id.popup_material_password_asking_text);
+
+        // init button variables
+        Button newemail_save_button = (Button) emailPopupView.findViewById(R.id.saveButton);
+        // may not be private
+        Button newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
+
+        // open View window
+        dialogBuilder.setView(emailPopupView);
+        dialog = dialogBuilder.create();
+        dialog.show();
+
+        // store user input
+        newemail_save_button.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                // store user input (only needed for DEBUGGING)
+                String name = newemail_name.getText().toString();
+                String email = newemail_email.getText().toString();
+                String password = newemail_password.getText().toString();
+
+                if (!mailFunctions.validateEmail(newemail_email) | !mailFunctions.validateName(newemail_name) | !mailFunctions.validatePassword(newemail_password)) {
+                    return;
+                }
+
+                // show all strings the user gave, this will later be stored to a secure database and checked for validation
+                showToast(name);
+                showToast(email);
+                showToast(password);
+
+
+                showSnackbar(emailPopupView,"save button clicked");
+            }
+        });
+
+    */
+
+    }
+
+

+ 50 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/EmailViewModel.java

@@ -0,0 +1,50 @@
+package com.noahvogt.miniprojekt.ui.slideshow;
+
+import android.app.Application;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.AndroidViewModel;
+
+import com.noahvogt.miniprojekt.ui.DataBase.EmailRepository;
+import com.noahvogt.miniprojekt.ui.DataBase.Message;
+
+import java.util.List;
+
+public class EmailViewModel extends AndroidViewModel {
+
+    private EmailRepository mEmailRepository;
+
+    private LiveData<List<Message>> mDraftMessage;
+    private LiveData<List<Message>> mInboxMessage;
+    private LiveData<List<Message>> mSentMessage;
+    private LiveData<List<Message>> mArchiveMessage;
+    private LiveData<List<Message>> mSpamMessage;
+
+    public EmailViewModel(Application application) {
+        super(application);
+        mEmailRepository = new EmailRepository(application);
+        mDraftMessage = mEmailRepository.getDraftMessages();
+        mInboxMessage = mEmailRepository.getInboxMessages();
+        mSentMessage = mEmailRepository.getSentMessages();
+        mArchiveMessage = mEmailRepository.getArchiveMessages();
+        mSpamMessage = mEmailRepository.getSpamMessage();
+    }
+
+    public LiveData<List<Message>> getDraftMessage(){
+        return mDraftMessage;
+    }
+
+    public LiveData<List<Message>> getSpamMessage(){return mSpamMessage;}
+
+    public LiveData<List<Message>> getInboxMessage(){ return mInboxMessage;}
+
+    public LiveData<List<Message>> getSentMessage(){ return mSentMessage;}
+
+    public LiveData<List<Message>> getArchiveMessage(){ return mArchiveMessage;}
+
+    public void insert(Message message){mEmailRepository.insert(message);}
+
+    public void deleteMessage(Message message){mEmailRepository.deleteMessage(message);}
+
+    public void updateMessage(Message message){mEmailRepository.updateMessage(message);}
+}

+ 0 - 35
app/src/main/java/com/noahvogt/miniprojekt/ui/slideshow/SlideshowFragment.java

@@ -1,35 +0,0 @@
-package com.noahvogt.miniprojekt.ui.slideshow;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-import androidx.lifecycle.Observer;
-import androidx.lifecycle.ViewModelProvider;
-
-import com.noahvogt.miniprojekt.R;
-
-public class SlideshowFragment extends Fragment {
-
-    private SlideshowViewModel slideshowViewModel;
-
-    public View onCreateView(@NonNull LayoutInflater inflater,
-                             ViewGroup container, Bundle savedInstanceState) {
-        slideshowViewModel =
-                new ViewModelProvider(this).get(SlideshowViewModel.class);
-        View root = inflater.inflate(R.layout.fragment_slideshow, container, false);
-        final TextView textView = root.findViewById(R.id.text_slideshow);
-        slideshowViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
-            @Override
-            public void onChanged(@Nullable String s) {
-                textView.setText(s);
-            }
-        });
-        return root;
-    }
-}

+ 66 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/spam/SpamFragment.java

@@ -0,0 +1,66 @@
+package com.noahvogt.miniprojekt.ui.spam;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.noahvogt.miniprojekt.MainActivity;
+import com.noahvogt.miniprojekt.R;
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
+import com.noahvogt.miniprojekt.ui.slideshow.EmailViewModel;
+
+public class SpamFragment extends Fragment {
+
+    private SpamViewModel spamViewModel;
+    EmailViewModel mEmailViewModel;
+    RecyclerView recyclerView;
+
+    public View onCreateView(@NonNull LayoutInflater inflater,
+                             ViewGroup container, Bundle savedInstanceState) {
+
+
+
+        recyclerView = MainActivity.recyclerView.findViewById(R.id.recyclerView);
+
+        final CustomAdapter adapter = new CustomAdapter(new CustomAdapter.EmailDiff());
+
+        /* Attach the adapter to the recyclerview to populate items */
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+        //mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+
+        mEmailViewModel = new ViewModelProvider(this).get(EmailViewModel.class);
+        mEmailViewModel.getSpamMessage().observe(getViewLifecycleOwner(), messages -> {
+            /* Update the cached copy of the messages in the adapter*/
+            adapter.submitList(messages);
+        });
+
+        // mEmailViewModel.deleteNewMessage();
+
+        spamViewModel =
+                new ViewModelProvider(this).get(SpamViewModel.class);
+        View root = inflater.inflate(R.layout.fragment_spam, container, false);
+        final TextView textView = root.findViewById(R.id.text_spam);
+        spamViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
+            @Override
+            public void onChanged(@Nullable String s) {
+                textView.setText(s);
+            }
+        });
+        return root;
+
+
+
+
+    }
+}

+ 19 - 0
app/src/main/java/com/noahvogt/miniprojekt/ui/spam/SpamViewModel.java

@@ -0,0 +1,19 @@
+package com.noahvogt.miniprojekt.ui.spam;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class SpamViewModel extends ViewModel {
+
+    private MutableLiveData<String> mText;
+
+    public SpamViewModel() {
+        mText = new MutableLiveData<>();
+        mText.setValue("This is Spam fragment");
+    }
+
+    public LiveData<String> getText() {
+        return mText;
+    }
+}

+ 11 - 0
app/src/main/res/drawable-anydpi/archive_icon.xml

@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="#000000"
+    android:alpha="0.8">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M20.54,5.23l-1.39,-1.68C18.88,3.21 18.47,3 18,3H6c-0.47,0 -0.88,0.21 -1.16,0.55L3.46,5.23C3.17,5.57 3,6.02 3,6.5V19c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V6.5c0,-0.48 -0.17,-0.93 -0.46,-1.27zM12,17.5L6.5,12H10v-2h4v2h3.5L12,17.5zM5.12,5l0.81,-1h12l0.94,1H5.12z"/>
+</vector>

+ 11 - 0
app/src/main/res/drawable-anydpi/spam_icon.xml

@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="#000000"
+    android:alpha="0.8">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z"/>
+</vector>

二进制
app/src/main/res/drawable-hdpi/archive_icon.png


二进制
app/src/main/res/drawable-hdpi/spam_icon.png


二进制
app/src/main/res/drawable-mdpi/archive_icon.png


二进制
app/src/main/res/drawable-mdpi/spam_icon.png


二进制
app/src/main/res/drawable-xhdpi/archive_icon.png


二进制
app/src/main/res/drawable-xhdpi/spam_icon.png


二进制
app/src/main/res/drawable-xxhdpi/archive_icon.png


二进制
app/src/main/res/drawable-xxhdpi/spam_icon.png


+ 10 - 0
app/src/main/res/drawable/ic_baseline_add_24.xml

@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?attr/colorControlNormal">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
+</vector>

+ 7 - 10
app/src/main/res/layout/activity_main.xml

@@ -9,16 +9,6 @@
     tools:openDrawer="start"
     tools:context=".MainActivity">
 
-
-    <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/recyclerView"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:paddingTop="50dp"
-        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager">
-
-    </androidx.recyclerview.widget.RecyclerView>
-
     <include
         layout="@layout/app_bar_main"
         android:layout_width="match_parent"
@@ -35,6 +25,11 @@
         app:headerLayout="@layout/nav_header_main"
         app:menu="@menu/activity_main_drawer" >
 
+        <View
+            android:id="@+id/accountView"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/nav_header_height"/>
+
         <Button
             android:id="@+id/addEmailButton"
             android:layout_width="wrap_content"
@@ -64,4 +59,6 @@
 
 
 
+
+
 </androidx.drawerlayout.widget.DrawerLayout>

+ 13 - 22
app/src/main/res/layout/content_main.xml

@@ -18,33 +18,24 @@
         app:layout_constraintTop_toTopOf="parent"
         app:navGraph="@navigation/mobile_navigation" />
 
-    <LinearLayout
-        android:id="@+id/container"
-        android:layout_width="96dp"
-        android:layout_height="96dp"
-
-        android:layout_marginEnd="16dp"
-        android:layout_marginRight="16dp"
-        android:layout_marginBottom="16dp"
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/recyclerView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingTop="50dp"
+        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager">
 
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent">
+    </androidx.recyclerview.widget.RecyclerView>
 
-        <ImageButton
+        <com.google.android.material.floatingactionbutton.FloatingActionButton
             android:id="@+id/messageButton"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_margin="16dp"
+            android:contentDescription="@string/write_email"
+            android:src="@drawable/ic_baseline_add_24"/>
 
-            android:paddingLeft="18dp"
-            android:paddingRight="18dp"
-            android:paddingTop="18dp"
-            android:paddingBottom="18dp"
-            android:scaleType="fitXY"
-
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:srcCompat="@drawable/mail_write_icon"
-            tools:ignore="VectorDrawableCompat" />
-    </LinearLayout>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 23 - 0
app/src/main/res/layout/fragment_archive.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".ui.archive.ArchiveFragment">
+
+    <TextView
+        android:id="@+id/text_archive"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginEnd="8dp"
+        android:layout_gravity="center_horizontal"
+        android:textAlignment="center"
+        android:textSize="20sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 7 - 3
app/src/main/res/layout/fragment_home.xml

@@ -1,11 +1,13 @@
 <?xml version="1.0" encoding="utf-8"?>
 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:paddingLeft="16dp"
     android:paddingTop="16dp"
     android:paddingRight="16dp"
-    android:layout_gravity="top">
+    android:layout_gravity="top"
+    tools:context=".ui.home.HomeFragment">
 
     <TextView
         android:id="@+id/textView"
@@ -16,7 +18,7 @@
         android:textSize="25dp"/>
 
     <TextView
-        android:id="@+id/begin"
+        android:id="@+id/message"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_row="2"
@@ -26,7 +28,7 @@
 
 
     <TextView
-        android:id="@+id/betreff"
+        android:id="@+id/subject"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_row="1"
@@ -46,4 +48,6 @@
         android:gravity="start" />
 
 
+
+
 </GridLayout>

+ 1 - 1
app/src/main/res/layout/fragment_slideshow.xml

@@ -4,7 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".ui.slideshow.SlideshowFragment">
+    tools:context=".ui.slideshow.DraftFragment">
 
     <TextView
         android:id="@+id/text_slideshow"

+ 23 - 0
app/src/main/res/layout/fragment_spam.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".ui.spam.SpamFragment">
+
+    <TextView
+        android:id="@+id/text_spam"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="8dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginEnd="8dp"
+        android:layout_gravity="center_horizontal"
+        android:textAlignment="center"
+        android:textSize="20sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 199 - 0
app/src/main/res/layout/message_show_fragment.xml

@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/messageFragment"
+    android:orientation="vertical"
+    tools:context=".ui.show.MessageShowFragment">
+
+
+    <androidx.cardview.widget.CardView
+        android:id="@+id/cardShowView"
+        android:layout_width="match_parent"
+        android:layout_height="?attr/actionBarSize"
+        app:cardBackgroundColor="#5e35b1"
+        tools:ignore="MissingConstraints">
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+            <ImageButton
+                android:id="@+id/show_message_close_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_marginLeft="0dp"
+                android:layout_marginStart="0dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:padding="8dp"
+                android:src="@mipmap/ic_close_purple" />
+
+            <ImageButton
+                android:id="@+id/show_message_dots_button"
+                android:layout_width="56dp"
+                android:layout_height="match_parent"
+
+                android:layout_marginLeft="360dp"
+                android:layout_marginStart="360dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:padding="8dp"
+                android:src="@mipmap/ic_more_vert_dots_purple" />
+
+            <ImageButton
+                android:id="@+id/show_message_attach_button"
+                android:layout_width="56dp"
+                android:layout_height="match_parent"
+
+
+                android:layout_toEndOf="@id/show_message_dots_button"
+                android:layout_marginLeft="-110dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:padding="8dp"
+                android:src="@mipmap/ic_attach_purple"
+                android:layout_toRightOf="@id/show_message_dots_button"
+                android:layout_marginStart="-110dp" />
+
+
+
+
+        </RelativeLayout>
+    </androidx.cardview.widget.CardView>
+
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:gravity="top">
+
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:id="@+id/show_message_sending_address_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+
+                android:layout_marginStart="12dp"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginEnd="12dp"
+                android:layout_marginRight="12dp"
+                android:layout_marginBottom="12dp">
+
+            <TextView
+                android:id="@+id/show_From"
+                android:text="@string/show_from"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+
+                android:layout_marginStart="12dp"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginEnd="12dp"
+                android:layout_marginRight="12dp"
+                android:layout_marginBottom="12dp" />
+            </com.google.android.material.textfield.TextInputLayout>
+
+
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:id="@+id/show_message_receiving_address_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+
+                android:layout_marginStart="12dp"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginEnd="12dp"
+                android:layout_marginRight="12dp"
+                android:layout_marginBottom="12dp">
+
+                <TextView
+                    android:id="@+id/show_To"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="12dp"
+
+                    android:layout_marginLeft="12dp"
+                    android:layout_marginTop="12dp"
+                    android:layout_marginEnd="12dp"
+                    android:layout_marginRight="12dp"
+                    android:layout_marginBottom="12dp"
+                    android:hint="@string/show_To" />
+            </com.google.android.material.textfield.TextInputLayout>
+
+
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:id="@+id/show_message_subject_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+
+                android:layout_marginStart="12dp"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginEnd="12dp"
+                android:layout_marginRight="12dp"
+                android:layout_marginBottom="12dp"
+
+                app:layout_constraintTop_toBottomOf="@+id/show_message_sending_address_layout"
+                tools:layout_editor_absoluteX="1dp">
+
+            <TextView
+                    android:id="@+id/show_message_subject_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:hint="@string/show_subject"
+                    android:inputType="textEmailSubject"
+
+                    android:layout_marginStart="12dp"
+                    android:layout_marginLeft="12dp"
+                    android:layout_marginTop="12dp"
+                    android:layout_marginEnd="12dp"
+                    android:layout_marginRight="12dp"
+                    android:layout_marginBottom="12dp"/>
+            </com.google.android.material.textfield.TextInputLayout>
+
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:id="@+id/show_message_body_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+
+                android:layout_marginStart="12dp"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginEnd="12dp"
+                android:layout_marginRight="12dp"
+                android:layout_marginBottom="12dp"
+
+                app:layout_constraintTop_toBottomOf="@+id/show_message_sending_address_layout"
+                tools:layout_editor_absoluteX="1dp">
+
+                <TextView
+                    android:id="@+id/show_message_body_text"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:minHeight="160dp"
+                    android:textAlignment="viewStart"
+                    android:hint="Message ..."
+                    android:inputType="textMultiLine"
+                    android:gravity="start" />
+            </com.google.android.material.textfield.TextInputLayout>
+
+        </LinearLayout>
+
+    </ScrollView>
+
+    <FrameLayout
+        android:id="@+id/show_Layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 10 - 0
app/src/main/res/menu/activity_main_drawer.xml

@@ -16,5 +16,15 @@
             android:id="@+id/nav_slideshow"
             android:icon="@drawable/drafts_icon"
             android:title="@string/drawer_drafts" />
+
+        <item
+            android:id="@+id/nav_archive"
+            android:icon="@drawable/archive_icon"
+            android:title="@string/drawer_archive" />
+
+        <item
+            android:id="@+id/nav_spam"
+            android:icon="@drawable/spam_icon"
+            android:title="@string/drawer_spam" />
     </group>
 </menu>

+ 9 - 10
app/src/main/res/menu/create_message_options_menu.xml

@@ -1,13 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item android:id="@+id/create_message_item_1"
-        android:title="@string/title_item_1"/>
-    <item android:id="@+id/create_message_item_2"
-        android:title="@string/title_item_2"/>
-    <item android:id="@+id/create_message_item_3"
-        android:title="@string/title_item_3"/>
-    <item android:id="@+id/create_message_item_4"
-        android:title="@string/title_item_4"/>
-
+    <!--wrong, should just be called in Emailviewer -->
+    <item android:id="@+id/create_message_delete"
+        android:title="@string/menu_delete"/>
+    <item android:id="@+id/create_message_spam"
+        android:title="@string/menu_spam"/>
+    <item android:id="@+id/create_message_sent_to"
+        android:title="@string/menu_sent_to"/>
+    <item android:id="@+id/create_message_move_to"
+        android:title="@string/menu_move_to"/>
 </menu>

+ 15 - 1
app/src/main/res/navigation/mobile_navigation.xml

@@ -19,9 +19,23 @@
 
     <fragment
         android:id="@+id/nav_slideshow"
-        android:name="com.noahvogt.miniprojekt.ui.slideshow.SlideshowFragment"
+        android:name="com.noahvogt.miniprojekt.ui.slideshow.DraftFragment"
         android:label="@string/drawer_drafts"
         tools:layout="@layout/fragment_slideshow" />
 
+    <fragment
+        android:id="@+id/nav_archive"
+        android:name="com.noahvogt.miniprojekt.ui.archive.ArchiveFragment"
+        android:label="@string/drawer_archive"
+        tools:layout="@layout/fragment_archive" />
+
+    <fragment
+        android:id="@+id/nav_spam"
+        android:name="com.noahvogt.miniprojekt.ui.spam.SpamFragment"
+        android:label="@string/drawer_spam"
+        tools:layout="@layout/fragment_spam" />
 
+    <fragment
+        android:id="@+id/nav_show"
+        android:name="com.noahvogt.miniprojekt.ui.show.MessageShowFragment"/>
 </navigation>

+ 16 - 0
app/src/main/res/values/strings.xml

@@ -11,10 +11,24 @@
     <string name="drawer_sent">Sent</string>
     <string name="drawer_drafts">Drafts</string>
     <string name="drawer_setting">Setting</string>
+    <string name="drawer_archive">Archive</string>
+    <string name="drawer_spam">Spam</string>
+
     <string name="your_password_filler">Your Password</string>
     <string name="your_email_address_filler">Your Email Address</string>
     <string name="your_full_name_filler">Your Full Name</string>
 
+
+    <string name="show_from">From</string>
+    <string name="show_To">To </string>
+    <string name="show_subject">Subject</string>
+    <string name="show_message">Message</string>
+
+    <string name="menu_delete">Delete</string>
+    <string name="menu_move_to">Move to</string>
+    <string name="menu_spam">Spam</string>
+    <string name="menu_sent_to">Sent to</string>
+
     <string name="Sender">Absender</string>
     <string name="Betreff">Betreff</string>
     <string name="Beginn">E-mail Beginn</string>
@@ -44,5 +58,7 @@
     <string name="title_item_3">Item 3</string>
     <string name="title_item_4">Item 4</string>
 
+    <string name="write_email">Write a Email</string>
+    <string name="empty_not_saved">Email not saved because it was empty.</string>
 </resources>
 

+ 3 - 0
build.gradle

@@ -8,6 +8,9 @@ buildscript {
     dependencies {
         classpath 'com.android.tools.build:gradle:4.2.0'
         classpath "com.chaquo.python:gradle:9.1.0"
+        classpath 'com.android.tools.build:gradle:4.2.2'
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
     }
 }