Skip to content

Commit

Permalink
Use dialogFullWidth for More-Dialogs; Begin list with image sources, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Aug 14, 2019
1 parent 02360f8 commit c2dddde
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,14 @@ private void setRecyclerMemeListAdapter(MemeItemAdapter adapter) {
private void updateSearchFilter(String newFilter) {
if (_currentMainMode != 0) {
_currentSearch = newFilter;
((MemeItemAdapter) _recyclerMemeList.getAdapter()).setFilter(newFilter);
if (_recyclerMemeList.getAdapter() != null) {
((MemeItemAdapter) _recyclerMemeList.getAdapter()).setFilter(newFilter);
}
} else {
MemeFragment page = ((MemeFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.main_activity__view_pager + ":" + _viewPager.getCurrentItem()));
((MemeItemAdapter) page._recyclerMemeList.getAdapter()).setFilter(newFilter);
if (page != null && page._recyclerMemeList.getAdapter() != null) {
((MemeItemAdapter) page._recyclerMemeList.getAdapter()).setFilter(newFilter);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Boolean onPreferenceClicked(Preference preference, String key, int keyRes
return true;
}
case R.string.pref_key__more_info__help: {
au.showDialogWithHtmlTextView(R.string.help, _cu.loadMarkdownForTextViewFromRaw(R.raw.resources, ""));
au.showDialogWithHtmlTextView(0, _cu.loadMarkdownForTextViewFromRaw(R.raw.resources, ""));
return true;
}
case R.string.pref_key__more_info__donate: {
Expand Down
31 changes: 28 additions & 3 deletions app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
Expand Down Expand Up @@ -175,11 +176,15 @@ public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, b
scroll.addView(textView);
textView.setMovementMethod(new LinkMovementMethod());
textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);

AlertDialog.Builder dialog = new AlertDialog.Builder(_context)
.setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener)
.setTitle(resTitleId).setView(scroll);
dialog.show();
.setView(scroll);
if (resTitleId != 0) {
dialog.setTitle(resTitleId);
}
dialogFullWidth(dialog.show(), true, false);
}

public void showDialogWithRawFileInWebView(String fileInRaw, @StringRes int resTitleId) {
Expand All @@ -189,7 +194,7 @@ public void showDialogWithRawFileInWebView(String fileInRaw, @StringRes int resT
.setPositiveButton(android.R.string.ok, null)
.setTitle(resTitleId)
.setView(wv);
dialog.show();
dialogFullWidth(dialog.show(), true, false);
}

// Toggle with no param, else set visibility according to first bool
Expand Down Expand Up @@ -291,4 +296,24 @@ public boolean isInSplitScreenMode() {
}
return false;
}

/**
* Show dialog in full width / show keyboard
*
* @param dialog Get via dialog.show()
*/
public void dialogFullWidth(AlertDialog dialog, boolean fullWidth, boolean showKeyboard) {
try {
Window w;
if (dialog != null && (w = dialog.getWindow()) != null) {
if (fullWidth) {
w.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
}
if (showKeyboard) {
w.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
} catch (Exception ignored) {
}
}
}
32 changes: 32 additions & 0 deletions app/src/main/res/raw/resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Meme Template Sources

### imgflip
Website: <https://imgflip.com/memetemplates>

* Select and click a template out of the list
* Press the "Blank" image below the "Caption this Meme" button
* Long press the image and click download/save


### Reddit
Website: <https://www.reddit.com/r/MemeTemplatesOfficial/.compact>

* Click and open a entry
* Long press the image and click download/save




## Memes and funny images
* [9GAG](https://9gag.com)

### Reddit
* [/r/memes](https://www.reddit.com/r/memes/.compact>)
* [/r/funny](https://www.reddit.com/r/funny/.compact>)
* [/r/gifs](https://www.reddit.com/r/gifs/.compact>)
* [/r/AdviceAnimals](https://www.reddit.com/r/AdviceAnimals/.compact>)
* [/r/BikiniBottomTwitter](https://www.reddit.com/r/BikiniBottomTwitter/.compact>)
* [/r/wowmemes](https://www.reddit.com/r/wowmemes/.compact>)
* [/r/de](https://www.reddit.com/r/de/.compact>)


0 comments on commit c2dddde

Please sign in to comment.