Skip to content

Commit

Permalink
Do not autopaste text that contains web urls
Browse files Browse the repository at this point in the history
  • Loading branch information
itkach committed May 10, 2015
1 parent 6911cdb commit ef5b996
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/itkach/aard2/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.util.Patterns;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -271,6 +272,10 @@ public void onWindowFocusChanged(boolean hasFocus) {
ClipData.Item item = clipData.getItemAt(i);
CharSequence text = item.getText();
if (text != null && text.length() > 0) {
if (Patterns.WEB_URL.matcher(text).find()) {
Log.d(TAG, "Text contains web url, not pasting: " + text);
return;
}
viewPager.setCurrentItem(0);
cm.setPrimaryClip(ClipData.newPlainText(null, ""));
appSectionsPagerAdapter.tabLookup.setQuery(text.toString());
Expand Down

0 comments on commit ef5b996

Please sign in to comment.