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.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
|||||||
public InstantAutoComplete(Context context) {
|
public InstantAutoComplete(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
|
public InstantAutoComplete(Context arg0, AttributeSet arg1) {
|
||||||
super(arg0, arg1);
|
super(arg0, arg1);
|
||||||
}
|
}
|
||||||
@@ -49,6 +51,7 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
|||||||
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
|
public InstantAutoComplete(Context arg0, AttributeSet arg1, int arg2) {
|
||||||
super(arg0, arg1, arg2);
|
super(arg0, arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enoughToFilter() {
|
public boolean enoughToFilter() {
|
||||||
return false;
|
return false;
|
||||||
@@ -57,19 +60,45 @@ class InstantAutoComplete extends androidx.appcompat.widget.AppCompatAutoComplet
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
public boolean testing;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
Intent myIntent = getIntent(); // gets the previously created intent
|
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);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
final ScrollView scrollview = findViewById(R.id.scrollArea);
|
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();
|
watchMeetingNameBox();
|
||||||
@@ -78,12 +107,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
fillMeeting(getLastMeeting());
|
fillMeeting(getLastMeeting());
|
||||||
scrollview.post(() -> scrollview.scrollTo(0, scrollview.getChildAt(0).getHeight()));
|
scrollview.post(() -> scrollview.scrollTo(0, scrollview.getChildAt(0).getHeight()));
|
||||||
}
|
} catch (IndexOutOfBoundsException e) {
|
||||||
catch (IndexOutOfBoundsException e) {
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||||
AlertDialog.Builder dialog=new AlertDialog.Builder(this);
|
|
||||||
dialog.setMessage(R.string.resetDataText);
|
dialog.setMessage(R.string.resetDataText);
|
||||||
dialog.setTitle(R.string.hint);
|
dialog.setTitle(R.string.hint);
|
||||||
AlertDialog alertDialog=dialog.create();
|
AlertDialog alertDialog = dialog.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
setLastMeeting(-1);
|
setLastMeeting(-1);
|
||||||
saveMeetingList(new ArrayList<>());
|
saveMeetingList(new ArrayList<>());
|
||||||
@@ -97,41 +125,61 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
watchShortcutIcon();
|
watchShortcutIcon();
|
||||||
|
|
||||||
|
|
||||||
if (meetingIndex <= getMeetings().size() && meetingIndex != -1) {
|
|
||||||
setLastMeeting(meetingIndex);
|
|
||||||
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
if (joinImmediately) {
|
||||||
textMeetingName.setEnabled(false);
|
Meeting currMeeting = getMeetings().get(meetingIndex);
|
||||||
textMeetingName.setAdapter(null);
|
String url = buildZoomURL(currMeeting.meetingID, currMeeting.meetingPWD, currMeeting.attendees.get(currMeeting.lastAtt).name, currMeeting.attendees.get(currMeeting.lastAtt).num);
|
||||||
ImageView imageTrash = findViewById(R.id.imageTrash);
|
launchZoomUrl(url);
|
||||||
imageTrash.setVisibility(View.GONE);
|
} else {
|
||||||
TextInputLayout layoutMeetingName = findViewById(R.id.layoutMeetingName);
|
AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/update.xml");
|
||||||
layoutMeetingName.setEndIconMode(TextInputLayout.END_ICON_NONE);
|
|
||||||
|
appUpdater.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppUpdater appUpdater = new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://baldaufwd.de/ZoomHelper/update.xml");
|
|
||||||
|
|
||||||
appUpdater.start();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void watchShortcutIcon() {
|
private void watchShortcutIcon() {
|
||||||
ImageView ShortcutIcon = findViewById(R.id.imageCreateShortcut);
|
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);
|
Meeting meeting = getMeetings().get(meetingIndex);
|
||||||
|
|
||||||
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
|
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
|
||||||
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, "#1")
|
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, meeting.meetingName)
|
||||||
.setShortLabel(meeting.meetingName)
|
.setShortLabel(meeting.meetingName)
|
||||||
.setLongLabel(meeting.meetingName)
|
.setLongLabel(meeting.meetingName)
|
||||||
.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_launcher))
|
.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_launcher))
|
||||||
.setIntents(new Intent[] {
|
.setIntents(new Intent[]{
|
||||||
new Intent(this, MainActivity.class)
|
new Intent(this, MainActivity.class)
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||||
.putExtra("meetingIndex", meetingIndex)
|
.putExtra("meetingName", meeting.meetingName)
|
||||||
|
.putExtra("joinImmediately", joinImmediately)
|
||||||
.setAction("LOCATION_SHORTCUT"),
|
.setAction("LOCATION_SHORTCUT"),
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -142,7 +190,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void watchShareIcon() {
|
private void watchShareIcon() {
|
||||||
ImageView ShareIcon = findViewById(R.id.imageShare);
|
ImageView ShareIcon = findViewById(R.id.imageShare);
|
||||||
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
||||||
@@ -193,8 +240,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if (meetings.size() > 1) {
|
if (meetings.size() > 1) {
|
||||||
fillDropdownMeetingName();
|
fillDropdownMeetingName();
|
||||||
if (getLastMeeting() > meetings.size()-1) {
|
if (getLastMeeting() > meetings.size() - 1) {
|
||||||
setLastMeeting(meetings.size()-1);
|
setLastMeeting(meetings.size() - 1);
|
||||||
fillMeeting(getLastMeeting());
|
fillMeeting(getLastMeeting());
|
||||||
}
|
}
|
||||||
} else if (meetings.size() == 1) {
|
} else if (meetings.size() == 1) {
|
||||||
@@ -340,12 +387,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
//For Debugging: Show URL in Alert
|
if (testing) {
|
||||||
AlertDialog.Builder dialog=new AlertDialog.Builder(this);
|
//For Debugging: Show URL in Alert
|
||||||
dialog.setMessage(url);
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||||
dialog.setTitle("Zoom URL (for testing)");
|
dialog.setMessage(url);
|
||||||
AlertDialog alertDialog=dialog.create();
|
dialog.setTitle("Zoom URL (for testing)");
|
||||||
alertDialog.show();
|
AlertDialog alertDialog = dialog.create();
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -354,11 +403,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
builder.scheme("zoomus")
|
builder.scheme("zoomus")
|
||||||
.authority("zoom.us")
|
.authority("zoom.us")
|
||||||
.appendPath("join")
|
.appendPath("join")
|
||||||
.appendQueryParameter("confno",confno.replace(" ", ""))
|
.appendQueryParameter("confno", confno.replace(" ", ""))
|
||||||
.appendQueryParameter("pwd", pwd);
|
.appendQueryParameter("pwd", pwd);
|
||||||
|
|
||||||
if (!Objects.equals(attendees, "")) {
|
if (!Objects.equals(attendees, "")) {
|
||||||
builder.appendQueryParameter("uname", name + " (" + attendees + ")");
|
builder.appendQueryParameter("uname", name + " (" + attendees + ")");
|
||||||
} else
|
} else
|
||||||
builder.appendQueryParameter("uname", name);
|
builder.appendQueryParameter("uname", name);
|
||||||
return builder.build().toString();
|
return builder.build().toString();
|
||||||
@@ -498,11 +547,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
editID.requestFocus();
|
editID.requestFocus();
|
||||||
editID.setError("Meeting kann nicht ohne ID gespeichert werden!");
|
editID.setError("Meeting kann nicht ohne ID gespeichert werden!");
|
||||||
return;
|
return;
|
||||||
}
|
} else if (currMeetingUI.meetingName.equals("")) {
|
||||||
else if (currMeetingUI.meetingName.equals("")) {
|
EditText editMName = findViewById(R.id.TextMeetingName);
|
||||||
EditText editMName = findViewById(R.id.TextMeetingName);
|
editMName.setText(currMeetingUI.meetingID);
|
||||||
editMName.setText(currMeetingUI.meetingID);
|
currMeetingUI.meetingName = currMeetingUI.meetingID;
|
||||||
currMeetingUI.meetingName = currMeetingUI.meetingID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -526,7 +574,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
saveMeetingList(listMeetings);
|
saveMeetingList(listMeetings);
|
||||||
fillDropdownMeetingName();
|
fillDropdownMeetingName();
|
||||||
fillDropdownAttendeeName(getLastMeeting());
|
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="idHint">Meeting ID</string>
|
||||||
<string name="shortcutTooltip">Direkte Verknüpfung zum gewählten Meeting erstellen</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="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>
|
</resources>
|
||||||
Reference in New Issue
Block a user