import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceManager;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
ed.apply();
}
+ private void addToSearchHistory() {
+ addToSearchHistory(searchView.getQuery().toString());
+ }
+
private void addToSearchHistory(String text) {
if (text == null || text.isEmpty()) return;
int exists = searchHistory.indexOf(text);
@Override
public boolean onSuggestionClick(int position) {
- setSearchText(searchHistory.get(position), true);
+ String h = searchHistory.get(position);
+ addToSearchHistory(h);
+ setSearchText(h, true);
return true;
}
});
for (int i = savedHistory.size() - 1; i >= 0; i--) {
addToSearchHistory(savedHistory.get(i));
}
+ addToSearchHistory(text);
setSearchText(text, true);
Log.d(LOG, "Trying to restore searchText=" + text);
@Override
public boolean onQueryTextSubmit(String query) {
Log.d(LOG, "OnQueryTextListener: onQueryTextSubmit: " + searchView.getQuery());
- addToSearchHistory(searchView.getQuery().toString());
+ addToSearchHistory();
hideKeyboard();
return true;
}
};
searchView.setOnQueryTextListener(onQueryTextListener);
searchView.setFocusable(true);
- searchTextView = (AutoCompleteTextView)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
+ searchTextView = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0,
FrameLayout.LayoutParams.WRAP_CONTENT, 1);
customSearchView.addView(searchView, lp);
@Override
protected void onPause() {
super.onPause();
+ addToSearchHistory();
saveSearchHistory();
}
updateTTSLanguage(indexIndex);
}
+ @SuppressWarnings("deprecation")
+ private void speak(String text) {
+ textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
+ }
+
private void updateTTSLanguage(int i) {
if (!ttsReady || index == null || textToSpeech == null) {
Log.d(LOG, "Can't updateTTSLanguage.");
searchView.requestFocus();
}
if (searchView.getQuery().toString().length() > 0) {
+ addToSearchHistory();
searchView.setQuery("", false);
}
showKeyboard();
speak.setOnMenuItemClickListener(new android.view.MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(android.view.MenuItem item) {
- textToSpeech.speak(textToSpeak, TextToSpeech.QUEUE_FLUSH,
- new HashMap<String, String>());
+ speak(textToSpeak);
return false;
}
});
String text = "";
for (Pair p : pairs) text += p.get(idx);
text = text.replaceAll("\\{[^{}]*\\}", "").replace("{", "").replace("}", "");
- textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH,
- new HashMap<String, String>());
+ speak(text);
return false;
}
});
String text = "";
for (Pair p : pairs) text += p.get(idx);
text = text.replaceAll("\\{[^{}]*\\}", "").replace("{", "").replace("}", "");
- textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH,
- new HashMap<String, String>());
+ speak(text);
return false;
}
});
@Override
public void run() {
setIndexAndSearchText(actualIndexToUse, selectedText, true);
+ addToSearchHistory(selectedText);
}
}, 100);
}
if (hideKeyboard) {
hideKeyboard();
}
- addToSearchHistory(text);
}
private void setSearchText(final String text, final boolean triggerSearch) {