Skip to content

Commit

Permalink
Merge pull request #619 from zurichat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
CephasPeter authored Oct 30, 2021
2 parents 2ced48a + 6bb12e4 commit 8481966
Show file tree
Hide file tree
Showing 49 changed files with 1,141 additions and 492 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CreateDialog(private val layoutInflaterr: LayoutInflater,
//save to shared preferences
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString("name", java.lang.String.valueOf(name.text.toString()))
editor.putString(getString(R.string.name), java.lang.String.valueOf(name.text.toString()))
editor.apply()
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ class CreateDialog(private val layoutInflaterr: LayoutInflater,

val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString("about", java.lang.String.valueOf(about.text.toString()))
editor.putString(getString(R.string.about), java.lang.String.valueOf(about.text.toString()))
editor.apply()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void startrecord() {
try {
mediaRecorder.prepare();
mediaRecorder.start();
Toast.makeText(DocumentSentActivity.this, "recording", Toast.LENGTH_SHORT).show();
Toast.makeText(DocumentSentActivity.this, getString(R.string.recording), Toast.LENGTH_SHORT).show();
}catch (Exception e){
e.printStackTrace();
// Toast.makeText(MainActivity.this, "recording error", Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class MainActivity : AppCompatActivity() {
val requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
//Shows Toast message if permission is granted or denied.
if (isGranted) {
Toast.makeText(this, "Permission Granted!", Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(R.string.permission_granted), Toast.LENGTH_LONG).show()
} else {
Toast.makeText(this, "Permission Denied!", Toast.LENGTH_LONG).show()
Toast.makeText(this, getString(R.string.permission_denied), Toast.LENGTH_LONG).show()
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ class MainActivity : AppCompatActivity() {
val isConnected: Boolean = activeNetwork?.isConnectedOrConnecting == true

if(!isConnected){
Toast.makeText(applicationContext,"No Internet Connection!",Toast.LENGTH_LONG).show()
Toast.makeText(applicationContext,getString(R.string.hello_blank_fragment),Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (intent.resolveActivity(getPackageManager()) != null){
activityResultLauncher.launch(intent);
}else{
Toast.makeText(OpenCameraActivity.this, "Unable to Start Camera!",
Toast.makeText(OpenCameraActivity.this, getString(R.string.unable_to_start_camera),
Toast.LENGTH_SHORT).show();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ open class ProfileActivity: AppCompatActivity() {

//user = intent.extras?.getParcelable("USER")!!

user = intent.getParcelableExtra<User>("USER") as User
user = intent.getParcelableExtra<User>(getString(R.string.user)) as User
setContentView(R.layout.activity_profile)

token = user?.token
Expand Down Expand Up @@ -154,8 +154,8 @@ open class ProfileActivity: AppCompatActivity() {
val phoneTextView = findViewById<TextView>(R.id.tv_phoneno)

with(builder){
setTitle("Edit Phone Number")
setPositiveButton("Save"){ _, _ ->
setTitle(getString(R.string.edit_number))
setPositiveButton(getString(R.string.save)){ _, _ ->

phoneTextView.text = editText.text.toString() // populates the value of the

Expand All @@ -169,7 +169,7 @@ open class ProfileActivity: AppCompatActivity() {
editor.apply()

}
setNegativeButton("Cancel") { _, _ ->
setNegativeButton(getString(R.string.cancel_mute_channel_settings)) { _, _ ->
Timber.d("This button clicked successfully!!") //just for log purposes
}
setView(dialogLayout)
Expand All @@ -196,7 +196,7 @@ open class ProfileActivity: AppCompatActivity() {
//set profile photo to image uri
profilePhoto.setImageURI(uri)
profilePhoto.invalidate()
Toast.makeText(this, "Update Successful", Toast.LENGTH_SHORT).show()
Toast.makeText(this, getString(R.string.successful), Toast.LENGTH_SHORT).show()
updateProfilePhoto(uri)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ private void sendAudio() {
@java.lang.Override
public void onResponse(Call call, Response response) {
if(response.isSuccessful()){
Toast.makeText(AudiosActivity.this, "Sent Successfully", Toast.LENGTH_SHORT).show();
Toast.makeText(AudiosActivity.this, getString(R.string.sent_successfully), Toast.LENGTH_SHORT).show();
}else if (response.code() == 400){
Toast.makeText(AudiosActivity.this, "Error 400, invalid", Toast.LENGTH_SHORT).show();
Toast.makeText(AudiosActivity.this, getString(R.string.invalid_error), Toast.LENGTH_SHORT).show();

}else if (response.code() == 404){
Toast.makeText(AudiosActivity.this, "Error 404, Not found", Toast.LENGTH_SHORT).show();
Toast.makeText(AudiosActivity.this, getString(R.string.not_found_error), Toast.LENGTH_SHORT).show();

}else if (response.code() == 401){
Toast.makeText(AudiosActivity.this, "Error 400, invalid", Toast.LENGTH_SHORT).show();
Toast.makeText(AudiosActivity.this, getString(R.string.invalid_error), Toast.LENGTH_SHORT).show();

}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/zurichat/app/ui/dm/DMFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DMFragment : Fragment(R.layout.fragment_dm) {
senderId = roomList.room_user_ids.last()

binding.iconBtn.setOnClickListener {
Toast.makeText(context, "Show Emoji", Toast.LENGTH_LONG).show()
Toast.makeText(context, getString(R.string.show_emoji), Toast.LENGTH_LONG).show()
}

// arguments?.let { bundle ->
Expand Down Expand Up @@ -202,7 +202,7 @@ class DMFragment : Fragment(R.layout.fragment_dm) {
when (imageResult) {
is ImageResult.Success -> handleAttachmentUpload(listOf(imageResult.value))
is ImageResult.Failure -> {
Toast.makeText(requireContext(), "Picture not taken", Toast.LENGTH_LONG).show()
Toast.makeText(requireContext(), getString(R.string.picture_not_taken), Toast.LENGTH_LONG).show()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fun makeNotification(context: Context, message: String) {
val notification = NotificationCompat.Builder(context, CHANNEL_ID)
.setContentText(message)
.setAutoCancel(true)
.setContentTitle("New message")
.setContentTitle(context.getString(R.string.new_message))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIcon(R.drawable.notifications_icon)
.setContentIntent(pendingIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.zurichat.app.ui.dm_chat.fragment
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.format.DateUtils
import android.util.Log
import android.view.LayoutInflater
Expand All @@ -29,16 +27,12 @@ import com.zurichat.app.models.User
import com.zurichat.app.ui.add_channel.BaseItem
import com.zurichat.app.ui.add_channel.BaseListAdapter
import com.zurichat.app.ui.dm.MEDIA
import com.zurichat.app.ui.dm_chat.apiservice.ApiDMService
import com.zurichat.app.ui.dm_chat.model.request.SendMessageBody
import com.zurichat.app.ui.dm_chat.model.response.message.BaseRoomData
import com.zurichat.app.ui.dm_chat.model.response.message.Data
import com.zurichat.app.ui.dm_chat.model.response.message.Result
import com.zurichat.app.ui.dm_chat.model.response.message.SendMessageResponse
import com.zurichat.app.ui.dm_chat.model.response.room.RoomsListResponseItem
import com.zurichat.app.ui.dm_chat.repository.Repository
import com.zurichat.app.ui.dm_chat.viewmodel.RoomViewModel
import com.zurichat.app.ui.dm_chat.viewmodel.RoomViewModelFactory
import com.zurichat.app.ui.fragments.channel_chat.ChannelHeaderItem
import com.zurichat.app.ui.fragments.home_screen.CentrifugeClient
import com.zurichat.app.util.isInternetAvailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ private void sendDocument() {
@java.lang.Override
public void onResponse(Call call, Response response) {
if(response.isSuccessful()){
Toast.makeText(DocumentActivity.this, "Sent Successfully", Toast.LENGTH_SHORT).show();
Toast.makeText(DocumentActivity.this, getString(R.string.successful), Toast.LENGTH_SHORT).show();
}else if (response.code() == 400){
Toast.makeText(DocumentActivity.this, "Error 400, invalid", Toast.LENGTH_SHORT).show();
Toast.makeText(DocumentActivity.this, getString(R.string.invalid_error), Toast.LENGTH_SHORT).show();

}else if (response.code() == 404){
Toast.makeText(DocumentActivity.this, "Error 404, Not found", Toast.LENGTH_SHORT).show();
Toast.makeText(DocumentActivity.this, getString(R.string.not_found_error), Toast.LENGTH_SHORT).show();

}else if (response.code() == 401){
Toast.makeText(DocumentActivity.this, "Error 400, invalid", Toast.LENGTH_SHORT).show();
Toast.makeText(DocumentActivity.this, getString(R.string.invalid_error), Toast.LENGTH_SHORT).show();

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ChannelChatFragment : Fragment() {
//sendVoiceNote.visibility = View.VISIBLE
dimmerBox.visibility = View.GONE
toolbar.subtitle = channel.members.plus(1).toString().plus(" Members")
Toast.makeText(requireContext(), "Joined Channel Successfully", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.join_channel_success), Toast.LENGTH_SHORT).show()
binding.channelJoinBar.visibility = View.GONE
channelJoined = true
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ class ChannelsFragment : Fragment(R.layout.fragment_channels) {

private fun showSnackBar() {
val view: View = CoordinatorLayout(requireContext())
val snack = Snackbar.make(view, "An Error Occurred!", Snackbar.LENGTH_INDEFINITE)
snack.setAction("Retry") {
val snack = Snackbar.make(view, getString(R.string.an_error_occured), Snackbar.LENGTH_INDEFINITE)
snack.setAction(getString(R.string.retry)) {
viewModel.getChannelsList(organizationID)
}
snack.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AccountsFragment : Fragment() {
if (!user.isNullOrEmpty())textView.visibility = View.GONE
adapter.setData(user)
if (user.isNotEmpty()){
toolbar.subtitle = user.size.toString()+ " Account(s)"
toolbar.subtitle = user.size.toString()+ getString(R.string.accts)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class ChangePassFragment: Fragment(R.layout.fragment_confirm_password) {
val newPassFld = binding.textEditNewpass
val confPassFld = binding.textEditConfirmpassWord
if (newPassFld.text.toString()==confPassFld.text.toString()){
Toast.makeText(requireContext(), "Password match", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.password_match), Toast.LENGTH_SHORT).show()
updatePass(newPassFld.text.toString())
}else if (newPassFld.text.toString()!=confPassFld.text.toString()){
binding.textEditNewpass.error = "Password doesn't match"
binding.textEditNewpass.error = getString(R.string.password_not_match)
}
}

Expand All @@ -83,19 +83,19 @@ class ChangePassFragment: Fragment(R.layout.fragment_confirm_password) {

userViewModel.deleteUser(args.account)
val action = ChangePassFragmentDirections.actionChangePassFragmentToLoginActivity()
Toast.makeText(requireContext(), "password change successful\n Fresh # required",
Toast.makeText(requireContext(), getString(R.string.fresh_sign_in),
Toast.LENGTH_SHORT).show()
findNavController().navigate(action)
requireActivity().finish()
}

private fun updateError(throwable: Throwable){
Toast.makeText(requireContext(), "Please try again", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.please_try_again), Toast.LENGTH_SHORT).show()
Timber.e(throwable)
}

private fun handleLoading(){
Toast.makeText(requireContext(), "Please wait", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.pls_wait), Toast.LENGTH_SHORT).show()
}

//update user state in database
Expand All @@ -119,16 +119,16 @@ class ChangePassFragment: Fragment(R.layout.fragment_confirm_password) {
when (it) {
is Result.Success -> {
Toast.makeText(context,
"You have been successfully logged out of previous account",
getString(R.string.log_out_success),
Toast.LENGTH_SHORT).show()
updateUser()
logoutSuccess()
}
is Result.Error -> {
Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show()
Toast.makeText(context, getString(R.string.error), Toast.LENGTH_SHORT).show()
}
is Result.Loading -> {
Toast.makeText(context, "Loading", Toast.LENGTH_SHORT).show()
Toast.makeText(context, getString(R.string.loading), Toast.LENGTH_SHORT).show()
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ class EnterOtpACFragment:Fragment(R.layout.fragment_enter_otp) {
}

private fun resetSuccess(){
Toast.makeText(requireContext(), "correct code", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.correct_code), Toast.LENGTH_SHORT).show()
val otpCode = binding.pinView.text.toString()
val action = EnterOtpACFragmentDirections
.actionEnterOtpACFragmentToChangePassFragment(args.account,otpCode,args.curUser)
findNavController().navigate(action)
}

private fun resetError(throwable: Throwable){
Toast.makeText(requireContext(), "Wrong code try again", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.wrong_code_retry), Toast.LENGTH_SHORT).show()
Timber.e(throwable)
}

private fun handleLoading() {
Toast.makeText(context, "Please wait", Toast.LENGTH_LONG).show()
Toast.makeText(context, getString(R.string.pls_wait), Toast.LENGTH_LONG).show()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ class ForgetAccountPassword : Fragment(R.layout.fragment_forget_account_pass) {
success(message)
}
is Result.Error -> {
Toast.makeText(requireContext(), "please try again", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.please_try_again), Toast.LENGTH_SHORT).show()
}
is Result.Loading ->{
Toast.makeText(requireContext(), "please wait", Toast.LENGTH_SHORT).show()
Toast.makeText(requireContext(), getString(R.string.pls_wait), Toast.LENGTH_SHORT).show()
}
}
})
}

private fun dialogue (){
MaterialAlertDialogBuilder(requireContext())
.setTitle("Confirmation ")
.setMessage("Are you sure you want to reset the password for this account?")
.setNegativeButton("No"){dialog,which->
.setTitle(getString(R.string.confirm))
.setMessage(getString(R.string.sure_reset_password))
.setNegativeButton(getString(R.string.no)){dialog,which->

}
.setPositiveButton("Yes"){dialog,which->
.setPositiveButton(getString(R.string.yes)){dialog,which->
viewModel.passwordReset(PasswordResetBody(args.account.email))
}
.show()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/zurichat/app/ui/#/#Activity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class LoginActivity : AppCompatActivity() {
val isConnected: Boolean = activeNetwork?.isConnectedOrConnecting == true

if(!isConnected){
Toast.makeText(applicationContext,"No Internet Connection!",Toast.LENGTH_LONG).show()
Toast.makeText(applicationContext,getString(R.string.hello_blank_fragment),Toast.LENGTH_LONG).show()
/*val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.fragment_placeholder, InternetFragment())
ft.commit()*/
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/zurichat/app/ui/#/#ViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.zurichat.app.ui.login

import androidx.lifecycle.*
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.zurichat.app.data.repository.UserRepository
import com.zurichat.app.models.*
import com.zurichat.app.ui.login.password.confirm.ConfirmPasswordData
Expand All @@ -9,10 +12,10 @@ import com.zurichat.app.ui.login.password.resetuserpass.ResetUserPasswordRespons
import com.zurichat.app.util.Result
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers

@HiltViewModel
class LoginViewModel @Inject constructor(private val repository: UserRepository) : ViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class NewChannelDataFragment : Fragment(R.layout.fragment_new_channel_data) {
bundle.putBoolean("Channel Joined", true)

if (binding.channelName.text!!.isEmpty()) {
binding.channelName.error = "Channel name can't be empty."
binding.channelName.error = getString(R.string.channel_name_not_empty)
} else {
try {
findNavController().navigate(R.id.channelChatFragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ class SelectMemberFragment : Fragment(R.layout.fragment_select_member) {
if (it.isEmpty()) {
binding.topRecyclerView.visibility = View.GONE
binding.fabAddChannel.visibility = View.GONE
binding.toolbar.subtitle = "Choose Channel Members"
binding.toolbar.subtitle = getString(R.string.choose_channel_members)
} else {
binding.topRecyclerView.visibility = View.VISIBLE
binding.fabAddChannel.visibility = View.VISIBLE
selectedMemberAdapter.selectedUserList = it
selectedMemberAdapter.notifyDataSetChanged()
binding.toolbar.subtitle = "${selectedUsers.size} out of ${userList.size} selected"
binding.toolbar.subtitle = "${selectedUsers.size}" + getString(R.string.out_of) + "${userList.size}" + getString(
R.string.selected)
binding.topRecyclerView.smoothScrollToPosition(selectedUsers.size - 1)

}
Expand Down
Loading

0 comments on commit 8481966

Please # to comment.