io.appium.settings 4.0.7 → 4.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/app/build.gradle CHANGED
@@ -6,8 +6,8 @@ android {
6
6
  defaultConfig {
7
7
  minSdkVersion 18
8
8
  targetSdkVersion 30
9
- versionCode 40
10
- versionName "4.0.7"
9
+ versionCode 43
10
+ versionName "4.0.10"
11
11
  applicationId "io.appium.settings"
12
12
  }
13
13
 
@@ -27,7 +27,8 @@ android {
27
27
  }
28
28
 
29
29
  dependencies {
30
- implementation 'com.google.android.gms:play-services-location:19.0.0'
30
+ implementation 'com.google.android.gms:play-services-location:19.0.1'
31
+ implementation 'org.apache.commons:commons-lang3:3.12.0'
31
32
  }
32
33
 
33
34
  static def renameAPK(variant) {
@@ -16,11 +16,16 @@
16
16
 
17
17
  package io.appium.settings.receivers;
18
18
 
19
+ import static org.apache.commons.lang3.StringUtils.isBlank;
20
+
21
+ import android.app.Activity;
19
22
  import android.content.BroadcastReceiver;
20
23
  import android.content.Context;
21
24
  import android.content.Intent;
22
25
  import android.util.Log;
23
26
 
27
+ import org.apache.commons.lang3.LocaleUtils;
28
+
24
29
  import java.util.Locale;
25
30
 
26
31
  import io.appium.settings.handlers.LocaleSettingHandler;
@@ -37,40 +42,40 @@ public class LocaleSettingReceiver extends BroadcastReceiver implements HasActio
37
42
  // am broadcast -a io.appium.settings.locale --es lang ja --es country JP
38
43
  @Override
39
44
  public void onReceive(Context context, Intent intent) {
40
- if(!hasExtraLocale(intent)) {
41
- Log.e(TAG, "Don't forget to set lang and country like: am broadcast -a io.appium.settings.locale --es lang ja --es country JP");
42
- Log.e(TAG, "Set en-US by default.");
43
-
44
- intent.putExtra(LANG, "en");
45
- intent.putExtra(COUNTRY, "US");
46
- }
47
-
48
45
  String language = intent.getStringExtra(LANG);
49
46
  String country = intent.getStringExtra(COUNTRY);
50
-
47
+ if (language == null || country == null) {
48
+ Log.w(TAG, "It is required to provide both language and country, for example: " +
49
+ "am broadcast -a io.appium.settings.locale --es lang ja --es country JP");
50
+ Log.i(TAG, "Set en-US by default.");
51
+ language = "en";
52
+ country= "US";
53
+ }
51
54
  // Expect https://developer.android.com/reference/java/util/Locale.html#Locale(java.lang.String,%20java.lang.String) format.
52
55
  Locale locale = new Locale(language, country);
53
-
54
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
55
- String script = intent.getStringExtra(SCRIPT);
56
-
57
- Locale.Builder builder = new Locale.Builder();
58
- builder.setLocale(locale);
59
- builder.setScript(script == null ? "" : script); // "Hans" part
60
- locale = builder.build();
61
- // "zh-Hans-CN" or "zh-CN" format
62
- Log.i(TAG, "Set language tag: " + locale.toLanguageTag());
63
- } else {
64
- Log.i(TAG, "Set locale: " + locale.toString());
56
+ String script = intent.getStringExtra(SCRIPT);
57
+ if (!isBlank(script)) {
58
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
59
+ locale = new Locale.Builder().setLocale(locale).setScript(script).build();
60
+ } else {
61
+ Log.w(TAG, String.format("Script value '%s' is ignored as " +
62
+ "setting of it is not supported by the current Android version", script));
63
+ }
64
+ }
65
+ if (!LocaleUtils.isAvailableLocale(locale)) {
66
+ Log.e(TAG, String.format(
67
+ "The locale %s is not known. Only the following locales are available: %s",
68
+ locale, LocaleUtils.availableLocaleList())
69
+ );
70
+ setResultCode(Activity.RESULT_CANCELED);
71
+ setResultData(String.format("The locale %s is not known", locale));
72
+ return;
65
73
  }
66
74
 
67
- LocaleSettingHandler localeSettingHandler = new LocaleSettingHandler(context);
68
-
69
- localeSettingHandler.setLocale(locale);
70
- }
71
-
72
- private boolean hasExtraLocale(Intent intent) {
73
- return intent.hasExtra(LANG) && intent.hasExtra(COUNTRY);
75
+ new LocaleSettingHandler(context).setLocale(locale);
76
+ Log.i(TAG, String.format("Set locale: %s", locale));
77
+ setResultCode(Activity.RESULT_OK);
78
+ setResultData(locale.toString());
74
79
  }
75
80
 
76
81
  @Override
package/build.gradle CHANGED
@@ -5,7 +5,7 @@ buildscript {
5
5
  mavenCentral()
6
6
  }
7
7
  dependencies {
8
- classpath 'com.android.tools.build:gradle:7.0.3'
8
+ classpath 'com.android.tools.build:gradle:7.2.0'
9
9
  }
10
10
  }
11
11
 
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "io.appium.settings",
3
- "version": "4.0.7",
3
+ "version": "4.0.10",
4
4
  "description": "App for dealing with Android settings",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "homepage": "https://github.com/appium/io.appium.settings",
42
42
  "devDependencies": {
43
- "@appium/gulp-plugins": "^6.0.0",
43
+ "@appium/gulp-plugins": "^7.0.0",
44
44
  "@semantic-release/git": "^10.0.1",
45
45
  "gulp": "^4.0.0",
46
46
  "semantic-release": "^19.0.2"