|
@@ -1,7 +1,6 @@
|
|
|
package com.noahvogt.miniprojekt;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
-
|
|
|
import android.view.Menu;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
@@ -14,33 +13,23 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
-
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-
|
|
|
-import com.noahvogt.miniprojekt.ui.home.CustomAdapter;
|
|
|
-import com.noahvogt.miniprojekt.ui.home.Data;
|
|
|
-
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
-import androidx.recyclerview.widget.RecyclerView;
|
|
|
-import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-
|
|
|
-
|
|
|
-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 java.util.ArrayList;
|
|
|
+
|
|
|
+import com.chaquo.python.android.PyApplication;
|
|
|
|
|
|
import static com.noahvogt.miniprojekt.R.id.drawer_layout;
|
|
|
|
|
@@ -48,20 +37,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
|
|
|
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;
|
|
|
-
|
|
|
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
|
|
|
-
|
|
|
- // empty descriptor
|
|
|
- public MainActivity() {
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /* empty descriptor */
|
|
|
+ public MainActivity() {}
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -69,7 +51,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
super.onCreate(savedInstanceState);
|
|
|
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);
|
|
|
add_email_button.setOnClickListener(new View.OnClickListener() {
|
|
@@ -88,13 +75,17 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /* invoke toolbar */
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
|
|
+ /* invoke drawer */
|
|
|
DrawerLayout drawer = findViewById(drawer_layout);
|
|
|
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(
|
|
|
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow)
|
|
|
.setDrawerLayout(drawer)
|
|
@@ -103,14 +94,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
|
|
|
NavigationUI.setupWithNavController(navigationView, navController);
|
|
|
|
|
|
+ /* invoke recycleViewer */
|
|
|
+
|
|
|
//initDataset();
|
|
|
- // Lookup the recyclerview in activity layou
|
|
|
+ /* Lookup the recyclerview in activity layout */
|
|
|
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
|
|
- // Initialize contacts
|
|
|
+ /* Initialize contacts */
|
|
|
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);
|
|
|
- // Attach the adapter to the recyclerview to populate items
|
|
|
+ /* Attach the adapter to the recyclerview to populate items */
|
|
|
recyclerView.setAdapter(adapter);
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
|
}
|
|
@@ -119,7 +112,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
|
|
|
@Override
|
|
|
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);
|
|
|
return true;
|
|
|
}
|
|
@@ -132,35 +125,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 createNewEmailDialog(){
|
|
|
- // define View window
|
|
|
+ /* define View window */
|
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
|
|
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_email = emailPopupView.findViewById(R.id.popup_material_email_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);
|
|
|
- // may not be private
|
|
|
+ /* may not be private */
|
|
|
Button newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
|
|
|
|
|
|
- // open View window
|
|
|
- dialogBuilder.setView(emailPopupView);
|
|
|
+ if (! Python.isStarted()) {
|
|
|
+ Python.start(new AndroidPlatform(this));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* open View window */
|
|
|
+ dialogBuilder.setView(emailPopupView);
|
|
|
dialog = dialogBuilder.create();
|
|
|
dialog.show();
|
|
|
|
|
|
- // store user input
|
|
|
+ /* store user input */
|
|
|
newemail_save_button.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
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 email = newemail_email.getText().toString();
|
|
|
String password = newemail_password.getText().toString();
|
|
@@ -169,33 +167,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // show all strings the user gave, this will later be stored to a secure database and checked for validation
|
|
|
+ /* 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() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- // define save button here
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
- // show debug output in specific view
|
|
|
+ /* show debug output in specific view */
|
|
|
private void showSnackbar(View View, String text) {
|
|
|
Snackbar.make(View, text, Snackbar.LENGTH_LONG)
|
|
|
.setAction("Action", null).show();
|
|
|
}
|
|
|
|
|
|
- // like showSnackbar(), but global and uglier
|
|
|
+ /* like showSnackbar(), but global and uglier */
|
|
|
private void showToast(String text) {
|
|
|
Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
|
|
|
}
|