1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2025-01-19 00:36:48 -06:00

Remake MainActivity layout

This commit is contained in:
RicomenPL 2017-07-22 17:19:10 +02:00
parent f4a8ad9b55
commit cf37785954
5 changed files with 110 additions and 100 deletions

View File

@ -27,7 +27,8 @@
<activity
android:name=".activity.main.MainActivity"
android:label="@string/login_title"
android:configChanges="orientation|screenSize"/>
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activity.dashboard.DashboardActivity"
android:label="@string/title_activity_dashboard"

View File

@ -18,10 +18,10 @@ import io.github.wulkanowy.activity.dashboard.marks.MarksFragment;
public class DashboardActivity extends AppCompatActivity {
MarksFragment marksFragment;
AttendanceFragment attendanceFragment = new AttendanceFragment();
BoardFragment boardFragment = new BoardFragment();
LessonplanFragment lessonplanFragment = new LessonplanFragment();
private MarksFragment marksFragment = new MarksFragment();
private AttendanceFragment attendanceFragment = new AttendanceFragment();
private BoardFragment boardFragment = new BoardFragment();
private LessonplanFragment lessonplanFragment = new LessonplanFragment();
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
@ -68,8 +68,6 @@ public class DashboardActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
marksFragment = new MarksFragment();
setTitle(R.string.title_dashboard);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);

View File

@ -1,10 +1,13 @@
package io.github.wulkanowy.activity.main;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
@ -14,7 +17,12 @@ import java.util.LinkedHashMap;
import io.github.wulkanowy.R;
public class MainActivity extends Activity {
public class MainActivity extends AppCompatActivity {
private float mTouchPosition;
private float mReleasePosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -25,7 +33,8 @@ public class MainActivity extends Activity {
.setTitle(R.string.warning_label)
.setMessage(R.string.warning_text)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {}
public void onClick(DialogInterface dialog, int which) {
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
@ -33,7 +42,7 @@ public class MainActivity extends Activity {
autoComplete();
}
private void autoComplete(){
private void autoComplete() {
// Get a reference to the AutoCompleteTextView in the layout
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.countyText);
@ -45,30 +54,56 @@ public class MainActivity extends Activity {
textView.setAdapter(adapter);
}
public void login(View a){
EditText adressEmail = (EditText)findViewById(R.id.emailText);
EditText passwordText = (EditText)findViewById(R.id.passwordText);
EditText countyText = (EditText)findViewById(R.id.countyText);
public void login(View a) {
EditText adressEmail = (EditText) findViewById(R.id.emailText);
EditText passwordText = (EditText) findViewById(R.id.passwordText);
EditText countyText = (EditText) findViewById(R.id.countyText);
String password = passwordText.getText().toString();
String email = adressEmail.getText().toString();
String county = countyText.getText().toString();
String[] keys = this.getResources().getStringArray(R.array.counties);
String[] values = this.getResources().getStringArray(R.array.counties_values);
LinkedHashMap<String,String> map = new LinkedHashMap<String,String>();
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
for (int i = 0; i < Math.min(keys.length, values.length); ++i) {
map.put(keys[i], values[i]);
}
if(map.containsKey(county)) {
if (map.containsKey(county)) {
county = map.get(county);
}
if (!email.isEmpty() && !password.isEmpty() && !county.isEmpty()){
if (!email.isEmpty() && !password.isEmpty() && !county.isEmpty()) {
new LoginTask(this).execute(email, password, county);
} else {
Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show();
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mTouchPosition = ev.getY();
}
if (ev.getAction() == MotionEvent.ACTION_UP) {
mReleasePosition = ev.getY();
if (mTouchPosition - mReleasePosition == 0 ) {
View view = getCurrentFocus();
if (view != null && (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_MOVE) && view instanceof EditText && !view.getClass().getName().startsWith("android.webkit.")) {
int scrcoords[] = new int[2];
view.getLocationOnScreen(scrcoords);
float x = ev.getRawX() + view.getLeft() - scrcoords[0];
float y = ev.getRawY() + view.getTop() - scrcoords[1];
if (x < view.getLeft() || x > view.getRight() || y < view.getTop() || y > view.getBottom()) {
((InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow((this.getWindow().getDecorView().getApplicationWindowToken()), 0);
}
}
}
}
return super.dispatchTouchEvent(ev);
}
}

View File

@ -1,87 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.github.wulkanowy.activity.main.MainActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
android:layout_height="match_parent">
<TextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.071" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/appName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:text="@string/app_name"
android:textSize="40sp" />
<EditText
android:id="@+id/emailText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress"
android:hint="@string/email_hint"
app:layout_constraintVertical_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.502"
tools:layout_constraintRight_creator="1"
tools:layout_constraintLeft_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.241" />
<EditText
android:id="@+id/emailText"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="@string/email_hint"
android:inputType="textEmailAddress"
/>
<EditText
android:id="@+id/passwordText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword"
android:hint="@string/pass_hint"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.502"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintVertical_chainStyle="spread_inside"
tools:layout_constraintLeft_creator="1"
app:layout_constraintVertical_bias="0.391" />
<EditText
android:id="@+id/passwordText"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="@string/pass_hint"
android:inputType="textPassword" />
<Button
android:id="@+id/agreeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintRight_creator="1"
tools:layout_constraintLeft_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.712"
android:onClick="login"/>
<AutoCompleteTextView
android:id="@+id/countyText"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:hint="@string/county_hint"
android:imeOptions="actionDone"
android:inputType="text" />
<AutoCompleteTextView
android:id="@+id/countyText"
android:imeOptions="actionDone"
android:inputType="text"
android:layout_width="215dp"
android:layout_height="45dp"
android:hint="@string/county_hint"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintVertical_bias="0.536" />
<Button
android:id="@+id/agreeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:onClick="login"
android:text="@string/login_button" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</ScrollView>

View File

@ -22,7 +22,8 @@
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="185dp" />
android:layout_marginBottom="228dp"
app:layout_constraintHorizontal_bias="0.503" />
<ImageView
android:id="@+id/logoImage"
@ -34,9 +35,9 @@
app:layout_constraintBottom_toTopOf="@+id/nameApp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="29dp"
android:layout_marginBottom="53dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.502" />
app:layout_constraintHorizontal_bias="0.503" />
<TextView
android:id="@+id/rawText"