Skip to content

Commit

Permalink
login: one for all (fixes #2766) (#2767)
Browse files Browse the repository at this point in the history
Co-authored-by: mutugiii <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 7532a02 commit 7a679e4
Show file tree
Hide file tree
Showing 15 changed files with 1,078 additions and 1,916 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 1174
versionName "0.11.74"
versionCode 1175
versionName "0.11.75"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:usesCleartextTraffic="true"
tools:replace="android:label">
<activity
android:name=".ui.sync.TeamLoginActivity"
android:name=".ui.sync.LoginActivity"
android:exported="false" />
<activity android:name=".ui.chat.ChatActivity" />
<activity
Expand Down Expand Up @@ -81,9 +81,6 @@
<activity
android:name=".ui.feedback.FeedbackDetailActivity"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.sync.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name=".ui.dashboard.DashboardActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.ole.planet.myplanet.ui.dashboard.DashboardActivity;
import org.ole.planet.myplanet.ui.sync.LoginActivity;
import org.ole.planet.myplanet.ui.sync.SyncActivity;
import org.ole.planet.myplanet.ui.sync.TeamLoginActivity;
import org.ole.planet.myplanet.utilities.Constants;
import org.ole.planet.myplanet.utilities.FileUtils;
import org.ole.planet.myplanet.utilities.SharedPrefManager;
Expand All @@ -37,10 +36,8 @@ protected void onCreate(Bundle savedInstanceState) {
finish();
return;
}
if (prefData.getFIRSTLAUNCH1() && prefData.getTEAMMODE1()) {
startActivity(new Intent(SplashActivity.this, TeamLoginActivity.class));
finish();
} else if (prefData.getFIRSTLAUNCH1() && !prefData.getTEAMMODE1()) {

if (prefData.getFIRSTLAUNCH1()) {
startActivity(new Intent(SplashActivity.this, LoginActivity.class));
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

protected void syncNow() {
settings.edit().putBoolean(Constants.KEY_LOGIN, false).commit();
if (prefData.getTEAMMODE1()){
startActivity(new Intent(this, TeamLoginActivity.class).putExtra("forceSync", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP));
} else {
startActivity(new Intent(this, LoginActivity.class).putExtra("forceSync", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP));
}
startActivity(new Intent(this, LoginActivity.class).putExtra("forceSync", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP));
doubleBackToExitPressedOnce = true;
finish();
}
Expand Down Expand Up @@ -188,15 +184,9 @@ public void logout() {
profileDbHandler.onLogout();
settings.edit().putBoolean(Constants.KEY_LOGIN, false).commit();
settings.edit().putBoolean(Constants.KEY_NOTIFICATION_SHOWN, false).commit();
if (prefData.getTEAMMODE1()){
Intent loginscreen = new Intent(this, TeamLoginActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(loginscreen);
} else {
Intent loginscreen = new Intent(this, LoginActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(loginscreen);
}
Intent loginscreen = new Intent(this, LoginActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(loginscreen);
doubleBackToExitPressedOnce = true;
this.finish();
}
Expand Down
152 changes: 0 additions & 152 deletions app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.databinding.ActivityTeamLoginBinding
import org.ole.planet.myplanet.databinding.ActivityLoginBinding
import org.ole.planet.myplanet.datamanager.Service
import org.ole.planet.myplanet.model.MyPlanet
import org.ole.planet.myplanet.model.RealmMyTeam
Expand All @@ -19,8 +19,8 @@ import org.ole.planet.myplanet.ui.userprofile.TeamListAdapter
import org.ole.planet.myplanet.utilities.FileUtils
import org.ole.planet.myplanet.utilities.Utilities

class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {
private lateinit var activityTeamLoginBinding: ActivityTeamLoginBinding
class LoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {
private lateinit var activityLoginBinding: ActivityLoginBinding
private var guest = false
var users: List<RealmUserModel>? = null
var mAdapter: TeamListAdapter? = null
Expand All @@ -29,23 +29,23 @@ class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityTeamLoginBinding = ActivityTeamLoginBinding.inflate(layoutInflater)
setContentView(activityTeamLoginBinding.root)
lblLastSyncDate = activityTeamLoginBinding.lblLastSyncDate
inputName = activityTeamLoginBinding.inputName
inputPassword = activityTeamLoginBinding.inputPassword
btnSignIn = activityTeamLoginBinding.btnSignin
syncIcon = activityTeamLoginBinding.syncIcon
becomeMember = activityTeamLoginBinding.becomeMember
btnGuestLogin = activityTeamLoginBinding.btnGuestLogin
imgBtnSetting = activityTeamLoginBinding.imgBtnSetting
syncIcon = activityTeamLoginBinding.syncIcon
lblVersion = activityTeamLoginBinding.lblVersion
btnLang = activityTeamLoginBinding.btnLang
tvAvailableSpace = activityTeamLoginBinding.tvAvailableSpace
openCommunity = activityTeamLoginBinding.openCommunity
btnFeedback = activityTeamLoginBinding.btnFeedback
customDeviceName = activityTeamLoginBinding.customDeviceName
activityLoginBinding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(activityLoginBinding.root)
lblLastSyncDate = activityLoginBinding.lblLastSyncDate
inputName = activityLoginBinding.inputName
inputPassword = activityLoginBinding.inputPassword
btnSignIn = activityLoginBinding.btnSignin
syncIcon = activityLoginBinding.syncIcon
becomeMember = activityLoginBinding.becomeMember
btnGuestLogin = activityLoginBinding.btnGuestLogin
imgBtnSetting = activityLoginBinding.imgBtnSetting
syncIcon = activityLoginBinding.syncIcon
lblVersion = activityLoginBinding.lblVersion
btnLang = activityLoginBinding.btnLang
tvAvailableSpace = activityLoginBinding.tvAvailableSpace
openCommunity = activityLoginBinding.openCommunity
btnFeedback = activityLoginBinding.btnFeedback
customDeviceName = activityLoginBinding.customDeviceName

service = Service(this)

Expand Down Expand Up @@ -116,17 +116,17 @@ class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {
TeamListAdapter(prefData.getSAVEDUSERS().toMutableList(), this, this)
}

activityTeamLoginBinding.recyclerView.layoutManager = LinearLayoutManager(this)
activityTeamLoginBinding.recyclerView.adapter = mAdapter
activityLoginBinding.recyclerView.layoutManager = LinearLayoutManager(this)
activityLoginBinding.recyclerView.adapter = mAdapter

val layoutManager: RecyclerView.LayoutManager = object : LinearLayoutManager(this) {
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams {
return RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}
}
activityTeamLoginBinding.recyclerView.layoutManager = layoutManager
activityTeamLoginBinding.recyclerView.isNestedScrollingEnabled = true
activityTeamLoginBinding.recyclerView.setHasFixedSize(true)
activityLoginBinding.recyclerView.layoutManager = layoutManager
activityLoginBinding.recyclerView.isNestedScrollingEnabled = true
activityLoginBinding.recyclerView.setHasFixedSize(true)
}

override fun onItemClick(user: User) {
Expand All @@ -135,7 +135,7 @@ class TeamLoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener {
.load(user.image)
.placeholder(R.drawable.profile)
.error(R.drawable.profile)
.into(activityTeamLoginBinding.userProfile)
.into(activityLoginBinding.userProfile)

inputName.setText(user.name)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,7 @@ public void settingDialog(SyncActivity activity) {
String url = serverUrlProtocol.getText().toString() + serverUrl.getText().toString();
if (isUrlValid(url)) {
prefData.setSELECTEDTEAMID1(selectedTeamId);
if (!prefData.getTEAMMODE1()){
prefData.setTEAMMODE1(true);
Intent intent = new Intent(this, TeamLoginActivity.class);
startActivity(intent);
} else if (prefData.getTEAMMODE1() && activity instanceof TeamLoginActivity) {
((TeamLoginActivity) activity).getTeamMembers();
}
((LoginActivity) activity).getTeamMembers();
saveConfigAndContinue(dialog);
} else {
saveConfigAndContinue(dialog);
Expand Down Expand Up @@ -1202,20 +1196,7 @@ public void onTextChanged(CharSequence s, int i, int i1, int i2) {
positiveAction.setEnabled(s.toString().trim().length() > 0 && URLUtil.isValidUrl(protocol + s.toString()));
}

public void afterTextChanged(Editable editable) {
switch (view.getId()) {
case R.id.input_name:
validateEditText(inputName, inputLayoutName, getString(R.string.err_msg_name));
break;
case R.id.input_password:
if(!prefData.getTEAMMODE1()) {
validateEditText(inputPassword, inputLayoutPassword, getString(R.string.err_msg_password));
}
break;
default:
break;
}
}
public void afterTextChanged(Editable editable) {}
}

@Override
Expand Down
Loading

0 comments on commit 7a679e4

Please sign in to comment.