Skip to content

Commit

Permalink
Merge pull request #117 from arpitmx/Mohit
Browse files Browse the repository at this point in the history
Mohit
  • Loading branch information
arpitmx authored Feb 11, 2024
2 parents 33ecfcc + 17b6f56 commit c29dcfb
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 134 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/com/ncs/o2/Constants/Endpoints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ object Endpoints {
const val APP_CONFIG = "AppConfig"
const val USERID = "userid1"
const val new_changes_des = "Certainly! In order to provide you with a more personalized description, could you please specify what kind of description you are looking for? Are you interested in a description of a person, a place, an event, or something else? Additionally, if you have any specific details or preferences in mind, feel free to share them, so I can tailor the description to your needs.```xml <application> <meta-data android:name=\"firebase_performance_logcat_enabled\" android:value=\"true\" /> </application>```"
const val defaultProject="Oxidizer"
const val defaultAlias="OXR"
const val defaultSegment="Getting started"
const val defaultProject="None" //Oxidizer
const val defaultAlias="None" //OXR
const val defaultSegment="Select Segment" //Getting started
val defaultSections=listOf("Must Read", "Features", "Working", "Instructions")
const val defaultLightSensi=.1F
const val defaultMediumSensi=1.5F
const val defaultHeavySensi=2.5F
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/ncs/o2/HelperClasses/PrefManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ object PrefManager {
val type = object : TypeToken<List<String>>() {}.type
return gson.fromJson(sectionsJson, type)
}else{
return listOf("Must Read", "Features", "Working", "Instructions")
return Endpoints.defaultSections
}
}
fun putProjectsList(projects:List<String>){
Expand Down Expand Up @@ -669,6 +669,9 @@ object PrefManager {
}

fun setAppMode(mode:String) {
if (mode==Endpoints.OFFLINE_MODE){
PrefManager.setShakePref(false)
}
editor.putString("appMode", mode)
editor.apply()
}
Expand Down
122 changes: 102 additions & 20 deletions app/src/main/java/com/ncs/o2/UI/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,39 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.


}
binding.gioActionbar.refresh.setOnClickThrottleBounceListener {
if (PrefManager.getAppMode()==Endpoints.ONLINE_MODE){
startActivity(Intent(this,CreateTaskActivity::class.java))
}
else{
easyElements.showSnackbar(binding.root,"Task Creation is not available in offline mode",3000)
}
}

manageNoProject()

}

private fun manageNoProject(){
if (PrefManager.getcurrentProject()=="None"){
binding.projectPlaceholder.visible()
binding.navHostFragmentActivityMain.gone()
binding.bottomNavParent.gone()
binding.gioActionbar.teamsSearch.gone()
binding.gioActionbar.notifications.gone()
binding.gioActionbar.btnMoreTeams.gone()
binding.gioActionbar.searchCont.gone()
PrefManager.setRadioButton(-1)
}
else{
binding.navHostFragmentActivityMain.visible()
binding.bottomNavParent.visible()
binding.gioActionbar.teamsSearch.visible()
binding.gioActionbar.notifications.visible()
binding.gioActionbar.btnMoreTeams.visible()
binding.projectPlaceholder.gone()

}
}

private fun initShake(){
Expand Down Expand Up @@ -297,10 +328,10 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.

// Set up various views and components
setUpProjects()
setUpActionBar()
setUpViewsOnClicks()
setupProjectsList()
setBottomNavBar()
setUpActionBar()

}

Expand Down Expand Up @@ -413,6 +444,7 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.

override fun onResume() {
super.onResume()
manageNoProject()
if (PrefManager.getShakePref()){
initShake()
shakeDetector.registerListener()
Expand Down Expand Up @@ -451,9 +483,18 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
}

binding.gioActionbar.btnQuickTask.setOnClickThrottleBounceListener {
val quickTaskBottomSheet =
AddQuickTaskBottomSheet(Message(messageId = "", messageType = MessageType.NORMAL_MSG, timestamp = Timestamp.now(), senderId = "", additionalData = emptyMap(), content = ""))
quickTaskBottomSheet.show(supportFragmentManager, "quickTask")
if (PrefManager.getAppMode()==Endpoints.ONLINE_MODE){
val quickTaskBottomSheet =
AddQuickTaskBottomSheet(Message(messageId = "", messageType = MessageType.NORMAL_MSG, timestamp = Timestamp.now(), senderId = "", additionalData = emptyMap(), content = ""))
quickTaskBottomSheet.show(supportFragmentManager, "quickTask")
}else {

easyElements.showSnackbar(
binding.root,
"Task Creation is not available in offline mode",
3000
)
}
}


Expand Down Expand Up @@ -585,19 +626,31 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
}
private fun setupProjectsList(){


manageNoProject()
//Version tag setup
binding.drawerheaderfile.versionCode.text = "Oxygen v${getVersionName(this)}"

projects=PrefManager.getProjectsList().toMutableList()
val list=ArrayList<String>()
list.addAll(projects)
if (list.contains("None")){
list.remove("None")
}
val recyclerView=binding.drawerheaderfile.projectRecyclerView
projectListAdapter = RecyclerViewAdapter(this,list)
val linearLayoutManager = LinearLayoutManager(this)
linearLayoutManager.orientation = LinearLayoutManager.VERTICAL
recyclerView.layoutManager = linearLayoutManager
recyclerView.adapter = projectListAdapter
if (list.isEmpty()){
recyclerView.gone()
binding.drawerheaderfile.projectPlaceholder.visible()
}
else{
recyclerView.visible()
binding.drawerheaderfile.projectPlaceholder.gone()
projectListAdapter = RecyclerViewAdapter(this,list)
val linearLayoutManager = LinearLayoutManager(this)
linearLayoutManager.orientation = LinearLayoutManager.VERTICAL
recyclerView.layoutManager = linearLayoutManager
recyclerView.adapter = projectListAdapter
}

}

