[UI/Login] Display class and school year in summary, show e-register logo icon.

This commit is contained in:
Kuba Szczodrzyński 2019-10-27 19:43:43 +01:00
parent 13b970f4e8
commit 7ce7859a5f
11 changed files with 135 additions and 23 deletions

View File

@ -113,6 +113,10 @@ fun String.getShortName(): String {
}
}
fun List<String>.join(delimiter: String): String {
return this.joinToString(delimiter)
}
fun colorFromName(context: Context, name: String?): Int {
var crc = crc16(name ?: "")
crc = (crc and 0xff) or (crc shr 8)

View File

@ -1,32 +1,40 @@
package pl.szczodrzynski.edziennik.ui.modules.login;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.List;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import pl.szczodrzynski.edziennik.App;
import pl.szczodrzynski.edziennik.ExtensionsKt;
import pl.szczodrzynski.edziennik.R;
import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile;
import pl.szczodrzynski.edziennik.databinding.FragmentLoginSummaryBinding;
import pl.szczodrzynski.edziennik.databinding.RowLoginProfileListItemBinding;
import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_MODE_LIBRUS_EMAIL;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_MODE_VULCAN_API;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_MODE_VULCAN_WEB;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_TYPE_IDZIENNIK;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_TYPE_LIBRUS;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_TYPE_MOBIDZIENNIK;
import static pl.szczodrzynski.edziennik.api.v2.LoginMethodsKt.LOGIN_TYPE_VULCAN;
public class LoginSummaryFragment extends Fragment {
@ -63,11 +71,19 @@ public class LoginSummaryFragment extends Fragment {
for (LoginProfileObject profileObject: LoginActivity.profileObjects) {
int subIndex = 0;
for (Profile profile: profileObject.profileList) {
List<String> subnameList = new ArrayList<>();
if (profile.getStudentClassName() != null)
subnameList.add(profile.getStudentClassName());
if (profile.getStudentSchoolYear() != null)
subnameList.add(profile.getStudentSchoolYear());
ItemProfileModel profileModel = new ItemProfileModel(
index,
subIndex,
profile.getName(),
ExtensionsKt.join(subnameList, " - "),
profileObject.loginStore.type,
profileObject.loginStore.mode,
profile.getAccountNameLong() != null,
profileObject.selectedList.get(subIndex)
);
profileList.add(profileModel);
@ -133,14 +149,20 @@ public class LoginSummaryFragment extends Fragment {
int listIndex;
int listSubIndex;
String name;
String subname;
int loginType;
int loginMode;
boolean isParent;
boolean selected;
public ItemProfileModel(int listIndex, int listSubIndex, String name, int loginType, boolean selected) {
public ItemProfileModel(int listIndex, int listSubIndex, String name, String subname, int loginType, int loginMode, boolean isParent, boolean selected) {
this.listIndex = listIndex;
this.listSubIndex = listSubIndex;
this.name = name;
this.subname = subname;
this.loginType = loginType;
this.loginMode = loginMode;
this.isParent = isParent;
this.selected = selected;
}
}
@ -176,9 +198,50 @@ public class LoginSummaryFragment extends Fragment {
b.checkBox.jumpDrawablesToCurrentState();
}
LoginActivity.profileObjects.get(m.listIndex).selectedList.set(m.listSubIndex, m.selected);
};
b.checkBox.setOnClickListener(onClickListener);
b.getRoot().setOnClickListener(onClickListener);
int imageRes = 0;
if (m.loginType == LOGIN_TYPE_MOBIDZIENNIK) {
imageRes = R.drawable.logo_mobidziennik;
}
else if (m.loginType == LOGIN_TYPE_IDZIENNIK) {
imageRes = R.drawable.logo_idziennik;
}
else if (m.loginType == LOGIN_TYPE_LIBRUS) {
if (m.loginMode == LOGIN_MODE_LIBRUS_EMAIL) {
imageRes = R.drawable.logo_librus;
}
else {
imageRes = R.drawable.logo_synergia;
}
}
else if (m.loginType == LOGIN_TYPE_VULCAN) {
if (m.loginMode == LOGIN_MODE_VULCAN_WEB) {
imageRes = R.drawable.logo_vulcan;
}
else if (m.loginMode == LOGIN_MODE_VULCAN_API) {
imageRes = R.drawable.logo_dzienniczek;
}
}
if (imageRes != 0) {
b.registerIcon.setImageResource(imageRes);
}
if (m.isParent) {
b.accountType.setText(R.string.login_summary_account_parent);
}
else {
b.accountType.setText(R.string.login_summary_account_child);
}
if (m.subname.trim().isEmpty()) {
b.textDetails.setText(null);
b.textDetails.setVisibility(View.GONE);
}
else {
b.textDetails.setText(m.subname);
b.textDetails.setVisibility(View.VISIBLE);
}
//b.root.setOnClickListener(onClickListener);
//holder.bind(b.textView, onClickListener);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -72,7 +72,8 @@
android:layout_height="0dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_weight="1">
android:layout_weight="1"
tools:listitem="@layout/row_login_profile_list_item">
</androidx.recyclerview.widget.RecyclerView>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
@ -9,7 +8,8 @@
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical">
android:gravity="center_vertical"
android:focusable="true">
<CheckBox
android:id="@+id/checkBox"
@ -18,13 +18,55 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:text="TextView"
android:textSize="16sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:textSize="16sp"
tools:text="Jan Kowalski" />
<TextView
android:id="@+id/accountType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:textAppearance="@style/NavView.TextView.Helper"
tools:text="(rodzic)" />
</LinearLayout>
<TextView
android:id="@+id/textDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:textAppearance="@style/NavView.TextView.Helper"
tools:text="2B3T - 2019/2020" />
</LinearLayout>
<ImageView
android:id="@+id/registerIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
tools:srcCompat="@drawable/logo_mobidziennik" />
</LinearLayout>
</layout>

View File

@ -964,4 +964,6 @@
<string name="edziennik_progress_endpoint_notice_types">Pobieranie kategorii uwag...</string>
<string name="edziennik_progress_endpoint_pt_meetings">Pobieranie zebrań z rodzicami...</string>
<string name="edziennik_progress_endpoint_messages_outbox">Pobieranie wiadomości wysłanych...</string>
<string name="login_summary_account_parent">(rodzic)</string>
<string name="login_summary_account_child">(uczeń)</string>
</resources>