aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-08 22:23:08 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-08 22:23:08 +0000
commita2390b72d5041a8fd314fcdedf6c66eb1dcaed1f (patch)
tree47e0860613a1024c4f6f8d07759d2c314988f383 /app/src/main/java/ml
parent72036e4744f206d505cb6b8cc67ceb7ab39f9440 (diff)
downloadinfinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar.gz
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar.bz2
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar.lz
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar.xz
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.tar.zst
infinity-for-reddit-a2390b72d5041a8fd314fcdedf6c66eb1dcaed1f.zip
Reset FAB position option in ViewPostDetailActivity.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/MovableFloatingActionButton.java27
2 files changed, 37 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index e0ee0210..0668a892 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -12,6 +12,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
@@ -287,9 +288,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
public void setTitle(String title) {
- if (binding.toolbarViewPostDetailActivity != null) {
- binding.toolbarViewPostDetailActivity.setTitle(title);
- }
+ binding.toolbarViewPostDetailActivity.setTitle(title);
}
public void showFab() {
@@ -738,10 +737,20 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
@Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.view_post_detail_activity, menu);
+ applyMenuItemTheme(menu);
+ return true;
+ }
+
+ @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
+ } else if (item.getItemId() == R.id.action_reset_fab_position_view_post_detail_activity) {
+ binding.fabViewPostDetailActivity.resetCoordinates();
+ return true;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/MovableFloatingActionButton.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/MovableFloatingActionButton.java
index 1a279ab7..edf28c60 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/MovableFloatingActionButton.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/MovableFloatingActionButton.java
@@ -102,13 +102,13 @@ public class MovableFloatingActionButton extends FloatingActionButton implements
newY = Math.max(layoutParams.topMargin, newY); // Don't allow the FAB past the top of the parent
newY = Math.min(parentHeight - viewHeight - layoutParams.bottomMargin, newY); // Don't allow the FAB past the bottom of the parent
+ saveCoordinates(newX, newY);
+
view.animate()
.x(newX)
.y(newY)
.setDuration(0)
.start();
-
- saveCoordinates(newX, newY);
return true;
} else if (action == MotionEvent.ACTION_UP) {
if (longClicked) {
@@ -177,6 +177,29 @@ public class MovableFloatingActionButton extends FloatingActionButton implements
}
}
+ public void resetCoordinates() {
+ if (portrait) {
+ if (postDetailsSharedPreferences != null) {
+ postDetailsSharedPreferences
+ .edit()
+ .remove(SharedPreferencesUtils.getPostDetailFabPortraitX(display))
+ .remove(SharedPreferencesUtils.getPostDetailFabPortraitY(display))
+ .apply();
+ }
+ } else {
+ if (postDetailsSharedPreferences != null) {
+ postDetailsSharedPreferences
+ .edit()
+ .remove(SharedPreferencesUtils.getPostDetailFabLandscapeX(display))
+ .remove(SharedPreferencesUtils.getPostDetailFabLandscapeY(display))
+ .apply();
+ }
+ }
+
+ setTranslationX(0);
+ setTranslationY(0);
+ }
+
private void saveCoordinates(float x, float y) {
if (postDetailsSharedPreferences == null) {
return;