Browse Source

Coding style

master
Lyubo Marinov 7 years ago
parent
commit
b55faab33e

+ 4
- 6
android/sdk/src/main/java/org/jitsi/meet/sdk/AndroidSettingsModule.java View File

15
 import com.facebook.react.bridge.ReactMethod;
15
 import com.facebook.react.bridge.ReactMethod;
16
 
16
 
17
 class AndroidSettingsModule extends ReactContextBaseJavaModule {
17
 class AndroidSettingsModule extends ReactContextBaseJavaModule {
18
-    /**
19
-     * React Native module name.
20
-     */
21
-    private static final String MODULE_NAME = "AndroidSettings";
22
-
23
     public AndroidSettingsModule(ReactApplicationContext reactContext) {
18
     public AndroidSettingsModule(ReactApplicationContext reactContext) {
24
         super(reactContext);
19
         super(reactContext);
25
     }
20
     }
26
 
21
 
22
+    /**
23
+     * {@inheritDoc}
24
+     */
27
     @Override
25
     @Override
28
     public String getName() {
26
     public String getName() {
29
-        return MODULE_NAME;
27
+        return "AndroidSettings";
30
     }
28
     }
31
 
29
 
32
     @ReactMethod
30
     @ReactMethod

+ 27
- 19
android/sdk/src/main/java/org/jitsi/meet/sdk/AppInfoModule.java View File

12
 import java.util.Map;
12
 import java.util.Map;
13
 
13
 
14
 class AppInfoModule extends ReactContextBaseJavaModule {
14
 class AppInfoModule extends ReactContextBaseJavaModule {
15
-    /**
16
-     * React Native module name.
17
-     */
18
-    private static final String MODULE_NAME = "AppInfo";
19
-
20
     public AppInfoModule(ReactApplicationContext reactContext) {
15
     public AppInfoModule(ReactApplicationContext reactContext) {
21
         super(reactContext);
16
         super(reactContext);
22
     }
17
     }
23
 
18
 
24
     /**
19
     /**
25
-     * Gets a mapping with the constants this module is exporting.
20
+     * Gets a <tt>Map</tt> of constants this module exports to JS. Supports JSON
21
+     * types.
26
      *
22
      *
27
-     * @return a {@link Map} mapping the constants to be exported with their
28
-     * values.
23
+     * @return a {@link Map} of constants this module exports to JS
29
      */
24
      */
30
     @Override
25
     @Override
31
     public Map<String, Object> getConstants() {
26
     public Map<String, Object> getConstants() {
32
-        Map<String, Object> constants = new HashMap<>();
33
         Context context = getReactApplicationContext();
27
         Context context = getReactApplicationContext();
34
-        PackageManager pm = context.getPackageManager();
35
-        ApplicationInfo appInfo;
28
+        PackageManager packageManager = context.getPackageManager();
29
+        ApplicationInfo applicationInfo;
36
         PackageInfo packageInfo;
30
         PackageInfo packageInfo;
37
 
31
 
38
         try {
32
         try {
39
-             appInfo = pm.getApplicationInfo(context.getPackageName(), 0);
40
-             packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
33
+             String packageName = context.getPackageName();
34
+
35
+             applicationInfo
36
+                 = packageManager.getApplicationInfo(packageName, 0);
37
+             packageInfo = packageManager.getPackageInfo(packageName, 0);
41
         } catch (PackageManager.NameNotFoundException e) {
38
         } catch (PackageManager.NameNotFoundException e) {
42
-            constants.put("name", "");
43
-            constants.put("version", "");
44
-            return constants;
39
+             applicationInfo = null;
40
+             packageInfo = null;
45
         }
41
         }
46
 
42
 
47
-        constants.put("name", pm.getApplicationLabel(appInfo));
48
-        constants.put("version", packageInfo.versionName);
43
+        Map<String, Object> constants = new HashMap<>();
44
+
45
+        constants.put(
46
+            "name",
47
+            applicationInfo == null
48
+                ? ""
49
+                : packageManager.getApplicationLabel(applicationInfo));
50
+        constants.put(
51
+            "version",
52
+            packageInfo == null ? "" : packageInfo.versionName);
53
+
49
         return constants;
54
         return constants;
50
     }
55
     }
51
 
56
 
57
+    /**
58
+     * {@inheritDoc}
59
+     */
52
     @Override
60
     @Override
53
     public String getName() {
61
     public String getName() {
54
-        return MODULE_NAME;
62
+        return "AppInfo";
55
     }
63
     }
56
 }
64
 }

+ 4
- 3
android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java View File

74
             : Intent.ACTION_HEADSET_PLUG;
74
             : Intent.ACTION_HEADSET_PLUG;
75
 
75
 
76
     /**
76
     /**
77
-     * React Native module name.
77
+     * The name of <tt>AudioModeModule</tt> to be used in the React Native
78
+     * bridge.
78
      */
79
      */
79
     private static final String MODULE_NAME = "AudioMode";
80
     private static final String MODULE_NAME = "AudioMode";
80
 
81
 
81
     /**
82
     /**
82
-     * Tag used when logging messages.
83
+     * The <tt>Log</tt> tag <tt>AudioModeModule</tt> is to log messages with.
83
      */
84
      */
84
     static final String TAG = MODULE_NAME;
85
     static final String TAG = MODULE_NAME;
85
 
86
 
155
     }
156
     }
