/** Determine whether this configuration has a better match in a different layout file */ private void updateForkStatus() { ConfigurationChooser chooser = mManager.getChooser(); FolderConfiguration config = mConfiguration.getFullConfig(); if (mAlternateInput != null && chooser.isBestMatchFor(mAlternateInput, config)) { return; } mAlternateInput = null; IFile editedFile = chooser.getEditedFile(); if (editedFile != null) { if (!chooser.isBestMatchFor(editedFile, config)) { ProjectResources resources = chooser.getResources(); if (resources != null) { ResourceFile best = resources.getMatchingFile(editedFile.getName(), ResourceType.LAYOUT, config); if (best != null) { IAbstractFile file = best.getFile(); if (file instanceof IFileWrapper) { mAlternateInput = ((IFileWrapper) file).getIFile(); } else if (file instanceof File) { mAlternateInput = AdtUtils.fileToIFile(((File) file)); } } } if (mAlternateInput != null) { mAlternateConfiguration = Configuration.create(mConfiguration, mAlternateInput); } } } }
boolean computeAndSetRealScale(boolean redraw) { // compute average dpi of X and Y ConfigurationChooser chooser = mEditor.getConfigurationChooser(); Configuration config = chooser.getConfiguration(); Device device = config.getDevice(); Screen screen = device.getDefaultHardware().getScreen(); double dpi = (screen.getXdpi() + screen.getYdpi()) / 2.; // get the monitor dpi float monitor = AdtPrefs.getPrefs().getMonitorDensity(); if (monitor == 0.f) { ResolutionChooserDialog dialog = new ResolutionChooserDialog(chooser.getShell()); if (dialog.open() == Window.OK) { monitor = dialog.getDensity(); AdtPrefs.getPrefs().setMonitorDensity(monitor); } else { return false; } } mEditor.getCanvasControl().setScale(monitor / dpi, redraw); return true; }