-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
244 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,13 @@ android { | |
buildTypes { | ||
debug { | ||
buildConfigField "String", "BASE_URL", "\"https://mashup.lhy.kr/\"" | ||
buildConfigField "String", "FEED_BACK_EMAIL", "\"[email protected]\"" | ||
} | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
buildConfigField "String", "BASE_URL", "\"\"" | ||
buildConfigField "String", "FEED_BACK_EMAIL", "\"[email protected]\"" | ||
} | ||
} | ||
dataBinding { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/mashup/app/setting/SettingBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mashup.app.setting | ||
|
||
import android.graphics.Paint | ||
import android.widget.TextView | ||
import androidx.databinding.BindingAdapter | ||
import com.mashup.BuildConfig | ||
|
||
@BindingAdapter("app:email") | ||
fun TextView.setEmailText(string: String) { | ||
text = string | ||
paintFlags = Paint.UNDERLINE_TEXT_FLAG | ||
} |
58 changes: 47 additions & 11 deletions
58
app/src/main/java/com/mashup/app/setting/SettingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,68 @@ | ||
package com.mashup.app.setting | ||
|
||
import androidx.lifecycle.ViewModelProviders | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.mashup.app.login.LoginFragment | ||
import com.mashup.databinding.SettingFragmentBinding | ||
import com.mashup.util.EventObserver | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
import com.mashup.BuildConfig | ||
import com.mashup.R | ||
import com.mashup.app.login.LoginActivity | ||
|
||
|
||
class SettingFragment : Fragment() { | ||
|
||
companion object { | ||
fun newInstance() = SettingFragment() | ||
} | ||
private val viewModel: SettingViewModel by viewModel() | ||
private lateinit var viewDataBinding: SettingFragmentBinding | ||
|
||
private lateinit var viewModel: SettingViewModel | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return inflater.inflate(R.layout.setting_fragment, container, false) | ||
viewDataBinding = SettingFragmentBinding.inflate(inflater, container, false).apply { | ||
viewmodel = viewModel | ||
} | ||
return viewDataBinding.root | ||
} | ||
|
||
override fun onActivityCreated(savedInstanceState: Bundle?) { | ||
super.onActivityCreated(savedInstanceState) | ||
viewModel = ViewModelProviders.of(this).get(SettingViewModel::class.java) | ||
// TODO: Use the ViewModel | ||
viewDataBinding.setLifecycleOwner(this.viewLifecycleOwner) | ||
setupEventObserver() | ||
} | ||
|
||
private fun setupEventObserver() { | ||
viewModel.logoutEvent.observe(viewLifecycleOwner, EventObserver { | ||
if (it) { | ||
activity?.finishAffinity() | ||
val intent = Intent(this.context, LoginActivity::class.java) | ||
startActivity(intent) | ||
} | ||
}) | ||
|
||
viewModel.sendEmailEvent.observe(viewLifecycleOwner, EventObserver { | ||
if (it) { | ||
val intent = Intent(Intent.ACTION_SEND).apply { | ||
val addressees: Array<String> = arrayOf(BuildConfig.FEED_BACK_EMAIL) | ||
putExtra(Intent.EXTRA_EMAIL, addressees) | ||
putExtra( | ||
Intent.EXTRA_SUBJECT, | ||
"<" + getString(R.string.app_name) + " " + getString(R.string.setting_send_feedback_email_title) + ">" | ||
) | ||
putExtra( | ||
Intent.EXTRA_TEXT, | ||
"앱 버전 (AppVersion):${BuildConfig.VERSION_NAME}\n기기명 (Device):\n안드로이드 OS (Android OS):\n내용 (Content):\n" | ||
) | ||
type = "message/rfc822" | ||
} | ||
startActivity(intent) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mashup.app.setting | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val SettingModule = module { | ||
viewModel { SettingViewModel(get()) } | ||
} |
23 changes: 21 additions & 2 deletions
23
app/src/main/java/com/mashup/app/setting/SettingViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
package com.mashup.app.setting | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.mashup.repository.user.UserRepository | ||
import com.mashup.util.Event | ||
|
||
class SettingViewModel : ViewModel() { | ||
// TODO: Implement the ViewModel | ||
class SettingViewModel( | ||
private val userRepository: UserRepository | ||
) : ViewModel() { | ||
private val _logoutEvent = MutableLiveData<Event<Boolean>>() | ||
val logoutEvent: LiveData<Event<Boolean>> = _logoutEvent | ||
|
||
private val _sendEmailEvent = MutableLiveData<Event<Boolean>>() | ||
val sendEmailEvent: LiveData<Event<Boolean>> = _sendEmailEvent | ||
|
||
fun sendFeedBackEmail() { | ||
_sendEmailEvent.value = Event(true) | ||
} | ||
|
||
fun onClickLogoutButton() { | ||
userRepository.logout() | ||
_logoutEvent.value = Event(true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.