List of usage examples for android.view OrientationEventListener OrientationEventListener
public OrientationEventListener(Context context)
From source file:org.openremote.android.console.GroupActivity.java
/** * Inits a orientation listener, set request orientation be sensor when the current screen's orientation equals device orientation. */// w w w .j a v a2 s. co m private void initOrientationListener() { OrientationEventListener orientationListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int orientation) { if (currentScreen == null) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); return; } if (orientation > 315 || orientation < 45 || (orientation > 135 && orientation < 225)) { // portrait if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && !currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (!currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else if ((orientation > 225 && orientation < 315) || (orientation > 45 && orientation < 135)) { // landscape if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } } }; orientationListener.enable(); }
From source file:com.digitalvotingpass.camera.CameraFragment.java
/** * Handles the setup that can start when the fragment is created. * @param savedInstanceState//from w w w .j av a 2s. co m */ @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); orientationListener = new OrientationEventListener(this.getActivity()) { public void onOrientationChanged(int orientation) { configureTransform(mTextureView.getWidth(), mTextureView.getHeight()); } }; int threadsToStart = Runtime.getRuntime().availableProcessors() / 2; createOCRThreads(threadsToStart); mCameraHandler = new CameraHandler(this); }
From source file:com.intel.xdk.device.Device.java
@Override public void initialize(CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); this.activity = cordova.getActivity(); this.webView = webView; //remote site support remoteLayout = new AbsoluteLayout(activity); remoteLayout.setBackgroundColor(Color.BLACK); //hide the remote site display until needed remoteLayout.setVisibility(View.GONE); //create the close button remoteClose = new ImageButton(activity); remoteClose.setBackgroundColor(Color.TRANSPARENT); Drawable remoteCloseImage = null;// ww w.ja v a 2 s . com remoteCloseImage = activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName())); File remoteCloseImageFile = new File(activity.getFilesDir(), "_intelxdk/remote_close.png"); if (remoteCloseImageFile.exists()) { remoteCloseImage = (Drawable.createFromPath(remoteCloseImageFile.getAbsolutePath())); } else { remoteCloseImage = (activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName()))); } //set the button image //remoteClose.setImageDrawable(remoteCloseImage); remoteClose.setBackgroundDrawable(remoteCloseImage); //set up the button click action remoteClose.setOnClickListener(new OnClickListener() { public void onClick(View v) { closeRemoteSite(); } }); //add the close button remoteLayout.addView(remoteClose); final ViewGroup parent = (ViewGroup) webView.getEngine().getView().getParent(); activity.runOnUiThread(new Runnable() { public void run() { if (parent != null) { //add layout to activity root layout parent.addView(remoteLayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER)); } } }); //Initialize the orientation. lastOrientation = "unknown"; //Listen to the orientation change. OrientationEventListener listener = new OrientationEventListener(activity) { @Override public void onOrientationChanged(int orientation) { //Log.d("orientation","orientation: " + orientation); String currentOrientation = "unknown"; boolean orientationChanged = false; //int displayOrientation = 0; if (orientation > 345 || orientation < 15) { currentOrientation = "portrait"; displayOrientation = 0; } else if (orientation > 75 && orientation < 105) { currentOrientation = "landscape"; displayOrientation = 90; } else if (orientation > 165 && orientation < 195) { currentOrientation = "portrait"; displayOrientation = 180; } else if (orientation > 255 && orientation < 285) { currentOrientation = "landscape"; displayOrientation = -90; } if (currentOrientation.equals("unknown")) { currentOrientation = lastOrientation; } if (!currentOrientation.equals(lastOrientation)) { orientationChanged = true; Log.d("orientation", "Orientation changes from " + lastOrientation + " to " + currentOrientation + ", current orientation: " + orientation + "."); } if (orientationChanged) { String js = "javascript:try{intel.xdk.device.orientation='" + displayOrientation + "';}catch(e){}var e = document.createEvent('Events');e.initEvent('intel.xdk.device.orientation.change', true, true);e.success=true;e.orientation='" + displayOrientation + "';document.dispatchEvent(e);"; injectJS(js); } lastOrientation = currentOrientation; } }; listener.enable(); registerScreenStatusReceiver(); //cache references to methods for use in injectJS try { evaluateJavascript = webView.getClass().getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch (Exception e) { } try { sendJavascript = webView.getClass().getMethod("sendJavascript", String.class); } catch (Exception e) { } emptyVC = new ValueCallback<String>() { @Override public void onReceiveValue(String s) { } }; }
From source file:com.almalence.opencam.ApplicationScreen.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sEvPref = getResources().getString(R.string.Preference_EvCompensationValue); sSceneModePref = getResources().getString(R.string.Preference_SceneModeValue); sWBModePref = getResources().getString(R.string.Preference_WBModeValue); sColorTemperaturePref = getResources().getString(R.string.Preference_ColorTemperatureValue); sFrontFocusModePref = getResources().getString(R.string.Preference_FrontFocusModeValue); sFrontFocusModeVideoPref = getResources().getString(R.string.Preference_FrontFocusModeVideoValue); sRearFocusModePref = getResources().getString(R.string.Preference_RearFocusModeValue); sRearFocusModeVideoPref = getResources().getString(R.string.Preference_RearFocusModeVideoValue); sFrontColorEffectPref = getResources().getString(R.string.Preference_FrontColorEffectValue); sRearColorEffectPref = getResources().getString(R.string.Preference_RearColorEffectValue); sFlashModePref = getResources().getString(R.string.Preference_FlashModeValue); sISOPref = getResources().getString(R.string.Preference_ISOValue); sMeteringModePref = getResources().getString(R.string.Preference_MeteringModeValue); sExposureTimePref = getResources().getString(R.string.Preference_ExposureTimeValue); sExposureTimeModePref = getResources().getString(R.string.Preference_ExposureTimeModeValue); sRealExposureTimeOnPreviewPref = getResources() .getString(R.string.Preference_RealExposureTimeOnPreviewValue); sFocusDistancePref = getResources().getString(R.string.Preference_FocusDistanceValue); sFocusDistanceModePref = getResources().getString(R.string.Preference_FocusDistanceModeValue); sCameraModePref = getResources().getString(R.string.Preference_CameraModeValue); sUseFrontCameraPref = getResources().getString(R.string.Preference_UseFrontCameraValue); sImageSizeRearPref = getResources().getString(R.string.Preference_ImageSizeRearValue); sImageSizeFrontPref = getResources().getString(R.string.Preference_ImageSizeFrontValue); sImageSizeSonyRemotePref = getResources().getString(R.string.Preference_ImageSizeSonyRemoteValue); sImageSizeMultishotBackPref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotBackValue); sImageSizeMultishotFrontPref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotFrontValue); sImageSizeMultishotSonyRemotePref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotSonyRemoteValue); sImageSizePanoramaBackPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaBackValue); sImageSizePanoramaFrontPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaFrontValue); sImageSizeVideoBackPref = getResources().getString(R.string.Preference_ImageSizePrefVideoBackValue); sImageSizeVideoFrontPref = getResources().getString(R.string.Preference_ImageSizePrefVideoFrontValue); sCaptureRAWPref = getResources().getString(R.string.Preference_CaptureRAWValue); sJPEGQualityPref = getResources().getString(R.string.Preference_JPEGQualityCommonValue); sAntibandingPref = getResources().getString(R.string.Preference_AntibandingValue); sExportNamePref = getResources().getString(R.string.Preference_ExportNameValue); sExportNameSeparatorPref = getResources().getString(R.string.Preference_ExportNameSeparatorValue); sExportNamePrefixPref = getResources().getString(R.string.Preference_SavePathPrefixValue); sExportNamePostfixPref = getResources().getString(R.string.Preference_SavePathPostfixValue); sSavePathPref = getResources().getString(R.string.Preference_SavePathValue); sSaveToPref = getResources().getString(R.string.Preference_SaveToValue); sSortByDataPref = getResources().getString(R.string.Preference_SortByDataValue); sEnableExifOrientationTagPref = getResources().getString(R.string.Preference_EnableExifTagOrientationValue); sAdditionalRotationPref = getResources().getString(R.string.Preference_AdditionalRotationValue); sUseGeotaggingPref = getResources().getString(R.string.Preference_UseGeotaggingValue); sTimestampDate = getResources().getString(R.string.Preference_TimestampDateValue); sTimestampAbbreviation = getResources().getString(R.string.Preference_TimestampAbbreviationValue); sTimestampTime = getResources().getString(R.string.Preference_TimestampTimeValue); sTimestampGeo = getResources().getString(R.string.Preference_TimestampGeoValue); sTimestampSeparator = getResources().getString(R.string.Preference_TimestampSeparatorValue); sTimestampCustomText = getResources().getString(R.string.Preference_TimestampCustomTextValue); sTimestampColor = getResources().getString(R.string.Preference_TimestampColorValue); sTimestampFontSize = getResources().getString(R.string.Preference_TimestampFontSizeValue); sAELockPref = getResources().getString(R.string.Preference_AELockValue); sAWBLockPref = getResources().getString(R.string.Preference_AWBLockValue); sExpoPreviewModePref = getResources().getString(R.string.Preference_ExpoBracketingPreviewModePref); sDefaultModeName = getResources().getString(R.string.Preference_DefaultModeName); mainContext = this.getBaseContext(); messageHandler = new Handler(this); instance = this; surfaceCreated = false;//from w w w.ja v a 2s . c o m requestWindowFeature(Window.FEATURE_NO_TITLE); // ensure landscape orientation setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // set to fullscreen getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // set some common view here // setContentView(R.layout.opencamera_main_layout); createPluginManager(); duringOnCreate(); try { cameraController = CameraController.getInstance(); } catch (VerifyError exp) { Log.e("ApplicationScreen", exp.getMessage()); } CameraController.onCreate(ApplicationScreen.instance, ApplicationScreen.instance, pluginManager, ApplicationScreen.instance.messageHandler); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); keepScreenOn = prefs.getBoolean("keepScreenOn", false); // set preview, on click listener and surface buffers // findViewById(R.id.SurfaceView02).setVisibility(View.GONE); // preview = (SurfaceView) this.findViewById(R.id.SurfaceView01); // preview.setOnClickListener(this); // preview.setOnTouchListener(this); // preview.setKeepScreenOn(true); // // surfaceHolder = preview.getHolder(); // surfaceHolder.addCallback(this); orientListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int orientation) { // figure landscape or portrait if (ApplicationScreen.instance.landscapeIsNormal) { orientation += 90; } if ((orientation < 45) || (orientation > 315 && orientation < 405) || ((orientation > 135) && (orientation < 225))) { if (ApplicationScreen.wantLandscapePhoto) { ApplicationScreen.wantLandscapePhoto = false; } } else { if (!ApplicationScreen.wantLandscapePhoto) { ApplicationScreen.wantLandscapePhoto = true; } } // orient properly for video if ((orientation > 135) && (orientation < 225)) orientationMain = 270; else if ((orientation < 45) || (orientation > 315)) orientationMain = 90; else if ((orientation < 325) && (orientation > 225)) orientationMain = 0; else if ((orientation < 135) && (orientation > 45)) orientationMain = 180; if (orientationMain != orientationMainPrevious) { orientationMainPrevious = orientationMain; } } }; // prevent power drain screenTimer = new CountDownTimer(180000, 180000) { public void onTick(long millisUntilFinished) { // Not used } public void onFinish() { boolean isVideoRecording = PreferenceManager .getDefaultSharedPreferences(ApplicationScreen.getMainContext()) .getBoolean("videorecording", false); if (isVideoRecording || keepScreenOn) { // restart timer screenTimer.start(); isScreenTimerRunning = true; if (preview != null) { preview.setKeepScreenOn(true); } return; } if (preview != null) { preview.setKeepScreenOn(keepScreenOn); } isScreenTimerRunning = false; } }; screenTimer.start(); isScreenTimerRunning = true; if (this.getIntent().getAction() != null) { if (this.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) { try { forceFilenameUri = this.getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT); ApplicationScreen.setForceFilename(new File(((Uri) forceFilenameUri).getPath())); if (ApplicationScreen.getForceFilename().getAbsolutePath().equals("/scrapSpace")) { ApplicationScreen.setForceFilename( new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/mms/scrapSpace/.temp.jpg")); new File(ApplicationScreen.getForceFilename().getParent()).mkdirs(); } } catch (Exception e) { ApplicationScreen.setForceFilename(null); } } else { ApplicationScreen.setForceFilename(null); } } else { ApplicationScreen.setForceFilename(null); } afterOnCreate(); }
From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player);/*from w w w . ja v a 2 s . co m*/ final MyHandler myHandler = new MyHandler(); final LayoutInflater inflater = LayoutInflater.from(this); msgContainer = (LinearLayout) findViewById(R.id.msg_container); int current_locID; if (ActivityDevice.current_locID == -1) current_locID = ActivityShiPin.current_locID; else current_locID = ActivityDevice.current_locID; ArrayList<Integer> locIDList = MainActivity.locIDList; HashMap<Integer, ArrayList<Integer>> loc_devMap = MainActivity.loc_devMap; dev_typeMap = MainActivity.dev_typeMap; HashMap<Integer, String> dev_nameMap = MainActivity.dev_nameMap; Log.e("*****localID", String.valueOf(current_locID)); if (current_locID != -1) { if (loc_devMap.containsKey(current_locID)) { devList = loc_devMap.get(current_locID); if (devList.size() != 0) { int sub = devList.get(0) - 0; final ArrayList<Integer> brokenList = new ArrayList<Integer>(); brokenList.add(0); int i; for (i = 0; i < devList.size(); i++) { int devID = devList.get(i); Log.e("@@@@@@@@", String.valueOf(i)); if (sub != devID - i) { brokenList.add(i); sub = devID - i; } //int typeID=dev_typeMap.get(devID); final View view = inflater.inflate(R.layout.senssor_msg, null); TextView type = (TextView) view.findViewById(R.id.type); TextView msg = (TextView) view.findViewById(R.id.msg); type.setText(dev_nameMap.get(devID) + ":"); msgContainer.addView(view); } brokenList.add(i); new Thread(new Runnable() { @Override public void run() { Log.e(">>>>>>>>>", "??"); String a = null; try { a = WebServiceUtil.getHd("sss", "njuptcloud"); } catch (Exception e1) { // TODO Auto-generated catch block //Toast.makeText(VideoPlayerActivity.this,"?a " , Toast.LENGTH_SHORT).show(); Log.e(">>>>>>>>>", "?a " + e1.getMessage()); e1.printStackTrace(); } if (a != null) { int i = 0; List<String> msgList = new ArrayList<String>(); while (i < (brokenList.size() - 1)) { try { //Toast.makeText(VideoPlayerActivity.this,"??... " , Toast.LENGTH_SHORT).show(); msgList.addAll(WebServiceUtil.getMs(a, devList.get(brokenList.get(i)), devList.get(brokenList.get(i + 1) - 1))); } catch (Exception e) { //Toast.makeText(VideoPlayerActivity.this,"?? " , Toast.LENGTH_SHORT).show(); e.printStackTrace(); } i++; } // List<String> resultList=new ArrayList<String>(); // resultList.add(object) Message msg = new Message(); //Toast.makeText(VideoPlayerActivity.this,msgList.get(0) , Toast.LENGTH_SHORT).show(); msg.obj = msgList; myHandler.sendMessage(msg); } else { Log.e(">>>>>>>", "??"); Message msg = new Message(); //Toast.makeText(VideoPlayerActivity.this,msgList.get(0) , Toast.LENGTH_SHORT).show(); msg.obj = null; myHandler.sendMessage(msg); } //Toast.makeText(VideoPlayerActivity.this, "??", Toast.LENGTH_SHORT).show(); } }).start(); } } } directionLayout = (LinearLayout) findViewById(R.id.direction_layout); left = (ImageButton) findViewById(R.id.left); left.setOnClickListener(directionListenr); bottom = (ImageButton) findViewById(R.id.bottom); bottom.setOnClickListener(directionListenr); top = (ImageButton) findViewById(R.id.top); top.setOnClickListener(directionListenr); right = (ImageButton) findViewById(R.id.right); right.setOnClickListener(directionListenr); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); if (Util.isICSOrLater()) getWindow().getDecorView().findViewById(android.R.id.content) .setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int visibility) { if (visibility == mUiVisibility) return; setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen); if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing) { showOverlay(); } mUiVisibility = visibility; } }); /** initialize Views an their Events */ mOverlayHeader = findViewById(R.id.player_overlay_header); mOverlayHeader.setVisibility(View.GONE); mOverlayLock = findViewById(R.id.lock_overlay); mOverlayOption = findViewById(R.id.option_overlay); mOverlayProgress = findViewById(R.id.progress_overlay); mOverlayInterface = findViewById(R.id.interface_overlay); play_lay = (RelativeLayout) findViewById(R.id.play_lay); progress_lay = (LinearLayout) findViewById(R.id.progress_lay); /* header */ mTitle = (TextView) findViewById(R.id.player_overlay_title); mSysTime = (TextView) findViewById(R.id.player_overlay_systime); mBattery = (TextView) findViewById(R.id.player_overlay_battery); // Position and remaining time mTime = (TextView) findViewById(R.id.player_overlay_time); mTime.setOnClickListener(mRemainingTimeListener); mLength = (TextView) findViewById(R.id.player_overlay_length); mLength.setOnClickListener(mRemainingTimeListener); // the info textView is not on the overlay mInfo = (TextView) findViewById(R.id.player_overlay_info); mEnableWheelbar = pref.getBoolean("enable_wheel_bar", false); mEnableBrightnessGesture = pref.getBoolean("enable_brightness_gesture", true); mScreenOrientation = Integer .valueOf(pref.getString("screen_orientation_value", "4" /*SCREEN_ORIENTATION_SENSOR*/)); mControls = mEnableWheelbar ? new PlayerControlWheel(this) : new PlayerControlClassic(this); mControls.setOnPlayerControlListener(mPlayerControlListener); FrameLayout mControlContainer = (FrameLayout) findViewById(R.id.player_control); mControlContainer.addView((View) mControls); mAudioTrack = (ImageButton) findViewById(R.id.player_overlay_audio); mAudioTrack.setVisibility(View.GONE); mSubtitle = (ImageButton) findViewById(R.id.player_overlay_subtitle); mSubtitle.setVisibility(View.GONE); mHandler.postDelayed(new Runnable() { @Override public void run() { /*FIXME * The setTracksAndSubtitles method probably doesn't work in case of many many Tracks and Subtitles * Moreover, in a video stream, if Tracks & Subtitles change, they won't be updated */ setESTrackLists(); } }, 1500); mLock = (ImageButton) findViewById(R.id.lock_overlay_button); mLock.setOnClickListener(mLockListener); mSize = (ImageButton) findViewById(R.id.player_overlay_size); mSize.setOnClickListener(mSizeListener); snapshot_lay = (LinearLayout) findViewById(R.id.snapshot_lay);//?? radio_onOrPause_lay = (LinearLayout) findViewById(R.id.radio_onOrPause_lay);//??? record_lay = (LinearLayout) findViewById(R.id.record_lay);// voice_lay = (LinearLayout) findViewById(R.id.voice_lay);// mSnapShot = (ImageButton) findViewById(R.id.snapshot_overlay_button); mSnapShot.setOnClickListener(mSnapShotListener); mRecord = (ImageButton) findViewById(R.id.record_overlay_button); mRecord.setOnClickListener(mRecordListener); //??? mRadio = (ImageButton) findViewById(R.id.radio_onOrPause_button); mRadio_tv = (TextView) findViewById(R.id.radio_onOrPause_tv); mRadio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mRadio.getBackground().getConstantState() == getResources().getDrawable(R.drawable.radio_on1) .getConstantState()) { //????? if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { mRadio.setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_pause)); } else { mRadio.setBackground(getResources().getDrawable(R.drawable.radio_pause)); } mRadio_tv.setText("?"); play(); } else { //???? if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { mRadio.setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_on1)); } else { mRadio.setBackground(getResources().getDrawable(R.drawable.radio_on1)); } mRadio_tv.setText("?"); pause(); } } }); mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE); mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); // mVoice = (ImageButton) findViewById(R.id.voice_overlay_button); mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioMax, 0); mVoice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mVoice.getBackground().getConstantState() == getResources().getDrawable(R.drawable.voice_on) .getConstantState()) { //?? if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { mVoice.setBackgroundDrawable(getResources().getDrawable(R.drawable.voice_off)); } else { mVoice.setBackground(getResources().getDrawable(R.drawable.voice_off)); } mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); } else { //?? if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { mVoice.setBackgroundDrawable(getResources().getDrawable(R.drawable.voice_on)); } else { mVoice.setBackground(getResources().getDrawable(R.drawable.voice_on)); } mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioMax, 0); } } }); mSurface = (SurfaceView) findViewById(R.id.player_surface); mSurfaceHolder = mSurface.getHolder(); mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame); mSurfaceFrame.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (MotionEvent.ACTION_DOWN == event.getAction()) { if (System.currentTimeMillis() - clickTime < 500) { //?? if (mCurrentSize == SURFACE_4_3) { //??? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { //?? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { if (!mShowing) { showOverlay(); mSurfaceFrame.setFocusable(false); } else { hideOverlay(true); } } clickTime = System.currentTimeMillis(); if (directionLayout.getVisibility() == View.INVISIBLE) { directionLayout.setVisibility(View.VISIBLE); } else { directionLayout.setVisibility(View.INVISIBLE); } } return true; } }); mOrientationListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int rotation) { if (((rotation >= 0) && (rotation <= 45)) || (rotation >= 315) || ((rotation >= 135) && (rotation <= 225))) {//portrait mCurrentOrient = true; if (mCurrentOrient != mScreenProtrait) { mScreenProtrait = mCurrentOrient; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Log.d(TAG, "Screen orientation changed from Landscape to Portrait!"); } } else if (((rotation > 45) && (rotation < 135)) || ((rotation > 225) && (rotation < 315))) {//landscape mCurrentOrient = false; if (mCurrentOrient != mScreenProtrait) { mScreenProtrait = mCurrentOrient; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Log.d(TAG, "Screen orientation changed from Portrait to Landscape!"); } } } }; mOrientationListener.enable(); int pitch; String chroma = pref.getString("chroma_format", ""); if (Util.isGingerbreadOrLater() && chroma.equals("YV12")) { mSurfaceHolder.setFormat(ImageFormat.YV12); pitch = ImageFormat.getBitsPerPixel(ImageFormat.YV12) / 8; } else if (chroma.equals("RV16")) { mSurfaceHolder.setFormat(PixelFormat.RGB_565); PixelFormat info = new PixelFormat(); PixelFormat.getPixelFormatInfo(PixelFormat.RGB_565, info); pitch = info.bytesPerPixel; } else { mSurfaceHolder.setFormat(PixelFormat.RGBX_8888); PixelFormat info = new PixelFormat(); PixelFormat.getPixelFormatInfo(PixelFormat.RGBX_8888, info); pitch = info.bytesPerPixel; } mSurfaceAlign = 16 / pitch - 1; mSurfaceHolder.addCallback(mSurfaceCallback); mSeekbar = (SeekBar) findViewById(R.id.player_overlay_seekbar); mSeekbar.setOnSeekBarChangeListener(mSeekListener); mSwitchingView = false; mEndReached = false; // Clear the resume time, since it is only used for resumes in external // videos. SharedPreferences preferences = getSharedPreferences(PreferencesActivity.NAME, MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1); // Also clear the subs list, because it is supposed to be per session // only (like desktop VLC). We don't want the customs subtitle file // to persist forever with this video. editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null); editor.commit(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); filter.addAction(VLCApplication.SLEEP_INTENT); registerReceiver(mReceiver, filter); try { mLibVLC = Util.getLibVlcInstance(); } catch (LibVlcException e) { Log.d(TAG, "LibVLC initialisation failed"); return; } EventHandler em = EventHandler.getInstance(); em.addHandler(eventHandler); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); // 100 is the value for screen_orientation_start_lock,?? // setRequestedOrientation(mScreenOrientation != 100 // ? mScreenOrientation // : getScreenOrientation()); //??? // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //?? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }