<commit_before>#######################################################
#
# ruboto.rb (by <NAME>)
#
# Wrapper for using RubotoActivity in Ruboto IRB
#
#######################################################

$RUBOTO_VERSION = 4

def confirm_ruboto_version(required_version, exact=true)
  raise "requires $RUBOTO_VERSION=#{required_version} or greater, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION < required_version and not exact
  raise "requires $RUBOTO_VERSION=#{required_version}, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION != required_version and exact
end

require 'java'



%w(Activity BroadcastReceiver Service).map do |klass|
  java_import "org.ruboto.Ruboto#{klass}"
end

RUBOTO_CLASSES = [RubotoActivity, RubotoBroadcastReceiver, RubotoService]
$init_methods = Hash.new 'create'
$init_methods[RubotoBroadcastReceiver] = 'receive'

java_import "org.ruboto.RubotoView"

java_import "android.app.Activity"
java_import "android.content.Intent"
java_import "android.os.Bundle"

java_import "android.view.View"
java_import "android.view.ViewGroup"

java_import "android.widget.Toast"

java_import "android.widget.ArrayAdapter"
java_import "java.util.Arrays"
java_import "java.util.ArrayList"
java_import "android.R"

java_import "android.util.Log"

module Ruboto
  java_import "THE_PACKAGE.R"
  begin
    Id = JavaUtilities.get_proxy_class("THE_PACKAGE.R$id")
  rescue NameError
    Log.d "RUBOTO", "no R$id"
  end

end
AndroidIds = JavaUtilities.get_proxy_class("android.R$id")

#############################################################################
#
# Activity
#

class Activity
  attr_accessor :init_block

  def start_ruboto_dialog(remote_variable, &block)
    start_ruboto_activity(remote_variable, true, &block)
  end

  def start_ruboto_activity(remote_variable, dialog=false, &block)
    @@init_block = block

    if @initialized or not self.is_a?(RubotoActivity)
      b = Bundle.new
      b.putString("Remote Variable", remote_variable)
      b.putBoolean("Define Remote Variable", true)
      b.putString("Initialize Script", "#{remote_variable}.initialize_activity")

      i = Intent.new
      i.setClassName "THE_PACKAGE",
                     "THE_PACKAGE.ACTIVITY_NAME"
      i.putExtra("RubotoActivity Config", b)

      self.startActivity i
    else
      instance_eval "#{remote_variable}=self"
      setRemoteVariable remote_variable<commit_msg>Added RubotoDialog; Modified Intent for invoking new activities<commit_after>#######################################################
#
# ruboto.rb (by <NAME>)
#
# Wrapper for using RubotoActivity in Ruboto IRB
#
#######################################################

$RUBOTO_VERSION = 4

def confirm_ruboto_version(required_version, exact=true)
  raise "requires $RUBOTO_VERSION=#{required_version} or greater, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION < required_version and not exact
  raise "requires $RUBOTO_VERSION=#{required_version}, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION != required_version and exact
end

require 'java'



%w(Activity Dialog BroadcastReceiver Service View).map do |klass|
  java_import "org.ruboto.Ruboto#{klass}"
end

RUBOTO_CLASSES = [RubotoActivity, RubotoBroadcastReceiver, RubotoService]
$init_methods = Hash.new 'create'
$init_methods[RubotoBroadcastReceiver] = 'receive'

java_import "android.app.Activity"
java_import "android.content.Intent"
java_import "android.os.Bundle"

java_import "android.view.View"
java_import "android.view.ViewGroup"

java_import "android.widget.Toast"

java_import "android.widget.ArrayAdapter"
java_import "java.util.Arrays"
java_import "java.util.ArrayList"
java_import "android.R"

java_import "android.util.Log"

module Ruboto
  java_import "THE_PACKAGE.R"
  begin
    Id = JavaUtilities.get_proxy_class("THE_PACKAGE.R$id")
  rescue NameError
    Log.d "RUBOTO", "no R$id"
  end

end
AndroidIds = JavaUtilities.get_proxy_class("android.R$id")

#############################################################################
#
# Activity
#

class Activity
  attr_accessor :init_block

  def start_ruboto_dialog(remote_variable, &block)
    start_ruboto_activity(remote_variable, RubotoDialog, &block)
  end

  def start_ruboto_activity(remote_variable, klass=RubotoActivity, &block)
    @@init_block = block

    if @initialized or not self.is_a?(RubotoActivity)
      b = Bundle.new
      b.putString("Remote Variable", remote_variable)
      b.putBoolean("Define Remote Variable", true)
      b.putString("Initialize Script", "#{remote_variable}.initialize_activity")

      i = Intent.new
      i.setClass self, klass.java_class
      i.putExtra("RubotoActivity Config", b)

      self.startActivity i
    else
      instance_eval "#{remote_variable}=self"
      setRemoteVariable remote_variable
{'fraction_non_alphanumeric': 0.17125573633708802, 'fraction_numerical': 0.00041718815185648727, 'mean_word_length': 5.696927374301676, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6118726', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1466, 'n_words': 310}