mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Fix navigation issues
This commit is contained in:
parent
04262f375e
commit
1904c6df3a
29 changed files with 170 additions and 182 deletions
|
|
@ -148,7 +148,7 @@ android {
|
|||
buildConfigField "String", "STORE", "\"google\""
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode 2045
|
||||
versionCode 2046
|
||||
versionName "1.7"
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ android {
|
|||
}
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
debuggable false
|
||||
debuggable true
|
||||
multiDexEnabled true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/messagesButtonWrapper"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp">
|
||||
|
|
@ -84,9 +85,10 @@
|
|||
tools:visibility="visible"/>
|
||||
</RelativeLayout>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="35dp"
|
||||
android:id="@+id/settingsButtonWrapper"
|
||||
android:layout_width="43dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="8dp">
|
||||
android:paddingLeft="8dp">
|
||||
<ImageButton
|
||||
android:id="@+id/settingsButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -851,4 +851,5 @@
|
|||
<string name="gift_one_get_one_detailed_description">While this promotion is active, you’ll receive a matching subscription automatically after sending your gift.</string>
|
||||
<string name="gift_subscription_subtitle">Choose the subscription you’d like to gift below! This purchase won’t automatically renew.</string>
|
||||
<string name="send_gift">Send Gift</string>
|
||||
<string name="server">Server</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -123,5 +123,14 @@
|
|||
<item>dewinTheme</item>
|
||||
<item>airuTheme</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="server_urls">
|
||||
<item>https://habitica.com</item>
|
||||
<item>https://habitrpg-staging.herokuapp.com</item>
|
||||
<item>https://habitrpg-beta.herokuapp.com</item>
|
||||
<item>https://habitrpg-gamma.herokuapp.com</item>
|
||||
<item>https://habitrpg-delta.herokuapp.com</item>
|
||||
</string-array>
|
||||
|
||||
<string name="frequency_monthly">Monthly</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -246,6 +246,11 @@
|
|||
<Preference android:title="@string/reload_content"
|
||||
android:key="reload_content"
|
||||
android:layout="@layout/preference_child_summary"/>
|
||||
<ListPreference android:title="@string/server"
|
||||
android:key="server_url"
|
||||
android:entries="@array/server_urls"
|
||||
android:entryValues="@array/server_urls"
|
||||
android:layout="@layout/preference_child_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
@ -61,12 +61,13 @@ public class HabiticaPurchaseVerifier extends BasePurchaseVerifier {
|
|||
} else {
|
||||
if (PurchaseTypes.allGemTypes.contains(purchase.sku)) {
|
||||
PurchaseValidationRequest validationRequest = new PurchaseValidationRequest();
|
||||
validationRequest.transaction = new Transaction();
|
||||
validationRequest.transaction.receipt = purchase.data;
|
||||
validationRequest.transaction.signature = purchase.signature;
|
||||
validationRequest.setSku(purchase.sku);
|
||||
validationRequest.setTransaction(new Transaction());
|
||||
validationRequest.getTransaction().receipt = purchase.data;
|
||||
validationRequest.getTransaction().signature = purchase.signature;
|
||||
if (pendingGifts.containsKey(purchase.sku)) {
|
||||
validationRequest.gift = new IAPGift();
|
||||
validationRequest.gift.uuid = pendingGifts.get(purchase.sku);
|
||||
validationRequest.setGift(new IAPGift());
|
||||
validationRequest.getGift().uuid = pendingGifts.get(purchase.sku);
|
||||
pendingGifts.remove(purchase.sku);
|
||||
}
|
||||
|
||||
|
|
@ -103,18 +104,21 @@ public class HabiticaPurchaseVerifier extends BasePurchaseVerifier {
|
|||
});
|
||||
} else if (PurchaseTypes.allSubscriptionNoRenewTypes.contains(purchase.sku)) {
|
||||
PurchaseValidationRequest validationRequest = new PurchaseValidationRequest();
|
||||
validationRequest.transaction = new Transaction();
|
||||
validationRequest.transaction.receipt = purchase.data;
|
||||
validationRequest.transaction.signature = purchase.signature;
|
||||
validationRequest.setSku(purchase.sku);
|
||||
validationRequest.setTransaction(new Transaction());
|
||||
validationRequest.getTransaction().receipt = purchase.data;
|
||||
validationRequest.getTransaction().signature = purchase.signature;
|
||||
if (pendingGifts.containsKey(purchase.sku)) {
|
||||
validationRequest.gift = new IAPGift();
|
||||
validationRequest.gift.uuid = pendingGifts.get(purchase.sku);
|
||||
validationRequest.setGift(new IAPGift());
|
||||
validationRequest.getGift().uuid = pendingGifts.get(purchase.sku);
|
||||
pendingGifts.remove(purchase.sku);
|
||||
}
|
||||
|
||||
apiClient.validateNoRenewSubscription(validationRequest).subscribe(purchaseValidationResult -> {
|
||||
purchasedOrderList.add(purchase.orderId);
|
||||
|
||||
if (pendingGifts.containsKey(purchase.sku)) {
|
||||
pendingGifts.remove(purchase.sku);
|
||||
}
|
||||
requestListener.onSuccess(verifiedPurchases);
|
||||
}, throwable -> {
|
||||
if (throwable.getClass().equals(retrofit2.adapter.rxjava2.HttpException.class)) {
|
||||
|
|
@ -133,10 +137,10 @@ public class HabiticaPurchaseVerifier extends BasePurchaseVerifier {
|
|||
});
|
||||
} else if (PurchaseTypes.allSubscriptionTypes.contains(purchase.sku)) {
|
||||
SubscriptionValidationRequest validationRequest = new SubscriptionValidationRequest();
|
||||
validationRequest.transaction = new Transaction();
|
||||
validationRequest.transaction.receipt = purchase.data;
|
||||
validationRequest.transaction.signature = purchase.signature;
|
||||
validationRequest.sku = purchase.sku;
|
||||
validationRequest.setSku(purchase.sku);
|
||||
validationRequest.setTransaction(new Transaction());
|
||||
validationRequest.getTransaction().receipt = purchase.data;
|
||||
validationRequest.getTransaction().signature = purchase.signature;
|
||||
apiClient.validateSubscription(validationRequest).subscribe(purchaseValidationResult -> {
|
||||
purchasedOrderList.add(purchase.orderId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,105 +0,0 @@
|
|||
package com.habitrpg.android.habitica.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
/**
|
||||
* The configuration of the host<br />
|
||||
* Currently, the Port isn't used at all.
|
||||
*
|
||||
* @author MagicMicky
|
||||
*/
|
||||
public class HostConfig {
|
||||
private String address;
|
||||
private String port;
|
||||
private String api;
|
||||
private String user;
|
||||
|
||||
public HostConfig(SharedPreferences sharedPreferences, Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.port = BuildConfig.PORT;
|
||||
this.address = BuildConfig.DEBUG ? BuildConfig.BASE_URL : context.getString(R.string.base_url);
|
||||
this.api = prefs.getString("APIToken", null);
|
||||
this.user = prefs.getString(context.getString(R.string.SP_userID), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HostConfig
|
||||
*
|
||||
* @param address the address of the server
|
||||
* @param port the port of the server
|
||||
* @param api the API token of the user
|
||||
* @param user the user ID
|
||||
*/
|
||||
public HostConfig(String address, String port, String api, String user) {
|
||||
this.setAddress(address);
|
||||
this.setPort(port);
|
||||
this.setApi(api);
|
||||
this.setUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the address
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param address the address to set
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the api
|
||||
*/
|
||||
public String getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param api the api to set
|
||||
*/
|
||||
public void setApi(String api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user the user to set
|
||||
*/
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public boolean hasAuthentication() {
|
||||
return user != null && user.length() > 0 && api != null && api.length() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.habitrpg.android.habitica.api
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.preference.PreferenceManager
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
||||
/**
|
||||
* The configuration of the host<br></br>
|
||||
* Currently, the Port isn't used at all.
|
||||
*
|
||||
* @author MagicMicky
|
||||
*/
|
||||
class HostConfig {
|
||||
var address: String
|
||||
var port: String
|
||||
var api: String? = null
|
||||
var user: String? = null
|
||||
|
||||
constructor(sharedPreferences: SharedPreferences, context: Context) {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
this.port = BuildConfig.PORT
|
||||
if (BuildConfig.DEBUG) {
|
||||
this.address = BuildConfig.BASE_URL
|
||||
} else {
|
||||
this.address = sharedPreferences.getString("server_url", null) ?: context.getString(R.string.base_url)
|
||||
}
|
||||
this.api = prefs.getString("APIToken", null)
|
||||
this.user = prefs.getString(context.getString(R.string.SP_userID), "")
|
||||
}
|
||||
|
||||
constructor(address: String, port: String, api: String, user: String) {
|
||||
this.address = address
|
||||
this.port = port
|
||||
this.api = api
|
||||
this.user = user
|
||||
}
|
||||
|
||||
fun hasAuthentication(): Boolean {
|
||||
return user?.isNotEmpty() == true && api?.length ?: 0 > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -247,4 +247,5 @@ interface ApiClient {
|
|||
|
||||
fun retrieveMarketGear(): Flowable<Shop>
|
||||
fun verifyUsername(username: String): Flowable<VerifyUsernameResponse>
|
||||
fun updateServerUrl(newAddress: String?)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
//private HostConfig mConfig;
|
||||
(private val gsonConverter: GsonConverterFactory, override val hostConfig: HostConfig, private val crashlyticsProxy: CrashlyticsProxy, private val popupNotificationsManager: PopupNotificationsManager, private val context: Context) : Consumer<Throwable>, ApiClient {
|
||||
|
||||
private val retrofitAdapter: Retrofit
|
||||
private lateinit var retrofitAdapter: Retrofit
|
||||
|
||||
// I think we don't need the ApiClientImpl anymore we could just use ApiService
|
||||
private val apiService: ApiService
|
||||
private lateinit var apiService: ApiService
|
||||
|
||||
private val apiCallTransformer = FlowableTransformer<HabitResponse<Any>, Any> { observable ->
|
||||
observable
|
||||
|
|
@ -91,7 +91,10 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
crashlyticsProxy.setUserIdentifier(this.hostConfig.user)
|
||||
crashlyticsProxy.setUserName(this.hostConfig.user)
|
||||
Amplitude.getInstance().userId = this.hostConfig.user
|
||||
buildRetrofit()
|
||||
}
|
||||
|
||||
fun buildRetrofit() {
|
||||
val logging = HttpLoggingInterceptor()
|
||||
if (BuildConfig.DEBUG) {
|
||||
logging.level = HttpLoggingInterceptor.Level.BODY
|
||||
|
|
@ -99,6 +102,10 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
|
||||
val userAgent = System.getProperty("http.agent")
|
||||
|
||||
val calendar = GregorianCalendar()
|
||||
val timeZone = calendar.timeZone
|
||||
val timezoneOffset = -TimeUnit.MINUTES.convert(timeZone.getOffset(calendar.timeInMillis).toLong(), TimeUnit.MILLISECONDS)
|
||||
|
||||
val client = OkHttpClient.Builder()
|
||||
.addInterceptor(logging)
|
||||
.addNetworkInterceptor { chain ->
|
||||
|
|
@ -110,6 +117,7 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
.header("x-api-user", this.hostConfig.user)
|
||||
}
|
||||
builder = builder.header("x-client", "habitica-android")
|
||||
.header("x-user-timzoneOffset", timezoneOffset.toString())
|
||||
if (userAgent != null) {
|
||||
builder = builder.header("user-agent", userAgent)
|
||||
}
|
||||
|
|
@ -137,6 +145,13 @@ class ApiClientImpl//private OnHabitsAPIResult mResultListener;
|
|||
this.apiService = retrofitAdapter.create(ApiService::class.java)
|
||||
}
|
||||
|
||||
override fun updateServerUrl(newAddress: String?) {
|
||||
if (newAddress != null) {
|
||||
hostConfig.address = newAddress
|
||||
buildRetrofit()
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerUser(username: String, email: String, password: String, confirmPassword: String): Flowable<UserAuthResponse> {
|
||||
val auth = UserAuth()
|
||||
auth.username = username
|
||||
|
|
|
|||
|
|
@ -60,16 +60,6 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
|
|||
}
|
||||
}
|
||||
}
|
||||
.flatMap { user ->
|
||||
val calendar = GregorianCalendar()
|
||||
val timeZone = calendar.timeZone
|
||||
val offset = -TimeUnit.MINUTES.convert(timeZone.getOffset(calendar.timeInMillis).toLong(), TimeUnit.MILLISECONDS)
|
||||
if (offset.toInt() != user.preferences?.timezoneOffset ?: 0) {
|
||||
return@flatMap updateUser(user, "preferences.timezoneOffset", offset.toString())
|
||||
} else {
|
||||
return@flatMap Flowable.just(user)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return getUser().take(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models;
|
||||
|
||||
/**
|
||||
* Created by Negue on 26.11.2015.
|
||||
*/
|
||||
public class PurchaseValidationRequest {
|
||||
public Transaction transaction;
|
||||
public IAPGift gift;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.habitrpg.android.habitica.models
|
||||
|
||||
class PurchaseValidationRequest {
|
||||
var sku: String? = null
|
||||
var transaction: Transaction? = null
|
||||
var gift: IAPGift? = null
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models;
|
||||
|
||||
|
||||
public class SubscriptionValidationRequest {
|
||||
|
||||
public Transaction transaction;
|
||||
public String sku;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.habitrpg.android.habitica.models
|
||||
|
||||
|
||||
class SubscriptionValidationRequest {
|
||||
var transaction: Transaction? = null
|
||||
var sku: String? = null
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.habitrpg.android.habitica.ui.activities
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
|
|
@ -91,14 +92,18 @@ class GemPurchaseActivity : BaseActivity(), InAppMessageListener {
|
|||
}
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("Purchase", "Consume", e)
|
||||
crashlyticsProxy.fabricLogE("PurchaseConsumeException", "Consume", e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("Purchase", "Error", e)
|
||||
crashlyticsProxy.fabricLogE("PurchaseFlowException", "Error", e)
|
||||
val billingError = e as? BillingException
|
||||
if (billingError != null) {
|
||||
Log.e("BILLING ERROR", billingError.toString())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -82,11 +82,6 @@ class GiftIAPActivity: BaseActivity() {
|
|||
|
||||
giftedUsername = intent.getStringExtra("username")
|
||||
|
||||
this.subscription1MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription1Month) })
|
||||
this.subscription3MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription3Month) })
|
||||
this.subscription6MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription6Month) })
|
||||
this.subscription12MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription12Month) })
|
||||
|
||||
subscriptionButton?.setOnClickListener {
|
||||
selectedSubscriptionSku?.notNull { sku -> purchaseSubscription(sku) }
|
||||
}
|
||||
|
|
@ -101,6 +96,7 @@ class GiftIAPActivity: BaseActivity() {
|
|||
giftedUserID = it.id
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
setupCheckout()
|
||||
|
||||
activityCheckout?.destroyPurchaseFlow()
|
||||
|
||||
|
|
@ -112,14 +108,14 @@ class GiftIAPActivity: BaseActivity() {
|
|||
}
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("Purchase", "Consume", e)
|
||||
crashlyticsProxy.fabricLogE("PurchaseConsumeException", "Consume", e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("Purchase", "Error", e)
|
||||
crashlyticsProxy.fabricLogE("PurchaseFlowException", "Error", e)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -132,11 +128,16 @@ class GiftIAPActivity: BaseActivity() {
|
|||
override fun onReady(billingRequests: BillingRequests, s: String, b: Boolean) {}
|
||||
})
|
||||
|
||||
setupCheckout()
|
||||
}
|
||||
|
||||
override fun onCreateView(name: String?, context: Context?, attrs: AttributeSet?): View? {
|
||||
val view = super.onCreateView(name, context, attrs)
|
||||
|
||||
this.subscription1MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription1Month) })
|
||||
this.subscription3MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription3Month) })
|
||||
this.subscription6MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription6Month) })
|
||||
this.subscription12MonthView?.setOnPurchaseClickListener(View.OnClickListener { selectSubscription(PurchaseTypes.Subscription12Month) })
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
avatarWithBars.setPadding(px.toInt(), statusBarHeight, px.toInt(), 0)
|
||||
}
|
||||
|
||||
compositeSubscription.add(userRepository.getUser(hostConfig.user)
|
||||
compositeSubscription.add(userRepository.getUser(hostConfig.user ?: "")
|
||||
.subscribe(Consumer { newUser ->
|
||||
this@MainActivity.user = newUser
|
||||
this@MainActivity.setUserData()
|
||||
|
|
@ -397,7 +397,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
drawerFragment?.setSettingsCount(if (this.user?.flags?.isVerifiedUsername != true) 1 else 0 )
|
||||
|
||||
if (remoteConfigManager.enableUsernameRelease()) {
|
||||
if (user?.flags?.isVerifiedUsername != true && isActivityVisible) {
|
||||
if (user?.flags?.isVerifiedUsername == false && isActivityVisible) {
|
||||
val intent = Intent(this, VerifyUsernameActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
compositeSubscription.add(userRepository.getUser(hostConfig.user)
|
||||
compositeSubscription.add(userRepository.getUser(hostConfig.user ?: "")
|
||||
.subscribe(Consumer { this.onUserReceived(it) }, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
val additionalData = HashMap<String, Any>()
|
||||
|
|
|
|||
|
|
@ -322,14 +322,14 @@ class TaskFormActivity : BaseActivity() {
|
|||
if (task != null) {
|
||||
populate(task)
|
||||
|
||||
setTitle(task)
|
||||
setTaskTitle(task)
|
||||
if (taskType == Task.TYPE_TODO || taskType == Task.TYPE_DAILY) {
|
||||
populateChecklistRecyclerView()
|
||||
populateRemindersRecyclerView()
|
||||
}
|
||||
}
|
||||
|
||||
setTitle(task)
|
||||
setTaskTitle(task)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
btnDelete.isEnabled = true
|
||||
|
|
@ -338,14 +338,14 @@ class TaskFormActivity : BaseActivity() {
|
|||
if (thisTask != null) {
|
||||
populate(thisTask)
|
||||
|
||||
setTitle(thisTask)
|
||||
setTaskTitle(thisTask)
|
||||
if (taskType == Task.TYPE_TODO || taskType == Task.TYPE_DAILY) {
|
||||
populateChecklistRecyclerView()
|
||||
populateRemindersRecyclerView()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//setTitle(null as? Task)
|
||||
setTaskTitle(null)
|
||||
taskText.requestFocus()
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +688,7 @@ class TaskFormActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setTitle(task: Task?) {
|
||||
private fun setTaskTitle(task: Task?) {
|
||||
val actionBar = supportActionBar
|
||||
|
||||
if (actionBar != null) {
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
questMenuView.configure(it)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
messagesButton.setOnClickListener { setSelection(R.id.inboxFragment) }
|
||||
settingsButton.setOnClickListener { setSelection(R.id.prefsActivity) }
|
||||
messagesButtonWrapper.setOnClickListener { setSelection(R.id.inboxFragment) }
|
||||
settingsButtonWrapper.setOnClickListener { setSelection(R.id.prefsActivity) }
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ class NewsFragment : BaseMainFragment() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
val view = container?.inflate(R.layout.fragment_news)
|
||||
hideToolbar()
|
||||
return container?.inflate(R.layout.fragment_news)
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ class ShopsFragment : BaseMainFragment() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
this.usesTabLayout = true
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater.inflate(R.layout.fragment_viewpager, container, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ import android.content.res.Configuration
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.ApiClient
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.extensions.notNull
|
||||
import com.habitrpg.android.habitica.helpers.*
|
||||
|
|
@ -36,10 +38,13 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
lateinit var pushNotificationManager: PushNotificationManager
|
||||
@Inject
|
||||
lateinit var configManager: RemoteConfigManager
|
||||
@Inject
|
||||
lateinit var apiClient: ApiClient
|
||||
|
||||
private var timePreference: TimePreference? = null
|
||||
private var pushNotificationsPreference: PreferenceScreen? = null
|
||||
private var classSelectionPreference: Preference? = null
|
||||
private var serverUrlPreference: ListPreference? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
HabiticaBaseApplication.component?.inject(this)
|
||||
|
|
@ -64,6 +69,10 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
|
||||
classSelectionPreference = findPreference("choose_class")
|
||||
classSelectionPreference?.isVisible = false
|
||||
|
||||
serverUrlPreference = findPreference("server_url") as? ListPreference
|
||||
serverUrlPreference?.isVisible = false
|
||||
serverUrlPreference?.summary = preferenceManager.sharedPreferences.getString("server_url", "")
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
@ -206,6 +215,10 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
}
|
||||
"dailyDueDefaultView" -> userRepository.updateUser(user, "preferences.dailyDueDefaultView", sharedPreferences.getBoolean(key, false))
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
"server_url" -> {
|
||||
apiClient.updateServerUrl(sharedPreferences.getString(key, ""))
|
||||
findPreference(key).summary = sharedPreferences.getString(key, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -255,5 +268,9 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
preference.layoutResource = R.layout.preference_child_summary_error
|
||||
preference.summary = context?.getString(R.string.username_not_confirmed)
|
||||
}
|
||||
|
||||
if (user?.contributor?.admin == true) {
|
||||
serverUrlPreference?.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ class GuildFragment : BaseMainFragment() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
this.usesTabLayout = true
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater.inflate(R.layout.fragment_viewpager, container, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ class InboxFragment : BaseMainFragment(), androidx.swiperefreshlayout.widget.Swi
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
compositeSubscription.add(this.socialRepository.markPrivateMessagesRead(user).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ class InboxMessageListFragment : BaseMainFragment(), androidx.swiperefreshlayout
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
return inflater.inflate(R.layout.fragment_inbox_message_list, container, false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ class TavernFragment : BaseMainFragment() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
this.usesTabLayout = true
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
val v = inflater.inflate(R.layout.fragment_viewpager, container, false)
|
||||
this.tutorialStepIdentifier = "tavern"
|
||||
this.tutorialText = getString(R.string.tutorial_tavern)
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ class PartyFragment : BaseMainFragment() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
this.usesTabLayout = true
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
hideToolbar()
|
||||
disableToolbarScrolling()
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater.inflate(R.layout.fragment_viewpager, container, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue