From e4409e8ea4e9621ea42d0a0ab1368f5e77e57d31 Mon Sep 17 00:00:00 2001 From: Klearchos-K <32612550+Klearchos-K@users.noreply.github.com> Date: Mon, 24 Dec 2018 20:11:21 +0200 Subject: [PATCH] Update RouterActivity.java Add dunction handleText() for #1951 issue --- .../java/org/schabi/newpipe/RouterActivity.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index b8941670f..d7bf07675 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -42,6 +42,7 @@ import org.schabi.newpipe.player.playqueue.PlayQueue; import org.schabi.newpipe.player.playqueue.PlaylistPlayQueue; import org.schabi.newpipe.player.playqueue.SinglePlayQueue; import org.schabi.newpipe.report.UserAction; +import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.NavigationHelper; @@ -94,7 +95,7 @@ public class RouterActivity extends AppCompatActivity { currentUrl = getUrl(getIntent()); if (TextUtils.isEmpty(currentUrl)) { - Toast.makeText(this, R.string.invalid_url_toast, Toast.LENGTH_LONG).show(); + handleText(); finish(); } } @@ -112,7 +113,7 @@ public class RouterActivity extends AppCompatActivity { @Override protected void onStart() { super.onStart(); - + handleUrl(currentUrl); } @@ -353,6 +354,15 @@ public class RouterActivity extends AppCompatActivity { positiveButton.setEnabled(state); } + private void handleText(){ + String searchString = getIntent().getStringExtra(Intent.EXTRA_TEXT); + int serviceId = getIntent().getIntExtra(Constants.KEY_SERVICE_ID, 0); + Intent intent = new Intent(getThemeWrapperContext(), MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + NavigationHelper.openSearch(getThemeWrapperContext(),serviceId,searchString); + } + private void handleChoice(final String selectedChoiceKey) { final List validChoicesList = Arrays.asList(getResources().getStringArray(R.array.preferred_open_action_values_list)); if (validChoicesList.contains(selectedChoiceKey)) {