Skip to content

Commit

Permalink
merging over removal all fdroid specific changes
Browse files Browse the repository at this point in the history
  • Loading branch information
balzack committed Jul 26, 2023
1 parent a8f300e commit 66c5be5
Show file tree
Hide file tree
Showing 17 changed files with 2,416 additions and 2,821 deletions.
11 changes: 3 additions & 8 deletions app/mobile/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import { RingContextProvider } from 'context/RingContext'
import { ChannelContextProvider } from 'context/ChannelContext';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import { ConversationContextProvider } from 'context/ConversationContext';
import { LogBox } from 'react-native';
import { Root } from 'src/root/Root';
import { Access } from 'src/access/Access';
import { Dashboard } from 'src/dashboard/Dashboard';
import { Session } from 'src/session/Session';
import ReceiveSharingIntent from 'react-native-receive-sharing-intent';
import { Platform, PermissionsAndroid } from 'react-native';
import { initUnifiedPush } from 'react-native-unifiedpush-connector';
import {PermissionsAndroid} from 'react-native';

// silence warning: Sending `onAnimatedValueUpdate` with no listeners registered
//LogBox.ignoreLogs(['Sending']);
Expand All @@ -29,11 +27,8 @@ export default function App() {
const [sharing, setSharing] = useState();

useEffect(() => {

if (Platform.OS !== 'ios') {
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
initUnifiedPush();
}

PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);

ReceiveSharingIntent.getReceivedFiles(files => {
setSharing(files);
Expand Down
18 changes: 9 additions & 9 deletions app/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply plugin: "com.facebook.react"

import com.android.build.OutputFile
Expand Down Expand Up @@ -59,7 +58,7 @@ react {
* use App Bundles (https://developer.android.com/guide/app-bundle/)
* and want to have separate APKs to upload to the Play Store.
*/
def enableSeparateBuildPerCPUArchitecture = false
def enableSeparateBuildPerCPUArchitecture = true

/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
Expand Down Expand Up @@ -94,18 +93,18 @@ android {

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

namespace "com.databag"
defaultConfig {
applicationId "com.databag"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1018
versionName "1.5"
versionCode 6
versionName "1.0"
}

splits {
Expand All @@ -116,6 +115,7 @@ compileOptions {
include (*reactNativeArchitectures())
}
}

signingConfigs {
release {
storeFile file('balzack.keystore')
Expand All @@ -124,6 +124,7 @@ compileOptions {
keyPassword 'balzack'
}
}

buildTypes {
debug {
signingConfig signingConfigs.debug
Expand Down Expand Up @@ -158,7 +159,6 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")


implementation 'androidx.core:core:1.8.0'

implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
Expand Down
39 changes: 0 additions & 39 deletions app/mobile/android/app/google-services.json

This file was deleted.

4 changes: 3 additions & 1 deletion app/mobile/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission tools:node="remove" android:name="android.vending.CHECK_LICENSE" />
<uses-permission tools:node="remove" android:name="com.android.vending.CHECK_LICENSE" />

<application
android:name=".MainApplication"
Expand Down Expand Up @@ -77,7 +79,7 @@

<receiver
android:enabled="true"
android:name="com.unifiedpushconnector.CustomReceiver"
android:name=".CustomReceiver"
android:exported="true">
<intent-filter>
<action android:name="org.unifiedpush.android.connector.MESSAGE"/>
Expand Down
103 changes: 103 additions & 0 deletions app/mobile/android/app/src/main/java/com/databag/CustomReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.databag;

import android.content.Context;
import org.jetbrains.annotations.NotNull;
import org.unifiedpush.android.connector.MessagingReceiver;
import android.util.Log;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;

import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.ActivityManager;
import android.os.Build;
import android.net.Uri;
import android.media.RingtoneManager;
import androidx.core.app.NotificationCompat;
import java.nio.charset.StandardCharsets;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

public class CustomReceiver extends MessagingReceiver {
public CustomReceiver() {
super();
}

private boolean forgrounded () {
ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
ActivityManager.getMyMemoryState(appProcessInfo);
return (appProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND || appProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_VISIBLE);
}

@Override
public void onNewEndpoint(@NotNull Context context, @NotNull String endpoint, @NotNull String instance) {

final ReactInstanceManager reactInstanceManager =
((ReactApplication) context.getApplicationContext())
.getReactNativeHost()
.getReactInstanceManager();
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();

WritableMap params = Arguments.createMap();
params.putString("instance", instance);
params.putString("endpoint", endpoint);
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("unifiedPushURL", params);

// Called when a new endpoint be used for sending push messages
}

@Override
public void onRegistrationFailed(@NotNull Context context, @NotNull String instance) {
// called when the registration is not possible, eg. no network
}

@Override
public void onUnregistered(@NotNull Context context, @NotNull String instance) {
// called when this application is unregistered from receiving push messages
}

@Override
public void onMessage(@NotNull Context context, @NotNull byte[] message, @NotNull String instance) {

if (forgrounded()) {
return;
}

String strMessage = new String(message, StandardCharsets.UTF_8);


Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* Request code */, intent,
PendingIntent.FLAG_IMMUTABLE);

String channelId = "fcm_default_channel";
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,
channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(strMessage).setAutoCancel(true).setSound(
defaultSoundUri).setContentIntent(pendingIntent);

NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Channel human readable title",
NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
}

notificationManager.notify(0, notificationBuilder.build());
}
}

19 changes: 19 additions & 0 deletions app/mobile/android/app/src/main/java/com/databag/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ protected String getMainComponentName() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
MainActivity activityContext = this;

this.getSharedPreferences("unifiedpush.connector", Context.MODE_PRIVATE).edit().putBoolean("unifiedpush.no_distrib_dialog", true).apply();


ReactInstanceManager mReactInstanceManager = getReactNativeHost().getReactInstanceManager();
mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
public void onReactContextInitialized(ReactContext validContext) {

UnifiedPush.registerAppWithDialog(
activityContext,
"default",
new RegistrationDialogContent(),
new ArrayList<String>(),
getApplicationContext().getPackageName()
);

}
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/mobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.15'
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.facebook.react:react-native-gradle-plugin")
}
Expand All @@ -32,3 +31,4 @@ allprojects {
}
}
}

5 changes: 0 additions & 5 deletions app/mobile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ import 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import messaging from '@react-native-firebase/messaging';

messaging().registerDeviceForRemoteMessages().then(() => {});

messaging().setBackgroundMessageHandler(async remoteMessage => {});

AppRegistry.registerComponent(appName, () => App);
3 changes: 0 additions & 3 deletions app/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"@bam.tech/react-native-image-resizer": "^3.0.5",
"@braintree/sanitize-url": "^6.0.2",
"@react-native-clipboard/clipboard": "^1.11.1",
"@react-native-firebase/app": "^17.2.0",
"@react-native-firebase/messaging": "^17.2.0",
"@react-navigation/bottom-tabs": "^6.5.5",
"@react-navigation/drawer": "^6.6.0",
"@react-navigation/native": "^6.1.4",
Expand Down Expand Up @@ -44,7 +42,6 @@
"react-native-screens": "^3.20.0",
"react-native-share": "^8.2.2",
"react-native-sqlite-storage": "^6.0.1",
"react-native-unifiedpush-connector": "^0.1.5",
"react-native-vector-icons": "^9.2.0",
"react-native-video": "^5.2.1",
"react-native-webrtc": "^106.0.7",
Expand Down
21 changes: 2 additions & 19 deletions app/mobile/src/access/admin/Admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,7 @@ export function Admin() {
</TouchableOpacity>
</View>

{ Platform.OS !== 'ios' && (
<View style={styles.tos}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<Text style={styles.viewtermstext}>View Terms of Service</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
{ state.agree && (
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
)}
{ !state.agree && (
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
)}
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
</TouchableOpacity>
</View>
)}

{ state.enabled && (Platform.OS === 'ios' || state.agree) && (
{ state.enabled && (
<TouchableOpacity style={styles.reset} onPress={admin}>
{ state.busy && (
<ActivityIndicator size="small" color="#ffffff" />
Expand All @@ -83,7 +66,7 @@ export function Admin() {
)}
</TouchableOpacity>
)}
{ (!state.enabled || (Platform.OS !== 'ios' && !state.agree)) && (
{ !state.enabled && (
<View style={styles.noreset}>
<Text style={styles.noresettext}>Access</Text>
</View>
Expand Down
21 changes: 2 additions & 19 deletions app/mobile/src/access/create/Create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,8 @@ export function Create() {
</View>
)}

{ Platform.OS !== 'ios' && (
<View style={styles.tos}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<Text style={styles.viewtermstext}>View Terms of Service</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
{ state.agree && (
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
)}
{ !state.agree && (
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
)}
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
</TouchableOpacity>
</View>
)}

<View style={styles.buttons}>
{ state.enabled && (Platform.OS === 'ios' || state.agree) && (
{ state.enabled && (
<TouchableOpacity style={styles.create} onPress={create}>
{ state.busy && (
<ActivityIndicator size="small" color="#ffffff" />
Expand All @@ -166,7 +149,7 @@ export function Create() {
)}
</TouchableOpacity>
)}
{ (!state.enabled || (Platform.OS !== 'ios' && !state.agree)) && (
{ !state.enabled && (
<View style={styles.nocreate}>
<Text style={styles.nocreatetext}>Create Account</Text>
</View>
Expand Down
Loading

0 comments on commit 66c5be5

Please sign in to comment.