mirror of https://github.com/jitsi/jitsi-meet
parent
d521deecc4
commit
3fdffa7497
@ -0,0 +1,56 @@ |
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import android.content.Context; |
||||
import android.content.pm.ApplicationInfo; |
||||
import android.content.pm.PackageInfo; |
||||
import android.content.pm.PackageManager; |
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext; |
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
class AppInfoModule extends ReactContextBaseJavaModule { |
||||
/** |
||||
* React Native module name. |
||||
*/ |
||||
private static final String MODULE_NAME = "AppInfo"; |
||||
|
||||
public AppInfoModule(ReactApplicationContext reactContext) { |
||||
super(reactContext); |
||||
} |
||||
|
||||
/** |
||||
* Gets a mapping with the constants this module is exporting. |
||||
* |
||||
* @return a {@link Map} mapping the constants to be exported with their |
||||
* values. |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> getConstants() { |
||||
Map<String, Object> constants = new HashMap<>(); |
||||
Context context = getReactApplicationContext(); |
||||
PackageManager pm = context.getPackageManager(); |
||||
ApplicationInfo appInfo; |
||||
PackageInfo packageInfo; |
||||
|
||||
try { |
||||
appInfo = pm.getApplicationInfo(context.getPackageName(), 0); |
||||
packageInfo = pm.getPackageInfo(context.getPackageName(), 0); |
||||
} catch (PackageManager.NameNotFoundException e) { |
||||
constants.put("name", ""); |
||||
constants.put("version", ""); |
||||
return constants; |
||||
} |
||||
|
||||
constants.put("name", pm.getApplicationLabel(appInfo)); |
||||
constants.put("version", packageInfo.versionName); |
||||
return constants; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return MODULE_NAME; |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
/* |
||||
* Copyright @ 2017-present Atlassian Pty Ltd |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
#import "RCTBridgeModule.h" |
||||
#import "RCTLog.h" |
||||
|
||||
#import <AVFoundation/AVFoundation.h> |
||||
|
||||
@interface AppInfo : NSObject<RCTBridgeModule> |
||||
@end |
||||
|
||||
@implementation AppInfo |
||||
|
||||
RCT_EXPORT_MODULE(); |
||||
|
||||
- (NSDictionary *)constantsToExport { |
||||
NSString *name = [[[NSBundle mainBundle]infoDictionary]objectForKey :@"CFBundleDisplayName"]; |
||||
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; |
||||
if (version == nil) { |
||||
version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
||||
if (version == nil) { |
||||
version = @""; |
||||
} |
||||
} |
||||
|
||||
return @{ @"name" : name, @"version" : version }; |
||||
}; |
||||
|
||||
@end |
Loading…
Reference in new issue