Skip to content

Commit

Permalink
Merge pull request #66 from Beldex-Coin/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
codeman-crypto authored Dec 16, 2024
2 parents 9fa34c1 + 3a5192a commit 8ca4532
Show file tree
Hide file tree
Showing 59 changed files with 1,590 additions and 963 deletions.
11 changes: 9 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dependencies {
configurations.all {
exclude module: "commons-logging"
}
def canonicalVersionCode = 73
def canonicalVersionName = "2.6.2"
def canonicalVersionCode = 74
def canonicalVersionName = "2.6.3"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down Expand Up @@ -146,32 +146,39 @@ android {
play {
dimension "distribution"

apply plugin: 'com.google.gms.google-services'
ext.websiteUpdateUrl = "null"
buildConfigField "boolean", "PLAY_STORE_DISABLED", "false"
buildConfigField "com.beldex.libbchat.utilities.Device", "DEVICE", "com.beldex.libbchat.utilities.Device.ANDROID"
buildConfigField "String", "NOPLAY_UPDATE_URL", "$ext.websiteUpdateUrl"
}
website {
dimension "distribution"

ext.websiteUpdateUrl = "https://github.com/Beldex-Coin/bchat-android/releases"
buildConfigField "boolean", "PLAY_STORE_DISABLED", "true"
buildConfigField "com.beldex.libbchat.utilities.Device", "DEVICE", "com.beldex.libbchat.utilities.Device.ANDROID"
buildConfigField "String", "NOPLAY_UPDATE_URL", "\"$ext.websiteUpdateUrl\""
}
mainNet {
dimension "targetNet"

apply plugin: 'com.google.gms.google-services'
buildConfigField "String", "NETWORK_TYPE", "\"mainnet\""
buildConfigField "String", "REPORT_ISSUE_ID", "\"bd27b58b7cfc65df45d1632c37609cdf3414040e2330b1814ec8fff2087d863952\""
buildConfigField "boolean", "USE_TESTNET", "false"
buildConfigField "String", "EXPLORER_URL", "\"https://explorer.beldex.io\""
buildConfigField "com.beldex.libbchat.utilities.Device", "DEVICE", "com.beldex.libbchat.utilities.Device.ANDROID"
}
devNet {
dimension "targetNet"

apply plugin: 'com.google.gms.google-services'
buildConfigField "String", "NETWORK_TYPE", "\"devnet\""
buildConfigField "String", "REPORT_ISSUE_ID", "\"bd27b58b7cfc65df45d1632c37609cdf3414040e2330b1814ec8fff2087d863952\""
buildConfigField "boolean", "USE_TESTNET", "true"
buildConfigField "String", "EXPLORER_URL", "\"http://154.26.139.105\""
buildConfigField "com.beldex.libbchat.utilities.Device", "DEVICE", "com.beldex.libbchat.utilities.Device.ANDROID"
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"project_info": {
"project_number": "225838187372",
"project_id": "bchat-android-ios",
"storage_bucket": "bchat-android-ios.appspot.com"
"storage_bucket": "bchat-android-ios.firebasestorage.app"
},
"client": [
{
Expand Down
28 changes: 14 additions & 14 deletions app/playMainNet/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"type": "UNIVERSAL",
"filters": [],
"attributes": [],
"versionCode": 73,
"versionName": "2.6.2",
"outputFile": "Bchat-2.6.2-universal.apk"
"versionCode": 74,
"versionName": "2.6.3",
"outputFile": "Bchat-2.6.3-universal.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -24,35 +24,35 @@
}
],
"attributes": [],
"versionCode": 73,
"versionName": "2.6.2",
"outputFile": "Bchat-2.6.2-x86_64.apk"
"versionCode": 74,
"versionName": "2.6.3",
"outputFile": "Bchat-2.6.3-x86_64.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 73,
"versionName": "2.6.2",
"outputFile": "Bchat-2.6.2-arm64-v8a.apk"
"versionCode": 74,
"versionName": "2.6.3",
"outputFile": "Bchat-2.6.3-armeabi-v7a.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 73,
"versionName": "2.6.2",
"outputFile": "Bchat-2.6.2-armeabi-v7a.apk"
"versionCode": 74,
"versionName": "2.6.3",
"outputFile": "Bchat-2.6.3-arm64-v8a.apk"
}
],
"elementType": "File"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@
android:theme="@style/Theme.Bchat.DayNight.NoActionBar" />

<service
android:name="io.beldex.bchat.notifications.PushNotificationService"
android:name="io.beldex.bchat.notifications.FirebasePushService"
android:enabled="true"
android:exported="false">
<intent-filter>
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/assets/changeLog.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@
"description":"Minor bug fixes"
}
]
},
{
"title": "2.6.3",
"descriptions": [
{
"description":"Improved push notification service"
},
{
"description":"Minor bug fixes"
}
]
}
]
}
41 changes: 7 additions & 34 deletions app/src/main/java/io/beldex/bchat/ApplicationContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.beldex.libbchat.messaging.utilities.WindowDebouncer;
import com.beldex.libbchat.mnode.MnodeModule;
import com.beldex.libbchat.utilities.Address;
import com.beldex.libbchat.utilities.Device;
import com.beldex.libbchat.utilities.ProfilePictureUtilities;
import com.beldex.libbchat.utilities.SSKEnvironment;
import com.beldex.libbchat.utilities.TextSecurePreferences;
Expand Down Expand Up @@ -70,9 +71,8 @@
import io.beldex.bchat.logging.UncaughtExceptionLogger;
import io.beldex.bchat.model.NetworkType;
import io.beldex.bchat.notifications.BackgroundPollWorker;
import io.beldex.bchat.notifications.BeldexPushNotificationManager;
import io.beldex.bchat.notifications.DefaultMessageNotifier;
import io.beldex.bchat.notifications.FcmUtils;
import io.beldex.bchat.notifications.PushRegistry;
import io.beldex.bchat.notifications.NotificationChannels;
import io.beldex.bchat.notifications.OptimizedMessageNotifier;
import io.beldex.bchat.providers.BlobProvider;
Expand Down Expand Up @@ -137,6 +137,8 @@ public class ApplicationContext extends Application implements DefaultLifecycleO

