Bladeren bron

added more icons + (PopupMenu) + features to createMessage + gitignore update + general

Noah Vogt 4 jaren geleden
bovenliggende
commit
6bc4fc3474

+ 1 - 0
.gitignore

@@ -14,3 +14,4 @@
 .externalNativeBuild
 .cxx
 local.properties
+app/release/

+ 17 - 30
app/src/main/java/com/noahvogt/miniprojekt/MainActivity.java

@@ -23,20 +23,13 @@ import com.google.android.material.snackbar.Snackbar;
 
 import static com.noahvogt.miniprojekt.R.id.drawer_layout;
 
-// regex utils for email string validation
-
 public class MainActivity extends AppCompatActivity implements View.OnClickListener {
 
     private AppBarConfiguration mAppBarConfiguration;
 
-    private AlertDialog.Builder dialogBuilder;
     private AlertDialog dialog;
 
     private EditText newemail_name, newemail_email, newemail_password; // may not be private
-    private Button newemail_save_button, newemail_cancel_button; // may not be private
-    private Button add_email_button;
-
-    private ImageButton message_create_button;
 
     // empty descriptor
     public MainActivity() {
@@ -48,7 +41,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
         setContentView(R.layout.activity_main);
 
         // define button listeners
-        add_email_button = (Button) findViewById(R.id.addEmailButton);
+
+        Button add_email_button = (Button) findViewById(R.id.addEmailButton);
         add_email_button.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -56,16 +50,18 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
             }
         });
 
-        Toolbar toolbar = findViewById(R.id.toolbar);
-        setSupportActionBar(toolbar);
-        /*FloatingActionButton fab = findViewById(R.id.fab);
-        fab.setOnClickListener(new View.OnClickListener() {
+        ImageButton message_create_button = (ImageButton) findViewById(R.id.messageButton);
+        message_create_button.setOnClickListener(new View.OnClickListener() {
             @Override
-            public void onClick(View view) {
-                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
-                        .setAction("Action", null).show();
+            public void onClick(View v) {
+                DialogFragment dialog = messageCreateFragment.newInstance();
+                dialog.show(getSupportFragmentManager(), "tag");
             }
-        });*/
+        });
+
+        Toolbar toolbar = findViewById(R.id.toolbar);
+        setSupportActionBar(toolbar);
+
         DrawerLayout drawer = findViewById(drawer_layout);
         NavigationView navigationView = findViewById(R.id.nav_view);
         // Passing each menu ID as a set of Ids because each
@@ -77,22 +73,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
         NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
         NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
         NavigationUI.setupWithNavController(navigationView, navController);
-
-        message_create_button = (ImageButton) 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");
-            }
-        });
-
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // Inflate the menu; this adds items to the action bar if it is present.
-        getMenuInflater().inflate(R.menu.main, menu);
+        getMenuInflater().inflate(R.menu.create_message_options_menu, menu);
         return true;
     }
 
@@ -109,7 +95,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
 
     public void createNewEmailDialog(){
         // define View window
-        dialogBuilder = new AlertDialog.Builder(this);
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
         final View emailPopupView = getLayoutInflater().inflate(R.layout.popup, null);
 
         // init text field variables
@@ -118,8 +104,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
         newemail_password = emailPopupView.findViewById(R.id.popup_material_password_asking_text);
 
         // init button variables
-        newemail_save_button = (Button) emailPopupView.findViewById(R.id.saveButton);
-        newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
+        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);

+ 51 - 10
app/src/main/java/com/noahvogt/miniprojekt/messageCreateFragment.java

@@ -2,18 +2,19 @@ package com.noahvogt.miniprojekt;
 
 import android.os.Bundle;
 import android.view.LayoutInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageButton;
-import android.widget.TextView;
+import android.widget.PopupMenu;
+import android.widget.Toast;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.fragment.app.DialogFragment;
 
-import com.noahvogt.miniprojekt.debuggingFeatures;
 
-public class messageCreateFragment extends DialogFragment {
+public class messageCreateFragment extends DialogFragment implements PopupMenu.OnMenuItemClickListener {
 
     static messageCreateFragment newInstance() {
         return new messageCreateFragment();
@@ -31,16 +32,39 @@ public class messageCreateFragment extends DialogFragment {
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.message_create_fragment, container, false);
-        ImageButton close = view.findViewById(R.id.create_message_close_button);
-        TextView action = view.findViewById(R.id.create_message_send_button);
+        ImageButton closeButton = view.findViewById(R.id.create_message_close_button);
+        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);
 
-        close.setOnClickListener(new View.OnClickListener() {
+        // TODO: add cc + bcc functionality
+
+        closeButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                // TODO: alert user when pressing this button in case input fields are not empty
                 dismiss();
             }
         });
-        action.setOnClickListener(new View.OnClickListener() {
+
+        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(messageCreateFragment.this::onMenuItemClick);
+                popupMenu.inflate(R.menu.create_message_options_menu);
+                popupMenu.show();
+            }
+        });
+
+        sendButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 // TODO: implement sending functionality
@@ -48,11 +72,28 @@ public class messageCreateFragment extends DialogFragment {
             }
         });
 
+
         return view;
     }
 
