diff --git a/app/src/main/java/omegacentauri/mobi/simplestopwatch/StopWatch.java b/app/src/main/java/omegacentauri/mobi/simplestopwatch/StopWatch.java index 22ce684..715f6c1 100755 --- a/app/src/main/java/omegacentauri/mobi/simplestopwatch/StopWatch.java +++ b/app/src/main/java/omegacentauri/mobi/simplestopwatch/StopWatch.java @@ -26,6 +26,7 @@ import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; +import android.view.SoundEffectConstants; import android.view.Surface; import android.view.View; import android.view.ViewGroup; @@ -204,6 +205,8 @@ void setTheme() { } void setOrientation() { + if (isTV()) + return; String o = options.getString(Options.PREF_ORIENTATION, "automatic"); if (o.equals("landscape")) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); @@ -372,10 +375,12 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { return super.onKeyDown(keyCode, event); } if (isFirstButton(keyCode)) { + chrono.playSoundEffect(SoundEffectConstants.CLICK); pressFirstButton(); return true; } else if (isSecondButton(keyCode)) { + chrono.playSoundEffect(SoundEffectConstants.CLICK); pressSecondButton(); return true; } @@ -433,7 +438,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } public void lockOrientation() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { + if (!isTV() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { switch(((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation()) { case Surface.ROTATION_0: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); @@ -587,6 +592,15 @@ public static void vibrate(Activity context, long time) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(time); } + + public boolean isTV() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { + return getPackageManager().hasSystemFeature("android.hardware.type.television"); + } + else { + return false; + } + } } class MyStateDrawable extends StateListDrawable { diff --git a/app/src/main/res/layout/activity_stop_watch.xml b/app/src/main/res/layout/activity_stop_watch.xml index b2ecf7e..586fb33 100755 --- a/app/src/main/res/layout/activity_stop_watch.xml +++ b/app/src/main/res/layout/activity_stop_watch.xml @@ -7,6 +7,7 @@ android:layout_height="match_parent" android:background="#000000" android:orientation="vertical" + android:soundEffectsEnabled="true" tools:context=".StopWatch">