class Fastlane::Actions::FivAddTransparentStatusbarAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 110
def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ['Your GitHub/Twitter Name']
end
available_options() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 64
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|
          unless File.exist?(value)
            UI.user_error!(
              'Couldnt find AppDelegate or Main Activity! Please change your path.'
            )
          end
        end,
      type: String
    )
  ]
end
description() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 54
def self.description
  'A short description with <= 80 characters of what this action does'
end
details() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 58
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) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 115
def self.is_supported?(platform)
  # you can do things like
  #
  #  true
  #
  #  platform == :ios
  #
  #  [:ios, :mac].include?(platform)
  #

  platform == :ios
end
output() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 95
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_value() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 106
def self.return_value
  # If your method provides a return value, you can describe here what it does
end
run(params) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_add_transparent_statusbar.rb, line 9
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