From 4ac240d8908aa2c9ca40fcf9e56a1ec6b7b5c1c6 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Thu, 30 Nov 2023 14:33:36 +0300 Subject: [PATCH] remove easy mode --- .../planet/myplanet/ui/SplashActivity.java | 6 +- .../myplanet/ui/sync/LoginActivity.java | 70 ++-- .../planet/myplanet/ui/sync/SyncActivity.java | 34 -- .../myplanet/ui/sync/TeamLoginActivity.kt | 1 - .../myplanet/utilities/SharedPrefManager.kt | 12 + .../activity_child_login.xml | 318 ------------------ .../res/layout-large-land/activity_login.xml | 11 - .../activity_child_login.xml | 317 ----------------- .../res/layout-normal-land/activity_login.xml | 12 - .../activity_child_login.xml | 317 ----------------- .../res/layout-small-land/activity_login.xml | 12 - .../activity_child_login.xml | 313 ----------------- .../res/layout-xlarge-land/activity_login.xml | 13 - .../main/res/layout/activity_child_login.xml | 313 ----------------- app/src/main/res/layout/activity_login.xml | 11 - app/src/main/res/layout/activity_splash.xml | 49 +-- 16 files changed, 36 insertions(+), 1773 deletions(-) delete mode 100644 app/src/main/res/layout-large-land/activity_child_login.xml delete mode 100644 app/src/main/res/layout-normal-land/activity_child_login.xml delete mode 100644 app/src/main/res/layout-small-land/activity_child_login.xml delete mode 100644 app/src/main/res/layout-xlarge-land/activity_child_login.xml delete mode 100644 app/src/main/res/layout/activity_child_login.xml diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/SplashActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/SplashActivity.java index d5bd389507..81459715e7 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/SplashActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/SplashActivity.java @@ -37,15 +37,15 @@ protected void onCreate(Bundle savedInstanceState) { finish(); return; } - if (settings.contains("isChild") && prefData.getTEAMMODE1()) { + if (prefData.getFIRSTLAUNCH1() && prefData.getTEAMMODE1()) { startActivity(new Intent(SplashActivity.this, TeamLoginActivity.class)); finish(); - } else if (settings.contains("isChild") && !prefData.getTEAMMODE1()) { + } else if (prefData.getFIRSTLAUNCH1() && !prefData.getTEAMMODE1()) { startActivity(new Intent(SplashActivity.this, LoginActivity.class)); finish(); } binding.getStarted.setOnClickListener(view -> { - settings.edit().putBoolean("isChild", binding.childLogin.isChecked()).commit(); + prefData.setFIRSTLAUNCH1(true); startActivity(new Intent(SplashActivity.this, LoginActivity.class)); }); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.java index b3591bc248..d984cbf444 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.java @@ -10,10 +10,8 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; -import androidx.viewbinding.ViewBinding; import org.ole.planet.myplanet.R; -import org.ole.planet.myplanet.databinding.ActivityChildLoginBinding; import org.ole.planet.myplanet.databinding.ActivityLoginBinding; import org.ole.planet.myplanet.databinding.LayoutUserListBinding; import org.ole.planet.myplanet.datamanager.Service; @@ -29,61 +27,34 @@ import java.util.List; public class LoginActivity extends SyncActivity { + private ActivityLoginBinding activityLoginBinding; private Button openCommunity, btnFeedback; private boolean guest = false; private TextView tvAvailableSpace, previouslyLoggedIn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - ViewBinding activityLoginBinding; - if (settings.getBoolean("isChild", false)) { - activityLoginBinding = ActivityChildLoginBinding.inflate(getLayoutInflater()); - } else { - activityLoginBinding = ActivityLoginBinding.inflate(getLayoutInflater()); - } - + activityLoginBinding = ActivityLoginBinding.inflate(getLayoutInflater()); setContentView(activityLoginBinding.getRoot()); - prefData = new SharedPrefManager(this); - if (activityLoginBinding instanceof ActivityLoginBinding) { - inputName = ((ActivityLoginBinding) activityLoginBinding).inputName; - inputPassword = ((ActivityLoginBinding) activityLoginBinding).inputPassword; - inputLayoutName = ((ActivityLoginBinding) activityLoginBinding).inputLayoutName; - inputLayoutPassword = ((ActivityLoginBinding) activityLoginBinding).inputLayoutPassword; - btnSignIn = ((ActivityLoginBinding) activityLoginBinding).btnSignin; - imgBtnSetting = ((ActivityLoginBinding) activityLoginBinding).imgBtnSetting; - tvAvailableSpace= ((ActivityLoginBinding) activityLoginBinding).tvAvailableSpace; - previouslyLoggedIn = ((ActivityLoginBinding) activityLoginBinding).previouslyLoggedIn; - openCommunity = ((ActivityLoginBinding) activityLoginBinding).openCommunity; - lblLastSyncDate = ((ActivityLoginBinding) activityLoginBinding).lblLastSyncDate; - btnFeedback =((ActivityLoginBinding) activityLoginBinding).btnFeedback; - customDeviceName =((ActivityLoginBinding) activityLoginBinding).customDeviceName; - becomeMember = ((ActivityLoginBinding) activityLoginBinding).becomeMember; - btnGuestLogin = ((ActivityLoginBinding) activityLoginBinding).btnGuestLogin; - switchChildMode = ((ActivityLoginBinding) activityLoginBinding).switchChildMode; - syncIcon = ((ActivityLoginBinding) activityLoginBinding).syncIcon; - lblVersion = ((ActivityLoginBinding) activityLoginBinding).lblVersion; - btnLang = ((ActivityLoginBinding) activityLoginBinding).btnLang; - } else { - inputName = ((ActivityChildLoginBinding) activityLoginBinding).inputName; - inputPassword = ((ActivityChildLoginBinding) activityLoginBinding).inputPassword; - inputLayoutName = ((ActivityChildLoginBinding) activityLoginBinding).inputLayoutName; - inputLayoutPassword = ((ActivityChildLoginBinding) activityLoginBinding).inputLayoutPassword; - btnSignIn = ((ActivityChildLoginBinding) activityLoginBinding).btnSignin; - imgBtnSetting = ((ActivityChildLoginBinding) activityLoginBinding).imgBtnSetting; - tvAvailableSpace= ((ActivityChildLoginBinding) activityLoginBinding).tvAvailableSpace; - previouslyLoggedIn = ((ActivityChildLoginBinding) activityLoginBinding).previouslyLoggedIn; - openCommunity = ((ActivityChildLoginBinding) activityLoginBinding).openCommunity; - lblLastSyncDate = ((ActivityChildLoginBinding) activityLoginBinding).lblLastSyncDate; - btnFeedback =((ActivityChildLoginBinding) activityLoginBinding).btnFeedback; - customDeviceName =((ActivityChildLoginBinding) activityLoginBinding).customDeviceName; - becomeMember = ((ActivityChildLoginBinding) activityLoginBinding).becomeMember; - btnGuestLogin = ((ActivityChildLoginBinding) activityLoginBinding).btnGuestLogin; - switchChildMode = ((ActivityChildLoginBinding) activityLoginBinding).switchChildMode; - syncIcon = ((ActivityChildLoginBinding) activityLoginBinding).syncIcon; - lblVersion = ((ActivityChildLoginBinding) activityLoginBinding).lblVersion; - btnLang = ((ActivityChildLoginBinding) activityLoginBinding).btnLang; - } + prefData = new SharedPrefManager(this); + inputName = activityLoginBinding.inputName; + inputPassword = activityLoginBinding.inputPassword; + inputLayoutName = activityLoginBinding.inputLayoutName; + inputLayoutPassword = activityLoginBinding.inputLayoutPassword; + btnSignIn = activityLoginBinding.btnSignin; + imgBtnSetting = activityLoginBinding.imgBtnSetting; + tvAvailableSpace= activityLoginBinding.tvAvailableSpace; + previouslyLoggedIn = activityLoginBinding.previouslyLoggedIn; + openCommunity = activityLoginBinding.openCommunity; + lblLastSyncDate = activityLoginBinding.lblLastSyncDate; + btnFeedback = activityLoginBinding.btnFeedback; + customDeviceName = activityLoginBinding.customDeviceName; + becomeMember = activityLoginBinding.becomeMember; + btnGuestLogin = activityLoginBinding.btnGuestLogin; + syncIcon = activityLoginBinding.syncIcon; + lblVersion = activityLoginBinding.lblVersion; + btnLang = activityLoginBinding.btnLang; tvAvailableSpace.setText(FileUtils.getAvailableOverTotalMemoryFormattedString()); changeLogoColor(); @@ -106,7 +77,6 @@ protected void onCreate(Bundle savedInstanceState) { service.checkVersion(this, settings); } checkUsagesPermission(); - setUpChildMode(); forceSyncTrigger(); if (!Utilities.getUrl().isEmpty()) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.java index 8bea05dcb3..a3dc77e8e5 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.java @@ -123,7 +123,6 @@ public abstract class SyncActivity extends ProcessUserDataActivity implements Sy TextView customDeviceName, lblVersion; SharedPreferences defaultPref; ImageButton imgBtnSetting; - SwitchCompat switchChildMode; Service service; @Override @@ -172,29 +171,6 @@ private void setSpinnerVisibility(boolean isChecked) { } } - public void setUpChildMode() { - try { - mRealm = Realm.getDefaultInstance(); - if (!settings.getBoolean("isChild", false)) return; - RecyclerView rvTeams = findViewById(R.id.rv_teams); - TextView tvNodata = findViewById(R.id.tv_nodata); - - List teams = mRealm.where(RealmMyTeam.class).isEmpty("teamId").findAll(); - rvTeams.setLayoutManager(new GridLayoutManager(this, 3)); - rvTeams.setAdapter(new AdapterTeam(this, teams, mRealm)); - if (teams.size() > 0) { - tvNodata.setVisibility(View.GONE); - } else { - tvNodata.setText(R.string.no_team_available); - tvNodata.setVisibility(View.VISIBLE); - } - } finally { - if (mRealm != null && !mRealm.isClosed()) { - mRealm.close(); - } - } - } - public boolean isServerReachable(String processedUrl) throws Exception { progressDialog.setMessage(getString(R.string.connecting_to_server)); progressDialog.show(); @@ -365,10 +341,6 @@ public void onSyncComplete() { DialogUtils.showSnack(findViewById(android.R.id.content), getString(R.string.sync_completed)); - if (settings.getBoolean("isChild", false)) { - setUpChildMode(); - } - NotificationUtil.cancellAll(this); }); } @@ -379,12 +351,6 @@ public void declareElements() { } if (!prefData.getTEAMMODE1()){ customDeviceName.setText(getCustomDeviceName()); - switchChildMode.setChecked(settings.getBoolean("isChild", false)); - switchChildMode.setOnCheckedChangeListener((compoundButton, b) -> { - inputName.setText(""); - settings.edit().putBoolean("isChild", b).commit(); - recreate(); - }); } btnSignIn.setOnClickListener(view -> { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/TeamLoginActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/TeamLoginActivity.kt index 8e405143ab..6be4bf2d7d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/TeamLoginActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/TeamLoginActivity.kt @@ -61,7 +61,6 @@ class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener { service.checkVersion(this, settings) } checkUsagesPermission() - setUpChildMode() forceSyncTrigger() if (Utilities.getUrl().isNotEmpty()) { diff --git a/app/src/main/java/org/ole/planet/myplanet/utilities/SharedPrefManager.kt b/app/src/main/java/org/ole/planet/myplanet/utilities/SharedPrefManager.kt index 1ee5509258..2606471718 100644 --- a/app/src/main/java/org/ole/planet/myplanet/utilities/SharedPrefManager.kt +++ b/app/src/main/java/org/ole/planet/myplanet/utilities/SharedPrefManager.kt @@ -18,6 +18,7 @@ class SharedPrefManager(context: Context) { var MANUALCONFIG = "manualConfig" var SELECTEDTEAMID = "selectedTeamId" var TEAMMODE = "teamMode" + var FIRSTLAUNCH = "firstLaunch" init { pref = context.getSharedPreferences(SHARED_PREF_NAME, PRIVATE_MODE) @@ -111,4 +112,15 @@ class SharedPrefManager(context: Context) { editor.putBoolean(TEAMMODE, teamMode) editor.apply() } + + @JvmName("getFIRSTLAUNCH1") + fun getFIRSTLAUNCH(): Boolean { + return pref.getBoolean(FIRSTLAUNCH, false) + } + + @JvmName("setFIRSTLAUNCH1") + fun setFIRSTLAUNCH(firstLaunch: Boolean) { + editor.putBoolean(FIRSTLAUNCH, firstLaunch) + editor.apply() + } } \ No newline at end of file diff --git a/app/src/main/res/layout-large-land/activity_child_login.xml b/app/src/main/res/layout-large-land/activity_child_login.xml deleted file mode 100644 index 8fd8faa60c..0000000000 --- a/app/src/main/res/layout-large-land/activity_child_login.xml +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - - - - - - - - - - -