Set up Volley request queue

This commit is contained in:
Garrett Mills 2021-05-12 12:51:38 -05:00
parent 7e02dcd87b
commit dd2f5c0886
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
6 changed files with 17 additions and 1 deletions

View File

@ -44,4 +44,5 @@ dependencies {
// CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha14"
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.android.volley:volley:1.2.0'
}

View File

@ -5,6 +5,7 @@
<uses-feature android:name="android.hardware.camera.any" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"

View File

@ -2,10 +2,12 @@ package dev.garrettmills.starship.hyperlink;
import android.content.SharedPreferences;
import com.android.volley.RequestQueue;
public class Hyperlink {
public static final String SHARED_PREFERENCES_NAME = "dev.garrettmills.starship.hyperlink.main";
public static final String SERVER_ADDR = "dev.garrettmills.starship.hyperlink.server";
public static final String SERVER_TOKEN = "dev.garrettmills.starship.hyperlink.token.server";
public static final String ACCESS_TOKEN = "dev.garrettmills.starship.hyperlink.token.server";
public static final String EXTRA_LOGIN_TOKEN = "dev.garrettmills.starship.hyperlink.extra.login_token";
@ -13,4 +15,5 @@ public class Hyperlink {
public static final int REQUEST_PERMISSION_CAMERA = 181;
public static SharedPreferences preferences;
public static RequestQueue httpRequestQueue;
}

View File

@ -7,11 +7,14 @@ import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.android.volley.toolbox.Volley;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Hyperlink.preferences = getSharedPreferences(Hyperlink.SHARED_PREFERENCES_NAME, MODE_PRIVATE);
Hyperlink.httpRequestQueue = Volley.newRequestQueue(this);
setContentView(R.layout.activity_main);
}

View File

@ -0,0 +1,4 @@
package dev.garrettmills.starship.hyperlink.util;
public class AccessToken {
}

View File

@ -1,5 +1,9 @@
package dev.garrettmills.starship.hyperlink.util;
/**
* Token format:
* "hyperlink|https://hyperlink.url|token"
*/
public class LoginToken {
public static boolean isValidLoginToken(String token) {
try {