mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-04 21:09:53 +02:00
Minor bugs fixed.
This commit is contained in:
@@ -363,29 +363,33 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
resumePosition = intent.getLongExtra(EXTRA_PROGRESS_SECONDS, -1);
|
resumePosition = intent.getLongExtra(EXTRA_PROGRESS_SECONDS, -1);
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_AUTOMATIC_LANDSCAPE_ORIENTATION, false)) {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_AUTOMATIC_LANDSCAPE_ORIENTATION, false)) {
|
||||||
originalOrientation = resources.getConfiguration().orientation;
|
originalOrientation = resources.getConfiguration().orientation;
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
try {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||||
|
|
||||||
if (android.provider.Settings.System.getInt(getContentResolver(),
|
if (android.provider.Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
|
Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
|
||||||
OrientationEventListener orientationEventListener = new OrientationEventListener(this) {
|
OrientationEventListener orientationEventListener = new OrientationEventListener(this) {
|
||||||
@Override
|
@Override
|
||||||
public void onOrientationChanged(int orientation) {
|
public void onOrientationChanged(int orientation) {
|
||||||
int epsilon = 10;
|
int epsilon = 10;
|
||||||
int leftLandscape = 90;
|
int leftLandscape = 90;
|
||||||
int rightLandscape = 270;
|
int rightLandscape = 270;
|
||||||
if(epsilonCheck(orientation, leftLandscape, epsilon) ||
|
if(epsilonCheck(orientation, leftLandscape, epsilon) ||
|
||||||
epsilonCheck(orientation, rightLandscape, epsilon)) {
|
epsilonCheck(orientation, rightLandscape, epsilon)) {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
try {
|
||||||
disable();
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
disable();
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean epsilonCheck(int a, int b, int epsilon) {
|
private boolean epsilonCheck(int a, int b, int epsilon) {
|
||||||
return a > b - epsilon && a < b + epsilon;
|
return a > b - epsilon && a < b + epsilon;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
orientationEventListener.enable();
|
orientationEventListener.enable();
|
||||||
}
|
}
|
||||||
|
} catch (Exception ignore) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -896,7 +900,9 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
wasPlaying = player.getPlayWhenReady();
|
wasPlaying = player.getPlayWhenReady();
|
||||||
player.setPlayWhenReady(false);
|
player.setPlayWhenReady(false);
|
||||||
if (originalOrientation != null) {
|
if (originalOrientation != null) {
|
||||||
setRequestedOrientation(originalOrientation);
|
try {
|
||||||
|
setRequestedOrientation(originalOrientation);
|
||||||
|
} catch (Exception ignore) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
@@ -20,6 +21,7 @@ import butterknife.BindView;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity;
|
||||||
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
@@ -39,7 +41,8 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
@BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment)
|
@BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment)
|
||||||
TextView copyAllMarkdownTextView;
|
TextView copyAllMarkdownTextView;
|
||||||
|
|
||||||
private BaseActivity activity;
|
private BaseActivity baseActivity;
|
||||||
|
private ViewRedditGalleryActivity viewRedditGalleryActivity;
|
||||||
private String markdownText;
|
private String markdownText;
|
||||||
|
|
||||||
public CopyTextBottomSheetFragment() {
|
public CopyTextBottomSheetFragment() {
|
||||||
@@ -73,7 +76,6 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (markdownText != null) {
|
if (markdownText != null) {
|
||||||
//markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
|
|
||||||
copyMarkdownTextView.setOnClickListener(view -> {
|
copyMarkdownTextView.setOnClickListener(view -> {
|
||||||
showCopyDialog(markdownText);
|
showCopyDialog(markdownText);
|
||||||
dismiss();
|
dismiss();
|
||||||
@@ -88,14 +90,17 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
copyAllMarkdownTextView.setVisibility(View.GONE);
|
copyAllMarkdownTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (baseActivity != null && baseActivity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(rootView, baseActivity.typeface);
|
||||||
|
} else if (viewRedditGalleryActivity != null && viewRedditGalleryActivity.typeface != null) {
|
||||||
|
Utils.setFontToAllTextViews(rootView, viewRedditGalleryActivity.typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCopyDialog(String text) {
|
private void showCopyDialog(String text) {
|
||||||
|
AppCompatActivity activity = baseActivity == null ? viewRedditGalleryActivity : baseActivity;
|
||||||
LayoutInflater inflater = activity.getLayoutInflater();
|
LayoutInflater inflater = activity.getLayoutInflater();
|
||||||
View layout = inflater.inflate(R.layout.copy_text_material_dialog, null);
|
View layout = inflater.inflate(R.layout.copy_text_material_dialog, null);
|
||||||
TextView textView = layout.findViewById(R.id.text_view_copy_text_material_dialog);
|
TextView textView = layout.findViewById(R.id.text_view_copy_text_material_dialog);
|
||||||
@@ -109,6 +114,7 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copyText(String text) {
|
private void copyText(String text) {
|
||||||
|
AppCompatActivity activity = baseActivity == null ? viewRedditGalleryActivity : baseActivity;
|
||||||
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
if (clipboard != null) {
|
if (clipboard != null) {
|
||||||
ClipData clip = ClipData.newPlainText("simple text", text);
|
ClipData clip = ClipData.newPlainText("simple text", text);
|
||||||
@@ -122,6 +128,10 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
activity = (BaseActivity) context;
|
if (context instanceof BaseActivity) {
|
||||||
|
baseActivity = (BaseActivity) context;
|
||||||
|
} else {
|
||||||
|
viewRedditGalleryActivity = (ViewRedditGalleryActivity) context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -96,8 +96,8 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
|
|||||||
CodeBlockSpan[] codeBlockSpans = markdownStringBuilder.getSpans(spoilerStart, spoilerEnd, CodeBlockSpan.class);
|
CodeBlockSpan[] codeBlockSpans = markdownStringBuilder.getSpans(spoilerStart, spoilerEnd, CodeBlockSpan.class);
|
||||||
|
|
||||||
if (codeSpans.length == 0 && codeBlockSpans.length == 0) {
|
if (codeSpans.length == 0 && codeBlockSpans.length == 0) {
|
||||||
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
|
||||||
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
||||||
|
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
||||||
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
||||||
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
@@ -108,8 +108,8 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
|
|||||||
int spanBeginning = markdownStringBuilder.getSpanStart(codeSpan);
|
int spanBeginning = markdownStringBuilder.getSpanStart(codeSpan);
|
||||||
int spanEnd = markdownStringBuilder.getSpanEnd(codeSpan);
|
int spanEnd = markdownStringBuilder.getSpanEnd(codeSpan);
|
||||||
if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
|
if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
|
||||||
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
|
||||||
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
||||||
|
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
||||||
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
||||||
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
@@ -122,8 +122,8 @@ public class SpoilerParserPlugin extends AbstractMarkwonPlugin {
|
|||||||
int spanBeginning = markdownStringBuilder.getSpanStart(codeBlockSpan);
|
int spanBeginning = markdownStringBuilder.getSpanStart(codeBlockSpan);
|
||||||
int spanEnd = markdownStringBuilder.getSpanEnd(codeBlockSpan);
|
int spanEnd = markdownStringBuilder.getSpanEnd(codeBlockSpan);
|
||||||
if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
|
if (spoilerStart + 2 <= spanBeginning && spanEnd <= spoilerEnd + 2) {
|
||||||
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
|
||||||
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
markdownStringBuilder.delete(spoilerEnd, spoilerEnd + 2);
|
||||||
|
markdownStringBuilder.delete(spoilerStart, spoilerStart + 2);
|
||||||
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
SpoilerSpan spoilerSpan = new SpoilerSpan(textColor, backgroundColor);
|
||||||
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
markdownStringBuilder.setSpan(spoilerSpan, spoilerStart, spoilerEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
Reference in New Issue
Block a user