forked from r0adkll/Slidr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Google Pixel panel orientation
- Loading branch information
1 parent
8fbe6f6
commit 9d834d3
Showing
6 changed files
with
86 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.r0adkll.slidr.util; | ||
|
||
import android.content.Context; | ||
import android.graphics.Point; | ||
import android.os.Build; | ||
import android.util.Log; | ||
import android.view.Display; | ||
import android.view.Surface; | ||
import android.view.WindowManager; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
public class Utils { | ||
public static int getNavigationBarSize(Context context) { | ||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
Point appUsableSize = getAppUsableScreenSize(windowManager); | ||
Point realScreenSize = getRealScreenSize(windowManager); | ||
|
||
// navigation bar on the right | ||
if (appUsableSize.x < realScreenSize.x && windowManager.getDefaultDisplay().getRotation() == Surface.ROTATION_270) { | ||
Log.v("Test", Integer.toString(realScreenSize.x - appUsableSize.x)); | ||
return realScreenSize.x - appUsableSize.x; | ||
} | ||
|
||
// navigation bar is not present | ||
return 0; | ||
} | ||
|
||
public static Point getAppUsableScreenSize(WindowManager windowManager) { | ||
Display display = windowManager.getDefaultDisplay(); | ||
Point size = new Point(); | ||
display.getSize(size); | ||
return size; | ||
} | ||
|
||
public static Point getRealScreenSize(WindowManager windowManager) { | ||
Display display = windowManager.getDefaultDisplay(); | ||
Point size = new Point(); | ||
|
||
if (Build.VERSION.SDK_INT >= 17) { | ||
display.getRealSize(size); | ||
} else if (Build.VERSION.SDK_INT >= 14) { | ||
try { | ||
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); | ||
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); | ||
} catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {} | ||
} | ||
|
||
return size; | ||
} | ||
} |
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