Skip to content

Commit

Permalink
Conflicts resolved and addressed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
manimaran96 committed Mar 5, 2023
1 parent e02f4aa commit 8bff155
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object ApiClient {

private fun getWiktionaryApiUrl(langCode: String): String {
return String.format(Urls.WIKTIONARY, langCode.makeNullIfEmpty()
?: pref?.languageCodes4wContributelang)
?: pref?.languageCodeSpell4WikiAll)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,13 @@ class PrefManager(private val mContext: Context?) {
editor.apply()
}

var languageCodes4wContributelang: String?
var languageCodeSpell4WikiAll: String?
get() = pref.getString(SPELL_4_WIKI_ALL, "ta")
set(languageCode) {
editor.putString(SPELL_4_WIKI_ALL, languageCode)
editor.apply()
}

var languageCodeWiktionary: String?
get() = pref.getString(LANGUAGE_CODE_WIKTIONARY, "ta")
set(languageCode) {
editor.putString(LANGUAGE_CODE_WIKTIONARY, languageCode)
editor.apply()
}
var uploadAudioLicense: String?
get() = pref.getString(UPLOAD_AUDIO_LICENSE, WikiLicense.LicensePrefs.CC_0)
set(uploadAudioLicense) {
Expand Down Expand Up @@ -137,11 +131,7 @@ class PrefManager(private val mContext: Context?) {
private const val IS_LOGGED_IN_USER = "is_logged_in_user"
private const val IS_ANONYMOUS_USER = "is_anonymous_user" // Only wiktionary use
private const val IS_FIRST_TIME_LAUNCH = "is_first_time_launch"
private const val SPELL_4_WIKI_ALL = "language_code_spell_4_wiki_contri_lang"
private const val LANGUAGE_CODE_SPELL_4_WIKI = "language_code_spell_4_wiki"
private const val LANGUAGE_CODE_SPELL_4_WORD_LIST = "language_code_spell_4_word_list"
private const val LANGUAGE_CODE_SPELL_4_WORD = "language_code_spell_4_word"
private const val LANGUAGE_CODE_WIKTIONARY = "language_code_wiktionary"
private const val SPELL_4_WIKI_ALL = "language_code_spell_4_wiki_all"
private const val UPLOAD_AUDIO_LICENSE = "upload_audio_license"
private const val RUN_FILTER_NO_OF_WORDS_TO_CHECK = "run_filter_no_of_words_to_check"
private const val WORDS_CATEGORY_FOR_LANG = "words_category_for_%s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ class LanguageSelectionFragment(private val mActivity: Activity) : BottomSheetDi
val languageSelectionListener = object : OnLanguageSelectionListener {
override fun onCallBackListener(langCode: String?) {
when (listMode) {

ListMode.WIKTIONARY -> pref.languageCodeWiktionary = langCode
ListMode.SPELL_4_WIKI_ALL -> pref.languageCodes4wContributelang = langCode

ListMode.SPELL_4_WIKI_ALL -> pref.languageCodeSpell4WikiAll = langCode
ListMode.TEMP -> {
}
}
Expand Down Expand Up @@ -136,20 +133,15 @@ class LanguageSelectionFragment(private val mActivity: Activity) : BottomSheetDi

private val existingLanguageCode: String?
get() = when (listMode) {

ListMode.WIKTIONARY -> pref.languageCodeWiktionary
ListMode.SPELL_4_WIKI_ALL -> pref.languageCodes4wContributelang

ListMode.SPELL_4_WIKI_ALL -> pref.languageCodeSpell4WikiAll
ListMode.TEMP -> null
else -> null
}
private val subTitleInfo: String?
get() {
var info: String? = null
when (listMode) {

ListMode.SPELL_4_WIKI_ALL -> info = getString(R.string.Spell_4_wiktionary_Contribution)

ListMode.SPELL_4_WIKI_ALL -> info = getString(R.string.spell_4_wiki_all)
ListMode.TEMP -> info = getString(R.string.temporary)
}
if (info != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class RecordAudioActivity : BaseActivity() {
wikiLangDao = DBHelper.getInstance(applicationContext).appDatabase.wikiLangDao
wordsHaveAudioDao = DBHelper.getInstance(applicationContext).appDatabase.wordsHaveAudioDao

langCode = intent?.extras?.getString(AppConstants.LANGUAGE_CODE, pref.languageCodes4wContributelang)
langCode = intent?.extras?.getString(AppConstants.LANGUAGE_CODE, pref.languageCodeSpell4WikiAll)
word = intent?.extras?.getString(AppConstants.WORD, "")

api = getCommonsApi(applicationContext).create(ApiInterface::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.manimarank.spell4wiki.ui.settings
import android.content.Intent
import android.os.Bundle
import com.manimarank.spell4wiki.R
import com.manimarank.spell4wiki.data.db.DBHelper
import com.manimarank.spell4wiki.data.db.dao.WikiLangDao
import com.manimarank.spell4wiki.data.prefs.PrefManager
import com.manimarank.spell4wiki.ui.appintro.AppIntroActivity
import com.manimarank.spell4wiki.ui.common.BaseActivity
Expand All @@ -16,7 +18,7 @@ import kotlinx.android.synthetic.main.bottom_sheet_language_selection.btnAddMyLa
import kotlinx.android.synthetic.main.bottom_sheet_language_selection.txtAddLangInfo

class LanguageSelectionActivity : BaseActivity() {
var spellforwiki :Spell4Wiktionary = Spell4Wiktionary();

private lateinit var pref: PrefManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -32,22 +34,23 @@ class LanguageSelectionActivity : BaseActivity() {
contributionLang()
}
}
private fun contributionLang(){
var wikiLangDao: WikiLangDao? = null;
private fun contributionLang() {
wikiLangDao = DBHelper.getInstance(applicationContext).appDatabase.wikiLangDao
setContentView(R.layout.contribution_language_selection)
txtAddLangInfo.text = String.format(getString(R.string.choose_your_preferred_contribution_language), AppLanguageDialog.getSelectedLanguage())
txtAddLangInfo.text = String.format(getString(R.string.choose_your_preferred_contribution_language), wikiLangDao?.getWikiLanguageWithCode(pref.languageCodeSpell4WikiAll)?.name ?: "")

btnAddMyLanguage.setOnClickListener { loadLanguages() }

btnNext.setOnClickListener {
openMainActivity()

}
}

private fun loadLanguages() {
val callback = object : OnLanguageSelectionListener {
override fun onCallBackListener(langCode: String?) {

txtAddLangInfo.text = String.format(getString(R.string.choose_your_preferred_contribution_language), wikiLangDao?.getWikiLanguageWithCode(pref.languageCodeSpell4WikiAll)?.name ?: "")
}
}
val languageSelectionFragment = LanguageSelectionFragment(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class SettingsActivity : BaseActivity() {
layoutLicenseOfUploadAudio.makeGone()
layoutRunFilter.makeGone()
}
updateLanguageView(txtSpell4WikiLang, pref.languageCodes4wContributelang)
updateLanguageView(txtSpell4WikiLang, pref.languageCodeSpell4WikiAll)
layoutSpell4WikiLang.setOnClickListener {
val callback = object : OnLanguageSelectionListener {
override fun onCallBackListener(langCode: String?) {
updateLanguageView(txtSpell4WikiLang, pref.languageCodes4wContributelang)
updateLanguageView(txtSpell4WikiLang, pref.languageCodeSpell4WikiAll)
}
}
val languageSelectionFragment = LanguageSelectionFragment(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,7 @@ class EndlessRecyclerAdapter(

private val languageCode: String?
get() = when (mode) {
// ListMode.SPELL_4_WIKI -> pref.languageCodeSpell4Wiki
// ListMode.SPELL_4_WORD_LIST -> pref.languageCodeSpell4WordList
// ListMode.SPELL_4_WORD -> pref.languageCodeSpell4Word
ListMode.WIKTIONARY -> pref.languageCodeWiktionary
ListMode.SPELL_4_WIKI_ALL -> pref.languageCodes4wContributelang

ListMode.SPELL_4_WIKI_ALL -> pref.languageCodeSpell4WikiAll
ListMode.TEMP -> null
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class Spell4Wiktionary : BaseActivity(), EndlessListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_spell_4_wiktionary)
pref = PrefManager(applicationContext)
// languageCode = pref.languageCodeSpell4Wiki
languageCode = pref.languageCodes4wContributelang

languageCode = pref.languageCodeSpell4WikiAll
init()
loadDataFromServer()
}
Expand Down Expand Up @@ -512,14 +510,22 @@ class Spell4Wiktionary : BaseActivity(), EndlessListener {
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinnerCategory.adapter = spinnerAdapter
wiktionaryTitleOfWordsWithoutAudio = categoryDataList.first()
spinnerCategory.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, pos: Int, id: Long) {
wiktionaryTitleOfWordsWithoutAudio = parent?.getItemAtPosition(pos)?.toString()
nextOffsetObj = null
recyclerView?.reset()
loadDataFromServer()
if (categoryDataList.isNotEmpty()) {
spinnerCategory.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View?,
pos: Int,
id: Long
) {
wiktionaryTitleOfWordsWithoutAudio = parent?.getItemAtPosition(pos)?.toString()
nextOffsetObj = null
recyclerView?.reset()
loadDataFromServer()
}

override fun onNothingSelected(p0: AdapterView<*>?) {}
}
override fun onNothingSelected(p0: AdapterView<*>?) {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ class Spell4WordActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_spell_4_word)
pref = PrefManager(this)
// languageCode = pref.languageCodeSpell4Word
languageCode = pref.languageCodes4wContributelang
languageCode = pref.languageCodeSpell4WikiAll
initUI()
}

private fun openWiktionaryPage(wordInfo: String) {
val intent = Intent(applicationContext, CommonWebActivity::class.java)
val url = String.format(Urls.WIKTIONARY_WEB, pref.languageCodes4wContributelang, wordInfo)
val url = String.format(Urls.WIKTIONARY_WEB, pref.languageCodeSpell4WikiAll, wordInfo)
intent.putExtra(AppConstants.TITLE, wordInfo)
intent.putExtra(AppConstants.URL, url)
intent.putExtra(AppConstants.IS_WIKTIONARY_WORD, true)
intent.putExtra(AppConstants.LANGUAGE_CODE, pref.languageCodes4wContributelang)
intent.putExtra(AppConstants.LANGUAGE_CODE, pref.languageCodeSpell4WikiAll)
startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Spell4WordListActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_spell_4_wordlist)
pref = PrefManager(applicationContext)
languageCode = pref.languageCodes4wContributelang
languageCode = pref.languageCodeSpell4WikiAll
initUI()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class WiktionarySearchActivity : BaseActivity(), EndlessListener {

private fun init() {
val pref = PrefManager(this@WiktionarySearchActivity)
languageCode = pref.languageCodeWiktionary
languageCode = pref.languageCodeSpell4WikiAll
api = getWiktionaryApi(applicationContext, languageCode ?: AppConstants.DEFAULT_LANGUAGE_CODE).create(ApiInterface::class.java)

// Views
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CommonWebActivity : BaseActivity() {
setContentView(R.layout.activity_common_web_view)

val pref = PrefManager(applicationContext)
languageCode = pref.languageCodeWiktionary
languageCode = pref.languageCodeSpell4WikiAll
wikiLangDao = DBHelper.getInstance(applicationContext).appDatabase.wikiLangDao

// Title & Sub title
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@color/settings_label_text"
android:text="@string/Spell_4_wiktionary_Contribution"
android:text="@string/spell_4_wiki_all"
android:textSize="@dimen/text_normal" />

<androidx.appcompat.widget.AppCompatTextView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!--Don't translate-->
<string name="app_name" translatable="false">Spell4Wiki</string>
<string name="Spell_4_wiktionary_Contribution" translatable="false">Spell 4 wiktionary Contribution</string>
<string name="spell_4_wiki_all" translatable="false">Spell4wiki</string>
<string name="spell4wiktionary" translatable="false">Spell for Wiktionary</string>
<string name="spell4wordlist" translatable="false">Spell for WordList</string>
<string name="spell4word" translatable="false">Spell for Word</string>
Expand Down

0 comments on commit 8bff155

Please sign in to comment.