From 60784629b7e2d8b4350ed76c553e9e1826597a33 Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Tue, 16 Feb 2021 18:38:00 -0800 Subject: [PATCH] Reverted Kotlin back to Java for this repo --- .../com/example/listify/MainActivity.java | 118 ------------------ ...{SplashActivity.kt => SplashActivity.java} | 30 +---- 2 files changed, 2 insertions(+), 146 deletions(-) rename Listify/app/src/main/java/com/example/listify/{SplashActivity.kt => SplashActivity.java} (53%) diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index 404ca8b..1ab00fb 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -81,125 +81,11 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF startActivity(intent); } -// LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); -// if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { -// Log.d("CHECKING", "WORKS"); -// } else { -// ActivityCompat.requestPermissions( -// this, -// new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, -// 0 -// ); -// } -// Location location; -// -// while(true) { -// try { -// location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); -// break; -// } catch(java.lang.SecurityException e) { -// //User clicked delete -// } -// } -// -// if(location != null) { -// double longitude = location.getLongitude(); -// double latitude = location.getLatitude(); -// } - - - //------------------------------Auth Testing---------------------------------------------// - - boolean testAuth = false; - - if (testAuth) { - - AuthManager authManager = new AuthManager(); - try { - authManager.signIn("merzn@purdue.edu", "Password123"); - Log.i("Authentication", authManager.getAuthSession().toString()); - Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); - } catch (AuthException e) { - Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); - try { - authManager.startSignUp("merzn@purdue.edu", "Password123"); - authManager.confirmSignUp("######"); - } catch (AuthException signUpError) { - Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); - } - } - } - - //----------------------------------API Testing---------------------------------------------// - - boolean testAPI = false; - - if (testAPI) { - AuthManager authManager = new AuthManager(); - try { - authManager.signIn("merzn@purdue.edu", "Password123"); - } catch (AuthException e) { - e.printStackTrace(); - } - Properties configs = new Properties(); - try { - configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); - } catch (IOException | JSONException e) { - e.printStackTrace(); - } - - /*Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey")); - SynchronousReceiver historyReceiver = new SynchronousReceiver<>(); - requestor.getObject("N/A", SearchHistory.class, historyReceiver, historyReceiver); - try { - requestor.putObject(new List(293, "Java.py", "me!", 1)); - System.out.println(historyReceiver.await()); - requestor.putObject(new ListReposition(291, 1)); - requestor.postObject(new ListDuplicate(290, "yet another list")); - } catch (Exception e) { - e.printStackTrace(); - } - - List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli()); - ListEntry entry = new ListEntry(1, 4, Math.abs(new Random().nextInt()), Instant.now().toEpochMilli(),false); - - SynchronousReceiver idReceiver = new SynchronousReceiver<>(); - try { - requestor.postObject(testList, idReceiver, idReceiver); - System.out.println(idReceiver.await()); - requestor.postObject(entry); - } - catch (Exception e) { - Log.i("Authentication", e.toString()); - e.printStackTrace(); - } - - SynchronousReceiver itemReceiver = new SynchronousReceiver<>(); - requestor.getObject("1", Item.class, itemReceiver, itemReceiver); - SynchronousReceiver listReceiver = new SynchronousReceiver<>(); - requestor.getObject("39", List.class, listReceiver, listReceiver); - SynchronousReceiver listIdsReceiver = new SynchronousReceiver<>(); - requestor.getListOfIds(List.class, listIdsReceiver, listIdsReceiver); - SynchronousReceiver itemSearchReceiver = new SynchronousReceiver<>(); - requestor.getObject("r", ItemSearch.class, itemSearchReceiver, itemSearchReceiver); - try { - System.out.println(itemReceiver.await()); - System.out.println(listReceiver.await()); - System.out.println(Arrays.toString(listIdsReceiver.await())); - System.out.println(itemSearchReceiver.await()); - } catch (Exception receiverError) { - receiverError.printStackTrace(); - } - */ - } - - //------------------------------------------------------------------------------------------// setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); - Properties configs = new Properties(); try { configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); @@ -218,11 +104,9 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF e.printStackTrace(); } profilePictureView.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); -// builder.setView(navigationView.getHeaderView(0)); builder.setTitle("Change picture"); builder.setMessage("Please select a method to add a new profile picture."); builder.setCancelable(true); @@ -447,6 +331,4 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF } } - - } \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/SplashActivity.kt b/Listify/app/src/main/java/com/example/listify/SplashActivity.java similarity index 53% rename from Listify/app/src/main/java/com/example/listify/SplashActivity.kt rename to Listify/app/src/main/java/com/example/listify/SplashActivity.java index d654079..36ce821 100644 --- a/Listify/app/src/main/java/com/example/listify/SplashActivity.kt +++ b/Listify/app/src/main/java/com/example/listify/SplashActivity.java @@ -1,30 +1,4 @@ -package com.example.listify - -import android.content.Intent -import android.os.Bundle -import android.os.Handler -import androidx.appcompat.app.AppCompatActivity - -class SplashActivity : AppCompatActivity() { - override fun onBackPressed() {} - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_splashscreen) - Handler().postDelayed({ - showSplash = false - val intent = Intent(this@SplashActivity, MainActivity::class.java) - intent.putExtra("prev", "Splash") - startActivity(intent) - }, 3000) - } - - companion object { - @JvmField - var showSplash = true - } -} - -/*package com.example.listify; +package com.example.listify; import android.content.Intent; import android.os.Bundle; @@ -54,4 +28,4 @@ public class SplashActivity extends AppCompatActivity { } }, 3000); } -}*/ \ No newline at end of file +}