Can now delete account

This commit is contained in:
Aaron Sun 2020-10-08 16:57:01 -07:00
parent 96760bd9f1
commit 83a929fd51
3 changed files with 30 additions and 7 deletions

View File

@ -18,7 +18,7 @@ public class Requestor {
String apiKey;
OkHttpClient client;
Requestor(AuthManager authManager, String apiKey) {
public Requestor(AuthManager authManager, String apiKey) {
this.authManager = authManager;
this.apiKey = apiKey;
client = new OkHttpClient();

View File

@ -10,7 +10,18 @@ import android.view.LayoutInflater;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import static com.example.listify.MainActivity.am;
import com.example.listify.AuthManager;
import com.example.listify.MainActivity;
import com.example.listify.R;
import com.example.listify.Requestor;
import com.example.listify.ui.LoginPage;
import org.json.JSONException;
import java.io.IOException;
import java.util.Properties;
public class HomeFragment extends Fragment {
private Button toLoginPage;
@ -23,7 +34,7 @@ public class HomeFragment extends Fragment {
toLoginPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ui.LoginPage.class);
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
startActivity(intent);
}
});
@ -32,8 +43,20 @@ public class HomeFragment extends Fragment {
toListPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ListPage.class);
startActivity(intent);
//Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ListPage.class);
//startActivity(intent);
try {
Properties configs = new Properties();
try {
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
} catch (IOException | JSONException e) {
e.printStackTrace();
}
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
am.deleteUser(requestor);
}
catch(Exception ex) {}
}
});

View File

@ -11,17 +11,17 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginStart="1dp"
android:layout_marginEnd="25dp"
android:text="Log in"
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintStart_toStartOf="@+id/button2" />
app:layout_constraintEnd_toEndOf="@+id/button2" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="148dp"
android:text="List"
android:text="Delete Account"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />