|
@@ -2,7 +2,6 @@ package com.noahvogt.miniprojekt;
|
|
|
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
-
|
|
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
@@ -35,15 +34,27 @@ import java.util.ArrayList;
|
|
|
|
|
|
import com.google.android.material.navigation.NavigationView;
|
|
import com.google.android.material.navigation.NavigationView;
|
|
|
|
|
|
-
|
|
|
|
import androidx.navigation.NavController;
|
|
import androidx.navigation.NavController;
|
|
import androidx.navigation.Navigation;
|
|
import androidx.navigation.Navigation;
|
|
import androidx.navigation.ui.AppBarConfiguration;
|
|
import androidx.navigation.ui.AppBarConfiguration;
|
|
import androidx.navigation.ui.NavigationUI;
|
|
import androidx.navigation.ui.NavigationUI;
|
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
-
|
|
|
|
|
|
+import com.chaquo.python.PyObject;
|
|
|
|
+import com.chaquo.python.Python;
|
|
|
|
+import com.chaquo.python.android.AndroidPlatform;
|
|
import com.google.android.material.navigation.NavigationView;
|
|
import com.google.android.material.navigation.NavigationView;
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
+import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
|
|
|
|
+import com.noahvogt.miniprojekt.ui.home.Data;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import com.chaquo.python.android.PyApplication;
|
|
|
|
+
|
|
|
|
+import com.noahvogt.miniprojekt.mailFunctions;
|
|
|
|
|
|
import static com.noahvogt.miniprojekt.R.id.drawer_layout;
|
|
import static com.noahvogt.miniprojekt.R.id.drawer_layout;
|
|
|
|
|
|
@@ -51,27 +62,28 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
|
|
|
private AppBarConfiguration mAppBarConfiguration;
|
|
private AppBarConfiguration mAppBarConfiguration;
|
|
|
|
|
|
- //imported by simon 2.may from RecyclerView Programm, changed to 23.may Simon to ArrayList<Data>...
|
|
|
|
|
|
+ /* declare vars that should always be used / shown by default */
|
|
protected ArrayList<Data> data;
|
|
protected ArrayList<Data> data;
|
|
-
|
|
|
|
private AlertDialog dialog;
|
|
private AlertDialog dialog;
|
|
|
|
+ private EditText newemail_name, newemail_email, newemail_password; /* may not be private */
|
|
|
|
|
|
private EditText newemail_name, newemail_email, newemail_password; // may not be private
|
|
private EditText newemail_name, newemail_email, newemail_password; // may not be private
|
|
|
|
|
|
- // empty descriptor
|
|
|
|
|
|
+ /* empty descriptor */
|
|
public MainActivity() {
|
|
public MainActivity() {
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_main);
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // define button listeners
|
|
|
|
|
|
+ /*
|
|
|
|
+ if (! Python.isStarted()) {
|
|
|
|
+ Python.start(new AndroidPlatform(this));
|
|
|
|
+ }
|
|
|
|
+ define button listeners
|
|
|
|
+ */
|
|
|
|
|
|
Button add_email_button = (Button) findViewById(R.id.addEmailButton);
|
|
Button add_email_button = (Button) findViewById(R.id.addEmailButton);
|
|
add_email_button.setOnClickListener(new View.OnClickListener() {
|
|
add_email_button.setOnClickListener(new View.OnClickListener() {
|
|
@@ -90,13 +102,17 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /* invoke toolbar */
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
setSupportActionBar(toolbar);
|
|
setSupportActionBar(toolbar);
|
|
|
|
|
|
|
|
+ /* invoke drawer */
|
|
DrawerLayout drawer = findViewById(drawer_layout);
|
|
DrawerLayout drawer = findViewById(drawer_layout);
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
- // Passing each menu ID as a set of Ids because each
|
|
|
|
- // menu should be considered as top level destinations.
|
|
|
|
|
|
+ /*
|
|
|
|
+ Passing each menu ID as a set of Ids because each
|
|
|
|
+ menu should be considered as top level destinations.
|
|
|
|
+ */
|
|
mAppBarConfiguration = new AppBarConfiguration.Builder(
|
|
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)
|
|
.setDrawerLayout(drawer)
|
|
.setDrawerLayout(drawer)
|
|
@@ -105,14 +121,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
|
|
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
|
|
NavigationUI.setupWithNavController(navigationView, navController);
|
|
NavigationUI.setupWithNavController(navigationView, navController);
|
|
|
|
|
|
|
|
+ /* invoke recycleViewer */
|
|
|
|
+
|
|
//initDataset();
|
|
//initDataset();
|
|
- // Lookup the recyclerview in activity layou
|
|
|
|
|
|
+ /* Lookup the recyclerview in activity layout */
|
|
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
|
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
|
- // Initialize contacts
|
|
|
|
|
|
+ /* Initialize contacts */
|
|
data = Data.createContactsList(20);
|
|
data = Data.createContactsList(20);
|
|
- // Create adapter passing in the sample user data
|
|
|
|
|
|
+ /* Create adapter passing in the sample user data */
|
|
CustomAdapter adapter = new CustomAdapter(data);
|
|
CustomAdapter adapter = new CustomAdapter(data);
|
|
- // Attach the adapter to the recyclerview to populate items
|
|
|
|
|
|
+ /* Attach the adapter to the recyclerview to populate items */
|
|
recyclerView.setAdapter(adapter);
|
|
recyclerView.setAdapter(adapter);
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
|
|
|
|
@@ -131,7 +149,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
- // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
|
|
|
+ /* Inflate the menu; this adds items to the action bar if it is present. */
|
|
getMenuInflater().inflate(R.menu.create_message_options_menu, menu);
|
|
getMenuInflater().inflate(R.menu.create_message_options_menu, menu);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -144,35 +162,40 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- // better leave empty to avoid any listener disambiguity
|
|
|
|
|
|
+ /* better leave empty to avoid any listener disambiguity */
|
|
public void onClick(View view) {}
|
|
public void onClick(View view) {}
|
|
|
|
|
|
|
|
|
|
public void createNewEmailDialog(){
|
|
public void createNewEmailDialog(){
|
|
- // define View window
|
|
|
|
|
|
+ /* define View window */
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
|
final View emailPopupView = getLayoutInflater().inflate(R.layout.popup, null);
|
|
final View emailPopupView = getLayoutInflater().inflate(R.layout.popup, null);
|
|
|
|
|
|
- // init text field variables
|
|
|
|
|
|
+ /* init text field variables */
|
|
newemail_name = emailPopupView.findViewById(R.id.popup_material_name_asking_text);
|
|
newemail_name = emailPopupView.findViewById(R.id.popup_material_name_asking_text);
|
|
newemail_email = emailPopupView.findViewById(R.id.popup_material_email_asking_text);
|
|
newemail_email = emailPopupView.findViewById(R.id.popup_material_email_asking_text);
|
|
newemail_password = emailPopupView.findViewById(R.id.popup_material_password_asking_text);
|
|
newemail_password = emailPopupView.findViewById(R.id.popup_material_password_asking_text);
|
|
|
|
|
|
- // init button variables
|
|
|
|
|
|
+ /* init button variables */
|
|
Button newemail_save_button = (Button) emailPopupView.findViewById(R.id.saveButton);
|
|
Button newemail_save_button = (Button) emailPopupView.findViewById(R.id.saveButton);
|
|
- // may not be private
|
|
|
|
|
|
+ /* may not be private */
|
|
Button newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
|
|
Button newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
|
|
|
|
|
|
- // open View window
|
|
|
|
- dialogBuilder.setView(emailPopupView);
|
|
|
|
|
|
+
|
|
|
|
+ /* open View window */
|
|
|
|
+ dialogBuilder.setView(emailPopupView);
|
|
dialog = dialogBuilder.create();
|
|
dialog = dialogBuilder.create();
|
|
dialog.show();
|
|
dialog.show();
|
|
|
|
|
|
- // store user input
|
|
|
|
|
|
+ if (! Python.isStarted()) {
|
|
|
|
+ Python.start(new AndroidPlatform(this));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* store user input */
|
|
newemail_save_button.setOnClickListener(new View.OnClickListener() {
|
|
newemail_save_button.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
- // store user input (only needed for DEBUGGING)
|
|
|
|
|
|
+ /* store user input (only needed for DEBUGGING) */
|
|
String name = newemail_name.getText().toString();
|
|
String name = newemail_name.getText().toString();
|
|
String email = newemail_email.getText().toString();
|
|
String email = newemail_email.getText().toString();
|
|
String password = newemail_password.getText().toString();
|
|
String password = newemail_password.getText().toString();
|
|
@@ -181,36 +204,45 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
return;
|
|
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);
|
|
|
|
|
|
+ /* connect to mail server and print various debugging output */
|
|
|
|
+ if (mailFunctions.canConnect(name, email, password) == Boolean.TRUE) {
|
|
|
|
+ showToast("was able to connect");
|
|
|
|
+ List l = mailFunctions.listMailboxes(mailFunctions.getIMAPConnection(name, email, password));
|
|
|
|
+ for (int i = 0; i < l.size(); i++) {
|
|
|
|
+ showToast(l.get(i).toString());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ showToast("failed to connect");
|
|
|
|
+
|
|
|
|
+ /* 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");
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
newemail_cancel_button.setOnClickListener(new View.OnClickListener() {
|
|
newemail_cancel_button.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
- // define save button here
|
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // show debug output in specific view
|
|
|
|
|
|
+ /* show debug output in specific view */
|
|
private void showSnackbar(View View, String text) {
|
|
private void showSnackbar(View View, String text) {
|
|
Snackbar.make(View, text, Snackbar.LENGTH_LONG)
|
|
Snackbar.make(View, text, Snackbar.LENGTH_LONG)
|
|
.setAction("Action", null).show();
|
|
.setAction("Action", null).show();
|
|
}
|
|
}
|
|
|
|
|
|
- // like showSnackbar(), but global and uglier
|
|
|
|
|
|
+ /* like showSnackbar(), but global and uglier */
|
|
private void showToast(String text) {
|
|
private void showToast(String text) {
|
|
Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
|
|
Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
+}
|