mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2026-03-06 15:59:17 +00:00
Reset FAB position option in ViewPostDetailActivity.
This commit is contained in:
@ -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() {
|
||||
@ -737,11 +736,21 @@ 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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
9
app/src/main/res/menu/view_post_detail_activity.xml
Normal file
9
app/src/main/res/menu/view_post_detail_activity.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_reset_fab_position_view_post_detail_activity"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_reset_fab_position"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@ -98,6 +98,7 @@
|
||||
<string name="action_contact_mods">Contact Mods</string>
|
||||
<string name="action_more_options">More Options</string>
|
||||
<string name="action_add_to_home_screen">Add to Home screen</string>
|
||||
<string name="action_reset_fab_position">Reset FAB position</string>
|
||||
|
||||
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
|
||||
<string name="retrieve_token_error">Error Retrieving the token</string>
|
||||
|
||||
Reference in New Issue
Block a user