List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:com.android.launcher3.Launcher.java
/** * Finds all the views we need and configure them properly. *//*from w w w.j a va 2 s.c om*/ private void setupViews() { mLauncherView = findViewById(R.id.launcher); mDragLayer = (DragLayer) findViewById(R.id.drag_layer); mFocusHandler = mDragLayer.getFocusIndicatorHelper(); mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace); mQsbContainer = mDragLayer.findViewById( mDeviceProfile.isVerticalBarLayout() ? R.id.workspace_blocked_row : R.id.qsb_container); mWorkspace.initParentViews(mDragLayer); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); // Setup the drag layer mDragLayer.setup(this, mDragController, mAllAppsController); // Setup the hotseat mHotseat = (Hotseat) findViewById(R.id.hotseat); if (mHotseat != null) { mHotseat.setOnLongClickListener(this); } // Setup the overview panel setupOverviewPanel(); setuphome(); // Setup the workspace mWorkspace.setHapticFeedbackEnabled(false); mWorkspace.setOnLongClickListener(this); mWorkspace.setup(mDragController); // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the // default state, otherwise we will update to the wrong offsets in RTL mWorkspace.lockWallpaperToDefaultPage(); mDragController.addDragListener(mWorkspace); // Get the search/delete/uninstall bar mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar); // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); } else { mAppsView.setSearchBarController(new DefaultAppSearchController()); } // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setDragScoller(mWorkspace); mDragController.setScrollView(mDragLayer); mDragController.setMoveTarget(mWorkspace); mDragController.addDropTarget(mWorkspace); mDropTargetBar.setup(mDragController); if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace); } if (TestingUtils.MEMORY_DUMP_ENABLED) { TestingUtils.addWeightWatcher(this); } FrameLayout gBar = (FrameLayout) findViewById(R.id.g_bar); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenXDimension(this) - Utils.getScreenXDimension(this) / 6; gBar.setLayoutParams(gBarLayout); } else { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenYDimension(this) - Utils.getScreenYDimension(this) / 12; gBar.setLayoutParams(gBarLayout); } gBar.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); ImageView gSearch = (ImageView) findViewById(R.id.g_search); gSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); FrameLayout.LayoutParams gSearchLayout = (FrameLayout.LayoutParams) gSearch.getLayoutParams(); gSearchLayout.leftMargin = 30; gSearch.setLayoutParams(gSearchLayout); ImageView gSearchMic = (ImageView) findViewById(R.id.g_search_mic); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); gSearchMic.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); startActivityForResult(intent, RECOGNIZER_REQ_CODE); } }); } else { gSearchMic.setVisibility(View.GONE); } FrameLayout.LayoutParams gSearchMicLayout = (FrameLayout.LayoutParams) gSearchMic.getLayoutParams(); gSearchMicLayout.rightMargin = 30; gSearchMic.setLayoutParams(gSearchMicLayout); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Utilities.isAllowNightModePrefEnabled(getApplicationContext())) { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape_night)); gSearch.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon_night)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); gSearchMic .setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic_night)); gSearchMic.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); } else { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape)); gSearch.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); gSearchMic.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic)); gSearchMic .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); } } if (!Utilities.isAllowPersisentSearchBarPrefEnabled(getApplicationContext())) { gBar.setVisibility(View.GONE); gSearch.setVisibility(View.GONE); gSearchMic.setVisibility(View.GONE); } else { gBar.setVisibility(View.VISIBLE); gSearch.setVisibility(View.VISIBLE); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); } else { gSearchMic.setVisibility(View.GONE); } } }
From source file:github.why168.swipeback.view.SwipeBackLayout.java
/** * ??// w w w.j a va 2 s. c o m * * @param activity * @return */ public int getNavigationBarHeight(Activity activity) { int navigationBarHeight = 0; Resources resources = activity.getResources(); int resourceId = resources .getIdentifier(resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); if (resourceId > 0 && checkDeviceHasNavigationBar(activity)) { navigationBarHeight = resources.getDimensionPixelSize(resourceId); } return navigationBarHeight; }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * Opens a camera, and attempts to establish preview mode at the specified width * and height.// ww w . ja va 2s. c o m * <p> * Sets mCameraPreviewWidth and mCameraPreviewHeight to the actual width/height * of the preview. */ private boolean openCamera(int desiredFacing, int videoQuality) { if (mCamera != null) { if (BuildConfig.DEBUG) Log.e(TAG, "openCamera: camera already initialized"); FirebaseCrash.report(new Exception("CamcorderActivity openCamera: camera already initialized")); return false; } final Camera.CameraInfo info = new Camera.CameraInfo(); /* * Try to find camera with desired facing */ int numCameras = Camera.getNumberOfCameras(); if (numCameras == 0) { if (BuildConfig.DEBUG) Log.e(TAG, "openCamera: No camera found, exiting"); FirebaseCrash.report(new Exception("openCamera: No camera found, exiting")); return false; } mCameraId = -1; for (int i = 0; i < numCameras; i++) { Camera.getCameraInfo(i, info); if (info.facing == desiredFacing) { mCameraId = i; break; } } if (mCameraId == -1) { if (BuildConfig.DEBUG) Log.d(TAG, "openCamera: No camera with desired facing found; opening default"); FirebaseCrash.report(new Exception("openCamera: No camera with desired facing found; opening default")); mCameraId = 0; } try { mCamera = Camera.open(mCameraId); } catch (RuntimeException e) { if (BuildConfig.DEBUG) Log.e(TAG, "openCamera: cannot open camera!"); FirebaseCrash.report(e); return false; } mCameraOrientation = info.orientation; mCameraFacing = info.facing; mCameraParams = mCamera.getParameters(); CameraUtils.setCamParams(mCameraParams); /* * if we can find a supported video/preview size that's the same as our desired size, * use it. otherwise, use the best quality supported by the camera. */ mSupportedVideoQualities = CameraUtils.getSupportedVideoQualities(); if ((mSupportedVideoQualities & (1 << mQualityPref)) == 0) { if (BuildConfig.DEBUG) Log.d(TAG, "openCamera: desired quality " + mQualityPref + " not supported"); mQualityPref = CameraUtils.getMaxVideoQuality(); /* * since this device doesn't support whatever quality preference we had before, * we save the best quality that it does support */ updateQualityPref(mQualityPref); } mCameraParams.setPreviewSize(MainConsts.VIDEO_DIMENSIONS[mQualityPref][0], MainConsts.VIDEO_DIMENSIONS[mQualityPref][1]); AspectFrameLayout afl = (AspectFrameLayout) findViewById(R.id.cameraPreview_frame); afl.setAspectRatio((float) MainConsts.VIDEO_DIMENSIONS[mQualityPref][0] / (float) MainConsts.VIDEO_DIMENSIONS[mQualityPref][1]); /* * give the camera a hint that we're recording video. this can have a big * impact on frame rate. */ mCameraParams.setRecordingHint(true); /* * disable all the automatic settings, in the hope that frame rate will * be less variable * * TODO: if any of the default modes are not available then we need to * sync it with the remote device */ List<String> modes; modes = mCameraParams.getSupportedFocusModes(); if (modes != null) { for (String mode : modes) { if (mode.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) { mCameraParams.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); break; } } } modes = mCameraParams.getSupportedFlashModes(); if (modes != null) { for (String mode : modes) { if (mode.contains(Camera.Parameters.FLASH_MODE_OFF)) { mCameraParams.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); break; } } } /* modes = mCameraParams.getSupportedWhiteBalance(); if(modes != null) { for(String mode : modes) { if(mode.contains(Camera.Parameters.WHITE_BALANCE_FLUORESCENT)) { mCameraParams.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_FLUORESCENT); break; } } } modes = mCameraParams.getSupportedSceneModes(); if(modes != null) { for(String mode : modes) { if(mode.contains(Camera.Parameters.SCENE_MODE_PORTRAIT)) { mCameraParams.setSceneMode(Camera.Parameters.SCENE_MODE_PORTRAIT); break; } } } */ /* * zoom can impact view angle. we should set it to 0 if it's not */ if (mCameraParams.isZoomSupported()) { int zoom = mCameraParams.getZoom(); if (zoom != 0) { if (BuildConfig.DEBUG) Log.d(TAG, "getViewAngle: camera zoom = " + zoom + ", forcing to zero"); mCameraParams.setZoom(0); } } /* * leave the frame rate set to default */ mCamera.setParameters(mCameraParams); /* int[] fpsRange = new int[2]; mCameraParams.getPreviewFpsRange(fpsRange); String previewFacts = VIDEO_DIMENSIONS[mQualityPref][0] + "x" + VIDEO_DIMENSIONS[mQualityPref][1]; if (fpsRange[0] == fpsRange[1]) { previewFacts += " @" + (fpsRange[0] / 1000.0) + "fps"; } else { previewFacts += " @[" + (fpsRange[0] / 1000.0) + " - " + (fpsRange[1] / 1000.0) + "] fps"; } TextView text = (TextView) findViewById(R.id.cameraParams_text); text.setText(previewFacts); */ if (mNaturalOrientation == Configuration.ORIENTATION_PORTRAIT) { if (((info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) && (mLandscapeOrientation == mCameraOrientation)) || ((info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) && (mLandscapeOrientation != mCameraOrientation))) { mCamera.setDisplayOrientation(180); mCameraOrientation = (mCameraOrientation + 180) % 360; } } if (mOrientationEventListener == null) { mOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { @Override public void onOrientationChanged(int deviceOrientation) { if (deviceOrientation == ORIENTATION_UNKNOWN) return; handleOrientationChanged(deviceOrientation); } }; if (mOrientationEventListener.canDetectOrientation()) { mOrientationEventListener.enable(); } } Runnable forceOrientationCalcRunnable = new Runnable() { public void run() { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { int deviceOrientation = mCurrDeviceOrientation; mCurrDeviceOrientation = -1; handleOrientationChanged(deviceOrientation); } }, 100); } }; runOnUiThread(forceOrientationCalcRunnable); return true; }
From source file:com.aimfire.demo.CamcorderActivity.java
public void handleOrientationChanged(int deviceOrientation) { int roundedOrientation = ((deviceOrientation + 45) / 90 * 90) % 360; /*/*from ww w . jav a 2 s .c o m*/ * show a level guide to help user position device */ if (deviceOrientation > 315) showDeviationFromLevel(deviceOrientation - roundedOrientation - 360); else showDeviationFromLevel(deviceOrientation - roundedOrientation); if (roundedOrientation != mCurrDeviceOrientation) { if (BuildConfig.DEBUG) Log.d(TAG, "device orientation change, new rotation = " + roundedOrientation); adjustUIControls((360 + mLandscapeOrientation - roundedOrientation) % 360); mCurrDeviceOrientation = roundedOrientation; int rotation; if (mNaturalOrientation == Configuration.ORIENTATION_PORTRAIT) { if (mCameraFacing == Camera.CameraInfo.CAMERA_FACING_BACK) { rotation = 360 - (mCameraOrientation + roundedOrientation) % 360; } else { rotation = 360 - (360 + mCameraOrientation - roundedOrientation) % 360; } } else { if (mCameraFacing == Camera.CameraInfo.CAMERA_FACING_BACK) { rotation = 360 - roundedOrientation; } else { rotation = roundedOrientation; } } /* * rotation could be 360 from above, convert it to 0. */ rotation %= 360; /* * now tell renderer */ final int fRotation = rotation; mGLView.queueEvent(new Runnable() { @Override public void run() { mRenderer.setCameraPreviewSize(mQualityPref, fRotation); } }); } }
From source file:com.ichi2.anki2.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefRecord = preferences.getBoolean("record", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;//from ww w. j a v a 2s. c o m mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mshowNextReviewTime = preferences.getBoolean("showNextReviewTime", true); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } return preferences; }
From source file:com.nit.vicky.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;//from w w w . jav a 2s . c o m mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeImageSize = preferences.getInt("relativeImageSize", 100); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", true); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mPrefCenterVertically = preferences.getBoolean("centerVertically", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } // These are preferences we pull out of the collection instead of SharedPreferences try { mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes"); mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts"); } catch (JSONException e) { throw new RuntimeException(); } return preferences; }
From source file:com.hichinaschool.flashcards.anki.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;/*from www . j a v a2s .c o m*/ mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeImageSize = preferences.getInt("relativeImageSize", 100); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", false); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mPrefCenterVertically = preferences.getBoolean("centerVertically", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } // These are preferences we pull out of the collection instead of SharedPreferences try { mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes"); mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts"); } catch (JSONException e) { throw new RuntimeException(); } return preferences; }
From source file:jmri.enginedriver.threaded_application.java
public boolean setActivityOrientation(Activity activity, Boolean webPref) { String to;// ww w . jav a 2 s . com to = prefs.getString("ThrottleOrientation", activity.getApplicationContext().getResources() .getString(R.string.prefThrottleOrientationDefaultValue)); if (to.equals("Auto-Web")) { int orient = activity.getResources().getConfiguration().orientation; if ((webPref && orient == Configuration.ORIENTATION_PORTRAIT) || (!webPref && orient == Configuration.ORIENTATION_LANDSCAPE)) return (false); } else if (webPref) { to = prefs.getString("WebOrientation", activity.getApplicationContext().getResources() .getString(R.string.prefWebOrientationDefaultValue)); } int co = activity.getRequestedOrientation(); if (to.equals("Landscape") && (co != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (to.equals("Auto-Rotate") && (co != ActivityInfo.SCREEN_ORIENTATION_SENSOR)) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); else if (to.equals("Portrait") && (co != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); return true; }
From source file:dentex.youtube.downloader.DashboardActivity.java
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { isLandscape = true;//w w w . j a v a2 s. c o m } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { isLandscape = false; } }
From source file:com.ichi2.anki2.DeckPicker.java
/** Handles item selections */ @Override//from w w w .j a v a 2s. co m public boolean onOptionsItemSelected(MenuItem item) { Resources res = getResources(); switch (item.getItemId()) { case MENU_HELP: showDialog(DIALOG_SELECT_HELP); return true; case MENU_SYNC: sync(); return true; case MENU_ADD_NOTE: addNote(); return true; case MENU_STATISTICS: showDialog(DIALOG_SELECT_STATISTICS_TYPE); return true; case MENU_CARDBROWSER: openCardBrowser(); return true; case MENU_CREATE_DECK: StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this); builder2.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder2.setView(mDialogEditText, false, false); builder2.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String deckName = mDialogEditText.getText().toString().replaceAll("[\'\"\\n\\r\\[\\]\\(\\)]", ""); Log.i(AnkiDroidApp.TAG, "Creating deck: " + deckName); AnkiDroidApp.getCol().getDecks().id(deckName, true); loadCounts(); } }); builder2.setNegativeButton(res.getString(R.string.cancel), null); builder2.create().show(); return true; case MENU_CREATE_DYNAMIC_DECK: StyledDialog.Builder builder3 = new StyledDialog.Builder(DeckPicker.this); builder3.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames(); int n = 1; String cramDeckName = "Cram 1"; while (names.contains(cramDeckName)) { n++; cramDeckName = "Cram " + n; } mDialogEditText.setText(cramDeckName); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder3.setView(mDialogEditText, false, false); builder3.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { long id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString()); openStudyOptions(id, new Bundle()); } }); builder3.setNegativeButton(res.getString(R.string.cancel), null); builder3.create().show(); return true; case MENU_ABOUT: startActivity(new Intent(DeckPicker.this, Info.class)); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(DeckPicker.this, ActivityTransitionAnimation.RIGHT); } return true; case MENU_ADD_SHARED_DECK: if (AnkiDroidApp.getCol() != null) { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String hkey = preferences.getString("hkey", ""); if (hkey.length() == 0) { showDialog(DIALOG_USER_NOT_LOGGED_IN_ADD_SHARED_DECK); } else { addSharedDeck(); } } return true; case MENU_IMPORT: showDialog(DIALOG_IMPORT_HINT); return true; case MENU_PREFERENCES: startActivityForResult(new Intent(DeckPicker.this, Preferences.class), PREFERENCES_UPDATE); return true; case MENU_FEEDBACK: Intent i = new Intent(DeckPicker.this, Feedback.class); i.putExtra("request", REPORT_FEEDBACK); startActivityForResult(i, REPORT_FEEDBACK); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT); } return true; case CHECK_DATABASE: integrityCheck(); return true; case StudyOptionsActivity.MENU_ROTATE: if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } return true; case StudyOptionsActivity.MENU_NIGHT: SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this); if (preferences.getBoolean("invertedColors", false)) { preferences.edit().putBoolean("invertedColors", false).commit(); item.setIcon(R.drawable.ic_menu_night); } else { preferences.edit().putBoolean("invertedColors", true).commit(); item.setIcon(R.drawable.ic_menu_night_checked); } return true; case MENU_REUPGRADE: restartUpgradeProcess(); return true; default: return super.onOptionsItemSelected(item); } }