Simon Hammer 3 vuotta sitten
vanhempi
sitoutus
3830063a01

+ 1 - 9
app/src/main/java/com/noahvogt/snailmail/DataBase/EmailRepository.java

@@ -29,10 +29,6 @@ public class EmailRepository {
     private List<Message> mAllMessages;
 
 
-    // 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);
@@ -44,8 +40,7 @@ public class EmailRepository {
         mSpamLiveMessage = messageDao.getLiveSpamMessages(userGlobal);
     }
 
-    // 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 mDraftLiveMessage;
@@ -67,13 +62,10 @@ public class EmailRepository {
 
     /*problems with main Thread */
     public List<Message> getAllMessages(){
-        //mAllMessages = messageDao.getAllMessages();
         return mAllMessages;}
 
 
 
-    // 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);

+ 1 - 1
app/src/main/java/com/noahvogt/snailmail/DataBase/EmailRoomDatabase.java

@@ -31,7 +31,7 @@ public abstract class EmailRoomDatabase extends RoomDatabase{
     /* 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
+    /* tells room the schema is changed from the version that is installed in device
      * is not used */
     static final Migration MIGRATION_2_3 = new Migration(2, 3) {
         @Override

+ 0 - 3
app/src/main/java/com/noahvogt/snailmail/DataBase/Message.java

@@ -16,9 +16,6 @@ import androidx.room.PrimaryKey;
 
 import com.google.gson.annotations.SerializedName;
 
-/* @Embedded to express entitys together
- *  https://developer.android.com/training/data-storage/room/relationships
- * to learn more */
 
 @Entity(tableName = "message_table")
 public class Message {

+ 9 - 14
app/src/main/java/com/noahvogt/snailmail/MainActivity.java

@@ -173,17 +173,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                         String jsonCredData = credReader.getString("data", "");
                         Type credentialsType = new TypeToken<ArrayList<MailServerCredentials>>(){}.getType();
                         ArrayList<MailServerCredentials> currentUsersCredentials = gson.fromJson(jsonCredData, credentialsType);
-                        showToast("clicked switch");
+
 
                         try {
                             for (int i = 0; i < currentUsersCredentials.size(); i++) {
-                                showToast("Credentials: "+ currentUsersCredentials.get(i).getUsername());
-                                showToast("userInput: " + userInput);
                                 if (currentUsersCredentials.get(i).getUsername().equals(userInput)) {
                                     credEditor.putString("currentUser", userInput).apply();
                                     userGlobal = userInput;
                                     showCurrentUserObject.setText(String.format("current user:\n%s", userInput));
-                                    showToast("switched account");
+                                    showToast("Switched account");
                                     updateNavHeaderText(headerView);
                                     break;
                                 }
@@ -202,7 +200,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                         String jsonCredData = credReader.getString("data", "");
                         Type credentialsType = new TypeToken<ArrayList<MailServerCredentials>>(){}.getType();
                         ArrayList<MailServerCredentials> currentUserCredentials = gson.fromJson(jsonCredData, credentialsType);
-                        showToast("clicked delete account");
+
 
                         try {
                             for (int i = 0; i < currentUserCredentials.size(); i++) {
@@ -237,7 +235,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                                         showCurrentUserObject.setText("current user:\n None");
                                         userGlobal = null;
                                     }
-                                    showToast("account removed");
+                                    showToast("Account removed");
                                     updateNavHeaderText(headerView);
                                     break;
                                 }
@@ -350,7 +348,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
             Date dNow = new Date();
             SimpleDateFormat ft =
                     new SimpleDateFormat("dd.MM.yy");
-            System.out.println(dNow);
 
                 Message word = new Message(userGlobal,
                         MessageCreateFragment.replyIntent.getStringExtra(MessageCreateFragment.EXTRA_TO),
@@ -557,19 +554,18 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                 credentialsEditor.putString("data", gson.toJson(allUsersCredentials, credentialsType));
                 credentialsEditor.putString("currentUser", email);
                 credentialsEditor.apply();
-                showToast("Success: added new email account");
                 updateNavHeaderText(headerView);
                 dialogContext.dismiss();
                 return true;
             } else {
-                showToast("Error: cannot add the same email twice");
+                showToast("You cannot add the same email twice");
                 return false;
             }
         } else {
             if (wantConnectionFailedDialog) {
                 askForChangeMailServerSettingsDialog(name, email, password, headerView);
             } else {
-                showToast("Error: failed to get connection");
+                showToast("Failed to get connection");
                 return false;
             }
         }
@@ -585,7 +581,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
         /* connect to mail server */
         showToast("Probe Connection ...");
         if (MailFunctions.canConnect(imapHost, email, password) == Boolean.TRUE) {
-            showToast("was able to connect");
+            showToast("Was able to connect");
 
             Gson gson = new Gson();
 
@@ -602,13 +598,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                     allUsersCredentials.set(i, new MailServerCredentials(name, email, password, imapHost, smtpHost, imapPort,
                             smtpPort, signature));
                     credentialsEditor.putString("data", gson.toJson(allUsersCredentials, credentialsType)).apply();
-                    showToast("changed account credentials");
                     dialogContext.dismiss();
                     break;
                 }
             }
         } else {
-                showToast("Error: failed to get connection");
+                showToast("Failed to get connection");
         }
     }
 
@@ -651,7 +646,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                 boolean connection = addNewAccountCredentials(name, email, password, 993, 587, MailFunctions.getImapHostFromEmail(email),
                         MailFunctions.getSmtpHostFromEmail(email), rootCreateNewEmailPopupDialog, true, headerView);
                 if (connection) {
-                    showToast("Downloading Messages");
+                    showToast("Downloading messages");
                     mEmailViewModel.applyDownload();
                     userGlobal = email;
                 }

+ 3 - 12
app/src/main/java/com/noahvogt/snailmail/MessageCreateFragment.java

@@ -118,13 +118,6 @@ public class MessageCreateFragment extends DialogFragment implements PopupMenu.O
 
         /* TODO: add cc + bcc functionality */
 
-        /* doesn't work cause Activity is not extended and used as variable */
-
-
-
-
-
-
         /* button listeners */
         closeButton.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -133,7 +126,6 @@ public class MessageCreateFragment extends DialogFragment implements PopupMenu.O
                 String messageBody = messageBodyObject.getText().toString();
 
                 /* give alert dialog box to user in case input fields are not empty */
-
                 if (subject.isEmpty() && messageBody.isEmpty()) {
                     dismiss();
                 }
@@ -245,7 +237,7 @@ public class MessageCreateFragment extends DialogFragment implements PopupMenu.O
                         Toast.makeText(getActivity(), "Sending ... ", Toast.LENGTH_SHORT).show();
                         dismiss();
                     }catch (com.chaquo.python.PyException pyException){
-                        Toast.makeText(getActivity(), "Couldn't send message", Toast.LENGTH_SHORT).show();
+                        Toast.makeText(getActivity(), "Could not send message", Toast.LENGTH_SHORT).show();
                     }
                 } else {
                     Toast.makeText(getActivity(), "Please check your input", Toast.LENGTH_SHORT).show();
@@ -260,7 +252,6 @@ public class MessageCreateFragment extends DialogFragment implements PopupMenu.O
     /* TODO: add useful functionality to the menu + consider not using Resource ID's in switch statement
 
         IDEAS:
-        - safe to draft
         - clear all user input
         - change / check email signature
         - some email header hacking / options / customization
@@ -271,10 +262,10 @@ public class MessageCreateFragment extends DialogFragment implements PopupMenu.O
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.create_message_delete:
-                Toast.makeText(getActivity(), "item 1 clicked", Toast.LENGTH_LONG).show();
+                Toast.makeText(getActivity(), "Nothing will happen", Toast.LENGTH_LONG).show();
                 return true;
             case R.id.create_message_spam:
-                Toast.makeText(getActivity(), "item 2 clicked", Toast.LENGTH_LONG).show();
+                Toast.makeText(getActivity(), "Nothing wil happen", Toast.LENGTH_LONG).show();
                 return true;
             default: /* this case should never occur */
                 return false;

+ 4 - 5
app/src/main/java/com/noahvogt/snailmail/SettingsActivity.java

@@ -17,17 +17,16 @@ public class SettingsActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_settings);
 
-        // below line is to change
-        // the title of our action bar.
+
+        /* change the title of our action bar */
         Objects.requireNonNull(getSupportActionBar()).setTitle("Settings");
 
-        // below line is used to check if
-        // frame layout is empty or not.
+        /*if frame layout is empty or not. */
         if (findViewById(R.id.idFrameLayout) != null) {
             if (savedInstanceState != null) {
                 return;
             }
-            // below line is to inflate our fragment.
+            /*inflate our fragment */
             getSupportFragmentManager().beginTransaction().add(R.id.idFrameLayout, new SettingsFragment()).commit();
         }
 

+ 0 - 1
app/src/main/java/com/noahvogt/snailmail/data/CustomAdapter.java

@@ -48,7 +48,6 @@ public class CustomAdapter extends ListAdapter<Message, EmailViewHolder> {
 
     /*get List from adapter which is shown*/
     public void getList(List<Message> messageList){
-        System.out.println("GetList Adapter Loop");
         this.messageList = messageList;
     }
 

+ 0 - 5
app/src/main/java/com/noahvogt/snailmail/data/DeleteThread.java

@@ -8,11 +8,6 @@ public class DeleteThread extends AsyncTask<Boolean, Void, Void> implements Runn
 
     @Override
     public void run() {
-       /* for (int delete = 0; delete <= mEmailViewModel.getAllMessages().size(); delete++){
-            mEmailViewModel.deleteMessage(mEmailViewModel.getAllMessages().get(delete));
-        }
-
-        */
     }
 
     @Override

+ 0 - 8
app/src/main/java/com/noahvogt/snailmail/data/EmailViewHolder.java

@@ -74,14 +74,6 @@ public class EmailViewHolder extends RecyclerView.ViewHolder {
         if (message.length() > 30){
             message = message.substring(0,30) + "...";
         }
-        /*if (date.length() > 9){
-            date = "INVALID";
-        }
-        if (!isDate(date)){
-            date = "INVALID";
-        }
-
-         */
 
         fromItemView.setText(from);
         subjectItemView.setText(subject);

+ 1 - 12
app/src/main/java/com/noahvogt/snailmail/data/EmailViewModel.java

@@ -54,7 +54,6 @@ public class EmailViewModel extends AndroidViewModel {
         mSentMessage = mEmailRepository.getSentMessages();
         mArchiveMessage = mEmailRepository.getArchiveMessages();
         mSpamMessage = mEmailRepository.getSpamMessage();
-        //mAllMessages = mEmailRepository.getAllMessages();
     }
 
     /*requests Worker and applies password, email to it */
@@ -70,13 +69,6 @@ public class EmailViewModel extends AndroidViewModel {
         /*if Messages being downloaded*/
         if (isDownloading){return;}
         if (userGlobal == null){return;}
-        System.out.println("setListAll: size messageListAll input: " + messageListAll.size());
-        System.out.println("setListAll: fragment: " + fragment);
-        System.out.println("setListAll: variable inbox: " + inbox);
-        System.out.println("setListAll: variable sent: " + sent);
-        System.out.println("setListAll: variable drafts: " + drafts);
-        System.out.println("setListAll: variable archive: " + archive);
-        System.out.println("setListAll: variable spam: " + spam);
         if (sent == null && fragment.equals("Sent")){
             for (int i = 0; i < messageListAll.size(); i++) {
                 this.all.add(messageListAll.get(i));
@@ -109,13 +101,10 @@ public class EmailViewModel extends AndroidViewModel {
             }
             spam = fragment;
         }
-        System.out.println("setListAll: size all output: " + all.size());
     }
 
     public List<Message> getAll(boolean status){
-        System.out.println("getAll: Size of all Lists " + all.size());
         for (int i = 0; i < all.size(); i++) {
-            System.out.println("EmailModel all list " + all.get(i) + "\n Size: " + all.size());
         }
         if (status){
             List<Message> emptyAll;
@@ -126,7 +115,7 @@ public class EmailViewModel extends AndroidViewModel {
             archive = null;
             inbox = null;
             drafts = null;
-            System.out.println("Size cleared list:" + all.size());
+
             return emptyAll;
         }
         return all;

+ 0 - 1
app/src/main/java/com/noahvogt/snailmail/ui/gallery/GalleryFragment.java

@@ -68,7 +68,6 @@ public class GalleryFragment extends Fragment implements CustomAdapter.SelectedM
             adapter.getList(messages);
             /*gives list of messages to EmailViewModel */
             MainActivity.mEmailViewModel.setListAll(messages, "Sent", isDownloading);
-            System.out.println("Gallery started");
         });
 
         return root;

+ 0 - 2
app/src/main/java/com/noahvogt/snailmail/ui/home/HomeFragment.java

@@ -56,9 +56,7 @@ public class HomeFragment extends Fragment implements CustomAdapter.SelectedMess
             /*get List of Message to show them onClick */
             adapter.getList(messages);
             /*gives list of messages to EmailViewModel */
-            System.out.println("HomeFragment List: "+messages);
             MainActivity.mEmailViewModel.setListAll(messages, "Inbox", isDownloading);
-            //mEmailViewModel.getAllMessages();
         });
 
 

+ 5 - 14
app/src/main/java/com/noahvogt/snailmail/ui/show/MessageShowFragment.java

@@ -56,11 +56,9 @@ public class MessageShowFragment extends DialogFragment implements PopupMenu.OnM
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        // set and inflate layout
+        /* set and inflate layout */
         View view = inflater.inflate(R.layout.message_show_fragment, container, false);
 
-        // init vars
-
         MessageShowViewModel messageShowViewModel =
                 new ViewModelProvider(this).get(MessageShowViewModel.class);
         View root = inflater.inflate(R.layout.message_show_fragment, container, false);
@@ -95,8 +93,6 @@ public class MessageShowFragment extends DialogFragment implements PopupMenu.OnM
 
 
         // TODO: add cc + bcc functionality
-
-        // button listeners
         showBccButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -129,10 +125,6 @@ public class MessageShowFragment extends DialogFragment implements PopupMenu.OnM
         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();
             }
         });
 
