Compare commits
11 Commits
0.5
...
f539bc3184
| Author | SHA1 | Date | |
|---|---|---|---|
| f539bc3184 | |||
| 6eef26e116 | |||
| 719224003e | |||
| 7cce6f1280 | |||
| fe99d0a377 | |||
| 8dbd025c36 | |||
| c240223e98 | |||
| 1c68db62b1 | |||
| 6dbcb548b5 | |||
| 066e3db80e | |||
| 50be09f6b4 |
Generated
-1
@@ -8,7 +8,6 @@
|
||||
<option name="disableWrapperSourceDistributionNotification" value="true" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="11" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoreAnonymousInnerClasses" value="false" />
|
||||
<option name="superClassString" value="java.awt.Component" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
+3
-3
@@ -10,8 +10,8 @@ android {
|
||||
applicationId "de.joel.zoomhelper"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 13
|
||||
versionName '0.4.9'
|
||||
versionCode 14
|
||||
versionName '0.5.1 beta'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -39,7 +39,7 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.lifecycle:lifecycle-process:2.2.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class APKDownloader {
|
||||
public void downloadAPK(Context context, String fileName, Uri uri) {
|
||||
Activity act = (Activity)context;
|
||||
File destination = new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), fileName);
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||
if (!context.getPackageManager().canRequestPackageInstalls()) {
|
||||
Toast.makeText(context, R.string.PleaseAllowUnknownSources, Toast.LENGTH_LONG).show();
|
||||
act.startActivityForResult(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:de.joel.zoomhelper")), 101);
|
||||
Timer timer = new Timer(true);
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (context.getPackageManager().canRequestPackageInstalls()) {
|
||||
act.finishActivity(101);
|
||||
downloadAPK(context, fileName, uri);
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
}, 0, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Delete update file if exists
|
||||
final Uri localUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", destination);
|
||||
if (destination.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
destination.delete();
|
||||
}
|
||||
|
||||
//Download Script
|
||||
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
DownloadManager.Request request = new DownloadManager.Request(uri);
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
Log.d("Desturi", localUri.getPath());
|
||||
request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
final long downloadID = downloadManager.enqueue(request);
|
||||
|
||||
BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
//Fetching the download id received with the broadcast
|
||||
long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
|
||||
//Checking if the received broadcast is for our enqueued download by matching download id
|
||||
if (downloadID == id) {
|
||||
Intent install = new Intent(Intent.ACTION_VIEW);
|
||||
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
install.setDataAndType(localUri,
|
||||
downloadManager.getMimeTypeForDownloadedFile(downloadID));
|
||||
context.startActivity(install);
|
||||
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
context.registerReceiver(onDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Attendee implements Serializable {
|
||||
private static final long serialVersionUID = 6196688086302483907L;
|
||||
public String name;
|
||||
public String num;
|
||||
|
||||
public Attendee(String name, String num) {
|
||||
this.name = name;
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoCompleteTextView {
|
||||
|
||||
public InstantAutoComplete(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enoughToFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,11 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
@@ -27,7 +16,6 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
@@ -37,71 +25,55 @@ 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.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
||||
|
||||
|
||||
class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoCompleteTextView {
|
||||
|
||||
public InstantAutoComplete(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enoughToFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public boolean testing;
|
||||
|
||||
private final MeetingsController meetingsController = new MeetingsController(this);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Intent myIntent = getIntent(); // gets the previously created intent
|
||||
String action = myIntent.getAction();
|
||||
String type = myIntent.getType();
|
||||
|
||||
|
||||
String meetingName = myIntent.getStringExtra("meetingName");
|
||||
boolean joinImmediately = myIntent.getBooleanExtra("joinImmediately", false);
|
||||
testing = myIntent.getBooleanExtra("testing", false);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//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);
|
||||
//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);
|
||||
@@ -113,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);
|
||||
@@ -137,64 +109,45 @@ public class MainActivity extends AppCompatActivity {
|
||||
dialog.setTitle(R.string.hint);
|
||||
AlertDialog alertDialog = dialog.create();
|
||||
alertDialog.show();
|
||||
setLastMeeting(-1);
|
||||
saveMeetingList(new ArrayList<>());
|
||||
meetingsController.setLastMeeting(-1);
|
||||
meetingsController.saveMeetingList(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
watchSaveIcon();
|
||||
watchAttIcon();
|
||||
watchDeleteIcon();
|
||||
watchNewIcon();
|
||||
watchShareIcon();
|
||||
watchShortcutIcon();
|
||||
|
||||
//handle meeting invitation text sent to ZoomHelper
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
handleSendText(myIntent); // Handle text being sent
|
||||
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");
|
||||
appUpdater.setButtonUpdateClickListener((dialog, which) -> downloadAPK());
|
||||
APKDownloader apkDownloader = new APKDownloader();
|
||||
appUpdater.setButtonUpdateClickListener((dialog, which) -> apkDownloader.downloadAPK(this, "ZoomHelper.apk", Uri.parse("https://baldaufwd.de/ZoomHelper/ZoomHelper.apk")));
|
||||
appUpdater.start();
|
||||
}
|
||||
}
|
||||
|
||||
@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 watchImportIcon() {
|
||||
ImageView ImportIcon = findViewById(R.id.imageImport);
|
||||
ImportIcon.setOnClickListener(v -> importFromClipboard());
|
||||
}
|
||||
|
||||
void importFromClipboard() {
|
||||
Log.d("import", "ImportFromClipboard");
|
||||
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
|
||||
Log.d("clipboardManager", clipboard.toString());
|
||||
if (clipboard.hasPrimaryClip() && clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
|
||||
String text = clipboard.getPrimaryClip().getItemAt(0).getText().toString();
|
||||
Log.d("text", text);
|
||||
handleSendText(text);
|
||||
}
|
||||
} */
|
||||
|
||||
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);
|
||||
@@ -211,77 +164,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void downloadAPK() {
|
||||
String fileName = "ZoomHelper.apk";
|
||||
File destination = new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), fileName);
|
||||
|
||||
/*
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// this will request for permission when user has not granted permission for the app
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||
downloadAPK();
|
||||
} else {*/
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||
if (!getPackageManager().canRequestPackageInstalls()) {
|
||||
Toast.makeText(this, R.string.PleaseAllowUnknownSources, Toast.LENGTH_LONG).show();
|
||||
startActivityForResult(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:de.joel.zoomhelper")), 101);
|
||||
Timer timer = new Timer(true);
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getPackageManager().canRequestPackageInstalls()) {
|
||||
finishActivity(101);
|
||||
downloadAPK();
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
}, 0, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Delete update file if exists
|
||||
final Uri localUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", destination);
|
||||
if (destination.exists())
|
||||
//file.delete() - test this, I think sometimes it doesnt work
|
||||
destination.delete();
|
||||
|
||||
//Download Script
|
||||
DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
Uri uri = Uri.parse("https://baldaufwd.de/ZoomHelper/ZoomHelper.apk");
|
||||
DownloadManager.Request request = new DownloadManager.Request(uri);
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
Log.d("Desturi", localUri.getPath());
|
||||
request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
final long downloadID = downloadManager.enqueue(request);
|
||||
|
||||
BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
//Fetching the download id received with the broadcast
|
||||
long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
|
||||
//Checking if the received broadcast is for our enqueued download by matching download id
|
||||
if (downloadID == id) {
|
||||
Intent install = new Intent(Intent.ACTION_VIEW);
|
||||
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
install.setDataAndType(localUri,
|
||||
downloadManager.getMimeTypeForDownloadedFile(downloadID));
|
||||
startActivity(install);
|
||||
|
||||
unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
registerReceiver(onDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||
}
|
||||
//}
|
||||
|
||||
private void handleSendText(Intent intent) {
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
handleSendText(sharedText);
|
||||
@@ -299,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);
|
||||
@@ -316,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;
|
||||
@@ -326,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();
|
||||
@@ -345,43 +225,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
builder.setTitle(R.string.app_name);
|
||||
|
||||
if (meetingID.equals("")) {
|
||||
builder.setMessage(R.string.importError);
|
||||
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(getString(R.string.wantToimportMeeting) + "\n" + mtgToImport.info());
|
||||
|
||||
builder.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
importMeetingToUI(mtgToImport);
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.no, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -395,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();
|
||||
@@ -413,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)
|
||||
@@ -440,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);
|
||||
@@ -456,66 +293,7 @@ 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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fillBlank() {
|
||||
public void fillBlank() {
|
||||
EditText editMeetingName = findViewById(R.id.TextMeetingName);
|
||||
EditText editID = findViewById(R.id.textBoxID);
|
||||
EditText editPW = findViewById(R.id.editTextTextPassword2);
|
||||
@@ -530,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);
|
||||
}
|
||||
@@ -555,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++) {
|
||||
@@ -563,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);
|
||||
@@ -571,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()];
|
||||
@@ -589,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);
|
||||
@@ -631,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() {
|
||||
@@ -792,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) {
|
||||
@@ -829,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);
|
||||
@@ -838,69 +451,4 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
importMeeting(currMeetingUI);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Attendee implements Serializable {
|
||||
public String name;
|
||||
public String num;
|
||||
|
||||
public Attendee(String name, String num) {
|
||||
this.name = name;
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
|
||||
class Meeting implements Serializable {
|
||||
public String meetingName;
|
||||
public String meetingID;
|
||||
public String meetingPWD;
|
||||
public ArrayList<Attendee> attendees;
|
||||
public int lastAtt;
|
||||
|
||||
public Meeting(String meetingName, String meetingID, String meetingPWD, String nameAttendee, String numAttendee) {
|
||||
this.meetingName = meetingName;
|
||||
this.meetingID = meetingID;
|
||||
this.meetingPWD = meetingPWD;
|
||||
this.attendees = new ArrayList<>();
|
||||
Attendee attendee = new Attendee(nameAttendee, numAttendee);
|
||||
this.attendees.add(attendee);
|
||||
this.lastAtt = 0;
|
||||
}
|
||||
|
||||
public void addAttendee(String name, String num) {
|
||||
Attendee attendee = new Attendee(name, num);
|
||||
this.attendees.add(attendee);
|
||||
this.lastAtt = attendees.size() - 1;
|
||||
}
|
||||
|
||||
public int searchAttendee(String name) {
|
||||
int found = -1;
|
||||
for (int i = 0; i < this.attendees.size(); i++) {
|
||||
if (this.attendees.get(i).name.equals(name)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public void updateAttendee(String name, String num) {
|
||||
|
||||
int found = searchAttendee(name);
|
||||
|
||||
if (found == -1) {
|
||||
addAttendee(name, num);
|
||||
} else {
|
||||
this.attendees.get(found).num = num;
|
||||
this.lastAtt = found;
|
||||
}
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return "Meeting Name: " + this.meetingName + "\n" +
|
||||
"Meeting-ID: " + this.meetingID + "\n" +
|
||||
"Kenncode: " + this.meetingPWD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Meeting implements Serializable {
|
||||
private static final long serialVersionUID = 2606722401897866931L;
|
||||
public String meetingName;
|
||||
public String meetingID;
|
||||
public String meetingPWD;
|
||||
public ArrayList<Attendee> attendees;
|
||||
public int lastAtt;
|
||||
|
||||
public Meeting(String meetingName, String meetingID, String meetingPWD, String nameAttendee, String numAttendee) {
|
||||
this.meetingName = meetingName;
|
||||
this.meetingID = meetingID;
|
||||
this.meetingPWD = meetingPWD;
|
||||
this.attendees = new ArrayList<>();
|
||||
Attendee attendee = new Attendee(nameAttendee, numAttendee);
|
||||
this.attendees.add(attendee);
|
||||
this.lastAtt = 0;
|
||||
}
|
||||
|
||||
public void addAttendee(String name, String num) {
|
||||
Attendee attendee = new Attendee(name, num);
|
||||
this.attendees.add(attendee);
|
||||
this.lastAtt = attendees.size() - 1;
|
||||
}
|
||||
|
||||
public int searchAttendee(String name) {
|
||||
int found = -1;
|
||||
for (int i = 0; i < this.attendees.size(); i++) {
|
||||
if (this.attendees.get(i).name.equals(name)) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public void updateAttendee(String name, String num) {
|
||||
|
||||
int found = searchAttendee(name);
|
||||
|
||||
if (found == -1) {
|
||||
addAttendee(name, num);
|
||||
} else {
|
||||
this.attendees.get(found).num = num;
|
||||
this.lastAtt = found;
|
||||
}
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return "Meeting Name: " + this.meetingName + "\n" +
|
||||
"Meeting-ID: " + this.meetingID + "\n" +
|
||||
"Kenncode: " + this.meetingPWD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
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;
|
||||
|
||||
public class MeetingsController {
|
||||
private final Context context;
|
||||
private final Activity activity;
|
||||
|
||||
public MeetingsController(Context context) {
|
||||
this.context = context;
|
||||
this.activity = (Activity) context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 = activity.getPreferences(Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor prefsEditor = mPrefs.edit();
|
||||
prefsEditor.putString("Meetings", meetingsToString(meetingList));
|
||||
prefsEditor.commit();
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void setLastMeeting(int id) {
|
||||
SharedPreferences mPrefs = activity.getPreferences(Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor prefsEditor = mPrefs.edit();
|
||||
prefsEditor.putInt("LastMeeting", id);
|
||||
prefsEditor.commit();
|
||||
}
|
||||
|
||||
public int getLastMeeting() {
|
||||
SharedPreferences mPrefs = activity.getPreferences(Context.MODE_PRIVATE);
|
||||
return mPrefs.getInt("LastMeeting", -1);
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Meeting> getMeetings() {
|
||||
SharedPreferences mPrefs = activity.getPreferences(Context.MODE_PRIVATE);
|
||||
String value = mPrefs.getString("Meetings", "");
|
||||
ArrayList<Meeting> meetingList;
|
||||
if (value.equals("")) {
|
||||
meetingList = new ArrayList<>();
|
||||
} else {
|
||||
meetingList = stringToMeetings(value);
|
||||
}
|
||||
return meetingList;
|
||||
}
|
||||
|
||||
public void removeMeeting(int meeting) {
|
||||
MainActivity act = (MainActivity)context;
|
||||
ArrayList<Meeting> meetings = getMeetings();
|
||||
if (meetings.size() > 0 && meeting != -1) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
builder.setTitle(R.string.app_name);
|
||||
builder.setMessage(context.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) {
|
||||
act.fillDropdownMeetingName();
|
||||
if (getLastMeeting() > meetings.size() - 1) {
|
||||
setLastMeeting(meetings.size() - 1);
|
||||
act.fillMeeting(getLastMeeting());
|
||||
}
|
||||
} else if (meetings.size() == 1) {
|
||||
setLastMeeting(0);
|
||||
act.fillDropdownMeetingName();
|
||||
act.fillMeeting(getLastMeeting());
|
||||
} else {
|
||||
setLastMeeting(-1);
|
||||
act.fillDropdownMeetingName();
|
||||
act.fillBlank();
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss());
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ZoomLink {
|
||||
private final Meeting meeting;
|
||||
private final Context context;
|
||||
|
||||
public ZoomLink(Context context, Meeting meeting) {
|
||||
this.meeting = meeting;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String buildZoomURL() {
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme("zoomus")
|
||||
.authority("zoom.us")
|
||||
.appendPath("join")
|
||||
.appendQueryParameter("confno", this.meeting.meetingID.replace(" ", ""))
|
||||
.appendQueryParameter("pwd", this.meeting.meetingPWD);
|
||||
|
||||
if (!Objects.equals(this.meeting.attendees.get(this.meeting.lastAtt).num, "")) {
|
||||
builder.appendQueryParameter("uname", this.meeting.attendees.get(this.meeting.lastAtt).name + " (" + this.meeting.attendees.get(this.meeting.lastAtt).num + ")");
|
||||
} else
|
||||
builder.appendQueryParameter("uname", this.meeting.attendees.get(this.meeting.lastAtt).name);
|
||||
return builder.build().toString();
|
||||
}
|
||||
|
||||
public void launch() {
|
||||
String url = buildZoomURL();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
if (intent.resolveActivity(context.getPackageManager()) != null) {
|
||||
context.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();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
<string name="alwaysAsk">Dialog immer anzeigen</string>
|
||||
<string name="wantToimportMeeting">Möchtest du das folgende Meeting importieren?</string>
|
||||
<string name="importError">"Dieser Text entspricht keinem für ZoomHelper bekannten Meetingeinladungs-Muster "</string>
|
||||
<string name="ok">ok</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="meetingAlreadyExists">Meeting unter diesem Namen existiert schon. Bitte umbenennen, ansonsten wird es beim Speichern überschrieben</string>
|
||||
<string name="override">überschreiben</string>
|
||||
<string name="rename">umbenennen</string>
|
||||
@@ -39,5 +39,7 @@
|
||||
<string name="cantCreateShortcut">Du musst das Meeting zunächst speichern, bevor du eine Verknüpfung dazu erstellen kannst</string>
|
||||
<string name="saveMeeting">Meeting speichern</string>
|
||||
<string name="cancel">abbrechen</string>
|
||||
<string name="meetingSaved">Meeting gespeichert</string>
|
||||
<string name="meetingWithoutID">Meeting kann nicht ohne ID gespeichert werden!</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user