override fun onClick(projectID: String, position: Int) {
Expand Down Expand Up @@ -625,6 +678,8 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
setUpTags(projectName = projectID)

}
manageNoProject()

}


Expand Down Expand Up @@ -829,11 +884,18 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
}

override fun onProjectAdded(userProjects: ArrayList<String>) {
manageNoProject()
Log.d("projectCheck",PrefManager.getProjectsList().toString())
PrefManager.putProjectsList(userProjects)
Log.d("projectCheck",PrefManager.getProjectsList().toString())
setupProjectsList()
projectListAdapter.notifyDataSetChanged()
if (this::projectListAdapter.isInitialized) {
projectListAdapter.notifyDataSetChanged()
}
else{
projectListAdapter = RecyclerViewAdapter(this,PrefManager.getProjectsList())
projectListAdapter.notifyDataSetChanged()
}
}

override fun onNewIntent(intent: Intent?) {
Expand Down Expand Up @@ -927,10 +989,17 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
}
}
Log.d("position",position.toString())
PrefManager.setcurrentProject(project)
PrefManager.setRadioButton(position)
PrefManager.selectedPosition.value = position
projectListAdapter.notifyDataSetChanged()

if (this@MainActivity::projectListAdapter.isInitialized) {
PrefManager.setcurrentProject(project)
PrefManager.setRadioButton(position)
PrefManager.selectedPosition.value = position
projectListAdapter.notifyDataSetChanged()
}
else{
projectListAdapter = RecyclerViewAdapter(this@MainActivity,PrefManager.getProjectsList())
projectListAdapter.notifyDataSetChanged()
}
setupProjectsList()
val intent =
Intent(this@MainActivity, TaskDetailActivity::class.java)
Expand Down Expand Up @@ -987,10 +1056,17 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
}
}
Log.d("position",position.toString())
PrefManager.setcurrentProject(project)
PrefManager.setRadioButton(position)
PrefManager.selectedPosition.value = position
projectListAdapter.notifyDataSetChanged()

