aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-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;