better creation and handling of shortcuts
This commit is contained in:
@@ -34,6 +34,7 @@ import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -42,6 +43,7 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
||||
public InstantAutoComplete(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
@@ -49,6 +51,7 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
||||
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
|
||||
super(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enoughToFilter() {
|
||||
return false;
|
||||
@@ -57,19 +60,45 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public boolean testing;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Intent myIntent = getIntent(); // gets the previously created intent
|
||||
int meetingIndex = myIntent.getIntExtra("meetingIndex", -1);
|
||||
String meetingName = myIntent.getStringExtra("meetingName");
|
||||
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);
|
||||
|
||||
int meetingIndex = searchMeetingInList(getMeetings(), meetingName);
|
||||
if (meetingIndex == -1) {
|
||||
if (meetingName != null) {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setMessage(R.string.shortcutLaunchFailedText);
|
||||
dialog.setTitle(R.string.hint);
|
||||
AlertDialog alertDialog = dialog.create();
|
||||
alertDialog.show();
|
||||
}
|
||||
joinImmediately = false;
|
||||
}
|
||||
|
||||
if (meetingIndex <= getMeetings().size() && meetingIndex != -1) {
|
||||
setLastMeeting(meetingIndex);
|
||||
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
||||
textMeetingName.setEnabled(false);
|
||||
textMeetingName.setAdapter(null);
|
||||
ImageView imageTrash = findViewById(R.id.imageTrash);
|
||||
imageTrash.setVisibility(View.GONE);
|
||||
TextInputLayout layoutMeetingName = findViewById(R.id.layoutMeetingName);
|
||||
layoutMeetingName.setEndIconMode(TextInputLayout.END_ICON_NONE);
|
||||
}
|
||||
|
||||
|
||||
watchMeetingNameBox();
|
||||
@@ -78,12 +107,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
try {
|
||||
fillMeeting(getLastMeeting());
|
||||
scrollview.post(() -> scrollview.scrollTo(0, scrollview.getChildAt(0).getHeight()));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
AlertDialog.Builder dialog=new AlertDialog.Builder(this);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setMessage(R.string.resetDataText);
|
||||
dialog.setTitle(R.string.hint);
|
||||
AlertDialog alertDialog=dialog.create();
|
||||
AlertDialog alertDialog = dialog.create();
|
||||
alertDialog.show();
|
||||
setLastMeeting(-1);
|
||||
saveMeetingList(new ArrayList<>());
|
||||
@@ -97,41 +125,61 @@ public class MainActivity extends AppCompatActivity {
|
||||
watchShortcutIcon();
|
||||
|
||||
|
||||
if (meetingIndex <= getMeetings().size() && meetingIndex != -1) {
|
||||
setLastMeeting(meetingIndex);
|
||||
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
||||
textMeetingName.setEnabled(false);
|
||||
textMeetingName.setAdapter(null);
|
||||
ImageView imageTrash = findViewById(R.id.imageTrash);
|
||||
imageTrash.setVisibility(View.GONE);
|
||||
TextInputLayout layoutMeetingName = findViewById(R.id.layoutMeetingName);
|
||||
layoutMeetingName.setEndIconMode(TextInputLayout.END_ICON_NONE);
|
||||
|
||||
|
||||
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);
|
||||
} else {
|
||||
AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/update.xml");
|
||||
|
||||
appUpdater.start();
|
||||
}
|
||||
|
||||
AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/update.xml");
|
||||
|
||||
appUpdater.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void watchShortcutIcon() {
|
||||
ImageView ShortcutIcon = findViewById(R.id.imageCreateShortcut);
|
||||
ShortcutIcon.setOnClickListener(v -> createMeetingShortcut(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName)));
|
||||
|
||||
ShortcutIcon.setOnClickListener(v -> {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
builder.setTitle(R.string.app_name);
|
||||
builder.setMessage(R.string.WantToJoinImmediately);
|
||||
|
||||
builder.setPositiveButton(R.string.joinImmediately, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
createMeetingShortcut(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName), true);
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.alwaysAsk, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
createMeetingShortcut(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName), false);
|
||||
});
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
|
||||
//createMeetingShortcut(searchMeetingInList(getMeetings(), createCurrMeetingFromUI().meetingName), false);
|
||||
});
|
||||
}
|
||||
|
||||
private void createMeetingShortcut(int meetingIndex) {
|
||||
private void createMeetingShortcut(int meetingIndex, boolean joinImmediately) {
|
||||
|
||||
Meeting meeting = getMeetings().get(meetingIndex);
|
||||
|
||||
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
|
||||
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, "#1")
|
||||
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, meeting.meetingName)
|
||||
.setShortLabel(meeting.meetingName)
|
||||
.setLongLabel(meeting.meetingName)
|
||||
.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_launcher))
|
||||
.setIntents(new Intent[] {
|
||||
.setIntents(new Intent[]{
|
||||
new Intent(this, MainActivity.class)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
.putExtra("meetingIndex", meetingIndex)
|
||||
.putExtra("meetingName", meeting.meetingName)
|
||||
.putExtra("joinImmediately", joinImmediately)
|
||||
.setAction("LOCATION_SHORTCUT"),
|
||||
})
|
||||
.build();
|
||||
@@ -142,7 +190,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void watchShareIcon() {
|
||||
ImageView ShareIcon = findViewById(R.id.imageShare);
|
||||
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
||||
@@ -193,8 +240,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
if (meetings.size() > 1) {
|
||||
fillDropdownMeetingName();
|
||||
if (getLastMeeting() > meetings.size()-1) {
|
||||
setLastMeeting(meetings.size()-1);
|
||||
if (getLastMeeting() > meetings.size() - 1) {
|
||||
setLastMeeting(meetings.size() - 1);
|
||||
fillMeeting(getLastMeeting());
|
||||
}
|
||||
} else if (meetings.size() == 1) {
|
||||
@@ -340,12 +387,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent);
|
||||
}
|
||||
//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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -354,11 +403,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
builder.scheme("zoomus")
|
||||
.authority("zoom.us")
|
||||
.appendPath("join")
|
||||
.appendQueryParameter("confno",confno.replace(" ", ""))
|
||||
.appendQueryParameter("confno", confno.replace(" ", ""))
|
||||
.appendQueryParameter("pwd", pwd);
|
||||
|
||||
if (!Objects.equals(attendees, "")) {
|
||||
builder.appendQueryParameter("uname", name + " (" + attendees + ")");
|
||||
builder.appendQueryParameter("uname", name + " (" + attendees + ")");
|
||||
} else
|
||||
builder.appendQueryParameter("uname", name);
|
||||
return builder.build().toString();
|
||||
@@ -498,11 +547,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
editID.requestFocus();
|
||||
editID.setError("Meeting kann nicht ohne ID gespeichert werden!");
|
||||
return;
|
||||
}
|
||||
else if (currMeetingUI.meetingName.equals("")) {
|
||||
EditText editMName = findViewById(R.id.TextMeetingName);
|
||||
editMName.setText(currMeetingUI.meetingID);
|
||||
currMeetingUI.meetingName = currMeetingUI.meetingID;
|
||||
} else if (currMeetingUI.meetingName.equals("")) {
|
||||
EditText editMName = findViewById(R.id.TextMeetingName);
|
||||
editMName.setText(currMeetingUI.meetingID);
|
||||
currMeetingUI.meetingName = currMeetingUI.meetingID;
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +574,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
saveMeetingList(listMeetings);
|
||||
fillDropdownMeetingName();
|
||||
fillDropdownAttendeeName(getLastMeeting());
|
||||
Toast.makeText(getApplicationContext(),"Meeting gespeichert",Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), "Meeting gespeichert", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,5 +22,9 @@
|
||||
<string name="idHint">Meeting ID</string>
|
||||
<string name="shortcutTooltip">Direkte Verknüpfung zum gewählten Meeting erstellen</string>
|
||||
<string name="ShortcutError">Dein Launcher unterstützt leider keine direkten Verknüpfungen</string>
|
||||
<string name="shortcutLaunchFailedText">Das verknüpfte Meeting wurde nicht gefunden, da es zuvor gelöscht wurde</string>
|
||||
<string name="WantToJoinImmediately">Wähle das Verhalten beim Öffnen der Verknüpfung aus</string>
|
||||
<string name="joinImmediately">sofort beitreten</string>
|
||||
<string name="alwaysAsk">Dialog immer anzeigen</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user