Skip to content

Commit

Permalink
login: learner conversion cleanup (fixes #2677) (#2678)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Nov 3, 2023
1 parent da33a86 commit eb3ea76
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1132
versionName "0.11.32"
versionCode 1133
versionName "0.11.33"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
Expand All @@ -93,7 +94,7 @@ public class LoginActivity extends SyncActivity implements Service.CheckVersionC
private Button btnSignIn, becomeMember, btnGuestLogin, btnLang, openCommunity, btnFeedback;
private View positiveAction;
private ImageButton imgBtnSetting;
private boolean isSync = false, forceSync = false;
private boolean isSync = false, forceSync = false, guest = false;
private SwitchCompat switchChildMode;
private SharedPreferences defaultPref;
private Service service;
Expand Down Expand Up @@ -196,6 +197,33 @@ protected void onCreate(Bundle savedInstanceState) {
});

previouslyLoggedIn.setOnClickListener(view -> showUserList());

guest = getIntent().getBooleanExtra("guest", false);
String username = getIntent().getStringExtra("username");
if (guest){
List<User> existingUsers = prefData.getSAVEDUSERS1();

boolean newUserExists = false;

for (User user : existingUsers) {
if (user.getName().equals(username)) {
newUserExists = true;
break;
}
}

if (newUserExists){
Iterator<User> iterator = existingUsers.iterator();
while (iterator.hasNext()) {
User user = iterator.next();
if (user.getName().equals(username)) {
iterator.remove();
}
}
prefData.setSAVEDUSERS1(existingUsers);
}
}

}

private void showUserList(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class BecomeMemberActivity : BaseActivity() {
settings = getSharedPreferences(SyncActivity.PREFS_NAME, Context.MODE_PRIVATE)
textChangedListener(mRealm)

if (username != null) {
if (guest) {
activityBecomeMemberBinding.etUsername.setText(username)
activityBecomeMemberBinding.etUsername.isFocusable = false
}

activityBecomeMemberBinding.etUsername.addTextChangedListener(object : TextWatcher {
Expand Down Expand Up @@ -264,6 +265,8 @@ class BecomeMemberActivity : BaseActivity() {

if (guest){
val intent = Intent(this, LoginActivity::class.java)
intent.putExtra("username", username)
intent.putExtra("guest", guest)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent)
finish()
Expand Down

0 comments on commit eb3ea76

Please sign in to comment.