|
|
|
@@ -4,10 +4,8 @@ import android.annotation.SuppressLint;
|
|
|
|
|
import android.content.ClipData;
|
|
|
|
|
import android.content.ClipboardManager;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Base64;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.AutoCompleteTextView;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
@@ -27,12 +25,6 @@ import com.github.javiersantos.appupdater.enums.UpdateFrom;
|
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.EOFException;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@@ -43,29 +35,45 @@ import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
public boolean testing;
|
|
|
|
|
private final MeetingsController meetingsController = new MeetingsController(this);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent myIntent = getIntent(); // gets the previously created intent
|
|
|
|
|
//get intent parameters
|
|
|
|
|
Intent myIntent = getIntent();
|
|
|
|
|
String action = myIntent.getAction();
|
|
|
|
|
String type = myIntent.getType();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String meetingName = myIntent.getStringExtra("meetingName");
|
|
|
|
|
boolean joinImmediately = myIntent.getBooleanExtra("joinImmediately", false);
|
|
|
|
|
testing = myIntent.getBooleanExtra("testing", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//boolean testing = myIntent.getBooleanExtra("testing", false);
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
|
|
//views
|
|
|
|
|
final ScrollView scrollview = findViewById(R.id.scrollArea);
|
|
|
|
|
final ImageView saveIcon = findViewById(R.id.imageSave);
|
|
|
|
|
final ImageView trashIcon = findViewById(R.id.imageTrash);
|
|
|
|
|
final ImageView AttIcon = findViewById(R.id.imageAttend);
|
|
|
|
|
final ImageView AddIcon = findViewById(R.id.imageAdd);
|
|
|
|
|
final EditText meetingID = findViewById(R.id.textBoxID);
|
|
|
|
|
final ImageView ShareIcon = findViewById(R.id.imageShare);
|
|
|
|
|
final ImageView ShortcutIcon = findViewById(R.id.imageCreateShortcut);
|
|
|
|
|
|
|
|
|
|
//add event listeners to views
|
|
|
|
|
saveIcon.setOnClickListener(v -> saveMeetingFromUI());
|
|
|
|
|
trashIcon.setOnClickListener(v -> meetingsController.removeMeeting(meetingsController.searchMeetingInList(meetingsController.getMeetings(), createCurrMeetingFromUI().meetingName)));
|
|
|
|
|
AttIcon.setOnClickListener(v -> btnJoin_onClick(null));
|
|
|
|
|
AddIcon.setOnClickListener(v -> {
|
|
|
|
|
fillBlank();
|
|
|
|
|
meetingID.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
|
|
|
|
ShortcutIcon.setOnClickListener(v -> showCreateShortcutUI());
|
|
|
|
|
|
|
|
|
|
int meetingIndex = searchMeetingInList(getMeetings(), meetingName);
|
|
|
|
|
//show alert if meeting from shortcut not found
|
|
|
|
|
int meetingIndex = meetingsController.searchMeetingInList(meetingsController.getMeetings(), meetingName);
|
|
|
|
|
if (meetingIndex == -1) {
|
|
|
|
|
if (meetingName != null) {
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
|
|
|
@@ -77,23 +85,23 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
joinImmediately = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (meetingIndex <= getMeetings().size() && meetingIndex != -1) {
|
|
|
|
|
setLastMeeting(meetingIndex);
|
|
|
|
|
//adjust ui for meeting from shortcut
|
|
|
|
|
if (meetingIndex <= meetingsController.getMeetings().size() && meetingIndex != -1) {
|
|
|
|
|
meetingsController.setLastMeeting(meetingIndex);
|
|
|
|
|
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
|
|
|
|
textMeetingName.setEnabled(false);
|
|
|
|
|
textMeetingName.setAdapter(null);
|
|
|
|
|
ImageView imageTrash = findViewById(R.id.imageTrash);
|
|
|
|
|
imageTrash.setVisibility(View.GONE);
|
|
|
|
|
trashIcon.setVisibility(View.GONE);
|
|
|
|
|
TextInputLayout layoutMeetingName = findViewById(R.id.layoutMeetingName);
|
|
|
|
|
layoutMeetingName.setEndIconMode(TextInputLayout.END_ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//watchMeetingNameBox();
|
|
|
|
|
fillDropdownMeetingName();
|
|
|
|
|
/*if (getLastMeeting() != -1) {
|
|
|
|
|
|
|
|
|
|
//fill ui with data from last selected meeting or show error if config version changed or index out of bounds
|
|
|
|
|
if (meetingsController.getLastMeeting() != -1) {
|
|
|
|
|
try {
|
|
|
|
|
fillMeeting(getLastMeeting());
|
|
|
|
|
fillMeeting(meetingsController.getLastMeeting());
|
|
|
|
|
scrollview.post(() -> scrollview.scrollTo(0, scrollview.getChildAt(0).getHeight()));
|
|
|
|
|
} catch (IndexOutOfBoundsException e) {
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
|
|
|
@@ -101,28 +109,24 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
dialog.setTitle(R.string.hint);
|
|
|
|
|
AlertDialog alertDialog = dialog.create();
|
|
|
|
|
alertDialog.show();
|
|
|
|
|
setLastMeeting(-1);
|
|
|
|
|
saveMeetingList(new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
watchSaveIcon();
|
|
|
|
|
watchAttIcon();
|
|
|
|
|
watchDeleteIcon();
|
|
|
|
|
watchNewIcon();
|
|
|
|
|
watchShareIcon();
|
|
|
|
|
watchShortcutIcon();
|
|
|
|
|
|
|
|
|
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
|
|
|
if ("text/plain".equals(type)) {
|
|
|
|
|
handleSendText(myIntent); // Handle text being sent
|
|
|
|
|
meetingsController.setLastMeeting(-1);
|
|
|
|
|
meetingsController.saveMeetingList(new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//handle meeting invitation text sent to ZoomHelper
|
|
|
|
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
|
|
|
if ("text/plain".equals(type)) {
|
|
|
|
|
handleSendText(myIntent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//join meeting immediately, otherwise enable app updater
|
|
|
|
|
if (joinImmediately) {
|
|
|
|
|
Meeting currMeeting = getMeetings().get(meetingIndex);
|
|
|
|
|
String url = buildZoomURL(currMeeting.meetingID, currMeeting.meetingPWD, currMeeting.attendees.get(currMeeting.lastAtt).name, currMeeting.attendees.get(currMeeting.lastAtt).num);
|
|
|
|
|
launchZoomUrl(url);
|
|
|
|
|
Meeting currMeeting = meetingsController.getMeetings().get(meetingIndex);
|
|
|
|
|
new ZoomLink(this, currMeeting).launch();
|
|
|
|
|
} else {
|
|
|
|
|
//TODO: updatetest.xml -> update.xml when finished testing
|
|
|
|
|
AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/updatetest.xml");
|
|
|
|
|
APKDownloader apkDownloader = new APKDownloader();
|
|
|
|
|
appUpdater.setButtonUpdateClickListener((dialog, which) -> apkDownloader.downloadAPK(this, "ZoomHelper.apk", Uri.parse("https://baldaufwd.de/ZoomHelper/ZoomHelper.apk")));
|
|
|
|
@@ -132,18 +136,18 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
|
|
//check for importable meeting invitation from clipboard when ZoomHelper gained focus
|
|
|
|
|
super.onWindowFocusChanged(hasFocus);
|
|
|
|
|
if (hasFocus) {
|
|
|
|
|
importFromClipboard();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void importFromClipboard() {
|
|
|
|
|
LinearLayout layoutBegin = findViewById(R.id.layoutBegin);
|
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
|
|
|
|
|
final LinearLayout layoutBegin = findViewById(R.id.layoutBegin);
|
|
|
|
|
final ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
|
|
|
|
|
|
|
|
|
|
Snackbar snackbar = Snackbar.make(layoutBegin,R.string.foundImportableMeetingClipboard,Snackbar.LENGTH_INDEFINITE).setDuration(7000);
|
|
|
|
|
Snackbar snackbar = Snackbar.make(layoutBegin, R.string.foundImportableMeetingClipboard, Snackbar.LENGTH_INDEFINITE).setDuration(7000);
|
|
|
|
|
snackbar.setAction(R.string.importMeeting, view -> {
|
|
|
|
|
String text = clipboard.getPrimaryClip().getItemAt(0).getText().toString();
|
|
|
|
|
handleSendText(text);
|
|
|
|
@@ -177,15 +181,15 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
if (sharedText != null) {
|
|
|
|
|
Matcher matcher = Pattern.compile("(?i)(?<=(Meeting-ID:)|(Meeting\\sID:)|(ID:)).+").matcher(sharedText);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
meetingID = matcher.group(0).trim();
|
|
|
|
|
meetingID = Objects.requireNonNull(matcher.group(0)).trim();
|
|
|
|
|
}
|
|
|
|
|
matcher = Pattern.compile("(?i)(?<=(Kenncode:)|(Passwort:)|(Passcode:)|(Password:)).+").matcher(sharedText);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
meetingPWD = matcher.group(0).trim();
|
|
|
|
|
meetingPWD = Objects.requireNonNull(matcher.group(0)).trim();
|
|
|
|
|
}
|
|
|
|
|
matcher = Pattern.compile("(?i)(?<=(Thema:)|(Meeting\\sName:)|(Topic:)).+").matcher(sharedText);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
meetingName = matcher.group(0).trim();
|
|
|
|
|
meetingName = Objects.requireNonNull(matcher.group(0)).trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
@@ -194,9 +198,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
if (meetingID.equals("")) {
|
|
|
|
|
builder.setMessage(R.string.importError);
|
|
|
|
|
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
});
|
|
|
|
|
builder.setPositiveButton(R.string.ok, (dialog, which) -> dialog.dismiss());
|
|
|
|
|
AlertDialog alert = builder.create();
|
|
|
|
|
if (!checkOnly) alert.show();
|
|
|
|
|
return false;
|
|
|
|
@@ -204,11 +206,11 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
Meeting mtgToImport = new Meeting(meetingName, meetingID, meetingPWD, "", "");
|
|
|
|
|
|
|
|
|
|
if (searchMeetingInList(getMeetings(), mtgToImport.meetingName) == -1 && !checkOnly) {
|
|
|
|
|
if (meetingsController.searchMeetingInList(meetingsController.getMeetings(), mtgToImport.meetingName) == -1 && !checkOnly) {
|
|
|
|
|
fillMeeting(mtgToImport);
|
|
|
|
|
} else {
|
|
|
|
|
builder.setPositiveButton(R.string.override, (dialog, which) -> {
|
|
|
|
|
int found = searchMeetingInList(getMeetings(), mtgToImport.meetingName);
|
|
|
|
|
int found = meetingsController.searchMeetingInList(meetingsController.getMeetings(), mtgToImport.meetingName);
|
|
|
|
|
importMeeting(mtgToImport, false);
|
|
|
|
|
fillMeeting(found);
|
|
|
|
|
dialog.dismiss();
|
|
|
|
@@ -227,13 +229,8 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watchShortcutIcon() {
|
|
|
|
|
ImageView ShortcutIcon = findViewById(R.id.imageCreateShortcut);
|
|
|
|
|
ShortcutIcon.setOnClickListener(v -> showCreateShortcutUI());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showCreateShortcutUI() {
|
|
|
|
|
int meeting = searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName);
|
|
|
|
|
int meeting = meetingsController.searchMeetingInList(meetingsController.getMeetings(), createCurrMeetingFromUI().meetingName);
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
|
@@ -247,11 +244,8 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
showCreateShortcutUI();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
builder.setNegativeButton(R.string.cancel, (dialog, which) -> {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
|
} else {
|
|
|
|
|
builder.setMessage(R.string.WantToJoinImmediately);
|
|
|
|
|
builder.setPositiveButton(R.string.joinImmediately, (dialog, which) -> {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
@@ -265,13 +259,10 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
AlertDialog alert = builder.create();
|
|
|
|
|
alert.show();
|
|
|
|
|
|
|
|
|
|
//createMeetingShortcut(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName), false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createMeetingShortcut(int meetingIndex, boolean joinImmediately) {
|
|
|
|
|
|
|
|
|
|
Meeting meeting = getMeetings().get(meetingIndex);
|
|
|
|
|
Meeting meeting = meetingsController.getMeetings().get(meetingIndex);
|
|
|
|
|
|
|
|
|
|
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
|
|
|
|
|
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, meeting.meetingName)
|
|
|
|
@@ -292,12 +283,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void watchShareIcon() {
|
|
|
|
|
ImageView ShareIcon = findViewById(R.id.imageShare);
|
|
|
|
|
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void shareMeeting(Meeting meeting) {
|
|
|
|
|
Intent sendIntent = new Intent();
|
|
|
|
|
sendIntent.setAction(Intent.ACTION_SEND);
|
|
|
|
@@ -308,65 +293,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
startActivity(shareIntent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watchNewIcon() {
|
|
|
|
|
ImageView AddIcon = findViewById(R.id.imageAdd);
|
|
|
|
|
EditText meetingID = findViewById(R.id.textBoxID);
|
|
|
|
|
AddIcon.setOnClickListener(v -> {
|
|
|
|
|
fillBlank();
|
|
|
|
|
meetingID.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watchAttIcon() {
|
|
|
|
|
ImageView AttIcon = findViewById(R.id.imageAttend);
|
|
|
|
|
AttIcon.setOnClickListener(v -> btnJoin_onClick(null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watchDeleteIcon() {
|
|
|
|
|
ImageView trashIcon = findViewById(R.id.imageTrash);
|
|
|
|
|
trashIcon.setOnClickListener(v -> removeMeeting(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void removeMeeting(int meeting) {
|
|
|
|
|
ArrayList<Meeting> meetings = getMeetings();
|
|
|
|
|
if (meetings.size() > 0 && meeting != -1) {
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
|
|
builder.setTitle(R.string.app_name);
|
|
|
|
|
builder.setMessage(getString(R.string.suretoremove, meetings.get(meeting).meetingName));
|
|
|
|
|
|
|
|
|
|
builder.setPositiveButton(R.string.yes, (dialog, which) -> {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
meetings.remove(meeting);
|
|
|
|
|
saveMeetingList(meetings);
|
|
|
|
|
|
|
|
|
|
if (meetings.size() > 1) {
|
|
|
|
|
fillDropdownMeetingName();
|
|
|
|
|
if (getLastMeeting() > meetings.size() - 1) {
|
|
|
|
|
setLastMeeting(meetings.size() - 1);
|
|
|
|
|
fillMeeting(getLastMeeting());
|
|
|
|
|
}
|
|
|
|
|
} else if (meetings.size() == 1) {
|
|
|
|
|
setLastMeeting(0);
|
|
|
|
|
fillDropdownMeetingName();
|
|
|
|
|
fillMeeting(getLastMeeting());
|
|
|
|
|
} else {
|
|
|
|
|
setLastMeeting(-1);
|
|
|
|
|
fillDropdownMeetingName();
|
|
|
|
|
fillBlank();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss());
|
|
|
|
|
|
|
|
|
|
AlertDialog alert = builder.create();
|
|
|
|
|
alert.show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void fillBlank() {
|
|
|
|
|
EditText editMeetingName = findViewById(R.id.TextMeetingName);
|
|
|
|
|
EditText editID = findViewById(R.id.textBoxID);
|
|
|
|
@@ -382,24 +308,9 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
editAtt.setText("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void watchSaveIcon() {
|
|
|
|
|
ImageView saveIcon = findViewById(R.id.imageSave);
|
|
|
|
|
saveIcon.setOnClickListener(v -> saveMeetingFromUI());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void watchMeetingNameBox() {
|
|
|
|
|
EditText meetingNameBox = findViewById(R.id.TextMeetingName);
|
|
|
|
|
meetingNameBox.setOnFocusChangeListener((v, hasFocus) -> {
|
|
|
|
|
if (!hasFocus) {
|
|
|
|
|
fillWithSelectedMeeting();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fillWithSelectedMeeting() {
|
|
|
|
|
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
|
|
|
|
int search = searchMeetingInList(getMeetings(), textMeetingName.getText().toString());
|
|
|
|
|
int search = meetingsController.searchMeetingInList(meetingsController.getMeetings(), textMeetingName.getText().toString());
|
|
|
|
|
if (search != -1) {
|
|
|
|
|
fillMeeting(search);
|
|
|
|
|
}
|
|
|
|
@@ -407,7 +318,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
|
public void fillDropdownMeetingName() {
|
|
|
|
|
ArrayList<Meeting> meetings = getMeetings();
|
|
|
|
|
ArrayList<Meeting> meetings = meetingsController.getMeetings();
|
|
|
|
|
|
|
|
|
|
String[] meetingNames = new String[meetings.size()];
|
|
|
|
|
for (int i = 0; i < meetings.size(); i++) {
|
|
|
|
@@ -415,7 +326,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
|
|
|
|
//ImageView dropdown = findViewById(R.id.iconDropdownMeetingName);
|
|
|
|
|
AutoSuggestAdapter adapter = new AutoSuggestAdapter(this, android.R.layout.simple_dropdown_item_1line);
|
|
|
|
|
adapter.setData(Arrays.asList(meetingNames));
|
|
|
|
|
textMeetingName.setAdapter(adapter);
|
|
|
|
@@ -423,16 +333,11 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
textMeetingName.setOnTouchListener((paramView, paramMotionEvent) -> false);
|
|
|
|
|
|
|
|
|
|
textMeetingName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedMeeting());
|
|
|
|
|
|
|
|
|
|
/*dropdown.setOnClickListener(v -> {
|
|
|
|
|
textMeetingName.showDropDown();
|
|
|
|
|
adapter.getFilter().filter(null);
|
|
|
|
|
});*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
|
public void fillDropdownAttendeeName(int meetingIndex) {
|
|
|
|
|
Meeting meeting = getMeetings().get(meetingIndex);
|
|
|
|
|
Meeting meeting = meetingsController.getMeetings().get(meetingIndex);
|
|
|
|
|
ArrayList<Attendee> attendees = meeting.attendees;
|
|
|
|
|
|
|
|
|
|
String[] attNames = new String[attendees.size()];
|
|
|
|
@@ -441,29 +346,23 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoCompleteTextView textName = findViewById(R.id.textBoxName);
|
|
|
|
|
//ImageView dropdown = findViewById(R.id.iconDropdownAttName);
|
|
|
|
|
AutoSuggestAdapter adapter = new AutoSuggestAdapter(this, android.R.layout.simple_dropdown_item_1line);
|
|
|
|
|
|
|
|
|
|
adapter.setData(Arrays.asList(attNames));
|
|
|
|
|
textName.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
textName.setOnTouchListener((paramView, paramMotionEvent) -> false);
|
|
|
|
|
|
|
|
|
|
textName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedAtt(meetingIndex));
|
|
|
|
|
|
|
|
|
|
/*dropdown.setOnClickListener(v -> {
|
|
|
|
|
textName.showDropDown();
|
|
|
|
|
adapter.getFilter().filter(null);
|
|
|
|
|
});*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillWithSelectedAtt(int meetingIndex) {
|
|
|
|
|
AutoCompleteTextView textName = findViewById(R.id.textBoxName);
|
|
|
|
|
EditText editAtt = findViewById(R.id.editAtt);
|
|
|
|
|
int found = getMeetings().get(meetingIndex).searchAttendee(textName.getText().toString());
|
|
|
|
|
editAtt.setText(getMeetings().get(meetingIndex).attendees.get(found).num);
|
|
|
|
|
int found = meetingsController.getMeetings().get(meetingIndex).searchAttendee(textName.getText().toString());
|
|
|
|
|
editAtt.setText(meetingsController.getMeetings().get(meetingIndex).attendees.get(found).num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void fillMeeting(Meeting meeting) {
|
|
|
|
|
EditText editMeetingName = findViewById(R.id.TextMeetingName);
|
|
|
|
|
EditText editID = findViewById(R.id.textBoxID);
|
|
|
|
@@ -483,155 +382,18 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fillMeeting(int id) {
|
|
|
|
|
fillMeeting(getMeetings().get(id));
|
|
|
|
|
fillMeeting(meetingsController.getMeetings().get(id));
|
|
|
|
|
fillDropdownAttendeeName(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void launchZoomUrl(String url) {
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
|
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
if (testing) {
|
|
|
|
|
//For Debugging: Show URL in Alert
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
|
|
|
|
dialog.setMessage(url);
|
|
|
|
|
dialog.setTitle("Zoom URL (for testing)");
|
|
|
|
|
AlertDialog alertDialog = dialog.create();
|
|
|
|
|
alertDialog.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String buildZoomURL(String confno, String pwd, String name, String attendees) {
|
|
|
|
|
Uri.Builder builder = new Uri.Builder();
|
|
|
|
|
builder.scheme("zoomus")
|
|
|
|
|
.authority("zoom.us")
|
|
|
|
|
.appendPath("join")
|
|
|
|
|
.appendQueryParameter("confno", confno.replace(" ", ""))
|
|
|
|
|
.appendQueryParameter("pwd", pwd);
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(attendees, "")) {
|
|
|
|
|
builder.appendQueryParameter("uname", name + " (" + attendees + ")");
|
|
|
|
|
} else
|
|
|
|
|
builder.appendQueryParameter("uname", name);
|
|
|
|
|
return builder.build().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String meetingsToString(ArrayList<Meeting> listMeetings) {
|
|
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
|
|
ObjectOutputStream objOutputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
objOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
for (Object obj : listMeetings) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (objOutputStream == null) throw new AssertionError();
|
|
|
|
|
objOutputStream.writeObject(obj);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
objOutputStream.reset();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
if (objOutputStream == null) throw new AssertionError();
|
|
|
|
|
objOutputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Meeting> stringToMeetings(String string) {
|
|
|
|
|
byte[] bytes = Base64.decode(string, 0);
|
|
|
|
|
|
|
|
|
|
ArrayList<Meeting> listMeetings = new ArrayList<>();
|
|
|
|
|
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
|
|
|
|
|
ObjectInputStream obj = null;
|
|
|
|
|
try {
|
|
|
|
|
obj = new ObjectInputStream(bis);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
while (bis.available() != -1) {
|
|
|
|
|
//Read object from file
|
|
|
|
|
if (obj == null) throw new AssertionError();
|
|
|
|
|
Meeting meeting = (Meeting) obj.readObject();
|
|
|
|
|
listMeetings.add(meeting);
|
|
|
|
|
}
|
|
|
|
|
} catch (EOFException ex) {
|
|
|
|
|
//ex.printStackTrace();
|
|
|
|
|
} catch (IOException | ClassNotFoundException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return listMeetings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ApplySharedPref")
|
|
|
|
|
public void saveMeetingList(ArrayList<Meeting> meetingList) {
|
|
|
|
|
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
|
|
|
|
SharedPreferences.Editor prefsEditor = mPrefs.edit();
|
|
|
|
|
prefsEditor.putString("Meetings", meetingsToString(meetingList));
|
|
|
|
|
prefsEditor.commit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ApplySharedPref")
|
|
|
|
|
public void setLastMeeting(int id) {
|
|
|
|
|
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
|
|
|
|
SharedPreferences.Editor prefsEditor = mPrefs.edit();
|
|
|
|
|
prefsEditor.putInt("LastMeeting", id);
|
|
|
|
|
prefsEditor.commit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getLastMeeting() {
|
|
|
|
|
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
|
|
|
|
return mPrefs.getInt("LastMeeting", -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Meeting> getMeetings() {
|
|
|
|
|
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
|
|
|
|
String value = mPrefs.getString("Meetings", "");
|
|
|
|
|
ArrayList<Meeting> meetingList;
|
|
|
|
|
if (value.equals("")) {
|
|
|
|
|
meetingList = new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
meetingList = stringToMeetings(value);
|
|
|
|
|
}
|
|
|
|
|
return meetingList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int searchMeetingInList(ArrayList<Meeting> meetings, String name) {
|
|
|
|
|
int found = -1;
|
|
|
|
|
for (int i = 0; i < meetings.size(); i++) {
|
|
|
|
|
if (meetings.get(i).meetingName.equals(name)) {
|
|
|
|
|
found = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void btnSave_onClick(View view) {
|
|
|
|
|
saveMeetingFromUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void btnJoin_onClick(View view) {
|
|
|
|
|
saveMeetingFromUI();
|
|
|
|
|
Meeting currMeeting = createCurrMeetingFromUI();
|
|
|
|
|
String url = buildZoomURL(currMeeting.meetingID, currMeeting.meetingPWD, currMeeting.attendees.get(currMeeting.lastAtt).name, currMeeting.attendees.get(currMeeting.lastAtt).num);
|
|
|
|
|
launchZoomUrl(url);
|
|
|
|
|
new ZoomLink(this, currMeeting).launch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Meeting createCurrMeetingFromUI() {
|
|
|
|
@@ -644,31 +406,30 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
return new Meeting(editMeetingName.getText().toString(), editID.getText().toString(), editPW.getText().toString(), editName.getText().toString(), editAtt.getText().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void importMeeting(Meeting meeting, boolean updateAttendee) {
|
|
|
|
|
ArrayList<Meeting> listMeetings = getMeetings();
|
|
|
|
|
int foundCurr = searchMeetingInList(listMeetings, meeting.meetingName);
|
|
|
|
|
ArrayList<Meeting> listMeetings = meetingsController.getMeetings();
|
|
|
|
|
int foundCurr = meetingsController.searchMeetingInList(listMeetings, meeting.meetingName);
|
|
|
|
|
if (foundCurr == -1) {
|
|
|
|
|
listMeetings.add(meeting);
|
|
|
|
|
if (listMeetings.size() == 1) {
|
|
|
|
|
setLastMeeting(0);
|
|
|
|
|
meetingsController.setLastMeeting(0);
|
|
|
|
|
} else {
|
|
|
|
|
setLastMeeting(listMeetings.size() - 1);
|
|
|
|
|
meetingsController.setLastMeeting(listMeetings.size() - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Meeting currMeeting = getMeetings().get(foundCurr);
|
|
|
|
|
Meeting currMeeting = meetingsController.getMeetings().get(foundCurr);
|
|
|
|
|
currMeeting.meetingID = meeting.meetingID;
|
|
|
|
|
currMeeting.meetingPWD = meeting.meetingPWD;
|
|
|
|
|
if (updateAttendee)
|
|
|
|
|
currMeeting.updateAttendee(meeting.attendees.get(0).name, meeting.attendees.get(0).num);
|
|
|
|
|
listMeetings.set(foundCurr, currMeeting);
|
|
|
|
|
setLastMeeting(foundCurr);
|
|
|
|
|
meetingsController.setLastMeeting(foundCurr);
|
|
|
|
|
}
|
|
|
|
|
saveMeetingList(listMeetings);
|
|
|
|
|
meetingsController.saveMeetingList(listMeetings);
|
|
|
|
|
fillDropdownMeetingName();
|
|
|
|
|
fillDropdownAttendeeName(getLastMeeting());
|
|
|
|
|
Toast.makeText(getApplicationContext(), "Meeting gespeichert", Toast.LENGTH_SHORT).show();
|
|
|
|
|
fillDropdownAttendeeName(meetingsController.getLastMeeting());
|
|
|
|
|
Toast.makeText(getApplicationContext(), R.string.meetingSaved, Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void importMeeting(Meeting meeting) {
|
|
|
|
@@ -681,7 +442,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
if (currMeetingUI.meetingID.equals("")) {
|
|
|
|
|
EditText editID = findViewById(R.id.textBoxID);
|
|
|
|
|
editID.requestFocus();
|
|
|
|
|
editID.setError("Meeting kann nicht ohne ID gespeichert werden!");
|
|
|
|
|
editID.setError(getString(R.string.meetingWithoutID));
|
|
|
|
|
return;
|
|
|
|
|
} else if (currMeetingUI.meetingName.equals("")) {
|
|
|
|
|
EditText editMName = findViewById(R.id.TextMeetingName);
|
|
|
|
@@ -690,5 +451,4 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
importMeeting(currMeetingUI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|