156
 
157
 
157
     /**
158
     /**
158
-     * Gets the name for this module, to be used in the React Native bridge.
159
+     * Gets the name for this module to be used in the React Native bridge.
159
      *
160
      *
160
      * @return a string with the module name.
161
      * @return a string with the module name.
161
      */
162
      */

+ 1
- 6
android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java View File

47
     private static final Map<String, Method> JITSI_MEET_VIEW_LISTENER_METHODS
47
     private static final Map<String, Method> JITSI_MEET_VIEW_LISTENER_METHODS
48
         = new HashMap<>();
48
         = new HashMap<>();
49
 
49
 
50
-    /**
51
-     * The name of this module to be used in the React Native bridge.
52
-     */
53
-    private static final String MODULE_NAME = "ExternalAPI";
54
-
55
     static {
50
     static {
56
         // Figure out the mapping between the JitsiMeetViewListener methods
51
         // Figure out the mapping between the JitsiMeetViewListener methods
57
         // and the events i.e. redux action types.
52
         // and the events i.e. redux action types.
113
      */
108
      */
114
     @Override
109
     @Override
115
     public String getName() {
110
     public String getName() {
116
-        return MODULE_NAME;
111
+        return "ExternalAPI";
117
     }
112
     }
118
 
113
 
119
     /**
114
     /**

+ 2
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/ProximityModule.java View File

33
  */
33
  */
34
 class ProximityModule extends ReactContextBaseJavaModule {
34
 class ProximityModule extends ReactContextBaseJavaModule {
35
     /**
35
     /**
36
-     * React Native module name.
36
+     * The name of <tt>ProximityModule</tt> to be used in the React Native
37
+     * bridge.
37
      */
38
      */
38
     private static final String MODULE_NAME = "Proximity";
39
     private static final String MODULE_NAME = "Proximity";
39
 
40
 

+ 10
- 4
ios/sdk/src/AppInfo.m View File

27
 RCT_EXPORT_MODULE();
27
 RCT_EXPORT_MODULE();
28
 
28
 
29
 - (NSDictionary *)constantsToExport {
29
 - (NSDictionary *)constantsToExport {
30
-    NSString *name = [[[NSBundle mainBundle]infoDictionary]objectForKey :@"CFBundleDisplayName"];
31
-    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
30
+    NSDictionary<NSString *, id> *infoDictionary
31
+        = [[NSBundle mainBundle] infoDictionary];
32
+    NSString *name = infoDictionary[@"CFBundleDisplayName"];
33
+    NSString *version = infoDictionary[@"CFBundleShortVersionString"];
34
+
32
     if (version == nil) {
35
     if (version == nil) {
33
-        version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
36
+        version = infoDictionary[@"CFBundleVersion"];
34
         if (version == nil) {
37
         if (version == nil) {
35
             version = @"";
38
             version = @"";
36
         }
39
         }
37
     }
40
     }
38
 
41
 
39
-    return @{ @"name" : name, @"version" : version };
42
+    return @{
43
+        @"name": name,
44
+        @"version": version
45
+    };
40
 };
46
 };
41
 
47
 
42
 @end
48
 @end

Loading…
Cancel
Save