Class: Fastlane::Actions::FivAddTransparentStatusbarAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



91
92
93
94
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 91

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["Your GitHub/Twitter Name"]
end

.available_optionsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 58

def self.available_options
  # Define all options your action supports. 
  
  # Below a few examples
  [
    FastlaneCore::ConfigItem.new(key: :ios,
    env_name: "FIV_ADD_TRANSPARENT_STATUSBAR_PLATFORM",
 description: "---",
    optional: false,
        type: Boolean),
    FastlaneCore::ConfigItem.new(key: :path,
                        env_name: "FIV_ADD_TRANSPARENT_STATUSBAR_PATH",
                        description: "Path to Appdelegate.m for ios and MainActivity.java for Android",
                        optional: false,
                        verify_block: proc do | value |
                          UI.user_error!("Couldnt find AppDelegate or Main Activity! Please change your path.") unless File.exist?(value)
                        end  ,
                            type: String)
  ]
end

.descriptionObject



48
49
50
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 48

def self.description
  "A short description with <= 80 characters of what this action does"
end

.detailsObject



52
53
54
55
56
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 52

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "You can use this action to do cool things..."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 96

def self.is_supported?(platform)
  # you can do things like
  # 
  #  true
  # 
  #  platform == :ios
  # 
  #  [:ios, :mac].include?(platform)
  # 

  platform == :ios
end

.outputObject



79
80
81
82
83
84
85
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 79

def self.output
  # Define the shared values you are going to provide
  # Example
  [
    ['ADD_TRANSPARENT_STATUSBAR_CUSTOM_VALUE', 'A description of what this value contains']
  ]
end

.return_valueObject



87
88
89
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 87

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb', line 8

def self.run(params)

  text = File.read(params[:path])

  if params[:ios]

    puts "platform is ios"

    /super.onCreate\(savedInstanceState\);/

    new_contents = text.gsub(/{/, "{\n [self.viewController.navigationController.navigationBar setBackgroundImage:[UIImage new]
      \nforBarMetrics:UIBarMetricsDefault];
      \nself.viewController.navigationController.navigationBar.shadowImage = [UIImage new];
      \nself.viewController.navigationController.navigationBar.translucent = YES;
      \nself.viewController.navigationController.view.backgroundColor = [UIColor clearColor];")

  else

    puts "platform is android"

    content = text.gsub(/super.onCreate\(savedInstanceState\);/, 
    "super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }")

      new_contents = content.gsub(/import org.apache.cordova.*;/,
        "import org.apache.cordova.*;\nimport android.os.Build;\nimport android.view.View;")

  end

  File.open(params[:path], "w") {|file| file.puts new_contents}
end