List of usage examples for android.content.res Configuration Configuration
public Configuration()
Construct an invalid Configuration.
From source file:com.pdmanager.views.patient.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // application = (VideoApp) getApplication(); // application.setContext(this); // application.addOperationChangeListener(this); // application.addCallNegotiationListener(this); // TelerikActivityHelper.updateActivityTaskDescription(this); try {/* ww w . j a v a2s. c om*/ String languageToLoad = RecordingSettings.newInstance(this.getApplicationContext()).getLang(); // your language Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); Resources resources = getResources(); ColorDrawable bgColorPrimary = new ColorDrawable(resources.getColor(R.color.primary_title_background)); ColorDrawable bgColorSecondary = new ColorDrawable( resources.getColor(R.color.secondary_title_background)); currentBgColor = bgColorSecondary; setContentView(R.layout.activity_main); Toolbar tb = (Toolbar) this.findViewById(R.id.toolbar); this.setSupportActionBar(tb); if (tb != null) { tb.setTitleTextColor(Color.WHITE); setOverflowButtonColor(tb, Color.WHITE); } actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setBackgroundDrawable(currentBgColor); } this.setupActionBar(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); ///Set Brightness float SysBackLightValue = 255f; // android.provider.Settings.System.putInt(BatteryBoosterActivity.this.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,(int) SysBackLightValue); // Window myWindow =BatteryBoosterActivity.this. getWindow(); // WindowManager.LayoutParams winParams = myWindow.getAttributes(); winParams.screenBrightness = 255f; // myWindow.setAttributes(winParams); } catch (Exception ex) { Log.e("MAINACTIVITY", "RES", ex.getCause()); } //RecordingSettingsHandler.getInstance().Init(getApplicationContext()); /* try { this.setupAlertFragmentManager(); } catch (Exception ex) { Log.e("MAINACTIVITY","RES",ex.getCause()); } */ if (savedInstanceState == null) { } try { Bundle extras = this.getIntent().getExtras(); if (extras != null) { String alertType = extras.getString(PDApplicationContext.INTENT_ALERT_TYPE); String alertId = extras.getString(PDApplicationContext.INTENT_ALERT_ID); if (alertType != null && alertId != null) { Log.d("MAINACTIVITY", alertType); } else { Log.d("MAINACTIVITY", "NULL Alert type"); } } } catch (Exception ex) { Log.e("MAINACTIVITY", "INTENT", ex.getCause()); } initFragment(); }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { e_print("onCreate"); // ActionBar? if (savedInstanceState == null) { // customActionBar?? View customActionBarView = this.getActionBarView(); // ActionBar?? ActionBar actionBar = this.getSupportActionBar(); // ?????('<' <- ???) if (actionBar != null) { // ??????? actionBar.setDisplayShowTitleEnabled(false); // icon??????? actionBar.setDisplayShowHomeEnabled(false); // ActionBar?customView? actionBar.setCustomView(customActionBarView); // CutomView?? actionBar.setDisplayShowCustomEnabled(true); }/* w ww.j ava2s .c o m*/ } // ????? Locale locale = Locale.getDefault(); if (locale.equals(Locale.JAPAN) || locale.equals(Locale.JAPANESE)) { locale = Locale.JAPAN; } else { locale = Locale.ENGLISH; } // ?? Locale.setDefault(locale); Configuration config = new Configuration(); // Resources?? config.locale = locale; Resources resources = getBaseContext().getResources(); // Resources?????? resources.updateConfiguration(config, null); super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); try { new CreateInitData(this).exec(locale); new SPARQL().query(AppSetting.query_place, "place"); new SPARQL().query(AppSetting.query_frame, "frame"); } catch (IOException | JSONException e) { e.printStackTrace(); } makeTempDir(); // ??? ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo == null) { Toast.makeText(getApplicationContext(), "???????????", Toast.LENGTH_LONG).show(); } buttons = new ArrayList<>(); View.OnClickListener change_button = new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos; if (v == TrainButton) { zoomLevel = 9.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else if (v == CarButton) { zoomLevel = 11.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else { zoomLevel = 14.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } if (!v.isActivated()) { v.setActivated(true); for (int i = 0; i < buttons.size(); i++) { if (buttons.get(i) != v) { buttons.get(i).setActivated(false); } } } mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); } }; View.OnClickListener marker_change_button = new View.OnClickListener() { @Override public void onClick(View v) { if (!v.isActivated()) { v.setActivated(true); if (v == FrameSwitch) { setMarker("frame"); FrameMarkerOptions.clear(); } else { setMarker("place"); PlaceMarkerOptions.clear(); } } else { v.setActivated(false); if (v == FrameSwitch) { for (Marker m : FrameMarker) { m.remove(); } FrameMarker.clear(); } else { for (Marker m : PlaceMarker) { m.remove(); } PlaceMarker.clear(); } } } }; // LocationManager? mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); TakePicture = (ImageButton) findViewById(R.id.takePicture); TakePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent TakePictureView = new Intent(getApplicationContext(), TakePicture.class); startActivity(TakePictureView); } }); TrainButton = (ImageButton) findViewById(R.id.Train); TrainButton.setActivated(false); TrainButton.setOnClickListener(change_button); CarButton = (ImageButton) findViewById(R.id.Car); CarButton.setActivated(true); CarButton.setOnClickListener(change_button); WalkButton = (ImageButton) findViewById(R.id.Walk); WalkButton.setActivated(false); WalkButton.setOnClickListener(change_button); buttons = Arrays.asList(TrainButton, CarButton, WalkButton); FrameSwitch = (ImageButton) findViewById(R.id.showFrame); FrameSwitch.setActivated(true); FrameSwitch.setOnClickListener(marker_change_button); PlaceSwitch = (ImageButton) findViewById(R.id.showPlace); PlaceSwitch.setActivated(true); PlaceSwitch.setOnClickListener(marker_change_button); GoFukuiButton = (ImageButton) findViewById(R.id.GoFukuiButton); // new AppSetting(this); // AppSetting.context = getApplicationContext(); AppSetting.Inc_CountRun(); e_print("Run_Count >> " + AppSetting.CountRun()); if (AppSetting.CountRun() % 20 == 0) { GoFukuiButton.setVisibility(View.VISIBLE); } FrameCollectionButton = (ImageButton) findViewById(R.id.frameCollection); FrameCollectionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent collection = new Intent(getApplicationContext(), FrameCollection.class); startActivity(collection); } }); mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); // mapFragment.getMap(); helper = new SQLiteHelper(this); db = helper.getWritableDatabase(); }
From source file:gr.ioanpier.auth.users.memorypaintings.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Language Locale String languageToLoad = getActivity().getIntent().getStringExtra(LANGUAGE); // your language if (languageToLoad != null) { Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;/* www.ja va2 s .com*/ getActivity().getResources().updateConfiguration(config, getActivity().getResources().getDisplayMetrics()); } View rootView = inflater.inflate(R.layout.fragment_main, container, false); //Calculate the level and the number of cards. level = getActivity().getIntent().getIntExtra(LEVEL_TAG, 0); if (level >= layoutsPerLevel.length) level = layoutsPerLevel.length - 1; numberOfCards = cardsPerLevel[level]; numberOfBitmapWorkerTasks = numberOfCards / 2; instantiateLoadingBar(); if (!isExternalStorageReadable()) { Log.e(LOG, "External storage wasn't readable"); storedDrawables = null; } else { File[] imageFiles = getFilesFromDirectory(WelcomeScreen.IMAGES_PATH, ".jpg", ".png"); if (imageFiles.length > 0) { String descriptionsFolder = "Descriptions"; Locale locale = getActivity().getResources().getConfiguration().locale; if (locale.getDisplayLanguage().equals(Locale.ENGLISH.getDisplayLanguage())) descriptionsFolder = descriptionsFolder.concat("_en"); else descriptionsFolder = descriptionsFolder.concat("_pl"); File[] descFiles = getFilesFromDirectory(WelcomeScreen.DESCRIPTIONS_PATH, ".txt"); //getDrawables storedDrawables = getDrawables(imageFiles, descFiles); } else { Log.e(LOG, "No files found in external storage"); storedDrawables = null; } } pairs = new int[numberOfCards]; for (int i = 0; i < numberOfCards; i++) { pairs[i] = -1; } cards = new ImageViewCard[numberOfCards]; //This is where the layout magic happens. LinearLayout linearLayout; int index; for (int i = 0; i < layoutsPerLevel[level]; i++) { //The layout consists of multiple vertical LinearLayout[s] positioned horizontally next to each other. linearLayout = new LinearLayout(getActivity()); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f)); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int j = 0; j < numberOfCards / layoutsPerLevel[level]; j++) { //Each LinearLayout has a number of ImageViewCard[s], each positioned evenly in inside the layout. The number depends on the level. //ImageViewCard is an extension of the ViewFlipper class with a built in flipCard method for flipping between 2 images and which also includes animation. ImageViewCard card = new ImageViewCard(getActivity()); card.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f)); ((LinearLayout.LayoutParams) card.getLayoutParams()).setMargins(16, 16, 16, 16); //SquareImageView is an extension of the ImageView class that ensures that the image is square. //Two are needed, one for the back of the image and one for the front. SquareImageView image1 = new SquareImageView(getActivity()); image1.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); SquareImageView image2 = new SquareImageView(getActivity()); image2.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); //Add the SquareImageView[s] to the ImageViewCard and subsequently that to the LinearLayout. card.addView(image1); card.addView(image2); index = i * numberOfCards / layoutsPerLevel[level] + j; linearLayout.addView(card); cardsIndex.put(card.hashCode(), index); //Set the back of the image. ((ImageView) card.getChildAt(0)) .setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.black)); //Save the ImageViewCard for later use. cards[index] = card; } //Add the LinearLayout to the rootView. ((LinearLayout) rootView.findViewById(R.id.parent)).addView(linearLayout); } //Assign a listener for every ImageViewCard. View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View view) { if (!stillAnimating && numberOfBitmapWorkerTasks == 0) { int cardID = cardsIndex.get(view.hashCode()); stillAnimating = true; synchronized (gameLogicLock) { if (numberOfCardsFound < numberOfCards) onCardFlipped(cardID); else onCardClicked(cardID); } //Add a delay before the listener can be activated again. new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { try { Thread.sleep(250); } catch (InterruptedException e) { } return null; } @Override protected void onPostExecute(Void n) { stillAnimating = false; } }.execute(); } else if (numberOfBitmapWorkerTasks > 0) { Toast.makeText(getActivity(), getString(R.string.loading_bar_message), Toast.LENGTH_SHORT) .show(); } } }; for (int i = 0; i < numberOfCards; i++) { cards[i].setOnClickListener(onClickListener); } //Initialize found = new boolean[numberOfCards]; for (int i = 0; i < numberOfCards; i++) found[i] = false; //Initialize int[] chosenDrawables = new int[numberOfCards / 2]; cardDrawablePairs = new int[numberOfCards]; //Initialize. Holds the index of every ImageViewCard in cards. Will later be used for the pairs. ArrayList<Integer> availablePairs = new ArrayList<>(); for (int i = 0; i < numberOfCards; i++) availablePairs.add(i); Collections.shuffle(availablePairs); Random r = new Random(); int pair1, pair2; BitmapWorkerTask bitmapWorkerTask; for (int i = 0; i < numberOfCards / 2; i++) { //Choose at random one of the available images. Make sure it's unique. int range; if (storedDrawables == null) range = colors.length; else range = storedDrawables.length; boolean unique = false; while (!unique) { unique = true; //If there are a lot of images, this should be changed (there will never be a lot) chosenDrawables[i] = r.nextInt(range); for (int j = 0; j < i; j++) { if (chosenDrawables[i] == chosenDrawables[j]) unique = false; } } //availablePairs have already been shuffled, so just remove the first 2. pair1 = availablePairs.remove(0); pair2 = availablePairs.remove(0); cardDrawablePairs[pair1] = chosenDrawables[i]; cardDrawablePairs[pair2] = chosenDrawables[i]; //Assign the front of the ImageViewCard to the randomly chosen Drawable. ImageView imageView1, imageView2; String absolutePath; if (storedDrawables == null) { (cards[pair1].getChildAt(1)) .setBackgroundColor(ContextCompat.getColor(getActivity(), colors[chosenDrawables[i]])); (cards[pair2].getChildAt(1)) .setBackgroundColor(ContextCompat.getColor(getActivity(), colors[chosenDrawables[i]])); } else { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut wm.getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels / (layoutsPerLevel[level]); int screenHeight = displayMetrics.heightPixels / (cardsPerLevel[level] / layoutsPerLevel[level]); absolutePath = storedDrawables[chosenDrawables[i]].absolute_path_image; imageView1 = ((ImageView) cards[pair1].getChildAt(1)); imageView2 = ((ImageView) cards[pair2].getChildAt(1)); bitmapWorkerTask = new BitmapWorkerTask(screenWidth, screenHeight, imageView1, imageView2); bitmapWorkerTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, absolutePath); } //Save the pairs. pairs[pair1] = pair2; pairs[pair2] = pair1; } if (storedDrawables == null) { numberOfBitmapWorkerTasks = 0; } return rootView; }
From source file:by.zatta.pilight.connection.ConnectionService.java
public void makeLocale(String language) { Log.w(TAG, language + " makeLocale"); Locale locale = new Locale(language); Locale.setDefault(locale);//from ww w . ja va2 s . c om Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); }
From source file:com.kanchi.periyava.old.Activity.MainActivity.java
public void loadLanguage(LANGUAGE language) { Locale locale = new Locale(language.getLanguage()); Locale.setDefault(locale);/*from w w w. j a v a2s .c om*/ Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); }
From source file:com.ninetwozero.battlelog.ViewPagerDashboard.java
public void setupLocale() { if (!sharedPreferences.getString(Constants.SP_BL_LANG, "").equals("")) { Locale locale = new Locale(sharedPreferences.getString(Constants.SP_BL_LANG, "en")); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;/*from w ww . j a v a2 s . com*/ getResources().updateConfiguration(config, getResources().getDisplayMetrics()); } }
From source file:com.ericsun.duom.Framework.Activity.BaseActivity.java
@Override public Resources getResources() { Resources res = super.getResources(); Configuration config = new Configuration(); // config.setToDefaults(); config.fontScale = 1.0f;/*from w ww .j a va 2s. c o m*/ res.updateConfiguration(config, res.getDisplayMetrics()); return res; }
From source file:com.android.projectz.teamrocket.thebusapp.activities.SplashScreenActivity.java
/** * Metodo che prende la lingua di sistema o quella delle SharedPreferences a seconda * della tipologia di avvio dell'app (se la prima volta quella di sistema, se non la * prima volta allora prende quella delle sharedpreferences) */// ww w. ja v a 2s . com private void setLanguage(String type) { Locale language = null; if (type.equals("system")) { language = Locale.getDefault(); SharedPreferencesUtils.setSelectedLanguage(this, Locale.getDefault().getLanguage()); } else if (type.equals("local")) { String languageToLoad = SharedPreferencesUtils.getSelectedLanguage(this); language = new Locale(languageToLoad); Locale.setDefault(language); } Configuration config = new Configuration(); config.locale = language; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); }
From source file:org.totschnig.myexpenses.MyApplication.java
public void setLanguage(Locale locale) { if (!Locale.getDefault().equals(locale)) { Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;// ww w . ja v a2s . co m config.fontScale = getResources().getConfiguration().fontScale; getResources().updateConfiguration(config, getResources().getDisplayMetrics()); } }