@Inject BeldexAPIDatabase beldexAPIDatabase;
@Inject Storage storage;
@Inject Device device;
@Inject PushRegistry pushRegistry;
@Inject MessageDataProvider messageDataProvider;
@Inject JobDatabase jobDatabase;
//New Line
Expand Down Expand Up @@ -194,6 +196,7 @@ public void onCreate() {
super.onCreate();
messagingModuleConfiguration = new MessagingModuleConfiguration(this,
storage,
device,
messageDataProvider,
()-> KeyPairUtilities.INSTANCE.getUserED25519KeyPair(this));
callMessageProcessor = new CallMessageProcessor(this, textSecurePreferences, ProcessLifecycleOwner.get().getLifecycle(), storage);
Expand All @@ -209,10 +212,6 @@ public void onCreate() {
broadcaster = new Broadcaster(this);
BeldexAPIDatabase apiDB = getDatabaseComponent().beldexAPIDatabase();
MnodeModule.Companion.configure(apiDB, broadcaster);
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
if (userPublicKey != null) {
registerForFCMIfNeeded(false);
}
UiModeUtilities.setupUiModeToUserSelected(this);
initializeExpiringMessageManager();
initializeTypingStatusRepository();
Expand Down Expand Up @@ -399,28 +398,6 @@ protected void attachBaseContext(Context base) {

private static class ProviderInitializationException extends RuntimeException { }

public void registerForFCMIfNeeded(final Boolean force) {
if (firebaseInstanceIdJob != null && firebaseInstanceIdJob.isActive() && !force) return;
if (force && firebaseInstanceIdJob != null) {
firebaseInstanceIdJob.cancel(null);
}
firebaseInstanceIdJob = FcmUtils.getFcmInstanceId(task->{
if (!task.isSuccessful()) {
Log.w("Beldex", "FirebaseMessaging.getInstance().token failed." + task.getException());
return Unit.INSTANCE;
}
String token = task.getResult();
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
if (userPublicKey == null) return Unit.INSTANCE;
if (TextSecurePreferences.isUsingFCM(this)) {
BeldexPushNotificationManager.register(token, userPublicKey, this, force);
} else {
BeldexPushNotificationManager.unregister(token, this);
}
return Unit.INSTANCE;
});
}

private void setUpPollingIfNeeded() {
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
if (userPublicKey == null) return;
Expand Down Expand Up @@ -474,18 +451,14 @@ private void resubmitProfilePictureIfNeeded() {
}

public void clearAllData(boolean isMigratingToV2KeyPair) {
String token = TextSecurePreferences.getFCMToken(this);
if (token != null && !token.isEmpty()) {
BeldexPushNotificationManager.unregister(token, this);
}
if (firebaseInstanceIdJob != null && firebaseInstanceIdJob.isActive()) {
firebaseInstanceIdJob.cancel(null);
}
String displayName = TextSecurePreferences.getProfileName(this);
boolean isUsingFCM = TextSecurePreferences.isUsingFCM(this);
boolean isUsingFCM = TextSecurePreferences.isPushEnabled(this);
TextSecurePreferences.clearAll(this);
if (isMigratingToV2KeyPair) {
TextSecurePreferences.setIsUsingFCM(this, isUsingFCM);
TextSecurePreferences.setPushEnabled(this, isUsingFCM);
TextSecurePreferences.setProfileName(this, displayName);
}
getSharedPreferences(PREFERENCES_NAME, 0).edit().clear().commit();
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/io/beldex/bchat/DeviceModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.beldex.bchat
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.beldex.bchat.BuildConfig
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object DeviceModule {
@Provides
@Singleton
fun provides() = BuildConfig.DEVICE
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object BackupPreferences {
addBackupEntryString(prefList, preferences, prefsFileName, TextSecurePreferences.PROFILE_AVATAR_URL_PREF)
addBackupEntryInt(prefList, preferences, prefsFileName, TextSecurePreferences.PROFILE_AVATAR_ID_PREF)
addBackupEntryString(prefList, preferences, prefsFileName, TextSecurePreferences.PROFILE_KEY_PREF)
addBackupEntryBoolean(prefList, preferences, prefsFileName, TextSecurePreferences.IS_USING_FCM)
addBackupEntryBoolean(prefList, preferences, prefsFileName, TextSecurePreferences.IS_PUSH_ENABLED)
return prefList
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import com.beldex.libbchat.messaging.contacts.Contact
import com.beldex.libbchat.messaging.sending_receiving.MessageSender
import com.beldex.libbchat.messaging.sending_receiving.groupSizeLimit
import com.beldex.libbchat.utilities.Address
import com.beldex.libbchat.utilities.Device
import com.beldex.libbchat.utilities.TextSecurePreferences
import com.beldex.libbchat.utilities.recipients.Recipient
import io.beldex.bchat.compose_utils.BChatCheckBox
Expand Down Expand Up @@ -91,6 +92,7 @@ fun CreateSecretGroup(
mutableStateOf("")
}
val context = LocalContext.current
var device: Device = Device.ANDROID
val keyboardController = LocalSoftwareKeyboardController.current
if (TextSecurePreferences.isScreenSecurityEnabled(context))
activity.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE) else {
Expand Down Expand Up @@ -271,7 +273,7 @@ fun CreateSecretGroup(
isButtonEnabled = false
scope.launch(Dispatchers.Main) {
if(CheckOnline.isOnline(context)) {
createClosedGroup(groupName.trim(), context, activity, selectedContact, showLoader={
createClosedGroup(device, groupName.trim(), context, activity, selectedContact, showLoader={
showLoader=it
})
}else {
Expand Down Expand Up @@ -409,6 +411,7 @@ fun getUserDisplayName(publicKey: String, context: Context): String {
}

private fun createClosedGroup(
device: Device,
name: String,
context: Context,
activity: Activity?,
Expand Down Expand Up @@ -445,7 +448,7 @@ private fun createClosedGroup(
}else {
showLoader(true)
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
MessageSender.createClosedGroup(name, selected + setOf(userPublicKey))
MessageSender.createClosedGroup(device, name, selected + setOf(userPublicKey))
.successUi { groupID ->
val threadID =
DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/beldex/bchat/crypto/IdentityKeyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class IdentityKeyUtil {
public static final String IDENTITY_PRIVATE_KEY_PREF = "pref_identity_private_v3";
public static final String ED25519_PUBLIC_KEY = "pref_ed25519_public_key";
public static final String ED25519_SECRET_KEY = "pref_ed25519_secret_key";
public static final String NOTIFICATION_KEY = "pref_notification_key";

public static final String BELDEX_SEED = "beldex_seed";
public static final String HAS_MIGRATED_KEY = "has_migrated_keys";
//New Line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.beldex.libbchat.messaging.sending_receiving.MessageSender
import com.beldex.libbchat.messaging.sending_receiving.groupSizeLimit
import com.beldex.libbchat.utilities.Address
import com.beldex.libbchat.utilities.Device
import com.beldex.libbchat.utilities.TextSecurePreferences
import com.beldex.libbchat.utilities.recipients.Recipient
import io.beldex.bchat.PassphraseRequiredActionBarActivity
Expand All @@ -32,8 +33,12 @@ import io.beldex.bchat.R
import io.beldex.bchat.databinding.ActivityCreateClosedGroupBinding
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
import javax.inject.Inject

class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderManager.LoaderCallbacks<List<String>> {
@Inject
lateinit var device: Device

private lateinit var binding: ActivityCreateClosedGroupBinding
private var isLoading = false
set(newValue) { field = newValue; invalidateOptionsMenu() }
Expand All @@ -58,6 +63,7 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderM
binding = ActivityCreateClosedGroupBinding.inflate(layoutInflater)
setContentView(binding.root)
supportActionBar!!.title = resources.getString(R.string.activity_create_closed_group_title)
device = Device.ANDROID

with(binding){
recyclerView.adapter = this@CreateClosedGroupActivity.selectContactsAdapter
Expand Down Expand Up @@ -163,7 +169,7 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderM
hideSoftKeyboard()
binding.nameEditText.text.clear()
binding.nameEditText.clearFocus()
MessageSender.createClosedGroup(name.toString(), selectedMembers + setOf( userPublicKey )).successUi { groupID ->
MessageSender.createClosedGroup(device, name.toString(), selectedMembers + setOf( userPublicKey )).successUi { groupID ->
binding.nameEditText.isFocusable = true
binding.loaderContainer.fadeOut()
isLoading = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager
import com.beldex.libbchat.messaging.sending_receiving.MessageSender
import com.beldex.libbchat.messaging.sending_receiving.groupSizeLimit
import com.beldex.libbchat.messaging.sending_receiving.notifications.PushNotificationAPI.context
import com.beldex.libbchat.utilities.Address
import com.beldex.libbchat.utilities.GroupUtil
import com.beldex.libbchat.utilities.TextSecurePreferences
Expand Down Expand Up @@ -110,7 +109,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
}

val recipient = Recipient.from(
context,
this,
Address.fromSerialized(groupID), false)
binding.profilePictureView.root.glide = glide
binding.profilePictureView.root.update(recipient, fromEditGroup = true)
Expand Down Expand Up @@ -283,20 +282,6 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
bottomSheet.show(supportFragmentManager, "GroupEditingOptionsBottomSheet")
}

private fun remove(member: String) {
val title = R.string.remove_this_contact
val message = R.string.remove_message
AlertDialog.Builder(context,R.style.BChatAlertDialog)
.setTitle(title)
.setMessage(message)
.setNegativeButton(android.R.string.no, null)
.setPositiveButton(R.string.RecipientPreferenceActivity_block) { _, _ ->
if (zombies.contains(member)) zombies.remove(member)
else members.remove(member)
updateMembers()
}.show()
}

private fun onAddMembersClick() {
val intent = Intent(this@EditClosedGroupActivity, SelectContactsActivity::class.java)
intent.putExtra(SelectContactsActivity.usersToExcludeKey, allMembers.toTypedArray())
Expand Down
Loading

0 comments on commit 8ca4532

Please sign in to comment.