List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL
int SCREENLAYOUT_SIZE_SMALL
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL.
Click Source Link
From source file:com.honeycomb.cocos2dx.Soccer.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(com.honeycomb.cocos2dx.R.layout.main); interstitial = new InterstitialAd(this); interstitial.setAdUnitId("ca-app-pub-2442035138707094/8795197567"); activity = Soccer.this; AndroidNDKHelper.SetNDKReciever(this); Cocos2dxGLSurfaceView mGLView = (Cocos2dxGLSurfaceView) findViewById( com.honeycomb.cocos2dx.R.id.game_gl_surfaceview); mGLView.setEGLContextClientVersion(2); mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); new Handler().postDelayed(new Runnable() { @Override/* w w w . j a va 2 s . c om*/ public void run() { Soccer.this.runOnUiThread(new Runnable() { @Override public void run() { findViewById(com.honeycomb.cocos2dx.R.id.logolayout).setVisibility(View.GONE); } }); } }, 3000); iapSetup = new IAPSetup(); mIABHelper = iapSetup.mIABHelper; if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { isLargeDevice = true; } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { isLargeDevice = true; } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { isLargeDevice = false; } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { isLargeDevice = false; } gamePrefrence = getSharedPreferences("null", MODE_PRIVATE); }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL & (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }//from ww w. j a va 2s.co m SharedPreferences usertheme = getSharedPreferences("theme", 0); int newTheme = usertheme.getInt("theme", 2); Utils.onActivityCreateSetTheme(this, newTheme); SharedPreferences userlang = getSharedPreferences("lang", 0); String newlang = userlang.getString("lang", Locale.getDefault().getLanguage()); Setlanguage.updateLanguage(getApplicationContext(), newlang); GestureOverlayView gestureOverlayView = new GestureOverlayView(this); View inflate = getLayoutInflater().inflate(R.layout.view, null); gestureOverlayView.addView(inflate); gestureOverlayView.addOnGesturePerformedListener(this); gestureOverlayView.setGestureColor(Color.TRANSPARENT); gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT); gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures); if (!gestureLib.load()) { finish(); } requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(gestureOverlayView); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); ImageView title_image = (ImageView) findViewById(R.id.title_image); title_image.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify))); startActivity(browse); } }); // setContentView(R.layout.view); // TODO: Add Loading dialog SharedPreferences setvmassage = getSharedPreferences("dialog", 0); boolean dialogShown = setvmassage.getBoolean("dialogShown", false); if (!dialogShown) { // prepare the alert box AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertbox.setMessage(R.string.view_massage); alertbox.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); alertbox.setCancelable(false); alertbox.show(); SharedPreferences.Editor editor = setvmassage.edit(); editor.putBoolean("dialogShown", true); editor.commit(); } // Init waiting dialog showWaitingDialog(); initLayoutAndControls(); }
From source file:de.androvdr.activities.AndroVDR.java
public void initWorkspaceView(Bundle savedInstanceState) { if (!Preferences.alternateLayout) setTheme(R.style.Theme_Original); logger.debug("Model: {}", Build.MODEL); logger.debug("SDK Version: {}", Build.VERSION.SDK_INT); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); logger.debug("Width: {}", metrics.widthPixels); logger.debug("Height: {}", metrics.heightPixels); logger.debug("Density: {}", metrics.densityDpi); Configuration conf = getResources().getConfiguration(); boolean screenSmall = ((conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL); boolean screenNormal = ((conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_NORMAL) == Configuration.SCREENLAYOUT_SIZE_NORMAL); boolean screenLong = ((conf.screenLayout & Configuration.SCREENLAYOUT_LONG_YES) == Configuration.SCREENLAYOUT_LONG_YES); boolean screenLarge = ((conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_LARGE) == Configuration.SCREENLAYOUT_SIZE_LARGE); boolean screenXLarge = ((conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_XLARGE) == Configuration.SCREENLAYOUT_SIZE_XLARGE); logger.debug("Screen Small: {}", screenSmall); logger.debug("Screen Normal: {}", screenNormal); logger.debug("Screen Long: {}", screenLong); logger.debug("Screen Large: {}", screenLarge); logger.debug("Screen XLarge: {}", screenXLarge); if (screenSmall) Preferences.screenSize = Preferences.SCREENSIZE_SMALL; if (screenNormal) Preferences.screenSize = Preferences.SCREENSIZE_NORMAL; if (screenLong) Preferences.screenSize = Preferences.SCREENSIZE_LONG; if (screenLarge) Preferences.screenSize = Preferences.SCREENSIZE_LARGE; if (screenXLarge) Preferences.screenSize = Preferences.SCREENSIZE_XLARGE; logger.trace("Screen size: {}", Preferences.screenSize); // --- init default text size for buttons --- TextResizeButton.resetDefaultTextSize(); TextResizeButton rb = (TextResizeButton) LayoutInflater.from(this).inflate(R.layout.reference_button, null); if ((Preferences.screenSize >= Preferences.SCREENSIZE_LARGE) && (metrics.widthPixels > metrics.heightPixels)) rb.setTextSizeAsDefault(metrics.widthPixels / 2 / 5, 100); else/* w ww. j a v a 2s . com*/ rb.setTextSizeAsDefault(Math.min(metrics.widthPixels, metrics.heightPixels) / 4, 100); logger.debug("Default TextSize (px): {}", rb.getTextSize()); // --- landscape mode only on large displays --- if (Preferences.screenSize < Preferences.SCREENSIZE_LARGE) { logger.trace("setting SCREEN_ORIENTATION_PORTRAIT"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } setContentView(R.layout.remote_pager); mPagerAdapter = new PagerAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter); LinePageIndicator indicator = (LinePageIndicator) findViewById(R.id.titles); if (mPagerAdapter.getCount() > 1) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); int last = sp.getInt("remote_last_page", 0); if (last < mPagerAdapter.getCount()) indicator.setViewPager(mPager, last); else indicator.setViewPager(mPager); } else { indicator.setVisibility(View.GONE); } // --- show current channel in status bar --- if (Preferences.screenSize < Preferences.SCREENSIZE_XLARGE) mDevices.addOnSensorChangeListener("VDR.channel", 1, new OnSensorChangeListener() { @Override public void onChange(String result) { logger.trace("Channel: {}", result); Message msg = Message.obtain(mSensorHandler, SENSOR_CHANNEL); Bundle bundle = new Bundle(); bundle.putString(MSG_RESULT, result); msg.setData(bundle); msg.sendToTarget(); } }); mDevices.startSensorUpdater(0); }
From source file:timer.com.maydaysdk.MayDayMessageChatFragment.java
private int getScreenResolution() { int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; int height;/*from w w w. ja v a 2 s. c om*/ switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: height = MayDayConstant.SIZE_LARGE; break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: height = MayDayConstant.SIZE_NORMAL; break; case Configuration.SCREENLAYOUT_SIZE_SMALL: height = MayDayConstant.SIZE_SMALL; break; case Configuration.SCREENLAYOUT_SIZE_XLARGE: height = MayDayConstant.SIZE_XLARGE; break; default: height = MayDayConstant.SIZE_SMALL; } return height; }
From source file:gr.scify.newsum.ui.ViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // Init custom category sCustomCategory = NewSumUiActivity.getAppContext(this).getResources().getString(R.string.custom_category); // Always select landscape orientation for big screens (?) if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL & (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }/*from w ww.ja v a 2 s .c o m*/ SharedPreferences usertheme = getSharedPreferences("theme", 0); int newTheme = usertheme.getInt("theme", 2); Utils.onActivityCreateSetTheme(this, newTheme); }
From source file:org.solovyev.android.calculator.ActivityUi.java
private void addHelpInfo(@Nonnull Activity activity, @Nonnull View root) { if (CalculatorApplication.isMonkeyRunner(activity)) { if (root instanceof ViewGroup) { final TextView helperTextView = new TextView(activity); final DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); helperTextView.setTextSize(15); helperTextView.setTextColor(Color.WHITE); final Configuration c = activity.getResources().getConfiguration(); final StringBuilder helpText = new StringBuilder(); helpText.append("Size: "); if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) { helpText.append("xlarge"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) { helpText.append("large"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) { helpText.append("normal"); } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) { helpText.append("small"); } else { helpText.append("unknown"); }/*from w ww . ja v a 2 s. c o m*/ helpText.append(" (").append(dm.widthPixels).append("x").append(dm.heightPixels).append(")"); helpText.append(" Density: "); switch (dm.densityDpi) { case DisplayMetrics.DENSITY_LOW: helpText.append("ldpi"); break; case DisplayMetrics.DENSITY_MEDIUM: helpText.append("mdpi"); break; case DisplayMetrics.DENSITY_HIGH: helpText.append("hdpi"); break; case DisplayMetrics.DENSITY_XHIGH: helpText.append("xhdpi"); break; case DisplayMetrics.DENSITY_TV: helpText.append("tv"); break; } helpText.append(" (").append(dm.densityDpi).append(")"); helperTextView.setText(helpText); ((ViewGroup) root).addView(helperTextView, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } } }
From source file:com.oliversride.wordryo.Utils.java
public static boolean hasSmallScreen(Context context) { if (null == s_hasSmallScreen) { int screenLayout = context.getResources().getConfiguration().screenLayout; boolean hasSmallScreen = (screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL; s_hasSmallScreen = new Boolean(hasSmallScreen); }// www. j av a 2 s.c om return s_hasSmallScreen; }
From source file:uni.oulu.mentor.TeacherVisionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //DO NOT USE THIS SERVICE YET, DOES NOT WORK //Intent intent = new Intent(this, TeacherVisionService.class); //startService(intent); /*Idea from http://stackoverflow.com/questions/2902640/android-get-the-screen-resolution-pixels-as-integer-values */ @SuppressWarnings("deprecation") int screenWidthPix = getWindowManager().getDefaultDisplay().getWidth(); @SuppressWarnings("deprecation") int screenHeightPix = getWindowManager().getDefaultDisplay().getHeight(); /*Idea from http://stackoverflow.com/questions/5015094/determine-device-screen-category-small-normal-large-xlarge-using-code*/ if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) screenType = 3;//from w w w . ja v a2 s . c o m else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) screenType = 4; else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) screenType = 1; else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) screenType = 2; //screen density is investigated here DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int density = metrics.densityDpi; if (density == DisplayMetrics.DENSITY_HIGH) { //400 dpi is 600px if (screenType == 1) translationX = 240; //240 / 1.5 = 160 else if (screenType == 2) translationX = 315; //315 / 1.5 = 210 in dpi, screen 800 pix wide screen, needs about 1024/400 = 800/x => 312,5, 2.56 else if (screenType == 3) translationX = 540; //540 / 1.5 = 360 in dpi else if (screenType == 4) translationX = 600; //600 / 1.5 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_MEDIUM) { //400 dpi is 400px if (screenType == 1) translationX = 160; //160 / 1 = 160 in dpi else if (screenType == 2) translationX = 210; //210 / 1 = 210 in dpi else if (screenType == 3) translationX = 360; //360 / 1 = 360 in dpi else if (screenType == 4) translationX = 400; //400 / 1 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_LOW) { //400 dpi is 300px if (screenType == 1) translationX = 120; //120 / 0.75 = 160 in dpi else if (screenType == 2) translationX = 158; //158 / 0.75 = 210 in dpi else if (screenType == 3) translationX = 270; //270 / 0.75 = 360 in dpi else if (screenType == 4) translationX = 300; //300 / 0.75 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_XHIGH || density == DisplayMetrics.DENSITY_XXHIGH) { //400 dpi is 800px if (screenType == 1) translationX = 320; //320 / 2 = 160 in dpi else if (screenType == 2) translationX = 420; // 420 / 2 = 210 in dpi else if (screenType == 3) translationX = 720; // 720 / 2 = 360 in dpi else if (screenType == 4) translationX = 800; // 800 / 2 = 400 in dpi } else { //not supported } int offsetX = ((int) screenWidthPix / 20); int offsetY = ((int) screenHeightPix / 10); maxPosOpenX = screenWidthPix; //boundary for minimum amount of width on x-axis, where the touch is seen as panel open touch minPosOpenX = screenWidthPix - offsetX; //boundary for maximum amount of width on x-axis, where the touch is seen as panel close touch maxPosCloseX = screenWidthPix - translationX + offsetX; //boundary for minimum amount of width on x-axis, where the touch is seen as panel close touch minPosCloseX = screenWidthPix - translationX - offsetX; //boundary for maximum amount of height on y-axis, where the touch is seen as panel open or close touch maxPosY = (screenHeightPix / 2) + offsetY; //boundary for minimum amount of height on y-axis, where the touch is seen as panel open or close touch minPosY = (screenHeightPix / 2) - offsetY; //instantiation of lists onlineStudentsList = new ArrayList<Student>(); feedbacksList = new ArrayList<Feedback>(); questionsList = new ArrayList<Question>(); answersList = new ArrayList<Answer>(); ownQuestionsList = new ArrayList<Question>(); //data stored for this user is fetched here, from the previous activity, and stored into the teacher instance Intent intent2 = getIntent(); teacher = (Teacher) intent2.getParcelableExtra("teacherObj"); ipStr = getResources().getString(R.string.IP); usersUrl = "http://" + ipStr + "/mentor/users"; coursesUrl = "http://" + ipStr + "/mentor/courses"; //default preferences are fetched, and listener is set to listen for preference changes PreferenceManager.setDefaultValues(this, R.xml.preferences, false); sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sp.registerOnSharedPreferenceChangeListener(this); //SharedPreferences.Editor editor = sp.edit(); //editor.putString("flaretimePref", "5"); //editor.clear(); //editor.commit(); // In case of notifications are added later /*String ns = Context.NOTIFICATION_SERVICE; mNotificationManager = (NotificationManager) getSystemService(ns); icon = R.drawable.mlogo2;*/ //AndAR preview renderer = new CustomRenderer();//optional, may be set to null super.setNonARRenderer(renderer);//or might be omitted try { //register an object for each marker type artoolkit = super.getArtoolkit(); oneObject = new CustomObject("onePatt", "onePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter, customColor twoObject = new CustomObject("twoPatt", "twoPatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter threeObject = new CustomObject("threePatt", "threePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter artoolkit.registerARObject(oneObject); artoolkit.registerARObject(twoObject); artoolkit.registerARObject(threeObject); } catch (AndARException ex) { Log.e("AndARException ", ex.getMessage()); } LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vv = inflater.inflate(R.layout.activity_teacher_vision, null); //screen width and height in pixels screenWidth = (float) this.getApplicationContext().getResources().getDisplayMetrics().widthPixels; screenHeight = (float) this.getApplicationContext().getResources().getDisplayMetrics().heightPixels; inflater.inflate(R.layout.fragment_teacher_vision, null); //UI elements are added on top of AndAR by calling this addContentView-method instead of setContentView super.addContentView(vv, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))); //create a layout for settings button. add it over video frames LinearLayout lil = new LinearLayout(this); Button settingsButton = new Button(this); settingsButton.setText("Settings"); settingsButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); settingsButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment()) .addToBackStack("settings").commit(); } }); lil.addView(settingsButton); super.addContentView(lil, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))); //starts the AndAR startPreview(); //mDetector is instantiated here for detecting gestures mDetector = new GestureDetectorCompat(this, new SwipeGestureListener()); //view pager instantiation, also mAdapter instantiated and set as adapter for view pager mPager = (ViewPager) findViewById(R.id.pager); mAdapter = new TabAdapter(getFragmentManager(), mPager); mPager.setAdapter(mAdapter); //begin to poll online users pollUsersCancelled = false; pollUsersTask = new PollUsersTask(this); pollUsersTask.execute(); //begin to poll feedbacks pollFeedbacksCancelled = false; pollFeedbacksTask = new PollFeedbacksTask(this); pollFeedbacksTask.execute(); //begin to poll questions pollQuestionsCancelled = false; pollQuestionsTask = new PollQuestionsTask(this); pollQuestionsTask.execute(); //begin to poll answers pollAnswersCancelled = false; pollAnswersTask = new PollAnswersTask(this); pollAnswersTask.execute(); //initialize tab buttons button = (Button) findViewById(R.id.goto_first); //first one is not enabled at the beginning, because the user is in first tab at first button.setEnabled(false); button2 = (Button) findViewById(R.id.goto_second); button3 = (Button) findViewById(R.id.goto_last); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(0); button.setEnabled(false); button2.setEnabled(true); button3.setEnabled(true); } }); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(1); button.setEnabled(true); button2.setEnabled(false); button3.setEnabled(true); } }); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(2); button.setEnabled(true); button2.setEnabled(true); button3.setEnabled(false); } }); }
From source file:uk.co.threeonefour.android.snowball.activities.game.GameActivity.java
void dbgScreenSize() { // Determine screen size int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_XLARGE: Toast.makeText(this, "XLarge screen", Toast.LENGTH_LONG).show(); break;/* w ww. ja v a 2 s.c o m*/ case Configuration.SCREENLAYOUT_SIZE_LARGE: Toast.makeText(this, "Large screen", Toast.LENGTH_LONG).show(); break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: Toast.makeText(this, "Normal sized screen", Toast.LENGTH_LONG).show(); break; case Configuration.SCREENLAYOUT_SIZE_SMALL: Toast.makeText(this, "Small sized screen", Toast.LENGTH_LONG).show(); break; default: Toast.makeText(this, "Unknown screen size", Toast.LENGTH_LONG).show(); break; } }