Skip to content

Commit

Permalink
Hide API key
Browse files Browse the repository at this point in the history
  • Loading branch information
tink-expo committed Dec 1, 2019
1 parent 886fe63 commit e5f1ae4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/.project
/.settings
/app/sampledata
/gradle.properties
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildTypes.each {
it.buildConfigField 'String', 'API_KEY', API_KEY
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FailActivity extends AppCompatActivity {
private String currentId;
private String currentPw;

private Timer timer;
private Timer timer = null;
private BroadcastReceiver wifiConnectReceiver = null;
private WifiManager wifiManager;

Expand Down Expand Up @@ -83,13 +83,13 @@ public void onClick(DialogInterface dialog, int which) {
}
});

timer = new Timer();
wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);

Button retryButton = (Button) findViewById(R.id.retryButton);
retryButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
timer = new Timer();
wifiConnectReceiver = WifiScanConnect.connectAndRegisterReceiver(FailActivity.this, wifiManager, new IntentFilter(), new SsidPw(currentId, currentPw), timer);
}
});
Expand All @@ -100,7 +100,9 @@ public void onClick(View view) {
protected void onPause() {
super.onPause();

timer.cancel();
if (timer != null) {
timer.cancel();
}

try {
unregisterReceiver(wifiConnectReceiver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
import java.util.ArrayList;
import java.util.List;

// Reference code : https://github.com/GoogleCloudPlatform/cloud-vision/tree/master/android/CloudVision

public class TextDetect {

private static final String CLOUD_VISION_API_KEY = "AIzaSyBeqND-h_JplQ_uV3_OyNTgORZLfRqMZOs";
private static final String CLOUD_VISION_API_KEY = BuildConfig.API_KEY;
private static final int MAX_TEXT_RESULTS = 20;
private static final int MAX_DIMENSION = 1200;

Expand Down
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

API_KEY="AIzaSyBeqND-h_JplQ_uV3_OyNTgORZLfRqMZOs"

0 comments on commit e5f1ae4

Please sign in to comment.