added option to create shortcut, bump version to 0.4.7
This commit is contained in:
@@ -4,8 +4,13 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Base64;
|
||||
import android.view.View;
|
||||
@@ -14,10 +19,15 @@ import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
|
||||
import com.github.javiersantos.appupdater.AppUpdater;
|
||||
import com.github.javiersantos.appupdater.enums.UpdateFrom;
|
||||
@@ -58,9 +68,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Intent myIntent = getIntent(); // gets the previously created intent
|
||||
int meetingIndex = myIntent.getIntExtra("meetingIndex", -1);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
final ScrollView scrollview = findViewById(R.id.scrollArea);
|
||||
|
||||
|
||||
|
||||
|
||||
watchMeetingNameBox();
|
||||
fillDropdownMeetingName();
|
||||
if (getLastMeeting() != -1) {
|
||||
@@ -83,14 +101,54 @@ public class MainActivity extends AppCompatActivity {
|
||||
watchDeleteIcon();
|
||||
watchNewIcon();
|
||||
watchShareIcon();
|
||||
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);
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
|
||||
private void createMeetingShortcut(int meetingIndex) {
|
||||
|
||||
Meeting meeting = getMeetings().get(meetingIndex);
|
||||
|
||||
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
|
||||
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, "#1")
|
||||
.setShortLabel(meeting.meetingName)
|
||||
.setLongLabel(meeting.meetingName)
|
||||
.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_launcher))
|
||||
.setIntents(new Intent[] {
|
||||
new Intent(this, MainActivity.class)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
.putExtra("meetingIndex", meetingIndex)
|
||||
.setAction("LOCATION_SHORTCUT"),
|
||||
})
|
||||
.build();
|
||||
ShortcutManagerCompat.requestPinShortcut(this, shortcutInfo, null);
|
||||
} else {
|
||||
Toast.makeText(this, "no shortcut", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void watchShareIcon() {
|
||||
ImageView ShareIcon = findViewById(R.id.imageShare);
|
||||
ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI()));
|
||||
|
||||
Reference in New Issue
Block a user