Skip to content

Commit

Permalink
Fix tips view blank (#499)
Browse files Browse the repository at this point in the history
* Revert "Revert "Feautre tips view (#418)" (#477)"

This reverts commit 11fd868.

* fix: #452 blank for tips view

* feat: add type of tips cell

* feat: support tips cell update cell type

* fix: when  selection translation the text is empty set special tips cell type

* fix: update show tips status

* fix: resolve merge dev

* fix: update action type

* pref: stash ocr error tips

* fix: control show tips code

* fix: update view

* fix: add mini cell height

* fix: tips cell type

* fix: remove unuse code

* fix: called showTipsView when showTips == true

* fix: display when user just want show query window again

* perf: improve displaying tips view

* perf: do not reload tableView when starting query text

* perf: remove unused Localizable.xcstrings

* perf: close tips view when just updating query text

* perf: close tips view when starting OCR image

* chore(deps): bump rexml in the bundler group across 1 directory

Bumps the bundler group with 1 update in the / directory: [rexml](https://github.com/ruby/rexml).


Updates `rexml` from 3.2.6 to 3.2.8
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](ruby/rexml@v3.2.6...v3.2.8)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
  dependency-group: bundler
...

Signed-off-by: dependabot[bot] <support@github.com>

* perf(UI): add icon for disableTipsView toggle

* perf(UI): adjust advanced tab height

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tisfeng <tisfeng@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jerry <89069957+Jerry23011@users.noreply.github.com>
  • Loading branch information
4 people authored May 19, 2024
1 parent 17f346d commit a2be466
Show file tree
Hide file tree
Showing 19 changed files with 665 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */; };
967712EA2B5B913600105E0F /* KeyHolder in Frameworks */ = {isa = PBXBuildFile; productRef = 967712E92B5B913600105E0F /* KeyHolder */; };
967712EE2B5B943400105E0F /* Shortcut.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967712ED2B5B943400105E0F /* Shortcut.swift */; };
96DFEB832B82588000F5C7EF /* EZTableTipsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */; };
A0B65CA0F31AC8ECFB8347CC /* Pods_EasydictTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 378E73A7EA8FC8FB9C975A63 /* Pods_EasydictTests.framework */; };
B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6372B33DFF803C7096A82250 /* Pods_Easydict.framework */; };
C415C0AD2B450D4800A9D231 /* GeminiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0AC2B450D4800A9D231 /* GeminiService.swift */; };
Expand Down Expand Up @@ -841,6 +842,8 @@
9672D7D02B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MASShortcutBinder+EZMASShortcutBinder.h"; sourceTree = "<group>"; };
9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MASShortcutBinder+EZMASShortcutBinder.m"; sourceTree = "<group>"; };
967712ED2B5B943400105E0F /* Shortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shortcut.swift; sourceTree = "<group>"; };
96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZTableTipsCell.h; sourceTree = "<group>"; };
96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZTableTipsCell.m; sourceTree = "<group>"; };
A230E9A2358C7FBC7FB26189 /* Pods-EasydictTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EasydictTests.debug.xcconfig"; path = "Target Support Files/Pods-EasydictTests/Pods-EasydictTests.debug.xcconfig"; sourceTree = "<group>"; };
C415C0AC2B450D4800A9D231 /* GeminiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeminiService.swift; sourceTree = "<group>"; };
C490BF712BE910B70021E40A /* AdvancedTabItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AdvancedTabItemView.swift; path = Easydict/Swift/View/AdvancedTabItemView.swift; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -1579,6 +1582,8 @@
children = (
0396D60F292C932F006A11D9 /* EZSelectLanguageCell.h */,
0396D610292C932F006A11D9 /* EZSelectLanguageCell.m */,
96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */,
96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */,
037852B7295D49F900D0E2CF /* EZTableRowView.h */,
037852B8295D49F900D0E2CF /* EZTableRowView.m */,
);
Expand Down Expand Up @@ -3093,6 +3098,7 @@
03B022FE29231FA6001C7E63 /* EZBaseQueryViewController.m in Sources */,
DC6D9C892B3969510055EFFC /* Appearance.swift in Sources */,
0396D611292C932F006A11D9 /* EZSelectLanguageCell.m in Sources */,
96DFEB832B82588000F5C7EF /* EZTableTipsCell.m in Sources */,
036196752A000F5900806370 /* FWEncryptorAES.m in Sources */,
9643D9462B71D103000FBEA6 /* KeyHolderRowView.swift in Sources */,
0399C6A829A74E0F00B4AFCC /* EZQueryResult+EZDeepLTranslateResponse.m in Sources */,
Expand Down
22 changes: 22 additions & 0 deletions Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "tip_Normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "tip_Normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
169 changes: 169 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,23 @@
}
}
},
"disable_tips_view" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Disable Tips View"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "关闭提示视图"
}
}
}
},
"disabled_app_list" : {
"comment" : "disabled app list",
"localizations" : {
Expand Down Expand Up @@ -4377,6 +4394,158 @@
}
}
},
"tips_edit_button" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why does the edit button in the upper right corner flicker when selecting words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用取词时,右上角编辑按钮会出现闪烁?"
}
}
}
},
"tips_more" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "See More"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "查看更多"
}
}
}
},
"tips_mouse_hover" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why can't I use mouse hover to select words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用中无法使用鼠标划词?"
}
}
}
},
"tips_select_words" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why can't I select words on some web pages in the browser?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么浏览器中某些网页无法取词?"
}
}
}
},
"tips_solve" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Solve This"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "如何解决"
}
}
}
},
"tips_still_pop_up" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why does macOS still pop up asking for permissions even though I have given Easydict the Accessibility/Screen Recording permissions?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "已经给 Easydict 辅助功能/录屏权限 macOS 仍然弹窗要求给予权限?"
}
}
}
},
"tips_text_empty" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why is the text empty when I select words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用中取词文本为空?"
}
}
}
},
"tips_title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tips"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "提示"
}
}
}
},
"tips_word_selection_OCR" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why do word selection and OCR need to enable system-related permissions?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么取词和 OCR 需要开启系统相关权限?"
}
}
}
},
"toggle_languages" : {
"localizations" : {
"en" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ extension Defaults.Keys {
Key("EZConfiguration_kEnableBetaNewAppKey", default: false)
}
}

static var disableTipsView = Key<Bool>("disableTipsViewKey", default: false)
}

