Browse Source

Cleanup, minor Shoutbox improvements

pull/70/head
Ezerous 4 years ago
parent
commit
074d0055c6
  1. 29
      app/src/main/AndroidManifest.xml
  2. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  3. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java
  4. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  5. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
  6. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java
  7. 42
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  8. 4
      app/src/main/java/gr/thmmy/mthmmy/utils/crashreporting/CrashReportingTree.java
  9. 4
      app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java
  10. 2
      app/src/main/res/layout/activity_create_content.xml
  11. 5
      app/src/main/res/values/strings.xml

29
app/src/main/AndroidManifest.xml

@ -150,6 +150,20 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" /> android:value=".activities.main.MainActivity" />
</activity> </activity>
<activity
android:name=".activities.shoutbox.ShoutboxActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" />
</activity>
<activity
android:name=".activities.create_content.CreateContentActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
@ -176,20 +190,5 @@
<action android:name="gr.thmmy.mthmmy.uploadservice.broadcast.status" /> <action android:name="gr.thmmy.mthmmy.uploadservice.broadcast.status" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<activity
android:name=".activities.create_content.CreateContentActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.shoutbox.ShoutboxActivity"
android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity" />
</activity>
</application> </application>
</manifest> </manifest>

3
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -8,6 +8,7 @@ import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -142,7 +143,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
mainContent.addOnScrollListener(new RecyclerView.OnScrollListener() { mainContent.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
totalItemCount = layoutManager.getItemCount(); totalItemCount = layoutManager.getItemCount();
lastVisibleItem = layoutManager.findLastVisibleItemPosition(); lastVisibleItem = layoutManager.findLastVisibleItemPosition();

7
app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java

@ -4,6 +4,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
@ -128,7 +129,7 @@ public class BookmarksActivity extends BaseActivity {
* it may be best to switch to a * it may be best to switch to a
* {@link FragmentStatePagerAdapter}. * {@link FragmentStatePagerAdapter}.
*/ */
private class SectionsPagerAdapter extends FragmentPagerAdapter { private static class SectionsPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> fragmentList = new ArrayList<>(); private final List<Fragment> fragmentList = new ArrayList<>();
private final List<String> fragmentTitleList = new ArrayList<>(); private final List<String> fragmentTitleList = new ArrayList<>();
@ -142,6 +143,7 @@ public class BookmarksActivity extends BaseActivity {
notifyDataSetChanged(); notifyDataSetChanged();
} }
@NonNull
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
return fragmentList.get(position); return fragmentList.get(position);
@ -158,8 +160,7 @@ public class BookmarksActivity extends BaseActivity {
} }
@Override @Override
public int getItemPosition(Object object) { public int getItemPosition(@NonNull Object object) {
@SuppressWarnings("RedundantCast")
int position = fragmentList.indexOf((Fragment) object); int position = fragmentList.indexOf((Fragment) object);
return position == -1 ? POSITION_NONE : position; return position == -1 ? POSITION_NONE : position;
} }

4
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -32,8 +32,6 @@ import gr.thmmy.mthmmy.utils.parsing.ParseException;
import gr.thmmy.mthmmy.views.CustomRecyclerView; import gr.thmmy.mthmmy.views.CustomRecyclerView;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
/** /**
* A {@link BaseFragment} subclass. * A {@link BaseFragment} subclass.
@ -86,10 +84,8 @@ public class RecentFragment extends BaseFragment {
recentTask = new RecentTask(this::onRecentTaskStarted, this::onRecentTaskFinished); recentTask = new RecentTask(this::onRecentTaskStarted, this::onRecentTaskFinished);
recentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.indexUrl.toString()); recentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.indexUrl.toString());
} }
Timber.d("onActivityCreated");
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {

3
app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java

@ -21,6 +21,7 @@ import org.jsoup.select.Elements;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Objects;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; import gr.thmmy.mthmmy.utils.parsing.ParseHelpers;
@ -68,7 +69,7 @@ public class SummaryFragment extends Fragment {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
profileSummaryDocument = Jsoup.parse(requireArguments().getString(PROFILE_DOCUMENT)); profileSummaryDocument = Jsoup.parse(Objects.requireNonNull(requireArguments().getString(PROFILE_DOCUMENT)));
parsedProfileSummaryData = new LinkedHashMap<>(); parsedProfileSummaryData = new LinkedHashMap<>();
} }

5
app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java

@ -56,6 +56,7 @@ public class ShoutboxFragment extends Fragment {
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setReverseLayout(true); layoutManager.setReverseLayout(true);
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemViewCacheSize(25);
recyclerView.setOnTouchListener((view, motionEvent) -> { recyclerView.setOnTouchListener((view, motionEvent) -> {
editorView.hideMarkdown(); editorView.hideMarkdown();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
@ -82,7 +83,7 @@ public class ShoutboxFragment extends Fragment {
} }
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.shoutbox_menu, menu); inflater.inflate(R.menu.shoutbox_menu, menu);
} }
@ -100,7 +101,7 @@ public class ShoutboxFragment extends Fragment {
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
shoutboxViewModel = ViewModelProviders.of(getActivity()).get(ShoutboxViewModel.class); shoutboxViewModel = ViewModelProviders.of(getActivity()).get(ShoutboxViewModel.class);
shoutboxViewModel.getShoutboxMutableLiveData().observe(this, shoutbox -> { shoutboxViewModel.getShoutboxMutableLiveData().observe(getViewLifecycleOwner(), shoutbox -> {
if (shoutbox != null) { if (shoutbox != null) {
Timber.i("Shoutbox loaded successfully"); Timber.i("Shoutbox loaded successfully");
shoutAdapter.setShouts(shoutbox.getShouts()); shoutAdapter.setShouts(shoutbox.getShouts());

42
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -43,7 +43,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatButton;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
@ -113,7 +113,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.postFocusListener = context; this.postFocusListener = context;
this.emojiKeyboard = emojiKeyboard; this.emojiKeyboard = emojiKeyboard;
viewModel = ViewModelProviders.of(context).get(TopicViewModel.class); viewModel = new ViewModelProvider(context).get(TopicViewModel.class);
} }
@Override @Override
@ -137,6 +137,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
quickReplyText.setFocusableInTouchMode(true); quickReplyText.setFocusableInTouchMode(true);
quickReplyText.setOnFocusChangeListener((v, hasFocus) -> quickReplyText.post(() -> { quickReplyText.setOnFocusChangeListener((v, hasFocus) -> quickReplyText.post(() -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(quickReplyText, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(quickReplyText, InputMethodManager.SHOW_IMPLICIT);
})); }));
quickReplyText.requestFocus(); quickReplyText.requestFocus();
@ -150,6 +151,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
editPostEdittext.setFocusableInTouchMode(true); editPostEdittext.setFocusableInTouchMode(true);
editPostEdittext.setOnFocusChangeListener((v, hasFocus) -> editPostEdittext.post(() -> { editPostEdittext.setOnFocusChangeListener((v, hasFocus) -> editPostEdittext.post(() -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(editPostEdittext, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(editPostEdittext, InputMethodManager.SHOW_IMPLICIT);
})); }));
editPostEdittext.requestFocus(); editPostEdittext.requestFocus();
@ -215,12 +217,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
for (Poll.Entry entry : entries) { for (Poll.Entry entry : entries) {
CheckBox checkBox = new CheckBox(context); CheckBox checkBox = new CheckBox(context);
checkBox.setMovementMethod(LinkMovementMethod.getInstance()); checkBox.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
checkBox.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY)); checkBox.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
} else { else
//noinspection deprecation
checkBox.setText(Html.fromHtml(entry.getEntryName())); checkBox.setText(Html.fromHtml(entry.getEntryName()));
}
checkBox.setTextColor(primaryTextColor); checkBox.setTextColor(primaryTextColor);
holder.optionsLayout.addView(checkBox); holder.optionsLayout.addView(checkBox);
} }
@ -236,10 +236,9 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
radioButton.setMovementMethod(LinkMovementMethod.getInstance()); radioButton.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
radioButton.setText(Html.fromHtml(entries[i].getEntryName(), Html.FROM_HTML_MODE_LEGACY)); radioButton.setText(Html.fromHtml(entries[i].getEntryName(), Html.FROM_HTML_MODE_LEGACY));
} else { } else
//noinspection deprecation
radioButton.setText(Html.fromHtml(entries[i].getEntryName())); radioButton.setText(Html.fromHtml(entries[i].getEntryName()));
}
radioButton.setText(ThmmyParser.html2span(context, entries[i].getEntryName())); radioButton.setText(ThmmyParser.html2span(context, entries[i].getEntryName()));
radioButton.setTextColor(primaryTextColor); radioButton.setTextColor(primaryTextColor);
radioGroup.addView(radioButton); radioGroup.addView(radioButton);
@ -255,12 +254,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Poll.Entry entry = entries1[i]; Poll.Entry entry = entries1[i];
TextView textView = new TextView(context); TextView textView = new TextView(context);
textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
textView.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY)); textView.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
} else { else
//noinspection deprecation
textView.setText(Html.fromHtml(entry.getEntryName())); textView.setText(Html.fromHtml(entry.getEntryName()));
}
textView.setTextColor(primaryTextColor); textView.setTextColor(primaryTextColor);
if (poll.getSelectedEntryIndex() == i) { if (poll.getSelectedEntryIndex() == i) {
// apply bold to the selected entry // apply bold to the selected entry
@ -363,7 +361,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.post.setClickable(true); holder.post.setClickable(true);
holder.post.setWebViewClient(new LinkLauncher()); holder.post.setWebViewClient(new LinkLauncher());
//noinspection ConstantConditions
loadAvatar(currentPost.getThumbnailURL(), holder.thumbnail, holder.itemView.getContext()); loadAvatar(currentPost.getThumbnailURL(), holder.thumbnail, holder.itemView.getContext());
//Sets username,submit date, index number, subject, post's and attached files texts //Sets username,submit date, index number, subject, post's and attached files texts
@ -385,7 +382,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
int filesTextColor; int filesTextColor;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
filesTextColor = context.getResources().getColor(R.color.accent, null); filesTextColor = context.getResources().getColor(R.color.accent, null);
} else //noinspection deprecation } else
filesTextColor = context.getResources().getColor(R.color.accent); filesTextColor = context.getResources().getColor(R.color.accent);
for (final ThmmyFile attachedFile : currentPost.getAttachedFiles()) { for (final ThmmyFile attachedFile : currentPost.getAttachedFiles()) {
@ -408,7 +405,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
int lastEditTextColor; int lastEditTextColor;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
lastEditTextColor = context.getResources().getColor(R.color.white, null); lastEditTextColor = context.getResources().getColor(R.color.white, null);
} else //noinspection deprecation } else
lastEditTextColor = context.getResources().getColor(R.color.white); lastEditTextColor = context.getResources().getColor(R.color.white);
final TextView lastEdit = new TextView(context); final TextView lastEdit = new TextView(context);
@ -492,7 +489,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
holder.cardChildLinear.setBackground(context.getResources(). holder.cardChildLinear.setBackground(context.getResources().
getDrawable(R.drawable.mention_card, null)); getDrawable(R.drawable.mention_card, null));
} else //noinspection deprecation } else
holder.cardChildLinear.setBackground(context.getResources(). holder.cardChildLinear.setBackground(context.getResources().
getDrawable(R.drawable.mention_card)); getDrawable(R.drawable.mention_card));
} else if (mUserColor == TopicParser.USER_COLOR_PINK) { } else if (mUserColor == TopicParser.USER_COLOR_PINK) {
@ -500,7 +497,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
holder.cardChildLinear.setBackground(context.getResources(). holder.cardChildLinear.setBackground(context.getResources().
getDrawable(R.drawable.member_of_the_month_card, null)); getDrawable(R.drawable.member_of_the_month_card, null));
} else //noinspection deprecation } else
holder.cardChildLinear.setBackground(context.getResources(). holder.cardChildLinear.setBackground(context.getResources().
getDrawable(R.drawable.member_of_the_month_card)); getDrawable(R.drawable.member_of_the_month_card));
} else holder.cardChildLinear.setBackground(null); } else holder.cardChildLinear.setBackground(null);
@ -623,7 +620,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
popUp.showAsDropDown(holder.overflowButton); popUp.showAsDropDown(holder.overflowButton);
}); });
//noinspection PointlessBooleanExpression,ConstantConditions
if (!BaseActivity.getSessionManager().isLoggedIn() || !viewModel.canReply()) if (!BaseActivity.getSessionManager().isLoggedIn() || !viewModel.canReply())
holder.quoteToggle.setVisibility(View.GONE); holder.quoteToggle.setVisibility(View.GONE);
else { else {
@ -644,7 +640,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final QuickReplyViewHolder holder = (QuickReplyViewHolder) currentHolder; final QuickReplyViewHolder holder = (QuickReplyViewHolder) currentHolder;
Post reply = (Post) topicItems.get(position); Post reply = (Post) topicItems.get(position);
//noinspection ConstantConditions
loadAvatar(getSessionManager().getAvatarLink(), holder.thumbnail, holder.itemView.getContext()); loadAvatar(getSessionManager().getAvatarLink(), holder.thumbnail, holder.itemView.getContext());
holder.username.setText(getSessionManager().getUsername()); holder.username.setText(getSessionManager().getUsername());
@ -669,7 +664,9 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
return; return;
} }
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
holder.itemView.setAlpha(0.5f); holder.itemView.setAlpha(0.5f);
holder.itemView.setEnabled(false); holder.itemView.setEnabled(false);
emojiKeyboard.hide(); emojiKeyboard.hide();
@ -706,7 +703,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} else if (currentHolder instanceof EditMessageViewHolder) { } else if (currentHolder instanceof EditMessageViewHolder) {
final EditMessageViewHolder holder = (EditMessageViewHolder) currentHolder; final EditMessageViewHolder holder = (EditMessageViewHolder) currentHolder;
//noinspection ConstantConditions
loadAvatar(getSessionManager().getAvatarLink(), holder.thumbnail, holder.itemView.getContext()); loadAvatar(getSessionManager().getAvatarLink(), holder.thumbnail, holder.itemView.getContext());
holder.username.setText(getSessionManager().getUsername()); holder.username.setText(getSessionManager().getUsername());
@ -729,7 +725,9 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
return; return;
} }
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
holder.itemView.setAlpha(0.5f); holder.itemView.setAlpha(0.5f);
holder.itemView.setEnabled(false); holder.itemView.setEnabled(false);
emojiKeyboard.hide(); emojiKeyboard.hide();
@ -898,9 +896,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
* This class is used to handle link clicks in WebViews. When link url is one that the app can * This class is used to handle link clicks in WebViews. When link url is one that the app can
* handle internally, it does. Otherwise user is prompt to open the link in a browser. * handle internally, it does. Otherwise user is prompt to open the link in a browser.
*/ */
@SuppressWarnings("unchecked")
private class LinkLauncher extends WebViewClient { private class LinkLauncher extends WebViewClient {
@SuppressWarnings("deprecation")
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Uri uri = Uri.parse(url); final Uri uri = Uri.parse(url);

4
app/src/main/java/gr/thmmy/mthmmy/utils/crashreporting/CrashReportingTree.java

@ -2,6 +2,8 @@ package gr.thmmy.mthmmy.utils.crashreporting;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.google.firebase.crashlytics.FirebaseCrashlytics; import com.google.firebase.crashlytics.FirebaseCrashlytics;
import timber.log.Timber.DebugTree; import timber.log.Timber.DebugTree;
@ -14,7 +16,7 @@ public class CrashReportingTree extends DebugTree {
} }
@Override @Override
protected void log(int priority, String tag, String message, Throwable t) { protected void log(int priority, String tag, @NonNull String message, Throwable t) {
if (priority == Log.VERBOSE || priority == Log.DEBUG) { if (priority == Log.VERBOSE || priority == Log.DEBUG) {
return; return;
} }

4
app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java

@ -375,10 +375,12 @@ public class EditorView extends LinearLayout implements EmojiInputField {
if (emojiKeyboard.onEmojiButtonToggle()) { if (emojiKeyboard.onEmojiButtonToggle()) {
//prevent system keyboard from appearing when clicking the edittext //prevent system keyboard from appearing when clicking the edittext
editText.setTextIsSelectable(true); editText.setTextIsSelectable(true);
if (imm != null)
imm.hideSoftInputFromWindow(getWindowToken(), 0); imm.hideSoftInputFromWindow(getWindowToken(), 0);
} }
else { else {
editText.requestFocus(); editText.requestFocus();
if (imm != null)
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
} }
editText.setSelection(selectionStart, selectionEnd); editText.setSelection(selectionStart, selectionEnd);
@ -398,9 +400,11 @@ public class EditorView extends LinearLayout implements EmojiInputField {
editText.setOnClickListener(view -> { editText.setOnClickListener(view -> {
if (!emojiKeyboard.isVisible()) { if (!emojiKeyboard.isVisible()) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
} else { } else {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm != null)
imm.hideSoftInputFromWindow(getWindowToken(), 0); imm.hideSoftInputFromWindow(getWindowToken(), 0);
requestEditTextFocus(); requestEditTextFocus();
} }

2
app/src/main/res/layout/activity_create_content.xml

@ -53,7 +53,7 @@
android:layout_below="@id/subject_input" android:layout_below="@id/subject_input"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:hint="topic message"/> app:hint="@string/message"/>
<gr.thmmy.mthmmy.views.editorview.EmojiKeyboard <gr.thmmy.mthmmy.views.editorview.EmojiKeyboard
android:id="@+id/emoji_keyboard" android:id="@+id/emoji_keyboard"

5
app/src/main/res/values/strings.xml

@ -61,10 +61,9 @@
<string name="button_page">Page</string> <string name="button_page">Page</string>
<string name="button_next">next</string> <string name="button_next">next</string>
<string name="button_last">last</string> <string name="button_last">last</string>
<string name="quick_reply">Quick reply&#8230;</string> <string name="subject">Subject</string>
<string name="subject">Subject&#8230;</string> <string name="message">Message</string>
<string name="submit">Submit</string> <string name="submit">Submit</string>
<string name="post_message">Message&#8230;</string>
<string name="network_error_retry_prompt">Could not connect to thmmy.gr\n\nTap to retry</string> <string name="network_error_retry_prompt">Could not connect to thmmy.gr\n\nTap to retry</string>
<string name="generic_network_error">Network error</string> <string name="generic_network_error">Network error</string>
<string name="retry">retry</string> <string name="retry">retry</string>

Loading…
Cancel
Save