Android Open Source - HockeySDK-Android Locale Manager






From Project

Back to project page HockeySDK-Android.

License

The source code is released under:

Apache License

If you think the Android project HockeySDK-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.hockeyapp.android;
/*from   ww  w.  j  a  v a  2s.c o  m*/
import android.content.Context;
import android.text.TextUtils;

/**
 * <h3>Description</h3>
 *
 * The LocaleManager replaces statically initialized strings with
 * the respective strings defined in the resources.
 *
 * <h3>License</h3>
 *
 * <pre>
 * Copyright (c) 2011-2014 Bit Stadium GmbH
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * </pre>
 *
 * @author Patrick Eschenbach
 */
public class LocaleManager {
  /**
   * Replaces all statically defined strings with the strings defined in XML resources by its specific key.
   *
   * @param context The {@link android.content.Context} instance.
   */
  public static void initialize(Context context) {
    // Crash Dialog
    loadFromResources("hockeyapp_crash_dialog_title", Strings.CRASH_DIALOG_TITLE_ID, context);
    loadFromResources("hockeyapp_crash_dialog_message", Strings.CRASH_DIALOG_MESSAGE_ID, context);
    loadFromResources("hockeyapp_crash_dialog_negative_button", Strings.CRASH_DIALOG_NEGATIVE_BUTTON_ID, context);
    loadFromResources("hockeyapp_crash_dialog_positive_button", Strings.CRASH_DIALOG_POSITIVE_BUTTON_ID, context);

    // Download Failed
    loadFromResources("hockeyapp_download_failed_dialog_title", Strings.DOWNLOAD_FAILED_DIALOG_TITLE_ID, context);
    loadFromResources("hockeyapp_download_failed_dialog_message", Strings.DOWNLOAD_FAILED_DIALOG_MESSAGE_ID, context);
    loadFromResources("hockeyapp_download_failed_dialog_negative_button", Strings.DOWNLOAD_FAILED_DIALOG_NEGATIVE_BUTTON_ID, context);
    loadFromResources("hockeyapp_download_failed_dialog_positive_button", Strings.DOWNLOAD_FAILED_DIALOG_POSITIVE_BUTTON_ID, context);

    // Update
    loadFromResources("hockeyapp_update_mandatory_toast", Strings.UPDATE_MANDATORY_TOAST_ID, context);
    loadFromResources("hockeyapp_update_dialog_title", Strings.UPDATE_DIALOG_TITLE_ID, context);
    loadFromResources("hockeyapp_update_dialog_message", Strings.UPDATE_DIALOG_MESSAGE_ID, context);
    loadFromResources("hockeyapp_update_dialog_negative_button", Strings.UPDATE_DIALOG_NEGATIVE_BUTTON_ID, context);
    loadFromResources("hockeyapp_update_dialog_positive_button", Strings.UPDATE_DIALOG_POSITIVE_BUTTON_ID, context);

    // Expiry Info
    loadFromResources("hockeyapp_expiry_info_title", Strings.EXPIRY_INFO_TITLE_ID, context);
    loadFromResources("hockeyapp_expiry_info_text", Strings.EXPIRY_INFO_TEXT_ID, context);

    // Feedback Activity
    loadFromResources("hockeyapp_feedback_failed_title", Strings.FEEDBACK_FAILED_TITLE_ID, context);
    loadFromResources("hockeyapp_feedback_failed_text", Strings.FEEDBACK_FAILED_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_name_hint", Strings.FEEDBACK_NAME_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_feedback_email_hint", Strings.FEEDBACK_EMAIL_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_feedback_subject_hint", Strings.FEEDBACK_SUBJECT_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_feedback_message_hint", Strings.FEEDBACK_MESSAGE_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_feedback_last_updated_text", Strings.FEEDBACK_LAST_UPDATED_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_attachment_button_text", Strings.FEEDBACK_ATTACHMENT_BUTTON_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_send_button_text", Strings.FEEDBACK_SEND_BUTTON_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_response_button_text", Strings.FEEDBACK_RESPONSE_BUTTON_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_refresh_button_text", Strings.FEEDBACK_REFRESH_BUTTON_TEXT_ID, context);
    loadFromResources("hockeyapp_feedback_title", Strings.FEEDBACK_TITLE_ID, context);
    loadFromResources("hockeyapp_feedback_send_generic_error", Strings.FEEDBACK_SEND_GENERIC_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_send_network_error", Strings.FEEDBACK_SEND_NETWORK_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_validate_subject_error", Strings.FEEDBACK_VALIDATE_SUBJECT_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_validate_email_error", Strings.FEEDBACK_VALIDATE_EMAIL_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_validate_email_empty", Strings.FEEDBACK_VALIDATE_EMAIL_EMPTY_ID, context);
    loadFromResources("hockeyapp_feedback_validate_name_error", Strings.FEEDBACK_VALIDATE_NAME_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_validate_text_error", Strings.FEEDBACK_VALIDATE_TEXT_ERROR_ID, context);
    loadFromResources("hockeyapp_feedback_generic_error", Strings.FEEDBACK_GENERIC_ERROR_ID, context);

    // Login Activity
    loadFromResources("hockeyapp_login_headline_text", Strings.LOGIN_HEADLINE_TEXT_ID, context);
    loadFromResources("hockeyapp_login_missing_credentials_toast", Strings.LOGIN_MISSING_CREDENTIALS_TOAST_ID, context);
    loadFromResources("hockeyapp_login_email_hint", Strings.LOGIN_EMAIL_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_login_password_hint", Strings.LOGIN_PASSWORD_INPUT_HINT_ID, context);
    loadFromResources("hockeyapp_login_login_button_text", Strings.LOGIN_LOGIN_BUTTON_TEXT_ID, context);

    // Paint Activity
    loadFromResources("hockeyapp_paint_indicator_toast", Strings.PAINT_INDICATOR_TOAST_ID, context);
    loadFromResources("hockeyapp_paint_menu_save", Strings.PAINT_MENU_SAVE_ID, context);
    loadFromResources("hockeyapp_paint_menu_undo", Strings.PAINT_MENU_UNDO_ID, context);
    loadFromResources("hockeyapp_paint_menu_clear", Strings.PAINT_MENU_CLEAR_ID, context);
    loadFromResources("hockeyapp_paint_dialog_message", Strings.PAINT_DIALOG_MESSAGE_ID, context);
    loadFromResources("hockeyapp_paint_dialog_negative_button", Strings.PAINT_DIALOG_NEGATIVE_BUTTON_ID, context);
    loadFromResources("hockeyapp_paint_dialog_positive_button", Strings.PAINT_DIALOG_POSITIVE_BUTTON_ID, context);
  }

  private static void loadFromResources(String name, int resourceId, Context context) {
    int resId = context.getResources().getIdentifier(name, "string", context.getPackageName());
    if (resId == 0) {
      return;
    }

    String string = context.getString(resId);
    if (!TextUtils.isEmpty(string)) {
      Strings.set(resourceId, string);
    }
  }
}




Java Source Code List

net.hockeyapp.android.Constants.java
net.hockeyapp.android.CrashManagerListener.java
net.hockeyapp.android.CrashManager.java
net.hockeyapp.android.ExceptionHandler.java
net.hockeyapp.android.ExpiryInfoActivity.java
net.hockeyapp.android.FeedbackActivityInterface.java
net.hockeyapp.android.FeedbackActivity.java
net.hockeyapp.android.FeedbackManagerListener.java
net.hockeyapp.android.FeedbackManager.java
net.hockeyapp.android.LocaleManager.java
net.hockeyapp.android.LoginActivity.java
net.hockeyapp.android.LoginManagerListener.java
net.hockeyapp.android.LoginManager.java
net.hockeyapp.android.PaintActivity.java
net.hockeyapp.android.StringListener.java
net.hockeyapp.android.Strings.java
net.hockeyapp.android.Tracking.java
net.hockeyapp.android.UpdateActivityInterface.java
net.hockeyapp.android.UpdateActivity.java
net.hockeyapp.android.UpdateFragment.java
net.hockeyapp.android.UpdateInfoListener.java
net.hockeyapp.android.UpdateManagerListener.java
net.hockeyapp.android.UpdateManager.java
net.hockeyapp.android.adapters.MessagesAdapter.java
net.hockeyapp.android.listeners.DownloadFileListener.java
net.hockeyapp.android.listeners.SendFeedbackListener.java
net.hockeyapp.android.objects.ErrorObject.java
net.hockeyapp.android.objects.FeedbackAttachment.java
net.hockeyapp.android.objects.FeedbackMessage.java
net.hockeyapp.android.objects.FeedbackResponse.java
net.hockeyapp.android.objects.Feedback.java
net.hockeyapp.android.tasks.AttachmentDownloader.java
net.hockeyapp.android.tasks.CheckUpdateTaskWithUI.java
net.hockeyapp.android.tasks.CheckUpdateTask.java
net.hockeyapp.android.tasks.DownloadFileTask.java
net.hockeyapp.android.tasks.GetFileSizeTask.java
net.hockeyapp.android.tasks.LoginTask.java
net.hockeyapp.android.tasks.ParseFeedbackTask.java
net.hockeyapp.android.tasks.SendFeedbackTask.java
net.hockeyapp.android.utils.AsyncTaskUtils.java
net.hockeyapp.android.utils.Base64.java
net.hockeyapp.android.utils.ConnectionManager.java
net.hockeyapp.android.utils.DeviceUtils.java
net.hockeyapp.android.utils.FeedbackParser.java
net.hockeyapp.android.utils.ImageUtils.java
net.hockeyapp.android.utils.PrefsUtil.java
net.hockeyapp.android.utils.SimpleMultipartEntity.java
net.hockeyapp.android.utils.UiThreadUtil.java
net.hockeyapp.android.utils.Util.java
net.hockeyapp.android.utils.VersionCache.java
net.hockeyapp.android.utils.VersionHelper.java
net.hockeyapp.android.utils.ViewHelper.java
net.hockeyapp.android.views.AttachmentListView.java
net.hockeyapp.android.views.AttachmentView.java
net.hockeyapp.android.views.ExpiryInfoView.java
net.hockeyapp.android.views.FeedbackMessageView.java
net.hockeyapp.android.views.FeedbackView.java
net.hockeyapp.android.views.LoginView.java
net.hockeyapp.android.views.PaintView.java
net.hockeyapp.android.views.UpdateView.java