Skip to content

Commit

Permalink
Merge branch 'release/v2.2.x' into fix/3003
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz authored Jul 6, 2022
2 parents 4922b9a + 77d8a96 commit 968357b
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 64 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

### 2.2.3 - Ongoing
## 2.2.3 - Ongoing

### Fixed

* Wrappable RichText in a Split container causes crash (#3003, #2961)
* meta.Version is always 1.0.0 on android & ios (3109)


## 2.2.2 - 30 June 2022
Expand Down
8 changes: 4 additions & 4 deletions app/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func (p *preferences) saveToFile(path string) error {
}

func (p *preferences) load() {
// err := p.loadFromFile(p.storagePath())
// if err != nil {
// fyne.LogError("Preferences load error:", err)
// }
err := p.loadFromFile(p.storagePath())
if err != nil {
fyne.LogError("Preferences load error:", err)
}
}

func (p *preferences) loadFromFile(path string) (err error) {
Expand Down
4 changes: 4 additions & 0 deletions app/preferences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func TestPreferences_Save(t *testing.T) {
assert.Fail(t, "Failed to load, %v", err)
}
assert.JSONEq(t, string(expected), string(content))

// check it reads the saved output
p = loadPreferences("dummy")
assert.Equal(t, "value", p.String("keyString"))
}

func TestPreferences_Save_OverwriteFast(t *testing.T) {
Expand Down
79 changes: 40 additions & 39 deletions cmd/fyne/internal/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,44 +165,6 @@ func getFyneGoModVersion(runner runner) (string, error) {
return "", fmt.Errorf("fyne version not found")
}

func (b *Builder) createMetadataInitFile() (func(), error) {
data, err := metadata.LoadStandard(b.srcdir)
if err == nil {
mergeMetadata(b.appData, data)
}

metadataInitFilePath := filepath.Join(b.srcdir, "fyne_metadata_init.go")
metadataInitFile, err := os.Create(metadataInitFilePath)
if err != nil {
return func() {}, err
}
defer metadataInitFile.Close()

err = templates.FyneMetadataInit.Execute(metadataInitFile, b.appData)
if err == nil {
if b.icon != "" {
writeResource(b.icon, "fyneMetadataIcon", metadataInitFile)
}
}

return func() { os.Remove(metadataInitFilePath) }, err
}

func (b *Builder) injectMetadataIfPossible(runner runner, createMetadataInitFile func() (func(), error)) (func(), error) {
fyneGoModVersion, err := getFyneGoModVersion(runner)
if err != nil {
return nil, err
}

fyneGoModVersionNormalized := version.Normalize(fyneGoModVersion)
fyneGoModVersionConstraint := version.NewConstrainGroupFromString(">=2.2")
if fyneGoModVersion != "master" && !fyneGoModVersionConstraint.Match(fyneGoModVersionNormalized) {
return nil, nil
}

return createMetadataInitFile()
}

func (b *Builder) build() error {
var versionConstraint *version.ConstraintGroup

Expand All @@ -221,7 +183,7 @@ func (b *Builder) build() error {
}
}

close, err := b.injectMetadataIfPossible(fyneGoModRunner, b.createMetadataInitFile)
close, err := injectMetadataIfPossible(fyneGoModRunner, b.srcdir, b.appData, b.icon, createMetadataInitFile)
if err != nil {
fyne.LogError("Failed to inject metadata init file, omitting metadata", err)
} else if close != nil {
Expand Down Expand Up @@ -298,6 +260,45 @@ func (b *Builder) build() error {
return err
}

func createMetadataInitFile(srcdir string, app *appData, icon string) (func(), error) {
data, err := metadata.LoadStandard(srcdir)
if err == nil {
mergeMetadata(app, data)
}

metadataInitFilePath := filepath.Join(srcdir, "fyne_metadata_init.go")
metadataInitFile, err := os.Create(metadataInitFilePath)
if err != nil {
return func() {}, err
}
defer metadataInitFile.Close()

err = templates.FyneMetadataInit.Execute(metadataInitFile, app)
if err == nil {
if icon != "" {
writeResource(icon, "fyneMetadataIcon", metadataInitFile)
}
}

return func() { os.Remove(metadataInitFilePath) }, err
}

func injectMetadataIfPossible(runner runner, srcdir string, app *appData, icon string,
createMetadataInitFile func(srcdir string, app *appData, icon string) (func(), error)) (func(), error) {
fyneGoModVersion, err := getFyneGoModVersion(runner)
if err != nil {
return nil, err
}

fyneGoModVersionNormalized := version.Normalize(fyneGoModVersion)
fyneGoModVersionConstraint := version.NewConstrainGroupFromString(">=2.2")
if fyneGoModVersion != "master" && !fyneGoModVersionConstraint.Match(fyneGoModVersionNormalized) {
return nil, nil
}

return createMetadataInitFile(srcdir, app, icon)
}

func targetOS() string {
osEnv, ok := os.LookupEnv("GOOS")
if ok {
Expand Down
10 changes: 5 additions & 5 deletions cmd/fyne/internal/commands/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ func Test_FyneGoMod(t *testing.T) {
called := false

fyneGoModTest := &testCommandRuns{runs: expected, t: t}
b := &Builder{appData: &appData{}, os: "wasm", srcdir: "myTest", runner: fyneGoModTest}
b.injectMetadataIfPossible(fyneGoModTest, func() (func(), error) {
called = true
return func() {}, nil
})
injectMetadataIfPossible(fyneGoModTest, "myTest", &appData{}, "",
func(string, *appData, string) (func(), error) {
called = true
return func() {}, nil
})

assert.Equal(t, j.expected, called)
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strconv"
"strings"

"fyne.io/fyne/v2"
_ "github.com/fyne-io/image/ico" // import image encodings
"github.com/urfave/cli/v2"
"golang.org/x/mod/modfile"
Expand All @@ -24,7 +25,7 @@ import (

const (
defaultAppBuild = 1
defaultAppVersion = "1.0.0"
defaultAppVersion = "0.0.1"
)

type appData struct {
Expand Down Expand Up @@ -274,6 +275,14 @@ func (p *Packager) doPackage(runner runner) error {
defer p.removeBuild(files)
}
}
if util.IsMobile(p.os) { // we don't use the normal build command for mobile so inject before gomobile...
close, err := injectMetadataIfPossible(newCommand("go"), p.dir, p.appData, p.icon, createMetadataInitFile)
if err != nil {
fyne.LogError("Failed to inject metadata init file, omitting metadata", err)
} else if close != nil {
defer close()
}
}

switch p.os {
case "darwin":
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/binres/binres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func TestTableMarshal(t *testing.T) {
err = xtbl.UnmarshalBinary(bin)
r.NoError(err)

r.Equal(len(tbl.pool.strings), xtbl.pool.strings)
r.Equal(len(tbl.pool.strings), len(xtbl.pool.strings))
r.Equal(len(tbl.pkgs), len(xtbl.pkgs))

pkg, xpkg := tbl.pkgs[0], xtbl.pkgs[0]
Expand Down
6 changes: 3 additions & 3 deletions internal/driver/glfw/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func init() {
}

func TestGoroutineID(t *testing.T) {
assert.Equal(t, 1, mainRoutineID)
assert.Equal(t, uint64(1), mainRoutineID)

var childID1, childID2 uint64
testID1 := goroutineID()
Expand All @@ -144,8 +144,8 @@ func TestGoroutineID(t *testing.T) {
testID2 := goroutineID()

assert.Equal(t, testID1, testID2)
assert.Greater(t, childID1, 0)
assert.Greater(t, childID1, uint64(0))
assert.NotEqual(t, testID1, childID1)
assert.Greater(t, childID2, 0)
assert.Greater(t, childID2, uint64(0))
assert.NotEqual(t, childID1, childID2)
}
13 changes: 6 additions & 7 deletions internal/driver/mobile/app/darwin_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var DisplayMetrics struct {

//export setDisplayMetrics
func setDisplayMetrics(width, height int, scale int) {
DisplayMetrics.WidthPx = width
DisplayMetrics.HeightPx = height
DisplayMetrics.WidthPx = width * scale
DisplayMetrics.HeightPx = height * scale
}

//export setScreen
Expand Down Expand Up @@ -127,15 +127,14 @@ func updateConfig(width, height, orientation int32) {
o = size.OrientationPortrait
case C.UIDeviceOrientationLandscapeLeft, C.UIDeviceOrientationLandscapeRight:
o = size.OrientationLandscape
width, height = height, width
}
insets := C.getDevicePadding()

theApp.events.In() <- size.Event{
WidthPx: int(width),
HeightPx: int(height),
WidthPt: float32(width) / pixelsPerPt,
HeightPt: float32(height) / pixelsPerPt,
WidthPx: int(width) * screenScale,
HeightPx: int(height) * screenScale,
WidthPt: float32(width),
HeightPt: float32(height),
InsetTopPx: int(float32(insets.top) * float32(screenScale)),
InsetBottomPx: int(float32(insets.bottom) * float32(screenScale)),
InsetLeftPx: int(float32(insets.left) * float32(screenScale)),
Expand Down
6 changes: 3 additions & 3 deletions internal/driver/mobile/app/darwin_ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]) {
scale = (int)[UIScreen mainScreen].scale; // either 1.0, 2.0, or 3.0.
}
CGSize size = [UIScreen mainScreen].nativeBounds.size;
CGSize size = [UIScreen mainScreen].bounds.size;
setDisplayMetrics((int)size.width, (int)size.height, scale);

lifecycleAlive();
Expand Down Expand Up @@ -149,7 +149,7 @@ - (void)viewWillTransitionToSize:(CGSize)ptSize withTransitionCoordinator:(id<UI
// TODO(crawshaw): come up with a plan to handle animations.
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGSize size = [UIScreen mainScreen].nativeBounds.size;
CGSize size = [UIScreen mainScreen].bounds.size;
updateConfig((int)size.width, (int)size.height, orientation);
}];
}
Expand Down Expand Up @@ -194,7 +194,7 @@ - (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection
[super traitCollectionDidChange: previousTraitCollection];

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGSize size = [UIScreen mainScreen].nativeBounds.size;
CGSize size = [UIScreen mainScreen].bounds.size;
updateConfig((int)size.width, (int)size.height, orientation);
}
@end
Expand Down

0 comments on commit 968357b

Please sign in to comment.