-    public interface Callback {
-        void onActionClick(String name);
+    // TODO: add useful functionality to the menu + consider not using Resource ID's in switch statement
+    @Override
+    public boolean onMenuItemClick(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.create_message_item_1:
+                Toast.makeText(getActivity(), "item 1 clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_item_2:
+                Toast.makeText(getActivity(), "item 2 clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_item_3:
+                Toast.makeText(getActivity(), "item 3 clicked", Toast.LENGTH_LONG).show();
+                return true;
+            case R.id.create_message_item_4:
+                Toast.makeText(getActivity(), "item 4 clicked", Toast.LENGTH_LONG).show();
+                return true;
+            default: // this case should never occur
+                return false;
+        }
     }
-
 }

+ 81 - 5
app/src/main/res/layout/message_create_fragment.xml

@@ -6,7 +6,7 @@
     android:layout_height="match_parent"
     android:id="@+id/messageFragment"
     android:orientation="vertical"
-    tools:context=".ui.messageCreateFragment">
+    tools:context=".messageCreateFragment">
 
     <androidx.cardview.widget.CardView
         android:id="@+id/cardView"
@@ -30,18 +30,55 @@
             android:src="@mipmap/ic_close_purple" />
 
         <TextView
+            android:id="@+id/create_message_text_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerVertical="true"
-            android:layout_marginLeft="8dp"
             android:layout_marginStart="8dp"
-            android:layout_toRightOf="@id/create_message_close_button"
+            android:layout_marginLeft="8dp"
             android:layout_toEndOf="@+id/create_message_close_button"
+            android:layout_toRightOf="@id/create_message_close_button"
             android:text="Create Message"
             android:textColor="@android:color/white"
             android:textSize="20sp" />
 
-        <TextView
+
+        <ImageButton
+            android:id="@+id/create_message_attach_button"
+            android:layout_width="56dp"
+            android:layout_height="match_parent"
+
+
+            android:layout_marginStart="0dp"
+            android:layout_marginLeft="0dp"
+            android:layout_marginEnd="40dp"
+            android:layout_marginRight="40dp"
+            android:layout_toStartOf="@+id/create_message_send_button"
+            android:layout_toLeftOf="@+id/create_message_send_button"
+            android:layout_toEndOf="@+id/create_message_text_text"
+            android:layout_toRightOf="@+id/create_message_text_text"
+            android:background="?attr/selectableItemBackgroundBorderless"
+            android:padding="8dp"
+            android:src="@mipmap/ic_attach_purple" />
+
+        <ImageButton
+        android:id="@+id/create_message_dots_button"
+        android:layout_width="56dp"
+        android:layout_height="match_parent"
+
+        android:layout_marginStart="50dp"
+        android:layout_marginLeft="50dp"
+        android:layout_marginEnd="-10dp"
+        android:layout_marginRight="-10dp"
+        android:layout_toStartOf="@+id/create_message_send_button"
+        android:layout_toLeftOf="@+id/create_message_send_button"
+        android:layout_toEndOf="@+id/create_message_text_text"
+        android:layout_toRightOf="@+id/create_message_text_text"
+        android:background="?attr/selectableItemBackgroundBorderless"
+        android:padding="8dp"
+        android:src="@mipmap/ic_more_vert_dots_purple" />
+
+        <ImageButton
             android:id="@+id/create_message_send_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
@@ -52,14 +89,22 @@
             android:layout_marginEnd="8dp"
             android:background="?attr/selectableItemBackground"
             android:padding="8dp"
-            android:text="SEND"
+            android:src="@mipmap/ic_send_purple"
             android:textColor="@android:color/white" />
 
     </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"
@@ -106,4 +151,35 @@
             android:hint="Subject" />
     </com.google.android.material.textfield.TextInputLayout>
 
+    <com.google.android.material.textfield.TextInputLayout
+        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+        android:id="@+id/create_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/create_message_sending_address_layout"
+        tools:layout_editor_absoluteX="1dp">
+
+        <com.google.android.material.textfield.TextInputEditText
+            android:id="@+id/create_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>
+
 </LinearLayout>

+ 13 - 0
app/src/main/res/menu/create_message_options_menu.xml

@@ -0,0 +1,13 @@
+<?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="Item 1"/>
+    <item android:id="@+id/create_message_item_2"
+        android:title="Item 2"/>
+    <item android:id="@+id/create_message_item_3"
+        android:title="Item 3"/>
+    <item android:id="@+id/create_message_item_4"
+        android:title="Item 4"/>
+
+</menu>

BIN
app/src/main/res/mipmap-hdpi/ic_attach_purple.png


BIN
app/src/main/res/mipmap-hdpi/ic_more_vert_dots_purple.png


BIN
app/src/main/res/mipmap-hdpi/ic_send_purple.png


BIN
app/src/main/res/mipmap-mdpi/ic_attach_purple.png


BIN
app/src/main/res/mipmap-mdpi/ic_more_vert_dots_purple.png


BIN
app/src/main/res/mipmap-mdpi/ic_send_purple.png


BIN
app/src/main/res/mipmap-xhdpi/ic_attach_purple.png


BIN
app/src/main/res/mipmap-xhdpi/ic_more_vert_dots_purple.png


BIN
app/src/main/res/mipmap-xhdpi/ic_send_purple.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_attach_purple.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_more_vert_dots_purple.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_send_purple.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_attach_purple.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_more_vert_dots_purple.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_send_purple.png