Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/assets/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version" : "1.1.7",
"version_code" : 9,
"testpress_site_subdomain" : "sandbox",
"version_code" : 123,
"testpress_site_subdomain" : "xandylearning",
Comment on lines 2 to +4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the shared default config.json (currently what master builds as "sandbox") to point at xandylearning and bumps version_code from 9 to 123. A couple of concerns:

  1. testpress_site_subdomain is now "xandylearning" but package_name (in.testpress.sandbox) and app_name ("Testpress Sandbox") are unchanged — is that intentional, or should this branch's config only be used for a client-specific build rather than merged into master's default config?
  2. The version_code jump from 9 to 123 looks unrelated to the "disable signup" feature — please confirm this is intentional and not a leftover from local testing.

If this repo builds a single app per branch/tag from config.json, merging this to master would change what everyone building from master gets by default. Worth double-checking before merge.

"package_name" : "in.testpress.sandbox",
"app_name" : "Testpress Sandbox",
"share_message": "Good app to prepare for online exams.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@

import java.io.IOException;
import java.security.PublicKey;
import java.util.Arrays;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java.util.Arrays is imported but never used anywhere in this file (no Arrays. reference). Unused import — please remove.

Fix this →

import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import javax.inject.Inject;
import in.testpress.testpress.core.Constants;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in.testpress.testpress.core.Constants is already imported further down in this file (pre-existing import, now at line 67 after this diff). This adds a duplicate import. Javac tolerates duplicate imports so it won't break the build, but it should be removed since it's redundant.

Fix this →

import in.testpress.core.TestpressCallback;
import in.testpress.core.TestpressException;
import in.testpress.core.TestpressSDKDatabase;
Expand All @@ -68,6 +70,7 @@
import in.testpress.testpress.models.DaoSession;
import in.testpress.testpress.models.InstituteSettings;
import in.testpress.testpress.models.InstituteSettingsDao;
import in.testpress.testpress.util.AppChecker;
import in.testpress.testpress.models.PostDao;
import in.testpress.testpress.ui.DeviceNotAllowedActivity;
import in.testpress.testpress.ui.MainActivity;
Expand Down Expand Up @@ -450,7 +453,11 @@ private void updateInstituteSpecificFields() {
ViewUtils.setGone(googleLoginButton, !instituteSettings.getGoogleLoginEnabled());
ViewUtils.setGone(socialLoginLayout, !instituteSettings.getFacebookLoginEnabled() &&
!instituteSettings.getGoogleLoginEnabled());
ViewUtils.setGone(signUpButton, !instituteSettings.getAllowSignup());
boolean allowSignup = instituteSettings.getAllowSignup() != null && instituteSettings.getAllowSignup();
if (AppChecker.INSTANCE.isSignupDisabledForSubdomain(this)) {
allowSignup = false;
}
ViewUtils.setGone(signUpButton, !allowSignup);
}


Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/in/testpress/testpress/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
public final class Constants {
private Constants() {}

public static final String[] DISALLOWED_SIGNUP_SUBDOMAINS = {"xandylearning"};

public static final class Http {
private Http() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import `in`.testpress.testpress.core.TestpressService
import `in`.testpress.testpress.databinding.UsernameLoginLayoutBinding
import `in`.testpress.testpress.models.InstituteSettings
import `in`.testpress.testpress.ui.WebViewActivity
import `in`.testpress.testpress.util.AppChecker
import `in`.testpress.testpress.util.UIUtils
import `in`.testpress.testpress.util.isEmpty
import `in`.testpress.util.ViewUtils
Expand Down Expand Up @@ -188,7 +189,7 @@ class UsernameAuthentication : BaseAuthenticationFragment() {
}

private fun showOrHideButtons() {
if (!instituteSettings.allowSignup) {
if (!instituteSettings.allowSignup || AppChecker.isSignupDisabledForSubdomain(requireContext())) {
binding.signUp.visibility = View.GONE
}
ViewUtils.setGone(binding.phoneLogin, 3 !in instituteSettings.allowedLoginMethods)
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/in/testpress/testpress/util/AppChecker.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package `in`.testpress.testpress.util

import `in`.testpress.testpress.R
import android.content.Context
import `in`.testpress.testpress.R
import `in`.testpress.testpress.core.Constants
import `in`.testpress.ui.WebViewWithSSOActivity

object AppChecker {
Expand All @@ -17,4 +18,8 @@ object AppChecker {
fun isCatkingApp(context: Context): Boolean {
return context.getString(R.string.testpress_site_subdomain) == "catking"
}

fun isSignupDisabledForSubdomain(context: Context): Boolean {
return Constants.DISALLOWED_SIGNUP_SUBDOMAINS.contains(context.getString(R.string.testpress_site_subdomain))
}
}
Loading