if (this@MainActivity::projectListAdapter.isInitialized) {
PrefManager.setcurrentProject(project)
PrefManager.setRadioButton(position)
PrefManager.selectedPosition.value = position
projectListAdapter.notifyDataSetChanged()
}
else{
projectListAdapter = RecyclerViewAdapter(this@MainActivity,PrefManager.getProjectsList())
projectListAdapter.notifyDataSetChanged()
}
setupProjectsList()
val intent =
Intent(this@MainActivity, TaskDetailActivity::class.java)
Expand Down Expand Up @@ -1064,7 +1140,13 @@ class MainActivity : AppCompatActivity(), ProjectCallback,AddProjectBottomSheet.
projects.addAll(result.data)
Timber.tag("result").d(result.data.toString())
PrefManager.putProjectsList(result.data)
projectListAdapter.notifyDataSetChanged()
if (this@MainActivity::projectListAdapter.isInitialized) {
projectListAdapter.notifyDataSetChanged()
}
else{
projectListAdapter = RecyclerViewAdapter(this@MainActivity,PrefManager.getProjectsList())
projectListAdapter.notifyDataSetChanged()
}
setupProjectsList()
CoroutineScope(Dispatchers.IO).launch {
val list = getProjectSegments(PrefManager.getlastaddedproject())
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/ncs/o2/UI/NewChanges.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NewChanges : AppCompatActivity() {


setViews()
val desc="## Release Notes [24.1.24] - [24/01/2024]\n" +
val desc="## Release Notes [24.2.10] - [10/02/2024]\n" +
"\n" +
"### New Features\n" +
" - Created project stats: Now you can easily track and analyze project statistics within the app.\n" +
Expand Down Expand Up @@ -67,7 +67,7 @@ class NewChanges : AppCompatActivity() {
"- Made general improvements in UX\n" +
"\n" +
"### How to Update\n" +
"- Latest Version of O2 is 24.1.24, it can be downloaded from the release page, find version 24.1.24 at [Release Page](https://github.com/arpitmx/Oxygen/releases)\n" +
"- Latest Version of O2 is 24.2.10, it can be downloaded from the release page, find version 24.2.10 at [Release Page](https://github.com/arpitmx/Oxygen/releases)\n" +
"\n" +
"### Feedback\n" +
"- Feedback is the key to enhancing user experience, it is our appeal to the users for providing any constructive feedback about any issues faced by them.\n" +
Expand Down
56 changes: 33 additions & 23 deletions app/src/main/java/com/ncs/o2/UI/Report/ShakePrefrencesFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ncs.o2.UI.Report

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
Expand All @@ -8,13 +9,15 @@ import android.view.ViewGroup
import android.widget.ImageView
import com.ncs.o2.Domain.Utility.ExtensionsUtil.gone
import com.ncs.o2.Domain.Utility.ExtensionsUtil.setOnClickThrottleBounceListener
import com.ncs.o2.Domain.Utility.ExtensionsUtil.toast
import com.ncs.o2.Domain.Utility.ExtensionsUtil.visible
import com.ncs.o2.Domain.Utility.GlobalUtils
import com.ncs.o2.HelperClasses.PrefManager
import com.ncs.o2.R
import com.ncs.o2.UI.MainActivity
import com.ncs.o2.databinding.FragmentShakePrefrencesBinding
import com.ncs.o2.databinding.FragmentTeamsBinding
import com.ncs.versa.Constants.Endpoints
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

Expand Down Expand Up @@ -72,32 +75,39 @@ class ShakePrefrencesFragment() : Fragment() {
}

binding.simpleSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
PrefManager.setShakePref(true)
binding.shakeControls.visible()
binding.message.visible()

binding.light.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(1)
setUpViews()
}
binding.medium.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(2)
setUpViews()

}
binding.heavy.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(3)
setUpViews()
if (PrefManager.getAppMode()== Endpoints.ONLINE_MODE) {
if (isChecked) {
PrefManager.setShakePref(true)
binding.shakeControls.visible()
binding.message.visible()

binding.light.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(1)
setUpViews()
}
binding.medium.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(2)
setUpViews()

}
binding.heavy.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(3)
setUpViews()

}

} else {
PrefManager.setShakePref(false)
binding.shakeControls.gone()
binding.message.gone()

}

} else {
PrefManager.setShakePref(false)
binding.shakeControls.gone()
binding.message.gone()

}
else{
binding.simpleSwitch.isChecked=false
toast("Shake to Report is not available while offline")
}

}
binding.light.setOnClickThrottleBounceListener{
PrefManager.setShakeSensitivity(1)
Expand Down
20 changes: 13 additions & 7 deletions app/src/main/java/com/ncs/o2/UI/Setting/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class SettingsActivity : AppCompatActivity(), settingAdater.onSettingClick,Netwo
settingOption("Edit Profile", R.drawable.round_edit_24, ""),

settingTitle("what's new"),
settingOption("What's New", R.drawable.baseline_info_24, "Version 24.1.24"),
settingOption("What's New", R.drawable.baseline_info_24, "Version 24.2.10"),

settingTitle("Report & Feedback"),
settingOption("Feedback", R.drawable.baseline_feedback_24, ""),
settingOption("Shake to Report", R.drawable.baseline_screen_rotation_24, ""),


settingTitle("Logs"),
settingOption("Logs", R.drawable.baseline_assistant_24, ""),
// settingTitle("Logs"),
// settingOption("Logs", R.drawable.baseline_assistant_24, ""),

settingTitle("Account"),
settingOption("Log Out", R.drawable.logout, "") ,
Expand Down Expand Up @@ -162,10 +162,16 @@ class SettingsActivity : AppCompatActivity(), settingAdater.onSettingClick,Netwo
this.overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left)
}
else if(Codes.STRINGS.clickedSetting == "Feedback"){
val intent = Intent(this, ShakeDetectedActivity::class.java)
intent.putExtra("type", "report")
startActivity(intent)
this.overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left)
if (PrefManager.getAppMode()== Endpoints.ONLINE_MODE) {
val intent = Intent(this, ShakeDetectedActivity::class.java)
intent.putExtra("type", "report")
startActivity(intent)
this.overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left)
}
else{
util.showSnackbar(binding.root,"Feedback can't be given in offline mode",2000)
}

}
}

Expand Down
Loading

0 comments on commit c29dcfb

Please sign in to comment.