mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 03:54:18 -04:00
#2342 Converted RateAppCounter.java to kotlin
This commit is contained in:
parent
83f7410b5d
commit
7df5ab19bb
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.kiwix.kiwixmobile.core.utils.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class RateAppCounter {
|
||||
|
||||
private static final String MASTER_NAME = "visitCounter";
|
||||
private static final String NOTHANKS_CLICKED = "clickedNoThanks";
|
||||
|
||||
private SharedPreferences visitCounter;
|
||||
|
||||
RateAppCounter(Context context) {
|
||||
visitCounter = context.getSharedPreferences(MASTER_NAME, 0);
|
||||
visitCounter = context.getSharedPreferences(NOTHANKS_CLICKED, 0);
|
||||
}
|
||||
|
||||
public boolean getNoThanksState() {
|
||||
return visitCounter.getBoolean(NOTHANKS_CLICKED, false);
|
||||
}
|
||||
|
||||
public void setNoThanksState(boolean val) {
|
||||
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
||||
CounterEditor.putBoolean(NOTHANKS_CLICKED, val);
|
||||
CounterEditor.apply();
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return visitCounter.getInt("count", 0);
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
SharedPreferences.Editor CounterEditor = visitCounter.edit();
|
||||
CounterEditor.putInt("count", count);
|
||||
CounterEditor.apply();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2019 Kiwix <android.kiwix.org>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.utils.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
class RateAppCounter internal constructor(context: Context) {
|
||||
private var visitCounter: SharedPreferences
|
||||
|
||||
init {
|
||||
visitCounter = context.getSharedPreferences(NO_THANKS_CLICKED, 0)
|
||||
}
|
||||
|
||||
var noThanksState: Boolean
|
||||
get() = visitCounter.getBoolean(NO_THANKS_CLICKED, false)
|
||||
set(value) {
|
||||
visitCounter.edit().apply {
|
||||
putBoolean(NO_THANKS_CLICKED, value)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
var count: Int
|
||||
get() = visitCounter.getInt("count", 0)
|
||||
set(count) {
|
||||
visitCounter.edit().apply {
|
||||
putInt("count", count)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NO_THANKS_CLICKED = "clickedNoThanks"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user