AppVersion.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* _____ _
  2. * |_ _| |_ _ _ ___ ___ _ __ __ _
  3. * | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. * |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. *
  6. * Threema Java Client
  7. * Copyright (c) 2013-2021 Threema GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. package ch.threema.client;
  22. public class AppVersion extends Version {
  23. private final String appVersionNumber;
  24. private final String appPlatformCode;
  25. private final String appLanguage;
  26. private final String appCountry;
  27. private final String appSystemModel;
  28. private final String appSystemVersion;
  29. /**
  30. * Create an app version object.
  31. *
  32. * @param appVersionNumber version number, a short string in the format major.minor (e.g. "1.0")
  33. * @param appPlatformCode platform code, single letter (A = Android, I = iPhone, J = Generic Java)
  34. * @param appLanguage language code, ISO 639-1 (e.g. "de", "en")
  35. * @param appCountry country code, ISO 3166-1 (e.g. "CH", "DE", "US")
  36. * @param appSystemModel system model string
  37. * @param appSystemVersion system version string
  38. */
  39. public AppVersion(String appVersionNumber, String appPlatformCode, String appLanguage, String appCountry, String appSystemModel, String appSystemVersion) {
  40. this.appVersionNumber = appVersionNumber;
  41. this.appPlatformCode = appPlatformCode;
  42. this.appLanguage = appLanguage;
  43. this.appCountry = appCountry;
  44. this.appSystemModel = appSystemModel;
  45. this.appSystemVersion = appSystemVersion;
  46. }
  47. @Override
  48. public String getVersion() {
  49. return appVersionNumber + appPlatformCode;
  50. }
  51. @Override
  52. public String getFullVersion() {
  53. return appVersionNumber.replace(";", "_") + ";" + appPlatformCode.replace(";", "_") + ";" +
  54. appLanguage.replace(";", "_") + "/" + appCountry.replace(";", "_") +
  55. ";" + appSystemModel.replace(";", "_") + ";" + appSystemVersion.replace(";", "_");
  56. }
  57. }