Skip to content

Commit

Permalink
remove easy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Nov 30, 2023
1 parent ef77f15 commit 4ac240d
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 1,773 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -106,7 +77,6 @@ protected void onCreate(Bundle savedInstanceState) {
service.checkVersion(this, settings);
}
checkUsagesPermission();
setUpChildMode();
forceSyncTrigger();

if (!Utilities.getUrl().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public abstract class SyncActivity extends ProcessUserDataActivity implements Sy
TextView customDeviceName, lblVersion;
SharedPreferences defaultPref;
ImageButton imgBtnSetting;
SwitchCompat switchChildMode;
Service service;

@Override
Expand Down Expand Up @@ -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<RealmMyTeam> 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();
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {
service.checkVersion(this, settings)
}
checkUsagesPermission()
setUpChildMode()
forceSyncTrigger()

if (Utilities.getUrl().isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}
Loading

0 comments on commit 4ac240d

Please sign in to comment.