-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add history scroll restoration for scroll views (#2366)
* feat(font size dialog): add auto scroll for selection list * feat(special key dialog): add auto restore scroll for key list * feat(text actions bar): add auto restore scroll position * refactor: remove unnecessary font size in range 1 to 4 * refactor: minor improvements to padding of Markdown in view mode * refactor: minor improvements to padding of editor in edit mode
- Loading branch information
Showing
9 changed files
with
90 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/net/gsantner/opoc/frontend/GsHorizontalScrollView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.gsantner.opoc.frontend; | ||
|
||
import android.content.Context; | ||
import android.os.Build; | ||
import android.util.AttributeSet; | ||
import android.widget.HorizontalScrollView; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
public class GsHorizontalScrollView extends HorizontalScrollView { | ||
|
||
private int currentScrollX; // Current X scroll value in pixels | ||
|
||
public GsHorizontalScrollView(Context context) { | ||
super(context); | ||
} | ||
|
||
public GsHorizontalScrollView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public GsHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) | ||
public GsHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
@Override | ||
protected void onLayout(boolean changed, int l, int t, int r, int b) { | ||
super.onLayout(changed, l, t, r, b); | ||
if (currentScrollX > 0) { | ||
// Restore previous X scroll value (horizontal position) | ||
scrollTo(currentScrollX, 0); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { | ||
currentScrollX = scrollX; | ||
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters