forked from jackpal/Android-Terminal-Emulator
-
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.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
term/src/main/java/jackpal/androidterm/compat/UIModeCompat.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,33 @@ | ||
package jackpal.androidterm.compat; | ||
|
||
import android.annotation.TargetApi; | ||
import android.app.UiModeManager; | ||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
|
||
/** | ||
* Shim for detecting UI Mode | ||
*/ | ||
|
||
public class UIModeCompat { | ||
private static class Api8OrLater { | ||
@TargetApi(8) | ||
public static boolean isUIModeTV(Context context) { | ||
boolean result=false; | ||
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE); | ||
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) { | ||
result=true; | ||
} | ||
uiModeManager=null; | ||
return result; | ||
} | ||
} | ||
|
||
public static boolean isUIModeTV(Context context) { | ||
boolean result=false; | ||
if(AndroidCompat.SDK >= 8) { | ||
result=Api8OrLater.isUIModeTV(context); | ||
} | ||
return result; | ||
} | ||
} |