Browse Source
* first step towards a working his online integration * rework AddSubjectDialog * activate fragment_on_loginpull/46/head
10 changed files with 236 additions and 56 deletions
@ -0,0 +1,27 @@
|
||||
/** |
||||
* ProjectLaogai |
||||
* |
||||
* Copyright 2019-2020 <seil0@mosad.xyz> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
* |
||||
*/ |
||||
|
||||
package org.mosad.seil0.projectlaogai.controller.login |
||||
|
||||
class LoginController { |
||||
// TODO implement |
||||
} |
@ -0,0 +1,81 @@
|
||||
/** |
||||
* ProjectLaogai |
||||
* |
||||
* Copyright 2019-2020 <seil0@mosad.xyz> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
* |
||||
*/ |
||||
|
||||
package org.mosad.seil0.projectlaogai.uicomponents.dialogs |
||||
|
||||
import android.content.Context |
||||
import android.widget.EditText |
||||
import com.afollestad.materialdialogs.MaterialDialog |
||||
import com.afollestad.materialdialogs.WhichButton |
||||
import com.afollestad.materialdialogs.actions.getActionButton |
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet |
||||
import com.afollestad.materialdialogs.bottomsheets.setPeekHeight |
||||
import com.afollestad.materialdialogs.customview.customView |
||||
import com.afollestad.materialdialogs.customview.getCustomView |
||||
import org.mosad.seil0.projectlaogai.R |
||||
import org.mosad.seil0.projectlaogai.controller.PreferencesController |
||||
|
||||
class LoginDialog(val context: Context) { |
||||
|
||||
private val dialog = MaterialDialog(context, BottomSheet()) |
||||
|
||||
private val editTextEmail: EditText |
||||
private val editTextPassword: EditText |
||||
|
||||
var email = "" |
||||
var password = "" |
||||
|
||||
init { |
||||
dialog.title(R.string.grades_heading) |
||||
.message(R.string.grades_desc_on) |
||||
.customView(R.layout.dialog_login) |
||||
.positiveButton(R.string.save) |
||||
.negativeButton(R.string.cancel) |
||||
.setPeekHeight(900) |
||||
|
||||
editTextEmail = dialog.getCustomView().findViewById(R.id.editText_email) |
||||
editTextPassword = dialog.getCustomView().findViewById(R.id.editText_password) |
||||
|
||||
// fix not working accent color |
||||
dialog.getActionButton(WhichButton.POSITIVE).updateTextColor(PreferencesController.cColorAccent) |
||||
dialog.getActionButton(WhichButton.NEGATIVE).updateTextColor(PreferencesController.cColorAccent) |
||||
} |
||||
|
||||
fun positiveButton(func: LoginDialog.() -> Unit): LoginDialog = apply { |
||||
dialog.positiveButton { |
||||
email = editTextEmail.text.toString() |
||||
password = editTextPassword.text.toString() |
||||
|
||||
func() |
||||
} |
||||
} |
||||
|
||||
fun show(func: LoginDialog.() -> Unit): LoginDialog = apply { |
||||
func() |
||||
|
||||
editTextEmail.setText(email) |
||||
editTextPassword.setText(password) |
||||
|
||||
dialog.show() |
||||
} |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/linLayout_login" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" |
||||
android:paddingStart="24dp" |
||||
android:paddingEnd="24dp"> |
||||
|
||||
<EditText |
||||
android:id="@+id/editText_email" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="7dp" |
||||
android:ems="10" |
||||
android:hint="@string/email" |
||||
android:importantForAutofill="no" |
||||
android:inputType="textEmailAddress" /> |
||||
|
||||
<EditText |
||||
android:id="@+id/editText_password" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="7dp" |
||||
android:ems="10" |
||||
android:hint="@string/password" |
||||
android:importantForAutofill="no" |
||||
android:inputType="textPassword" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue