IprintLicenseInfo.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package epson.common;
  2. import android.content.Context;
  3. import androidx.annotation.NonNull;
  4. import com.epson.mobilephone.common.license.DefaultLicenseInfo;
  5. import java.util.Locale;
  6. import epson.print.R;
  7. /**
  8. *
  9. */
  10. public class IprintLicenseInfo extends DefaultLicenseInfo {
  11. private static final int LICENSE_VERSION_CODE = 70006;
  12. private static final int PRIVACY_STATEMENT_VERSION_CODE = 60600;
  13. public int getLicenseAgreement(@NonNull Context context) {
  14. IprintAppRecord iprintAppRecord = new IprintAppRecord();
  15. if (!iprintAppRecord.getLicenseAgreementValue(context)) {
  16. return -1;
  17. }
  18. int licenseAgreeVersionCode = iprintAppRecord.getLicenseAgreeVersionCode(context);
  19. return licenseAgreeVersionCode < LICENSE_VERSION_CODE ? licenseAgreeVersionCode < PRIVACY_STATEMENT_VERSION_CODE ? 0 : 1 : licenseAgreeVersionCode < PRIVACY_STATEMENT_VERSION_CODE ? 2 : 3;
  20. }
  21. public void setLicenceAgreement(@NonNull Context context) {
  22. new IprintAppRecord().setLicenseAgreement(context, Math.max(LICENSE_VERSION_CODE, PRIVACY_STATEMENT_VERSION_CODE), true);
  23. }
  24. public String getDocumentString(@NonNull Context context, int i) {
  25. switch (i) {
  26. case 1:
  27. return getLicenseText(context);
  28. case 2:
  29. String language = Locale.getDefault().getLanguage();
  30. if (language == null || !language.equalsIgnoreCase(Locale.JAPAN.getLanguage())) {
  31. return Utils.getAssetsFileContents(context, "iPrint_PRIVACY_STATEMENT20180322.txt");
  32. }
  33. return Utils.getAssetsFileContents(context, "iPrint_privacy_statement_jp20180122.txt");
  34. case 3:
  35. return Utils.getAssetsFileContents(context, "oss_license.txt");
  36. default:
  37. return super.getDocumentString(context, i);
  38. }
  39. }
  40. private String getLicenseText(@NonNull Context context) {
  41. return Utils.getAssetsFileContents(context, "License.txt");
  42. }
  43. public String getApplicationName(@NonNull Context context) {
  44. return context.getString(R.string.app_name);
  45. }
  46. public static boolean isAgreedCurrentVersion(@NonNull Context context) {
  47. return new IprintLicenseInfo().getLicenseAgreement(context) == 3;
  48. }
  49. /**
  50. * 是否同意隐私协议检测
  51. *
  52. * @param context
  53. */
  54. public static void beforeLicenseCheck(@NonNull Context context) {
  55. if (!new IprintAppRecord().getLicenseAgreementValue(context)) {
  56. ExternalFileUtils.getInstance(context).clearRemotePrintersInfo();
  57. ExternalFileUtils.getInstance(context).clearIpPrintersInfo();
  58. }
  59. }
  60. }