Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] [WIP] Feat: share text to KISS #2111

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
<intent-filter>
<action android:name="android.content.pm.action.CONFIRM_PIN_SHORTCUT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<meta-data
android:name="com.android.systemui.action_assist_icon"
android:resource="@drawable/ic_launcher" />
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/fr/neamar/kiss/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;

import androidx.annotation.NonNull;

Expand All @@ -50,6 +51,7 @@
import fr.neamar.kiss.dataprovider.simpleprovider.SearchProvider;
import fr.neamar.kiss.forwarder.ForwarderManager;
import fr.neamar.kiss.pojo.SearchPojo;
import fr.neamar.kiss.R;
import fr.neamar.kiss.result.Result;
import fr.neamar.kiss.searcher.ApplicationsSearcher;
import fr.neamar.kiss.searcher.HistorySearcher;
Expand Down Expand Up @@ -377,6 +379,21 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
searchEditText.requestFocus();
}

// Pasting shared text from Sharesheet via intent-filter into kiss search bar
Intent receivedIntent = getIntent();
String receivedIntentAction = receivedIntent.getAction();
String receivedIntentType = receivedIntent.getType();
if (Intent.ACTION_SEND.equals(action) && receivedIntentType != null && "text/plain".equals(receivedIntentType)) {
marunjar marked this conversation as resolved.
Show resolved Hide resolved
hideKeyboard();
String sharedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT);
// making sure the shared text is not an empty string
if (sharedText != null && sharedText.trim().length() > 0) {
marunjar marked this conversation as resolved.
Show resolved Hide resolved
searchEditText.setText(sharedText);
} else {
Toast.makeText(this, R.string.shared_text_empty, Toast.LENGTH_SHORT).show();
}
}

marunjar marked this conversation as resolved.
Show resolved Hide resolved
/*
* Defer everything else to the forwarders
*/
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<string name="settings_tethering">Tethering</string>
<string name="menu_wallpaper">Perbarui wallpaper…</string>
<string name="application_not_found">Ups... gagal menjalankan apl tersebut.</string>
<string name="shared_text_empty">Ups... text-nya ternyata kosong.</string>
<string name="history_erased">Riwayat dihapus.</string>
<string name="favorites_erased">Favorit dihapus.</string>
<string name="menu_favorites_add">Tambahkan ke favorit</string>
Expand Down Expand Up @@ -324,4 +325,4 @@
<string name="reset_excluded_app_shortcuts_name">Setel ulang daftar aplikasi yang dikecualikan dari menampilkan pintasan</string>
<string name="reset_excluded_app_shortcuts_warn">Apakah Anda benar-benar ingin mengatur ulang daftar aplikasi yang dikecualikan dari menampilkan pintasan\?</string>
<string name="ui_excluded_from_shortcuts_apps">Lihat atau edit aplikasi yang dikecualikan dari menampilkan pintasan</string>
</resources>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<string name="settings_display">Display</string>
<string name="menu_wallpaper">Update wallpaper…</string>
<string name="application_not_found">Whoops… unable to launch that app.</string>
<string name="shared_text_empty">Whoops… text is actually empty.</string>
<string name="history_erased">History erased.</string>
<string name="favorites_erased">Favorites erased.</string>
<string name="menu_favorites_add">Add to favorites</string>
Expand Down