Skip to content

Commit a5b441b

Browse files
committed
Final Changes
1 parent 3820bfd commit a5b441b

File tree

63 files changed

+370
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+370
-430
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/ic_launcher-web.png

48.8 KB
Loading

app/src/main/java/in/krharsh17/programmersdate/Constants.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,20 @@ public interface Constants {
4949
LatLng miniAuditorium = new LatLng(25.6198062, 85.1737271);
5050

5151
String sacBuildingText = "SAC";
52-
String cafeteriaText = "Cafeteria";
5352
String mainBuildingText = "Main Building";
5453
String civilDeptText = "Civil Department";
5554
String computerCentreText = "Computer Centre";
5655
String tennisCourtText = "Basketball Court";
5756
String directorBungalowText = "Director's Bungalow";
5857
String guestHouseText = "Guest House";
59-
String mechanicalWorkshopText = "Mechanical Workshop";
6058
String gangaHostelText = "Ganga Hostel";
6159
String cseDeptText = "CSE Department";
6260
String CWRSText = "CWRS";
6361
String canteenGopalJiText = "Canteen Gopal Ji";
6462
String canteenShuklaJiText = "Canteen Shukla Ji";
6563
String electricalDeptText = "Electrical Department";
66-
String mechanicalDeptText = "Mechanical Department";
67-
String newElectricalDeptText = "New Electrical Department";
6864
String electronicsDeptText = "Electronics Department";
69-
String physicsDeptText = "Physics Department";
70-
String groundText = "Main Ground";
71-
String miniAuditoriumText = "Mini Auditorium";
65+
String groundText = "Ground";
7266

7367

7468
LatLngBounds NITP_BOUNDS = new LatLngBounds(new LatLng(25.619097, 85.170036),
@@ -97,6 +91,6 @@ public interface Constants {
9791

9892
int REQUEST_CAMERA_PERMISSION = 1;
9993

100-
long startTime = 1580304964;
94+
long startTime = 1580380200;
10195

10296
}

app/src/main/java/in/krharsh17/programmersdate/ViewUtils.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.animation.Animator;
44
import android.app.Activity;
5-
import android.content.Context;
65
import android.graphics.Color;
76
import android.os.Handler;
87
import android.util.Log;
@@ -22,6 +21,8 @@
2221
import static in.krharsh17.programmersdate.Constants.TAG;
2322

2423
public class ViewUtils {
24+
public static boolean completeShowing = false;
25+
2526
public static int DURATION_LONG = Toast.LENGTH_LONG;
2627
public static int DURATION_SHORT = Toast.LENGTH_SHORT;
2728

@@ -44,21 +45,6 @@ public static void showToast(Activity context, String text, int duration) {
4445
}
4546
}
4647

47-
public static void showToast(Context context, String text, int duration) {
48-
if (context != null) {
49-
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
50-
View layout = inflater.inflate(R.layout.custom_toast,
51-
(ViewGroup) ((Activity) context).findViewById(R.id.custom_toast_root));
52-
53-
((TextView) layout.findViewById(R.id.custom_toast_textview)).setText(text);
54-
// create a new Toast using context
55-
Toast toast = new Toast(context);
56-
toast.setDuration(duration); // set the duration for the Toast
57-
toast.setView(layout); // set the inflated layout
58-
toast.show(); // display the custom Toast
59-
}
60-
}
61-
6248
public static void showCompleteDialog(Activity activity) {
6349
root = new ConstraintLayout(activity);
6450
ConstraintLayout parent = activity.findViewById(R.id.root);
@@ -106,6 +92,8 @@ public static void showCompleteDialog(Activity activity) {
10692

10793
ViewUtils.cards.add(mainCard);
10894
ViewUtils.backgrounds.add(background);
95+
96+
completeShowing = true;
10997
}
11098

11199
public static void showProgressDialog(Activity activity, String text) {

app/src/main/java/in/krharsh17/programmersdate/events/AudioActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onCoupleFetched(Couple couple) {
5454
currentlevel = couple.getCurrentLevel();
5555
Level level = couple.getLevels().get(currentlevel-1);
5656
actualTwister = level.getAudioValue();
57-
for(int i=0;i<9;i++){
57+
for (int i = 0; i < 4; i++) {
5858
actualTwister = actualTwister + " " + level.getAudioValue();
5959
}
6060
twister.setText(actualTwister);

app/src/main/java/in/krharsh17/programmersdate/events/LogoActivity.java

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ public void onBackPressed() {
7171
super.onBackPressed();
7272
}
7373

74+
static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches) {
75+
List<DMatch> matches_original = matches.toList();
76+
List<DMatch> matches_filtered = new ArrayList<DMatch>();
77+
78+
int DIST_LIMIT = 30;
79+
// Check all the matches distance and if it passes add to list of filtered matches
80+
Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
81+
for (int i = 0; i < matches_original.size(); i++) {
82+
DMatch d = matches_original.get(i);
83+
if (Math.abs(d.distance) <= DIST_LIMIT) {
84+
matches_filtered.add(d);
85+
}
86+
}
87+
Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");
88+
89+
MatOfDMatch mat = new MatOfDMatch();
90+
mat.fromList(matches_filtered);
91+
return mat;
92+
}
93+
94+
static {
95+
System.loadLibrary("opencv_java3");
96+
}
97+
7498
@Override
7599
protected void onCreate(Bundle savedInstanceState) {
76100
super.onCreate(savedInstanceState);
@@ -104,7 +128,7 @@ public void onPreviewFrame(byte[] data, Camera camera) {
104128
public void onCoupleFetched(Couple couple) {
105129
currentlevel = couple.getCurrentLevel();
106130
coupleId = couple.getId();
107-
level = couple.getLevels().get(currentlevel-1);
131+
level = couple.getLevels().get(currentlevel - 1);
108132
hintText.setText(level.getLevelHint());
109133
String root = Environment.getExternalStorageDirectory().toString();
110134
File myDir = new File(root);
@@ -119,7 +143,7 @@ public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
119143

120144
}
121145
});
122-
ViewUtils.showToast(LogoActivity.this, "Scanning..", ViewUtils.DURATION_SHORT);
146+
// ViewUtils.showToast(LogoActivity.this, "Scanning..", ViewUtils.DURATION_SHORT);
123147
handler = new Handler();
124148
ViewUtils.removeDialog();
125149

@@ -143,12 +167,12 @@ public void onErrorOccured(String message) {
143167
hint.setOnButtonClickListener(new TapHoldUpButton.OnButtonClickListener() {
144168
@Override
145169
public void onLongHoldStart(View v) {
146-
170+
hint.resetLongHold();
147171
}
148172

149173
@Override
150174
public void onLongHoldEnd(View v) {
151-
175+
hint.resetLongHold();
152176
}
153177

154178
@Override
@@ -159,31 +183,7 @@ public void onClick(View v) {
159183

160184
}
161185

162-
static {
163-
System.loadLibrary("opencv_java3");
164-
}
165-
166-
static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
167-
List<DMatch> matches_original = matches.toList();
168-
List<DMatch> matches_filtered = new ArrayList<DMatch>();
169-
170-
int DIST_LIMIT = 30;
171-
// Check all the matches distance and if it passes add to list of filtered matches
172-
Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
173-
for (int i = 0; i < matches_original.size(); i++) {
174-
DMatch d = matches_original.get(i);
175-
if (Math.abs(d.distance) <= DIST_LIMIT) {
176-
matches_filtered.add(d);
177-
}
178-
}
179-
Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");
180-
181-
MatOfDMatch mat = new MatOfDMatch();
182-
mat.fromList(matches_filtered);
183-
return mat;
184-
}
185-
186-
public void startMatching(){
186+
public void startMatching() {
187187
Runnable r = new Runnable() {
188188
public void run() {
189189
while (true) {
@@ -207,15 +207,15 @@ public void run() {
207207

208208
}
209209

210-
public void captureAndMatch(){
211-
mCamera.takePicture(null, null, new Camera.PictureCallback(){
210+
public void captureAndMatch() {
211+
mCamera.takePicture(null, null, new Camera.PictureCallback() {
212212

213213
@Override
214214
public void onPictureTaken(byte[] bytes, Camera camera) {
215215
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
216216
Matrix matrix = new Matrix();
217217
matrix.postRotate(90);
218-
Bitmap bmprotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
218+
Bitmap bmprotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
219219
String root = Environment.getExternalStorageDirectory().toString();
220220
File myDir = new File(root);
221221
myDir.mkdirs();
@@ -238,7 +238,7 @@ public void onPictureTaken(byte[] bytes, Camera camera) {
238238
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
239239
Mat img1 = Imgcodecs.imread(path1);
240240
Mat img2 = Imgcodecs.imread(path2);
241-
if(img1!=null&&img2!=null){
241+
if (img1 != null && img2 != null) {
242242
Log.i("imageaayikya", "aagyi");
243243
}
244244
Mat descriptors1 = new Mat();
@@ -250,22 +250,23 @@ public void onPictureTaken(byte[] bytes, Camera camera) {
250250
detector.detect(img2, keypoints2);
251251
extractor.compute(img2, keypoints2, descriptors2);
252252
MatOfDMatch matches = new MatOfDMatch();
253-
matcher.match(descriptors1,descriptors2,matches);
253+
matcher.match(descriptors1, descriptors2, matches);
254254
MatOfDMatch filtered = filterMatchesByDistance(matches);
255255
int total = (int) matches.size().height;
256-
int Match= (int) filtered.size().height;
257-
Log.i("itnaMatchKiya", "total: " + total + " Match: "+Match);
258-
if(total>totalCheckPoints){
259-
if(Match>upperMatchPoints){
256+
int Match = (int) filtered.size().height;
257+
Log.i("itnaMatchKiya", "total: " + total + " Match: " + Match);
258+
if (total > totalCheckPoints) {
259+
if (Match > upperMatchPoints) {
260260
if (!isSuccess) {
261261
levelSuccess();
262262
}
263263
}
264-
}else{
265-
if(Match>lowerMatchPoints){
264+
} else {
265+
if (Match > lowerMatchPoints) {
266266
if (!isSuccess) {
267267
levelSuccess();
268-
} }
268+
}
269+
}
269270
}
270271
} catch (Exception e) {
271272
e.printStackTrace();
@@ -275,10 +276,10 @@ public void onPictureTaken(byte[] bytes, Camera camera) {
275276
});
276277
}
277278

278-
public void levelSuccess(){
279+
public void levelSuccess() {
279280
isSuccess = true;
280-
couplesRef.child(coupleId).child("currentLevel").setValue(currentlevel+1);
281-
ViewUtils.showToast(this,"Level completed successfully",ViewUtils.DURATION_LONG);
281+
couplesRef.child(coupleId).child("currentLevel").setValue(currentlevel + 1);
282+
ViewUtils.showToast(this, "Level completed successfully", ViewUtils.DURATION_LONG);
282283
onBackPressed();
283284
}
284285

app/src/main/java/in/krharsh17/programmersdate/events/PoseActivity.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@
3434
import in.krharsh17.programmersdate.models.Level;
3535

3636
import static in.krharsh17.programmersdate.Constants.couplesRef;
37-
import static in.krharsh17.programmersdate.Constants.lowerMatchPoints;
3837
import static in.krharsh17.programmersdate.Constants.poseLowerMatchCriteria;
3938
import static in.krharsh17.programmersdate.Constants.poseTotalChecks;
4039
import static in.krharsh17.programmersdate.Constants.poseUpperMatchCriteria;
4140
import static in.krharsh17.programmersdate.Constants.runtime;
42-
import static in.krharsh17.programmersdate.Constants.totalCheckPoints;
43-
import static in.krharsh17.programmersdate.Constants.upperMatchPoints;
4441
import static in.krharsh17.programmersdate.events.LogoActivity.filterMatchesByDistance;
4542

4643
public class PoseActivity extends AppCompatActivity {
@@ -67,6 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
6764
public void onCoupleFetched(Couple couple) {
6865
currentlevel = couple.getCurrentLevel();
6966
coupleId = couple.getId();
67+
Log.i("TAG", "onCoupleFetched: " + currentlevel);
7068
level = couple.getLevels().get(currentlevel-1);
7169
String root = Environment.getExternalStorageDirectory().toString();
7270
File myDir = new File(root);
@@ -90,7 +88,6 @@ public void onErrorOccured(String message) {
9088
.replace(R.id.camera_preview_pose, posenetActivity)
9189
.commit();
9290

93-
9491
handler = new Handler();
9592
handler.postDelayed(new Runnable() {
9693
public void run() {

app/src/main/java/in/krharsh17/programmersdate/events/QRActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ public class QRActivity extends AppCompatActivity {
3939
private BarcodeCallback callback = new BarcodeCallback() {
4040
@Override
4141
public void barcodeResult(BarcodeResult result) {
42+
if (lastText != null && lastText.equals(result.getText()))
43+
return;
4244
lastText = result.getText();
4345

4446
Log.i("resulthere",lastText);
4547
if(lastText.equals(codeValueActual)){
4648
levelSuccess();
49+
} else {
50+
ViewUtils.showToast(QRActivity.this, "Try another code", ViewUtils.DURATION_LONG);
4751
}
4852

4953
beepManager.setVibrateEnabled(true);

app/src/main/java/in/krharsh17/programmersdate/home/LevelsAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public void setUnlocked(ViewHolder viewHolder, Level level) {
9393
} else if (level.getTaskType().equals("LOGO")) {
9494
viewHolder.levelIcon.setImageResource(R.drawable.level_logo_bright);
9595
viewHolder.levelIcon.setBackgroundResource(R.drawable.level_background_bright);
96-
} else if (level.getTaskType().equals("AUDIO")) {
97-
// viewHolder.levelIcon.setImageResource(R.drawable.level_audio);
96+
} else if (level.getTaskType().equals("TWISTER")) {
97+
viewHolder.levelIcon.setImageResource(R.drawable.level_audio_bright);
9898
viewHolder.levelIcon.setBackgroundResource(R.drawable.level_background_bright);
9999
}
100100
}
@@ -113,8 +113,8 @@ public void setCompleted(ViewHolder viewHolder, Level level) {
113113
} else if (level.getTaskType().equals("LOGO")) {
114114
viewHolder.levelIcon.setImageResource(R.drawable.level_logo_dull);
115115
viewHolder.levelIcon.setBackgroundResource(R.drawable.level_background_dull);
116-
} else if (level.getTaskType().equals("AUDIO")) {
117-
viewHolder.levelIcon.setImageResource(R.drawable.cross);
116+
} else if (level.getTaskType().equals("TWISTER")) {
117+
viewHolder.levelIcon.setImageResource(R.drawable.level_audio_dull);
118118
viewHolder.levelIcon.setBackgroundResource(R.drawable.level_background_dull);
119119
}
120120
}

0 commit comments

Comments
 (0)