diff --git a/app/build.gradle b/app/build.gradle index c12874f..6828c3f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { minSdkVersion 21 targetSdkVersion 30 versionCode 14 - versionName '0.5' + versionName '0.5.1 beta' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/de/joel/zoomhelper/APKDownloader.java b/app/src/main/java/de/joel/zoomhelper/APKDownloader.java new file mode 100644 index 0000000..e64b656 --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/APKDownloader.java @@ -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)); + } +} diff --git a/app/src/main/java/de/joel/zoomhelper/Attendee.java b/app/src/main/java/de/joel/zoomhelper/Attendee.java new file mode 100644 index 0000000..f0a504f --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/Attendee.java @@ -0,0 +1,13 @@ +package de.joel.zoomhelper; + +import java.io.Serializable; + +public class Attendee implements Serializable { + public String name; + public String num; + + public Attendee(String name, String num) { + this.name = name; + this.num = num; + } +} \ No newline at end of file diff --git a/app/src/main/java/de/joel/zoomhelper/InstantAutoComplete.java b/app/src/main/java/de/joel/zoomhelper/InstantAutoComplete.java new file mode 100644 index 0000000..439d723 --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/InstantAutoComplete.java @@ -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; + } + +} \ No newline at end of file diff --git a/app/src/main/java/de/joel/zoomhelper/MainActivity.java b/app/src/main/java/de/joel/zoomhelper/MainActivity.java index d61d7fe..17afd9b 100644 --- a/app/src/main/java/de/joel/zoomhelper/MainActivity.java +++ b/app/src/main/java/de/joel/zoomhelper/MainActivity.java @@ -1,22 +1,13 @@ 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 +18,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; @@ -40,51 +30,25 @@ 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; - @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Intent myIntent = getIntent(); // gets the previously created intent String action = myIntent.getAction(); @@ -95,7 +59,7 @@ public class MainActivity extends AppCompatActivity { boolean joinImmediately = myIntent.getBooleanExtra("joinImmediately", false); testing = myIntent.getBooleanExtra("testing", false); - super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); final ScrollView scrollview = findViewById(R.id.scrollArea); @@ -127,7 +91,7 @@ public class MainActivity extends AppCompatActivity { //watchMeetingNameBox(); fillDropdownMeetingName(); - if (getLastMeeting() != -1) { + /*if (getLastMeeting() != -1) { try { fillMeeting(getLastMeeting()); scrollview.post(() -> scrollview.scrollTo(0, scrollview.getChildAt(0).getHeight())); @@ -140,7 +104,7 @@ public class MainActivity extends AppCompatActivity { setLastMeeting(-1); saveMeetingList(new ArrayList<>()); } - } + }*/ watchSaveIcon(); watchAttIcon(); watchDeleteIcon(); @@ -159,8 +123,9 @@ public class MainActivity extends AppCompatActivity { String url = buildZoomURL(currMeeting.meetingID, currMeeting.meetingPWD, currMeeting.attendees.get(currMeeting.lastAtt).name, currMeeting.attendees.get(currMeeting.lastAtt).num); launchZoomUrl(url); } else { - AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/update.xml"); - appUpdater.setButtonUpdateClickListener((dialog, which) -> downloadAPK()); + 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"))); appUpdater.start(); } } @@ -174,22 +139,6 @@ public class MainActivity extends AppCompatActivity { } - /* 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); @@ -211,77 +160,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); @@ -345,32 +223,6 @@ 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; } @@ -515,7 +367,7 @@ public class MainActivity extends AppCompatActivity { } - private void fillBlank() { + public void fillBlank() { EditText editMeetingName = findViewById(R.id.TextMeetingName); EditText editID = findViewById(R.id.textBoxID); EditText editPW = findViewById(R.id.editTextTextPassword2); @@ -839,68 +691,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 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; - } } \ No newline at end of file diff --git a/app/src/main/java/de/joel/zoomhelper/Meeting.java b/app/src/main/java/de/joel/zoomhelper/Meeting.java new file mode 100644 index 0000000..b513ace --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/Meeting.java @@ -0,0 +1,57 @@ +package de.joel.zoomhelper; + +import java.io.Serializable; +import java.util.ArrayList; + +public class Meeting implements Serializable { + public String meetingName; + public String meetingID; + public String meetingPWD; + public ArrayList 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; + } +} \ No newline at end of file diff --git a/app/src/main/java/de/joel/zoomhelper/MeetingsController.java b/app/src/main/java/de/joel/zoomhelper/MeetingsController.java new file mode 100644 index 0000000..a51b25f --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/MeetingsController.java @@ -0,0 +1,159 @@ +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 Context context; + + public MeetingsController(Context context) { + this.context = context; + } + + Activity activity = (Activity) context; + + public String meetingsToString(ArrayList 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 stringToMeetings(String string) { + byte[] bytes = Base64.decode(string, 0); + + ArrayList 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 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 getMeetings() { + SharedPreferences mPrefs = activity.getPreferences(Context.MODE_PRIVATE); + String value = mPrefs.getString("Meetings", ""); + ArrayList meetingList; + if (value.equals("")) { + meetingList = new ArrayList<>(); + } else { + meetingList = stringToMeetings(value); + } + return meetingList; + } + + private void removeMeeting(int meeting) { + MainActivity act = (MainActivity)context; + ArrayList 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(); + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/de/joel/zoomhelper/ZoomLink.java b/app/src/main/java/de/joel/zoomhelper/ZoomLink.java new file mode 100644 index 0000000..1675eda --- /dev/null +++ b/app/src/main/java/de/joel/zoomhelper/ZoomLink.java @@ -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(); + }*/ + } +}