List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE
int SCREEN_ORIENTATION_LANDSCAPE
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.
Click Source Link
landscape
in the android.R.attr#screenOrientation attribute. From source file:com.Beat.RingdroidEditActivity.java
/** * Called from both onCreate and onConfigurationChanged * (if the user switched layouts)//from w w w . ja v a 2 s. c o m */ private void loadGui() { // Inflate our UI from its XML layout description. setContentView(R.layout.editor); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mDensity = metrics.density; mMarkerLeftInset = (int) (46 * mDensity); mMarkerRightInset = (int) (48 * mDensity); mMarkerTopOffset = (int) (10 * mDensity); mMarkerBottomOffset = (int) (10 * mDensity); mStartText = (TextView) findViewById(R.id.starttext); mStartText.addTextChangedListener(mTextWatcher); mEndText = (TextView) findViewById(R.id.endtext); mEndText.addTextChangedListener(mTextWatcher); mPlayButton = (ImageButton) findViewById(R.id.play); mPlayButton.setOnClickListener(mPlayListener); mRewindButton = (ImageButton) findViewById(R.id.rew); mRewindButton.setOnClickListener(mRewindListener); mFfwdButton = (ImageButton) findViewById(R.id.ffwd); mFfwdButton.setOnClickListener(mFfwdListener); mZoomInButton = (ImageButton) findViewById(R.id.zoom_in); mZoomInButton.setOnClickListener(mZoomInListener); mZoomOutButton = (ImageButton) findViewById(R.id.zoom_out); mZoomOutButton.setOnClickListener(mZoomOutListener); mSaveButton = (ImageButton) findViewById(R.id.save); mSaveButton.setOnClickListener(mSaveListener); TextView markStartButton = (TextView) findViewById(R.id.mark_start); markStartButton.setOnClickListener(mMarkStartListener); TextView markEndButton = (TextView) findViewById(R.id.mark_end); markEndButton.setOnClickListener(mMarkStartListener); enableDisableButtons(); mWaveformView = (WaveformView) findViewById(R.id.waveform); mWaveformView.setListener(this); mInfo = (TextView) findViewById(R.id.info); mInfo.setText(mCaption); mMaxPos = 0; mLastDisplayedStartPos = -1; mLastDisplayedEndPos = -1; if (mSoundFile != null) { mWaveformView.setSoundFile(mSoundFile); mWaveformView.recomputeHeights(mDensity); mMaxPos = mWaveformView.maxPos(); } mStartMarker = (MarkerView) findViewById(R.id.startmarker); mStartMarker.setListener(this); mStartMarker.setAlpha(255); mStartMarker.setFocusable(true); mStartMarker.setFocusableInTouchMode(true); mStartVisible = true; mEndMarker = (MarkerView) findViewById(R.id.endmarker); mEndMarker.setListener(this); mEndMarker.setAlpha(255); mEndMarker.setFocusable(true); mEndMarker.setFocusableInTouchMode(true); mEndVisible = true; final AlertDialog.Builder nomp3 = new AlertDialog.Builder(this); nomp3.setCancelable(true); nomp3.setMessage("Filters Only work on wav files at this time"); nomp3.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); Button echo = (Button) findViewById(R.id.echobutton); echo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.echo(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension, 200, .6, false); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension); } else nomp3.show(); } }); Button high = (Button) findViewById(R.id.highbutton); high.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension, true, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension); } else nomp3.show(); } }); Button low = (Button) findViewById(R.id.Lowbutton); low.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension, false, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension); } else nomp3.show(); } }); Button speedup = (Button) findViewById(R.id.up); speedup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.decreaseTimescaleIncreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension); } else nomp3.show(); } }); Button speeddown = (Button) findViewById(R.id.down); speeddown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.increaseTimescaleDecreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension); } else nomp3.show(); } }); Button record = (Button) findViewById(R.id.record); record.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { Intent i = new Intent(); i.setClassName("com.Beat", "com.Beat.recordScreen"); startActivity(i); exit(); } }); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); updateDisplay(); }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
/** * */// ww w . j a v a 2 s . c om private void configureOrientation() { String rotateDefault; if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; else rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) rotate = rotateDefault; // request a forced orientation if requested by user if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_SENSOR.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); forcedOrientation = false; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); forcedOrientation = false; } }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
private int getOrientationForRotation() { int ori = ActivityInfo.SCREEN_ORIENTATION_USER; int rotation = this.getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_0) { ori = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (rotation == Surface.ROTATION_90) { ori = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (rotation == Surface.ROTATION_180) { ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else if (rotation == Surface.ROTATION_270) { ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; }/*from www . j a va 2 s. co m*/ return ori; }
From source file:au.gov.ga.worldwind.androidremote.client.Remote.java
public void setLockLandscape(boolean lockLandscape) { this.lockLandscape = lockLandscape; setRequestedOrientation(//from w w w. j a v a 2 s. com lockLandscape ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR); }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
public final int intoOrientation(int flag) { int or = ActivityInfo.SCREEN_ORIENTATION_USER; if (flag == 1) {// portrait or = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } else if (flag == 2) {// landscape or = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (flag == 4) {// reverse portrait or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else if (flag == 8) {// reverse landscape or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else if (flag == 15) {// sensor or = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; } else {/* ww w . j a v a 2 s . c o m*/ ; } return or; }
From source file:com.aimfire.demo.CameraActivity.java
@Override public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) Log.d(TAG, "create CameraActivity"); checkPreferences();//w w w .ja v a 2s. c o m /* * keep the screen on until we turn off the flag */ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); /* * Obtain the FirebaseAnalytics instance. */ mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); /* * disable nfc push */ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this); /* * get the natural orientation of this device. need to be called before * we fix the display orientation */ mNaturalOrientation = getDeviceDefaultOrientation(); /* * force CameraActivity in landscape because it is the natural * orientation of the camera sensor */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mLandscapeOrientation = getDeviceLandscapeOrientation(); Bundle extras = getIntent().getExtras(); if (extras == null) { if (BuildConfig.DEBUG) Log.e(TAG, "onCreate: error create CameraActivity, wrong parameter"); finish(); return; } /* * make sure we have camera */ if (!checkCameraHardware(this)) { if (BuildConfig.DEBUG) Log.e(TAG, "onCreate: error create CameraActivity, cannot find camera!!!"); finish(); return; } mIsLeft = extras.getBoolean(MainConsts.EXTRA_ISLEFT); mView3DButton = (ImageButton) findViewById(R.id.view3D_button); mExitButton = (ImageButton) findViewById(R.id.exit_button); mCaptureButton = (ImageButton) findViewById(R.id.capture_button); mPvButton = (ImageButton) findViewById(R.id.switch_photo_video_button); mFbButton = (ImageButton) findViewById(R.id.switch_front_back_button); mLevelButton = (Button) findViewById(R.id.level_button); mModeButton = (ImageButton) findViewById(R.id.mode_button); if (mIsLeft) { mCaptureButton.setImageResource(R.drawable.ic_photo_camera_black_24dp); } else { mCaptureButton.setVisibility(View.INVISIBLE); mPvButton.setVisibility(View.INVISIBLE); mFbButton.setVisibility(View.INVISIBLE); } mView3DButton.setOnClickListener(oclView3D); mExitButton.setOnClickListener(oclExit); mPvButton.setOnClickListener(oclPV); mFbButton.setOnClickListener(oclFB); mCaptureButton.setOnClickListener(oclCapture); /* * we could get here in two ways: 1) directly after MainActivity -> * AimfireService sync with remote device. 2) we could get here * because of a switch from video to photo mode. * * mSyncTimeUs is determined by AudioContext. each device * calculates it, and they correspond to the same absolute moment * in time */ mSyncTimeUs = extras.getLong(MainConsts.EXTRA_SYNCTIME, -1); /* * start camera client object in a dedicated thread */ mCameraClient = new CameraClient(Camera.CameraInfo.CAMERA_FACING_BACK, PHOTO_DIMENSION[0], PHOTO_DIMENSION[1]); /* * create our SurfaceView for preview */ mPreview = new CameraPreview(this); mPreviewLayout = (AspectFrameLayout) findViewById(R.id.cameraPreview_frame); mPreviewLayout.addView(mPreview); mPreviewLayout.setOnTouchListener(otl); if (BuildConfig.DEBUG) Log.d(TAG, "add camera preview view"); mShutterSoundPlayer = MediaPlayer.create(this, Uri.parse("file:///system/media/audio/ui/camera_click.ogg")); /* * place UI controls at their initial, default orientation */ adjustUIControls(0); /* * load the latest thumbnail to the view3D button */ loadCurrThumbnail(); /* * initializes AimfireService, and bind to it */ mAimfireServiceConn = new AimfireServiceConn(this); /* * binding doesn't happen until later. wait for it to happen in another * thread and connect to p2p peer if necessary */ (new Thread(mAimfireServiceInitTask)).start(); if (ADD_LOGO) { /* * init our logo that will be embedded in processed photos */ AssetManager assetManager = getAssets(); p.getInstance().a(assetManager, MainConsts.MEDIA_3D_RAW_PATH, "logo.png"); } /* * register for AimfireService message broadcast */ LocalBroadcastManager.getInstance(this).registerReceiver(mAimfireServiceMsgReceiver, new IntentFilter(MainConsts.AIMFIRE_SERVICE_MESSAGE)); /* * register for intents sent by the media processor service */ LocalBroadcastManager.getInstance(this).registerReceiver(mPhotoProcessorMsgReceiver, new IntentFilter(MainConsts.PHOTO_PROCESSOR_MESSAGE)); }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
@Override protected WebView createViewInstance(final ThemedReactContext reactContext) { final ReactWebView webView = new ReactWebView(reactContext); /**/*from w ww . j a va2 s. c om*/ * cookie? * 5.0???cookie,5.0?false * */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true); } webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); reactContext.getCurrentActivity().startActivity(intent); // DownloadManager.Request request = new DownloadManager.Request( // Uri.parse(url)); // // request.setMimeType(mimetype); // String cookies = CookieManager.getInstance().getCookie(url); // request.addRequestHeader("cookie", cookies); // request.addRequestHeader("User-Agent", userAgent); // request.allowScanningByMediaScanner(); //// request.setTitle() // request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! // request.setDestinationInExternalPublicDir( // Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName( // url, contentDisposition, mimetype)); // DownloadManager dm = (DownloadManager) reactContext.getCurrentActivity().getSystemService(DOWNLOAD_SERVICE); // dm.enqueue(request); // Toast.makeText(reactContext, "...", //To notify the Client that the file is being downloaded // Toast.LENGTH_LONG).show(); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage message) { if (ReactBuildConfig.DEBUG) { return super.onConsoleMessage(message); } // Ignore console logs in non debug builds. return true; } @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File imageFile = new File(storageDir, /* directory */ imageFileName + ".jpg" /* filename */ ); return imageFile; } public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent .resolveActivity(reactContext.getCurrentActivity().getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File FLog.e(ReactConstants.TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("*/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "?"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); reactContext.getCurrentActivity().startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); // final Intent galleryIntent = new Intent(Intent.ACTION_PICK); // galleryIntent.setType("image/*"); // final Intent chooserIntent = Intent.createChooser(galleryIntent, "Choose File"); // reactContext.getCurrentActivity().startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } @Override public void onShowCustomView(View view, CustomViewCallback callback) { if (mVideoView != null) { callback.onCustomViewHidden(); return; } // Store the view and it's callback for later, so we can dispose of them correctly mVideoView = view; mCustomViewCallback = callback; view.setBackgroundColor(Color.BLACK); getRootView().addView(view, FULLSCREEN_LAYOUT_PARAMS); webView.setVisibility(View.GONE); UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { // If the status bar is translucent hook into the window insets calculations // and consume all the top insets so no padding will be added under the status bar. View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); decorView.setOnApplyWindowInsetsListener(null); ViewCompat.requestApplyInsets(decorView); } }); reactContext.getCurrentActivity() .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } @Override public void onHideCustomView() { if (mVideoView == null) { return; } mVideoView.setVisibility(View.GONE); getRootView().removeView(mVideoView); mVideoView = null; mCustomViewCallback.onCustomViewHidden(); webView.setVisibility(View.VISIBLE); // View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); // // Show Status Bar. // int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; // decorView.setSystemUiVisibility(uiOptions); UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { // If the status bar is translucent hook into the window insets calculations // and consume all the top insets so no padding will be added under the status bar. View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); // decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { // @Override // public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // WindowInsets defaultInsets = v.onApplyWindowInsets(insets); // return defaultInsets.replaceSystemWindowInsets( // defaultInsets.getSystemWindowInsetLeft(), // 0, // defaultInsets.getSystemWindowInsetRight(), // defaultInsets.getSystemWindowInsetBottom()); // } // }); decorView.setOnApplyWindowInsetsListener(null); ViewCompat.requestApplyInsets(decorView); } }); reactContext.getCurrentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } private ViewGroup getRootView() { return ((ViewGroup) reactContext.getCurrentActivity().findViewById(android.R.id.content)); } }); reactContext.addLifecycleEventListener(webView); reactContext.addActivityEventListener(new ActivityEventListener() { @Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) { return; } Uri[] results = null; // Check that the response is a good one if (resultCode == Activity.RESULT_OK) { if (data == null) { // If there is not data, then we may have taken a photo if (mCameraPhotoPath != null) { results = new Uri[] { Uri.parse(mCameraPhotoPath) }; } } else { String dataString = data.getDataString(); if (dataString != null) { results = new Uri[] { Uri.parse(dataString) }; } } } if (results == null) { mFilePathCallback.onReceiveValue(new Uri[] {}); } else { mFilePathCallback.onReceiveValue(results); } mFilePathCallback = null; return; } @Override public void onNewIntent(Intent intent) { } }); mWebViewConfig.configWebView(webView); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setDefaultFontSize(16); webView.getSettings().setTextZoom(100); // Fixes broken full-screen modals/galleries due to body height being 0. webView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } return webView; }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
/********************************************** * /*from w ww .j ava 2s .c o m*/ * Called when the activity is first created * **********************************************/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; System.gc(); //Log.i("PRFMC", "1"); /* * Window Properties */ //requestWindowFeature(Window.FEATURE_PROGRESS); //requestWindowFeature(Window.PROGRESS_VISIBILITY_ON); requestWindowFeature(Window.FEATURE_NO_TITLE); /* * Blur&Dim the BG */ // Have the system blur any windows behind this one. // getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, // WindowManager.LayoutParams.FLAG_BLUR_BEHIND); //// getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, //// WindowManager.LayoutParams.FLAG_DITHER); // getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, // WindowManager.LayoutParams.FLAG_DIM_BEHIND); // WindowManager.LayoutParams params = getWindow().getAttributes(); // params.dimAmount = 0.625f; // getWindow().setAttributes(params); // Resources.Theme theme = getTheme(); // theme.dump(arg0, arg1, arg2) //setContentView(R.layout.songfest_main); //Log.i("PRFMC", "2"); /* * Initialize Display */ WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); this.display = windowManager.getDefaultDisplay(); //Log.i("PRFMC", "3"); /* * Set Bug Report Handler */ fdHandler = new FilexDefaultExceptionHandler(this); /* * Check if Album Art Directory exists */ checkAlbumArtDirectory(); checkConcertDirectory(); checkPreferencesDirectory(); checkBackgroundDirectory(); //Log.i("PRFMC", "7"); /* * Get Preferences */ readPreferences(); /* * Force landscape or auto-rotate orientation if user requested */ if (alwaysLandscape) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (autoRotate) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); /* * Create UI and initialize UI vars */ setContentView(R.layout.songfest_main); //getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //if (true) return; //if(true) // return; //Log.i("PRFMC", "4"); initializeAnimations(); //Log.i("PRFMC", "5"); initializeUiVariables(); //Log.i("PRFMC", "6"); /* * Set Background */ setBackground(); /* * Set Current View */ switch (VIEW_STATE) { case LIST_EXPANDED_VIEW: setListExpandedView(); break; case FULLSCREEN_VIEW: setFullScreenView(); break; default: setNormalView(); break; } // AlphaAnimation aAnim = new AlphaAnimation(0.0f, 0.92f); // aAnim.setFillAfter(true); // aAnim.setDuration(200); // mainUIContainer.startAnimation(aAnim); /* * Check for SD Card */ if (!android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { Dialog noSDDialog = new Dialog(this); noSDDialog.setTitle("SD Card Error!"); noSDDialog.setContentView(R.layout.no_sd_alert_layout); noSDDialog.show(); return; } /* * Get a Content Resolver to browse * the phone audio database */ contentResolver = getContentResolver(); /* * Get Preferences */ //SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); settings = new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH); // Shuffle boolean shuffle = settings.getBoolean("Shuffle", false); this.SHUFFLE = shuffle; //Playlist if (playlist == constants.PLAYLIST_NONE) playlist = settings.getLong(constants.PREF_KEY_PLAYLIST, constants.PLAYLIST_ALL); Log.i("PLAYLIST PREF", constants.PREF_KEY_PLAYLIST + " " + constants.PLAYLIST_ALL + " " + playlist); /* * Check if the MediaScanner is scanning */ // ProgressDialog pD = null; // while(isMediaScannerScanning(this, contentResolver) == true){ // if(pD == null){ // pD = new ProgressDialog(this); // pD.setTitle("Scanning Media"); // pD.setMessage("Wait please..."); // pD.show(); // } // try { // wait(2000); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // if(pD != null) // pD.dismiss(); /* * Initialize mediaPlayer */ //this.mediaPlayer = new MediaPlayer(); //this.mediaPlayer.setOnCompletionListener(songCompletedListener); /* * Initialize (or connect to) BG Service * - when connected it will call the method getCurrentPlaying() * and will cause the Service to reset its albumCursor */ initializeService(); //Log.i("PRFMC", "8"); musicChangedIntentReceiver = new MusicChangedIntentReceiver(); albumChangedIntentReceiver = new AlbumChangedIntentReceiver(); mediaButtonPauseIntentReceiver = new MediaButtonPauseIntentReceiver(); mediaButtonPlayIntentReceiver = new MediaButtonPlayIntentReceiver(); registerReceiver(musicChangedIntentReceiver, musicChangedIntentFilter); //Log.i("PRFMC", "9"); registerReceiver(albumChangedIntentReceiver, albumChangedIntentFilter); //Log.i("PRFMC", "10"); registerReceiver(mediaButtonPauseIntentReceiver, mediaButtonPauseIntentFilter); registerReceiver(mediaButtonPlayIntentReceiver, mediaButtonPlayIntentFilter); // calls also getCurrentPlaying() upon connection /* * Register Media Button Receiver */ // mediaButtonIntentReceiver = new MediaButtonIntentReceiver(); // registerReceiver(mediaButtonIntentReceiver, new IntentFilter("android.intent.action.MEDIA_BUTTON")); /* * Get album information on a new * thread */ //new Thread(){ // public void run(){ getAlbums(false); //Log.i("PRFMC", "11"); // } //}.start(); /* * Check for first time run ---------- * * Save Software Version * & * Show Help Screen */ // if(!settings.contains("Version")){ // Editor settingsEditor = settings.edit(); // settingsEditor.putLong("Version", VERSION); // settingsEditor.commit(); // this.hideMainUI(); // this.showHelpUI(); // } Log.i("DBG", "Version - " + (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0) + " - " + VERSION); if (!(new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).contains("Version") || (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0) < VERSION) { (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).putLong("Version", VERSION); /* * Clear previous Album Art */ Builder aD = new AlertDialog.Builder(context); aD.setTitle("New Version"); aD.setMessage( "The new version of RockOn supports album art download from higher quality sources. Do you want to download art now? " + "Every 10 albums will take aproximately 1 minute to download. " + "(You can always do this later by choosing the 'Get Art' menu option)"); aD.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //(new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).putLong("artImportDate", 0); try { File albumArtDir = new File(FILEX_ALBUM_ART_PATH); String[] fileList = albumArtDir.list(); File albumArtFile; for (int i = 0; i < fileList.length; i++) { albumArtFile = new File(albumArtDir.getAbsolutePath() + "/" + fileList[i]); albumArtFile.delete(); } checkAlbumArtDirectory(); triggerAlbumArtFetching(); } catch (Exception e) { e.printStackTrace(); } } }); aD.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); aD.show(); /* * Version 2 specific default preference changes */ // version 2 specific if (albumCursor.getCount() > 100) (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)) .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, false); else (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)) .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, true); readPreferences(); albumAdapter.showArtWhileScrolling = showArtWhileScrolling; albumAdapter.showFrame = showFrame; // /* * Show help screen */ this.hideMainUI(); this.showHelpUI(); } else { /* * Run albumArt getter in background */ long lastAlbumArtImportDate = settings.getLong("artImportDate", 0); Log.i("SYNCTIME", lastAlbumArtImportDate + " + " + this.ART_IMPORT_INTVL + " < " + System.currentTimeMillis()); if (lastAlbumArtImportDate + this.ART_IMPORT_INTVL < System.currentTimeMillis()) { triggerAlbumArtFetching(); } //Log.i("PRFMC", "13"); } }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
public void setOrientation(MBPage page) { MBPage.OrientationPermission orientationPermissions = page.getOrientationPermissions(); /*// w w w .j ava2 s . co m * If no orientation permissions have been set on a Page level we want to use the permission that is defined in the the AndroidManifest.xml (if any) */ if (orientationPermissions == MBPage.OrientationPermission.UNDEFINED) { if (_defaultScreenOrientation != getRequestedOrientation()) { setRequestedOrientation(_defaultScreenOrientation); } } else if (orientationPermissions == MBPage.OrientationPermission.ANY) { if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_SENSOR) { Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to SENSOR"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } } else if (orientationPermissions == OrientationPermission.PORTRAIT) { Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to PORTRAIT"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientationPermissions == OrientationPermission.LANDSCAPE) { Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to LANDSCAPE"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }
From source file:com.android.purenexussettings.TinkerActivity.java
public static void lockCurrentOrientation(Activity activity) { int currentRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int orientation = activity.getResources().getConfiguration().orientation; int frozenRotation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; switch (currentRotation) { case Surface.ROTATION_0: frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break;/*from ww w. jav a 2s . c o m*/ case Surface.ROTATION_90: frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: frozenRotation = orientation == Configuration.ORIENTATION_LANDSCAPE ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: frozenRotation = orientation == Configuration.ORIENTATION_PORTRAIT ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; } activity.setRequestedOrientation(frozenRotation); }