@@ -144,20 +136,19 @@ public class MessageShowFragment extends DialogFragment implements PopupMenu.OnM
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.create_message_delete:
-                Toast.makeText(getActivity(), "item delete clicked", Toast.LENGTH_LONG).show();
-                //mEmailViewModel.deleteFolder("Inbox");
+                Toast.makeText(getActivity(), "Deleting message", Toast.LENGTH_LONG).show();
                 mEmailViewModel.deleteMessage(mCurrent);
                 return true;
             case R.id.create_message_spam:
-                Toast.makeText(getActivity(), "item spam clicked", Toast.LENGTH_LONG).show();
+                Toast.makeText(getActivity(), "Moving message to spam", Toast.LENGTH_LONG).show();
                 mEmailViewModel.updateFolder(mCurrent.getId(), "Spam");
                 return true;
             case R.id.create_message_move_archive:
-                Toast.makeText(getActivity(), "item archive clicked", Toast.LENGTH_LONG).show();
+                Toast.makeText(getActivity(), "Moving message to archive", Toast.LENGTH_LONG).show();
                 mEmailViewModel.updateFolder(mCurrent.getId(), "Archive");
 
 
-            default: // this case should never occur
+            default: /* this case should never occur */
                 return false;
         }
     }

+ 1 - 3
app/src/main/java/com/noahvogt/snailmail/workers/DownloadWorker.java

