use of me.ccrama.redditslide.util.stubs.SimpleTextWatcher in project Slide by ccrama.
the class SettingsActivity method setSettingItems.
private void setSettingItems() {
View pro = findViewById(R.id.settings_child_pro);
if (SettingValues.isPro) {
pro.setVisibility(View.GONE);
} else {
pro.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
ProUtil.proUpgradeMsg(SettingsActivity.this, R.string.settings_support_slide).setNegativeButton(R.string.btn_no_thanks, (dialog, whichButton) -> dialog.dismiss()).show();
}
});
}
((EditText) findViewById(R.id.settings_search)).addTextChangedListener(new SimpleTextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String text = s.toString().trim();
/* No idea why, but this event can fire many times when there is no change */
if (text.equalsIgnoreCase(prev_text))
return;
BuildLayout(text);
prev_text = text;
}
});
findViewById(R.id.settings_child_general).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsGeneral.class);
startActivityForResult(i, RESTART_SETTINGS_RESULT);
}
});
findViewById(R.id.settings_child_history).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsHistory.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_about).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsAbout.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_offline).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(SettingsActivity.this, ManageOfflineContent.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_datasave).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsData.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_subtheme).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsSubreddit.class);
startActivityForResult(i, RESTART_SETTINGS_RESULT);
}
});
findViewById(R.id.settings_child_filter).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsFilter.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_synccit).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsSynccit.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_reorder).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View view) {
Intent inte = new Intent(SettingsActivity.this, ReorderSubreddits.class);
startActivity(inte);
}
});
findViewById(R.id.settings_child_maintheme).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsTheme.class);
startActivityForResult(i, RESTART_SETTINGS_RESULT);
}
});
findViewById(R.id.settings_child_handling).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsHandling.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_layout).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, EditCardsLayout.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_backup).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsBackup.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_font).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsFont.class);
startActivity(i);
}
});
findViewById(R.id.settings_child_tablet).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View view) {
/* Intent inte = new Intent(Overview.this, Overview.class);
inte.putExtra("type", UpdateSubreddits.COLLECTIONS);
Overview.this.startActivity(inte);*/
if (SettingValues.isPro) {
LayoutInflater inflater = getLayoutInflater();
final View dialoglayout = inflater.inflate(R.layout.tabletui, null);
final Resources res = getResources();
dialoglayout.findViewById(R.id.title).setBackgroundColor(Palette.getDefaultColor());
// todo final Slider portrait = (Slider) dialoglayout.findViewById(R.id.portrait);
final SeekBar landscape = dialoglayout.findViewById(R.id.landscape);
// todo portrait.setBackgroundColor(Palette.getDefaultColor());
landscape.setProgress(Reddit.dpWidth - 1);
((TextView) dialoglayout.findViewById(R.id.progressnumber)).setText(res.getQuantityString(R.plurals.landscape_columns, landscape.getProgress() + 1, landscape.getProgress() + 1));
landscape.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
((TextView) dialoglayout.findViewById(R.id.progressnumber)).setText(res.getQuantityString(R.plurals.landscape_columns, landscape.getProgress() + 1, landscape.getProgress() + 1));
SettingsActivity.changed = true;
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
final AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this).setView(dialoglayout);
final Dialog dialog = builder.create();
dialog.show();
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Reddit.dpWidth = landscape.getProgress() + 1;
Reddit.colors.edit().putInt("tabletOVERRIDE", landscape.getProgress() + 1).apply();
}
});
SwitchCompat s = dialog.findViewById(R.id.dualcolumns);
s.setChecked(SettingValues.dualPortrait);
s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SettingValues.dualPortrait = isChecked;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_DUAL_PORTRAIT, isChecked).apply();
}
});
SwitchCompat s2 = dialog.findViewById(R.id.fullcomment);
s2.setChecked(SettingValues.fullCommentOverride);
s2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SettingValues.fullCommentOverride = isChecked;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_FULL_COMMENT_OVERRIDE, isChecked).apply();
}
});
SwitchCompat s3 = dialog.findViewById(R.id.singlecolumnmultiwindow);
s3.setChecked(SettingValues.singleColumnMultiWindow);
s3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SettingValues.singleColumnMultiWindow = isChecked;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SINGLE_COLUMN_MULTI, isChecked).apply();
}
});
} else {
ProUtil.proUpgradeMsg(SettingsActivity.this, R.string.general_multicolumn_ispro).setNegativeButton(R.string.btn_no_thanks, (dialog, whichButton) -> dialog.dismiss()).show();
}
}
});
if (BuildConfig.isFDroid) {
((TextView) findViewById(R.id.settings_child_donatetext)).setText("Donate via PayPal");
}
findViewById(R.id.settings_child_support).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if (BuildConfig.isFDroid) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=56FKCCYLX7L72"));
startActivity(browserIntent);
} else {
Intent inte = new Intent(SettingsActivity.this, DonateView.class);
startActivity(inte);
}
}
});
findViewById(R.id.settings_child_comments).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent inte = new Intent(SettingsActivity.this, SettingsComments.class);
startActivity(inte);
}
});
if (Authentication.isLoggedIn && NetworkUtil.isConnected(this)) {
findViewById(R.id.settings_child_reddit_settings).setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsReddit.class);
startActivity(i);
}
});
} else {
findViewById(R.id.settings_child_reddit_settings).setEnabled(false);
findViewById(R.id.settings_child_reddit_settings).setAlpha(0.25f);
}
if (Authentication.mod) {
findViewById(R.id.settings_child_moderation).setVisibility(View.VISIBLE);
findViewById(R.id.settings_child_moderation).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(SettingsActivity.this, SettingsModeration.class);
startActivity(i);
}
});
}
}
use of me.ccrama.redditslide.util.stubs.SimpleTextWatcher in project Slide by ccrama.
the class CommentSearch method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideRedditSwipeAnywhere();
super.onCreate(savedInstance);
applyColorTheme();
setContentView(R.layout.activity_filtercomments);
final EditText search = (EditText) findViewById(R.id.search);
RecyclerView rv = (RecyclerView) findViewById(R.id.vertical_content);
final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(this);
rv.setLayoutManager(mLayoutManager);
ArrayList<CommentNode> comments = new ArrayList<>();
List<CommentObject> commentsOld = DataShare.sharedComments;
if (commentsOld != null && !commentsOld.isEmpty())
for (CommentObject o : commentsOld) {
if (o instanceof CommentItem)
comments.add(o.comment);
}
else
finish();
final CommentAdapterSearch adapter = new CommentAdapterSearch(this, comments);
rv.setAdapter(adapter);
search.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable editable) {
String result = search.getText().toString();
adapter.setResult(result);
adapter.getFilter().filter(result);
}
});
}
use of me.ccrama.redditslide.util.stubs.SimpleTextWatcher in project Slide by ccrama.
the class MainActivity method setupSubredditSearchToolbar.
/**
* If the user has the Subreddit Search method set to "long press on toolbar title", an
* OnLongClickListener needs to be set for the toolbar as well as handling all of the relevant
* onClicks for the views of the search bar.
*/
private void setupSubredditSearchToolbar() {
if (!NetworkUtil.isConnected(this)) {
if (findViewById(R.id.drawer_divider) != null) {
findViewById(R.id.drawer_divider).setVisibility(View.GONE);
}
} else {
if ((SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) && usedArray != null && !usedArray.isEmpty()) {
if (findViewById(R.id.drawer_divider) != null) {
if (SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) {
findViewById(R.id.drawer_divider).setVisibility(View.GONE);
} else {
findViewById(R.id.drawer_divider).setVisibility(View.VISIBLE);
}
}
final ListView TOOLBAR_SEARCH_SUGGEST_LIST = (ListView) findViewById(R.id.toolbar_search_suggestions_list);
final ArrayList<String> subs_copy = new ArrayList<>(usedArray);
final SideArrayAdapter TOOLBAR_SEARCH_SUGGEST_ADAPTER = new SideArrayAdapter(this, subs_copy, UserSubscriptions.getAllSubreddits(this), TOOLBAR_SEARCH_SUGGEST_LIST);
if (TOOLBAR_SEARCH_SUGGEST_LIST != null) {
TOOLBAR_SEARCH_SUGGEST_LIST.setAdapter(TOOLBAR_SEARCH_SUGGEST_ADAPTER);
}
if (mToolbar != null) {
mToolbar.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final AutoCompleteTextView GO_TO_SUB_FIELD = (AutoCompleteTextView) findViewById(R.id.toolbar_search);
final ImageView CLOSE_BUTTON = (ImageView) findViewById(R.id.close_search_toolbar);
final CardView SUGGESTIONS_BACKGROUND = (CardView) findViewById(R.id.toolbar_search_suggestions);
// if the view mode is set to Subreddit Tabs, save the title ("Slide" or "Slide (debug)")
tabViewModeTitle = (!SettingValues.single) ? getSupportActionBar().getTitle().toString() : null;
getSupportActionBar().setTitle(// clear title to make room for search field
"");
if (GO_TO_SUB_FIELD != null && CLOSE_BUTTON != null && SUGGESTIONS_BACKGROUND != null) {
GO_TO_SUB_FIELD.setVisibility(View.VISIBLE);
CLOSE_BUTTON.setVisibility(View.VISIBLE);
SUGGESTIONS_BACKGROUND.setVisibility(View.VISIBLE);
// run enter animations
enterAnimationsForToolbarSearch(ANIMATE_DURATION, SUGGESTIONS_BACKGROUND, GO_TO_SUB_FIELD, CLOSE_BUTTON);
// Get focus of the search field and show the keyboard
GO_TO_SUB_FIELD.requestFocus();
KeyboardUtil.toggleKeyboard(MainActivity.this, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
// Close the search UI and keyboard when clicking the close button
CLOSE_BUTTON.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final View view = MainActivity.this.getCurrentFocus();
if (view != null) {
// Hide the keyboard
KeyboardUtil.hideKeyboard(MainActivity.this, view.getWindowToken(), 0);
}
// run the exit animations
exitAnimationsForToolbarSearch(ANIMATE_DURATION, SUGGESTIONS_BACKGROUND, GO_TO_SUB_FIELD, CLOSE_BUTTON);
// clear sub text when close button is clicked
GO_TO_SUB_FIELD.setText("");
}
});
GO_TO_SUB_FIELD.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
// If it the input text doesn't match a subreddit from the list exactly, openInSubView is true
if (sideArrayAdapter.fitems == null || sideArrayAdapter.openInSubView || !usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
Intent intent = new Intent(MainActivity.this, SubredditView.class);
intent.putExtra(SubredditView.EXTRA_SUBREDDIT, GO_TO_SUB_FIELD.getText().toString());
MainActivity.this.startActivityForResult(intent, 2002);
} else {
if (commentPager && adapter instanceof MainPagerAdapterComment) {
openingComments = null;
toOpenComments = -1;
((MainPagerAdapterComment) adapter).size = (usedArray.size() + 1);
adapter.notifyDataSetChanged();
if (usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
doPageSelectedComments(usedArray.indexOf(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH)));
} else {
doPageSelectedComments(usedArray.indexOf(sideArrayAdapter.fitems.get(0)));
}
}
if (usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
pager.setCurrentItem(usedArray.indexOf(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH)));
} else {
pager.setCurrentItem(usedArray.indexOf(sideArrayAdapter.fitems.get(0)));
}
}
View view = MainActivity.this.getCurrentFocus();
if (view != null) {
// Hide the keyboard
KeyboardUtil.hideKeyboard(MainActivity.this, view.getWindowToken(), 0);
}
SUGGESTIONS_BACKGROUND.setVisibility(View.GONE);
GO_TO_SUB_FIELD.setVisibility(View.GONE);
CLOSE_BUTTON.setVisibility(View.GONE);
if (SettingValues.single) {
getSupportActionBar().setTitle(selectedSub);
} else {
// Set the title back to "Slide" or "Slide (debug)"
getSupportActionBar().setTitle(tabViewModeTitle);
}
}
return false;
}
});
GO_TO_SUB_FIELD.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable editable) {
final String RESULT = GO_TO_SUB_FIELD.getText().toString().replaceAll(" ", "");
TOOLBAR_SEARCH_SUGGEST_ADAPTER.getFilter().filter(RESULT);
}
});
}
return true;
}
});
}
}
}
}
use of me.ccrama.redditslide.util.stubs.SimpleTextWatcher in project Slide by ccrama.
the class Shortcut method doShortcut.
public void doShortcut() {
setContentView(R.layout.activity_setup_widget);
setupAppBar(R.id.toolbar, R.string.shortcut_creation_title, true, true);
header = getLayoutInflater().inflate(R.layout.shortcut_header, null);
ListView list = (ListView) findViewById(R.id.subs);
list.addHeaderView(header);
final ArrayList<String> sorted = UserSubscriptions.getSubscriptionsForShortcut(Shortcut.this);
final SubChooseAdapter adapter = new SubChooseAdapter(this, sorted, UserSubscriptions.getAllSubreddits(this));
list.setAdapter(adapter);
(header.findViewById(R.id.sort)).clearFocus();
((EditText) header.findViewById(R.id.sort)).addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable editable) {
final String result = editable.toString();
adapter.getFilter().filter(result);
}
});
}
Aggregations