-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from antest1/feature/new_button_drawer
Improve side panel button drawer
- Loading branch information
Showing
10 changed files
with
334 additions
and
276 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
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/antest1/gotobrowser/Browser/CustomDrawerLayout.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,70 @@ | ||
package com.antest1.gotobrowser.Browser; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.Rect; | ||
import android.util.AttributeSet; | ||
import android.view.Gravity; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.core.view.GravityCompat; | ||
import androidx.drawerlayout.widget.DrawerLayout; | ||
|
||
import com.antest1.gotobrowser.R; | ||
|
||
public class CustomDrawerLayout extends DrawerLayout | ||
{ | ||
public CustomDrawerLayout(@NonNull Context context) { | ||
super(context); | ||
setScrimColor(Color.TRANSPARENT); | ||
setDrawerElevation(0); | ||
} | ||
|
||
public CustomDrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
setScrimColor(Color.TRANSPARENT); | ||
setDrawerElevation(0); | ||
} | ||
|
||
public CustomDrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
setScrimColor(Color.TRANSPARENT); | ||
setDrawerElevation(0); | ||
} | ||
|
||
@Override | ||
public boolean dispatchTouchEvent(MotionEvent event) { | ||
if (!this.isDrawerOpen(Gravity.LEFT)) { | ||
return super.dispatchTouchEvent(event); | ||
} | ||
|
||
// Only pass the event to main panel if not handled by side panel | ||
// To avoid touching both at the same time | ||
boolean handledBySidePanel = getChildAt(1).dispatchTouchEvent(event); | ||
if (!handledBySidePanel) { | ||
getChildAt(0).dispatchTouchEvent(event); | ||
} | ||
|
||
boolean clickedOutside = false; | ||
if (event.getAction() == MotionEvent.ACTION_UP) { | ||
View content = findViewById(R.id.navigation); | ||
int[] contentLocation = new int[2]; | ||
content.getLocationOnScreen(contentLocation); | ||
Rect rect = new Rect(contentLocation[0], | ||
contentLocation[1], | ||
contentLocation[0] + content.getWidth(), | ||
contentLocation[1] + content.getHeight()); | ||
clickedOutside = !(rect.contains((int) event.getX(), (int) event.getY())); | ||
} | ||
|
||
if (clickedOutside) { | ||
this.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); | ||
return true; | ||
} | ||
this.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); | ||
return super.dispatchTouchEvent(event); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
app/src/main/java/com/antest1/gotobrowser/Helpers/AnimationUtils.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.