forked from mistamek/Android-drawable-preview-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added settings to control preview size
- Loading branch information
vlgrigorev
committed
Nov 13, 2018
1 parent
fb97c47
commit 1be3d47
Showing
6 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.mistamek.drawablepreview | ||
|
||
fun String.getDigits() = try { | ||
this.replace("\\D+", "").toInt() | ||
} catch (exception: Exception) { | ||
null | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/kotlin/com/mistamek/drawablepreview/factories/BitmapImageFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/kotlin/com/mistamek/drawablepreview/factories/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package com.mistamek.drawablepreview.factories | ||
|
||
import com.intellij.util.ui.UIUtil | ||
|
||
object Constants { | ||
const val ICON_SIZE = 16 | ||
val ICON_SIZE = if (UIUtil.isRetina()) 36 else 16 | ||
const val XML_TYPE = ".xml" | ||
const val DRAWABLES_FOLDER_TYPE = "drawable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/main/kotlin/com/mistamek/drawablepreview/settings/SettingsConfigurable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/mistamek/drawablepreview/settings/SettingsUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.mistamek.drawablepreview.settings | ||
|
||
import com.intellij.ide.util.PropertiesComponent | ||
import com.mistamek.drawablepreview.factories.Constants | ||
|
||
object SettingsUtils { | ||
|
||
private const val PROPERTIES_SIZE = "com.mistamek.drawablepreview.settings.PropertiesSize" | ||
|
||
fun getPreviewSize() = PropertiesComponent.getInstance().getInt(PROPERTIES_SIZE, Constants.ICON_SIZE) | ||
|
||
fun isModified(previewSize: Int): Boolean { | ||
return previewSize != getPreviewSize() | ||
} | ||
|
||
fun apply(previewSize: Int) { | ||
PropertiesComponent.getInstance().setValue(PROPERTIES_SIZE, previewSize, Constants.ICON_SIZE) | ||
} | ||
} |