Merge pull request #693 from DanielWeigl/sendKeystrokesOtp
Add the feature to share the current OTP via an Intent
This commit is contained in:
commit
aea7fa6964
8 changed files with 36 additions and 1 deletions
|
@ -61,7 +61,7 @@ public class Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TapMode {
|
public enum TapMode {
|
||||||
NOTHING, REVEAL, COPY, COPY_BACKGROUND
|
NOTHING, REVEAL, COPY, COPY_BACKGROUND, SEND_KEYSTROKES
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LabelDisplay {
|
public enum LabelDisplay {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -317,6 +318,10 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
establishPinIfNeeded(position);
|
establishPinIfNeeded(position);
|
||||||
copyHandler(position, text, true);
|
copyHandler(position, text, true);
|
||||||
break;
|
break;
|
||||||
|
case SEND_KEYSTROKES:
|
||||||
|
establishPinIfNeeded(position);
|
||||||
|
sendKeystrokes(position);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// If tap-to-reveal is disabled a single tab still needs to establish the PIN
|
// If tap-to-reveal is disabled a single tab still needs to establish the PIN
|
||||||
if (!settings.getTapToReveal())
|
if (!settings.getTapToReveal())
|
||||||
|
@ -340,6 +345,10 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
establishPinIfNeeded(position);
|
establishPinIfNeeded(position);
|
||||||
copyHandler(position, text, true);
|
copyHandler(position, text, true);
|
||||||
break;
|
break;
|
||||||
|
case SEND_KEYSTROKES:
|
||||||
|
establishPinIfNeeded(position);
|
||||||
|
sendKeystrokes(position);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -669,6 +678,19 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sends the current OTP code via a "Send Action" with the MIME type "text/x-keystrokes"
|
||||||
|
// other apps (eg. https://github.com/KDE/kdeconnect-android ) can listen for this and handle
|
||||||
|
// the current code on their own (eg. sending it to a connected device/browser/...)
|
||||||
|
private void sendKeystrokes(final int pos) {
|
||||||
|
String otp = displayedEntries.get(pos).getCurrentOTP();
|
||||||
|
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
sendIntent.setType("text/x-keystrokes");
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_TEXT, otp);
|
||||||
|
if (sendIntent.resolveActivity(this.context.getPackageManager()) != null) {
|
||||||
|
this.context.startActivity(sendIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showQRCode(final int pos) {
|
private void showQRCode(final int pos) {
|
||||||
Uri uri = displayedEntries.get(pos).toUri();
|
Uri uri = displayedEntries.get(pos).toUri();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
|
@ -727,6 +749,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
} else if (id == R.id.menu_popup_show_qr_code) {
|
} else if (id == R.id.menu_popup_show_qr_code) {
|
||||||
showQRCode(pos);
|
showQRCode(pos);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (id == R.id.menu_send_keystrokes) {
|
||||||
|
sendKeystrokes(pos);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,8 @@
|
||||||
android:id="@+id/menu_popup_remove"
|
android:id="@+id/menu_popup_remove"
|
||||||
android:title="@string/menu_popup_remove" />
|
android:title="@string/menu_popup_remove" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_send_keystrokes"
|
||||||
|
android:title="@string/menu_send_keystrokes" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
|
@ -45,6 +45,8 @@
|
||||||
<string name="menu_popup_change_image">Bild ändern</string>
|
<string name="menu_popup_change_image">Bild ändern</string>
|
||||||
<string name="menu_popup_remove">Entfernen</string>
|
<string name="menu_popup_remove">Entfernen</string>
|
||||||
<string name="menu_popup_show_qr_code">Zeige QR-Code</string>
|
<string name="menu_popup_show_qr_code">Zeige QR-Code</string>
|
||||||
|
<string name="menu_send_keystrokes">Als Keystrokes teilen</string>
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<string name="button_card_options">Weitere Optionen</string>
|
<string name="button_card_options">Weitere Optionen</string>
|
||||||
<string name="button_card_options_format">Weitere Optionen für %1$s</string>
|
<string name="button_card_options_format">Weitere Optionen für %1$s</string>
|
||||||
|
|
|
@ -137,6 +137,7 @@
|
||||||
<item>Anzeigen/Verstecken</item>
|
<item>Anzeigen/Verstecken</item>
|
||||||
<item>Kopieren</item>
|
<item>Kopieren</item>
|
||||||
<item>Kopieren und in den Hintergrund wechseln</item>
|
<item>Kopieren und in den Hintergrund wechseln</item>
|
||||||
|
<item>Als Keystrokes teilen</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="settings_entries_search_includes">
|
<string-array name="settings_entries_search_includes">
|
||||||
<item>Beschriftung</item>
|
<item>Beschriftung</item>
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
<item>reveal</item>
|
<item>reveal</item>
|
||||||
<item>copy</item>
|
<item>copy</item>
|
||||||
<item>copy_background</item>
|
<item>copy_background</item>
|
||||||
|
<item>send_keystrokes</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_values_search_includes" translatable="false">
|
<string-array name="settings_values_search_includes" translatable="false">
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
<string name="menu_popup_remove">Remove</string>
|
<string name="menu_popup_remove">Remove</string>
|
||||||
<string name="menu_popup_show_qr_code">Show QR Code</string>
|
<string name="menu_popup_show_qr_code">Show QR Code</string>
|
||||||
<string name="menu_popup_establish_pin">Enter pin</string>
|
<string name="menu_popup_establish_pin">Enter pin</string>
|
||||||
|
<string name="menu_send_keystrokes">Share as Keystrokes</string>
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<string name="button_card_options">More options</string>
|
<string name="button_card_options">More options</string>
|
||||||
|
|
|
@ -205,6 +205,7 @@
|
||||||
<item>Reveal/Hide</item>
|
<item>Reveal/Hide</item>
|
||||||
<item>Copy</item>
|
<item>Copy</item>
|
||||||
<item>Copy and go to background</item>
|
<item>Copy and go to background</item>
|
||||||
|
<item>Share as Keystrokes</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_entries_search_includes">
|
<string-array name="settings_entries_search_includes">
|
||||||
|
|
Loading…
Reference in a new issue