user actions
This commit is contained in:
parent
274d00a222
commit
d39a7d3480
2 changed files with 60 additions and 5 deletions
|
@ -15,6 +15,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||||
public class MainScreen extends AppCompatActivity {
|
public class MainScreen extends AppCompatActivity {
|
||||||
String username;
|
String username;
|
||||||
HttpsURLConnection myConnection;
|
HttpsURLConnection myConnection;
|
||||||
String myData;
|
String myData, usertype;
|
||||||
URL endpoint;
|
URL endpoint;
|
||||||
boolean success;
|
boolean success;
|
||||||
BufferedReader br;
|
BufferedReader br;
|
||||||
|
@ -38,7 +39,8 @@ public class MainScreen extends AppCompatActivity {
|
||||||
SQLiteDatabase db;
|
SQLiteDatabase db;
|
||||||
MyDbHelper dbHelper;
|
MyDbHelper dbHelper;
|
||||||
TextView id ,email, nacionalidad, nacimiento;
|
TextView id ,email, nacionalidad, nacimiento;
|
||||||
Button logout, notification;
|
Button logout, notification, edit, delete;
|
||||||
|
LinearLayout adminactions;
|
||||||
Uri crashsound;
|
Uri crashsound;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +54,9 @@ public class MainScreen extends AppCompatActivity {
|
||||||
nacimiento = (TextView) findViewById(R.id.nacimiento);
|
nacimiento = (TextView) findViewById(R.id.nacimiento);
|
||||||
logout = (Button)findViewById(R.id.logout);
|
logout = (Button)findViewById(R.id.logout);
|
||||||
notification = (Button)findViewById(R.id.notification);
|
notification = (Button)findViewById(R.id.notification);
|
||||||
|
adminactions = (LinearLayout) findViewById(R.id.linearLayoutAdmin);
|
||||||
|
edit = (Button)findViewById(R.id.editaccount);
|
||||||
|
delete = (Button)findViewById(R.id.deleteaccount);
|
||||||
dbHelper = new MyDbHelper(this);
|
dbHelper = new MyDbHelper(this);
|
||||||
crashsound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + this.getPackageName() + "/" + R.raw.crash);
|
crashsound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + this.getPackageName() + "/" + R.raw.crash);
|
||||||
id.setText(username);
|
id.setText(username);
|
||||||
|
@ -94,11 +99,15 @@ public class MainScreen extends AppCompatActivity {
|
||||||
public void run() {
|
public void run() {
|
||||||
//Test
|
//Test
|
||||||
if (success) {
|
if (success) {
|
||||||
Toast.makeText(getApplicationContext(), "Credenciales correctas", Toast.LENGTH_SHORT).show();
|
//Toast.makeText(getApplicationContext(), "Credenciales correctas", Toast.LENGTH_SHORT).show();
|
||||||
try {
|
try {
|
||||||
email.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("email"));
|
email.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("email"));
|
||||||
nacionalidad.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("country"));
|
nacionalidad.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("country"));
|
||||||
nacimiento.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("birthdate"));
|
nacimiento.setText((String) jsonObj.getJSONArray("items").getJSONObject(0).getString("birthdate"));
|
||||||
|
usertype = (String) jsonObj.getJSONArray("items").getJSONObject(0).getString("permission");
|
||||||
|
if (usertype.equals("admin")) {
|
||||||
|
adminactions.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -187,6 +196,20 @@ public class MainScreen extends AppCompatActivity {
|
||||||
logout.start();
|
logout.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
edit.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//buttonaction
|
||||||
|
Toast.makeText(getApplicationContext(),"editar", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
delete.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//buttonaction
|
||||||
|
Toast.makeText(getApplicationContext(),"eliminar", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mainMenu() {
|
private void mainMenu() {
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
android:id="@+id/activity_main"
|
android:id="@+id/activity_main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/galaxy"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:theme="@style/Theme.AppCompat"
|
android:theme="@style/Theme.AppCompat"
|
||||||
android:background="@drawable/galaxy"
|
|
||||||
tools:context=".MainScreen">
|
tools:context=".MainScreen">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayoutSubmit"
|
android:id="@+id/linearLayoutAction"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="70dp"
|
android:layout_height="70dp"
|
||||||
android:layout_margin="0dp"
|
android:layout_margin="0dp"
|
||||||
|
@ -72,4 +72,36 @@
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="25sp" />
|
android:textSize="25sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayoutAdmin"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="70dp"
|
||||||
|
android:layout_margin="0dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="invisible"
|
||||||
|
tools:ignore="MissingConstraints"
|
||||||
|
tools:layout_editor_absoluteX="20dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/editaccount"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/black"
|
||||||
|
android:text="Editar"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/deleteaccount"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/black"
|
||||||
|
android:text="Eliminar"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in a new issue