extension Defaults.Keys {
Expand Down
2 changes: 2 additions & 0 deletions Easydict/Swift/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class Configuration: NSObject {

@DefaultsWrapper(.selectQueryTextWhenWindowActivate) var selectQueryTextWhenWindowActivate: Bool

@DefaultsWrapper(.disableTipsView) var disableTipsView: Bool

var disabledAutoSelect: Bool = false

var isRecordingSelectTextShortcutKey: Bool = false
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/View/SettingView/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct SettingView: View {
case .disabled:
500
case .advanced:
280
310
case .privacy:
320
case .about:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ struct AdvancedTab: View {
.tag(option)
}
}
Toggle(isOn: $disableTipsView) {
AdvancedTabItemView(
color: .yellow,
systemImage: "lightbulb.fill",
labelText: "disable_tips_view"
)
}
}
Section {
Toggle(isOn: $enableBetaFeature) {
Expand Down Expand Up @@ -58,6 +65,7 @@ struct AdvancedTab: View {
@Default(.defaultTTSServiceType) private var defaultTTSServiceType
@Default(.enableBetaFeature) private var enableBetaFeature
@Default(.enableBetaNewApp) private var enableBetaNewApp
@Default(.disableTipsView) private var disableTipsView
}

@available(macOS 13, *)
Expand Down
5 changes: 5 additions & 0 deletions Easydict/objc/Utility/EZCategory/NSString/NSString+EZUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ static NSArray *const EZDashCharacterList = @[ @"—", @"-", @"–" ];

- (NSString *)removeAlphabetAndNumbers;

#pragma mark - Check Empty String
#ifndef EZ_isEmptyString
FOUNDATION_EXPORT BOOL EZ_isEmptyString(id param);
#endif

@end

NS_ASSUME_NONNULL_END
17 changes: 15 additions & 2 deletions Easydict/objc/Utility/EZCategory/NSString/NSString+EZUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
@"" : @"",
};

BOOL EZ_isEmptyString(id param) {
if (!param) {
return YES;
}
if ([param isKindOfClass:[NSString class]]) {
NSString *str = param;
return (str.length == 0);
}
NSCAssert(NO, @"isEmptyString: param %@ is not NSString", param);
return YES;
}


@implementation NSString (EZUtils)

/// Check if it is a single letter of the alphabet, like 'a', 'A'
Expand Down Expand Up @@ -224,7 +237,7 @@ - (BOOL)isEnglishWordWithLanguage:(EZLanguage)language {
}

- (NLLanguage)detectText {
NLTagger *tagger = [[NLTagger alloc] initWithTagSchemes:@[NLTagSchemeLanguage]];
NLTagger *tagger = [[NLTagger alloc] initWithTagSchemes:@[ NLTagSchemeLanguage ]];
tagger.string = self;
NLLanguage language = [tagger dominantLanguage];
return language;
Expand Down Expand Up @@ -466,7 +479,7 @@ - (NSString *)suffixQuote {
}
return quotes;
}


- (NSString *)tryToRemovePrefixQuote {
NSString *prefixQuote = [self prefixQuote];
Expand Down
45 changes: 45 additions & 0 deletions Easydict/objc/ViewController/Cell/EZTableTipsCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// EZTableTipsCell.h
// Easydict
//
// Created by Sharker on 2024/2/18.
// Copyright © 2024 izual. All rights reserved.
//

#import <Cocoa/Cocoa.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, EZTipsCellType) {
EZTipsCellTypeNone = -1,
EZTipsCellTypeTextEmpty = 0,
EZTipsCellTypeMouseHover,
EZTipsCellTypeBeep,
EZTipsCellTypeEditButton,
EZTipsCellTypeMightSelecting,
EZTipsCellTypeWordSelectionOCR,
EZTipsCellTypeSelectWords,
EZTipsCellTypeStillPopup,
};

@interface EZTableTipsCell : NSTableRowView

- (CGFloat)cellHeight;


- (instancetype)initWithFrame:(CGRect)frame type:(EZTipsCellType)type;

/// update tips cell content with type
/// - Parameters:
/// - content: string value for content
/// - type: cell type default value is none
- (void)updateTipsContent:(NSString *)content type:(EZTipsCellType)type;


/// update tips cell of type
/// - Parameter type: cell type default value is none
- (void)updateTipsCellType:(EZTipsCellType)type;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit a2be466

Please sign in to comment.