added option to create shortcut, bump version to 0.4.7

This commit is contained in:
2021-03-24 18:25:46 +01:00
parent 457c4abd46
commit 3fcf7bd3ed
6 changed files with 91 additions and 4 deletions
@@ -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()));
Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

+16 -1
View File
@@ -45,10 +45,25 @@
android:contentDescription="@string/saveTooltip"
android:focusable="true"
android:tooltipText="@string/saveTooltip"
app:layout_constraintEnd_toStartOf="@+id/imageShare"
app:layout_constraintEnd_toStartOf="@+id/imageCreateShortcut"
app:layout_constraintTop_toTopOf="@+id/imageAdd"
app:srcCompat="@drawable/iconfinder_save_7124134_32" />
<ImageView
android:id="@+id/imageCreateShortcut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/shortcutTooltip"
android:focusable="true"
android:tooltipText="@string/shortcutTooltip"
app:layout_constraintEnd_toStartOf="@+id/imageShare"
app:layout_constraintTop_toTopOf="@+id/imageAdd"
app:srcCompat="@drawable/iconfinder_heart_7124225_32" />
<ImageView
android:id="@+id/imageShare"
android:layout_width="wrap_content"
+14 -1
View File
@@ -41,10 +41,23 @@
android:clickable="true"
android:contentDescription="@string/saveTooltip"
android:focusable="true"
app:layout_constraintEnd_toStartOf="@+id/imageShare"
app:layout_constraintEnd_toStartOf="@+id/imageCreateShortcut"
app:layout_constraintTop_toTopOf="@+id/imageAdd"
app:srcCompat="@drawable/iconfinder_save_7124134_32" />
<ImageView
android:id="@+id/imageCreateShortcut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/shortcutTooltip"
android:focusable="true"
app:layout_constraintEnd_toStartOf="@+id/imageShare"
app:layout_constraintTop_toTopOf="@+id/imageAdd"
app:srcCompat="@drawable/iconfinder_heart_7124225_32" />
<ImageView
android:id="@+id/imageShare"
android:layout_width="wrap_content"
+1
View File
@@ -20,5 +20,6 @@
<string name="dropdownBtn">aufklappen</string>
<string name="pwdHint">Kenncode</string>
<string name="idHint">Meeting ID</string>
<string name="shortcutTooltip">Direkte Verknüpfung zum gewählten Meeting erstellen</string>
</resources>