protected function _prepareFiles() { // $source = $this->_sources_dst.'/java/com/'.$this->_formatted_bundle_name.'/'.$this->_folder_name; $source = $this->_sources_dst . '/java/' . str_replace(".", "/", $this->_package_name); $links = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, 4096), RecursiveIteratorIterator::SELF_FIRST); $allowed_extensions = array("java", "xml"); if (!$links) { return $this; } foreach ($links as $link) { if (!$link->isDir()) { $info = pathinfo($link->getPathName()); $extension = $info["extension"]; if (in_array($extension, $allowed_extensions)) { if (strpos($link, 'CommonUtilities.java') !== false) { $this->__replace(array('String SENDER_ID = ""' => 'String SENDER_ID = "' . Push_Model_Certificate::getAndroidSenderId() . '"', 'String APP_ID = ""' => 'String APP_ID = "' . $this->getApplication()->getId() . '"', 'SERVEUR_URL = "http://base.appsmobilecompany.com/";' => 'SERVEUR_URL = "' . $this->getUrl() . '";'), $link); } } } } $replacements = array('com.appsmobilecompany.base' => $this->_package_name, '[ENCRYPT_KEY]' => $this->getDevice()->getKeyPass()); $source = $this->_dst; $links = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, 4096), RecursiveIteratorIterator::SELF_FIRST); foreach ($links as $link) { if ($link->isDir()) { continue; } $this->__replace($replacements, $link->getRealPath()); } $this->__replace($replacements, $this->_sources_dst . '/AndroidManifest.xml'); $this->__replace($replacements, $this->_sources_dst . '/../../build.gradle'); $name = str_replace("'", "\\'", $this->getApplication()->getName()); // Retrieve the available languages $languages = Core_Model_Language::getLanguageCodes(); // Check if all the available languages exist in the Android source foreach ($languages as $lang) { if ($lang == "en") { continue; } if (stripos($lang, "_") !== false) { $lang = explode("_", $lang); if (count($lang) == 2) { $lang[1] = "r" . $lang[1]; } $lang = implode("-", $lang); } // If not, create them out of the English one. if (!file_exists($this->_sources_dst . '/res/values-' . $lang . '/strings.xml')) { mkdir($this->_sources_dst . '/res/values-' . $lang, 0777); copy($this->_sources_dst . '/res/values/strings.xml', $this->_sources_dst . '/res/values-' . $lang . '/strings.xml'); } } $replacements = array('http://localhost/overview' => $this->getApplication()->getUrl(null, array(), 'en', false), '<string name="app_name">Apps Mobile Company</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>'); $this->__replace($replacements, $this->_sources_dst . '/res/values/strings.xml'); if ($fbk_app_id = $this->getApplication()->getFacebookId()) { $replacements_sharing = array('<!-- FACEBOOK -->' => '<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>'); if ($this->getApplication()->getData("facebook_id")) { $replacements_sharing['<!-- FACEBOOK PROVIDER -->'] = '<provider android:authorities="com.facebook.app.FacebookContentProvider' . $fbk_app_id . '" android:name="com.facebook.FacebookContentProvider" android:exported="true" />'; } $replacements_sharing_ids = array('[FACEBOOK_APP_ID]' => $fbk_app_id); $this->__replace($replacements_sharing_ids, $this->_sources_dst . '/res/values/sharings_id.xml'); $this->__replace($replacements_sharing, $this->_sources_dst . '/AndroidManifest.xml'); } foreach ($languages as $lang) { if ($lang == "en") { continue; } if (stripos($lang, "_") !== false) { $android_lang = explode("_", $lang); if (count($android_lang) == 2) { $android_lang[1] = "r" . $android_lang[1]; } $android_lang = implode("-", $android_lang); } else { $android_lang = $lang; } $replacements = array('http://localhost/overview' => $this->getApplication()->getUrl(null, array(), $lang, false), '<string name="app_name">SiberianCMS</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>', '<string name="app_name">Apps Mobile Company</string>' => '<string name="app_name"><![CDATA[' . $name . ']]></string>'); $this->__replace($replacements, $this->_sources_dst . "/res/values-{$android_lang}/strings.xml"); } if (file_exists($this->_sources_dst . '/res/values-fr/strings.xml')) { $this->__replace($replacements, $this->_sources_dst . '/res/values-fr/strings.xml'); } $version = explode(".", $this->getDevice()->getVersion()); $version_code = !empty($version[0]) ? $version[0] : 1; $version_name = !empty($version[0]) && !empty($version[1]) ? $version[0] . "." . $version[1] : "1.0"; if ($version_code != 1 || $version_name != "1.0") { $replacements = array("versionCode 1" => "versionCode {$version_code}", 'versionName "1.0"' => 'versionName "' . $version_name . '"'); $this->__replace($replacements, $this->_sources_dst . "/../../build.gradle"); $this->__replace($replacements, $this->_sources_dst . "/../../build.gradle.save"); } return $this; }
public function findallAction() { $data = array("title" => '<i class="fa fa-android"></i> Android', "keys" => array(array("title" => "GCM Key", "name" => "android_key", "value" => Push_Model_Certificate::getAndroidKey()), array("title" => "Sender ID", "name" => "android_sender_id", "value" => Push_Model_Certificate::getAndroidSenderId()))); $this->_sendHtml($data); }