@@ -31,8 +31,6 @@ import static com.noahvogt.snailmail.MainActivity.mEmailViewModel;
 public class DownloadWorker extends Worker {
 
     //TODO: upload every data to server
-
-
     public DownloadWorker(
             @NonNull Context appContext,
             @NonNull WorkerParameters workerParameters){
@@ -90,7 +88,7 @@ public class DownloadWorker extends Worker {
                 for (int i = 0; i < folders.size(); i++) {
                     String folderName;
                     String folderNow = folders.get(i).toString();
-                    System.out.println("ALL Folders: " + folders);
+
 
                     if (folderNow.equals("Inbox") || folderNow.equals("INBOX") || folderNow.equals("inbox")){
                         folderName = "Inbox";

+ 3 - 3
app/src/main/res/layout/message_show_fragment.xml

@@ -29,7 +29,7 @@
                 android:layout_marginStart="0dp"
                 android:background="?attr/selectableItemBackgroundBorderless"
                 android:padding="8dp"
-                android:src="@mipmap/ic_close_purple" />
+                android:src="@drawable/ic_baseline_close_24" />
 
             <ImageButton
                 android:id="@+id/show_message_dots_button"
@@ -40,7 +40,7 @@
                 android:layout_marginLeft="320dp"
                 android:background="?attr/selectableItemBackgroundBorderless"
                 android:padding="8dp"
-                android:src="@mipmap/ic_more_vert_dots_purple" />
+                android:src="@drawable/ic_round_pending_24" />
 
             <ImageButton
                 android:id="@+id/show_message_attach_button"
@@ -54,7 +54,7 @@
                 android:layout_toRightOf="@id/show_message_dots_button"
                 android:background="?attr/selectableItemBackgroundBorderless"
                 android:padding="8dp"
-                android:src="@mipmap/ic_attach_purple" />
+                android:src="@drawable/ic_baseline_attachment_24" />
 
 
         </RelativeLayout>

+ 5 - 7
app/src/main/res/xml/settings.xml

@@ -2,14 +2,12 @@
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <SwitchPreferenceCompat
-        android:key="@string/key_notification"
-        android:title="@string/enable_message_notification"/>
-
-
     <PreferenceCategory android:title="General">
 
-    <ListPreference
+        <SwitchPreferenceCompat
+            android:key="@string/key_notification"
+            android:title="@string/enable_message_notification"/>
+    <!--ListPreference
         android:defaultValue="3"
         android:dialogTitle="@string/remind_to_take_a_break"
         android:entries="@array/pref_remind_me_to_take_a_break"
@@ -57,7 +55,7 @@
         <SwitchPreference
             android:defaultValue="false"
             android:key="@string/prefs_enable_stats"
-            android:title="@string/enable_stats" />
+            android:title="@string/enable_stats" / -->
 
     </PreferenceCategory>