Skip to content

Commit

Permalink
3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya committed Apr 15, 2021
1 parent abba219 commit 5011804
Show file tree
Hide file tree
Showing 39 changed files with 1,229 additions and 1,163 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ android {

defaultConfig {
applicationId "com.aditya.hopon"
minSdkVersion 29
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode 3
versionName "3.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -35,11 +35,11 @@ dependencies {
implementation "androidx.cursoradapter:cursoradapter:1.0.0"
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.firebase:firebase-database:19.7.0'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.firebase:firebase-auth:20.0.4'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
testImplementation 'junit:junit:4.+'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
17 changes: 11 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aditya.hopon">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -16,14 +14,21 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:fullBackupContent="@xml/backup_descriptor"
android:theme="@style/Theme.HopOn">
<activity android:name=".communityActivity"></activity>
<activity android:name=".patternsActivity" />
<activity android:name=".UserGenActivity" />
<activity
android:name=".communityActivity"
android:parentActivityName=".MainActivity" />
<activity
android:name=".patternsActivity"
android:parentActivityName=".MainActivity" />
<activity
android:name=".UserGenActivity"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
39 changes: 22 additions & 17 deletions app/src/main/java/com/aditya/hopon/Custom_Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,41 @@

public class Custom_Adapter extends SimpleCursorAdapter {

private Context mContext;
private final Context mContext;
private Context appContext;
private int layout;
private Cursor cr;
private final int layout;
private final Cursor cr;
private final LayoutInflater inflater;

public Custom_Adapter(Context context,int layout, Cursor c,String[] from,int[] to,int flags) {
super(context,layout,c,from,to,0);
this.layout=layout;
public Custom_Adapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, 0);
this.layout = layout;
this.mContext = context;
this.inflater=LayoutInflater.from(context);
this.cr=c;
this.inflater = LayoutInflater.from(context);
this.cr = c;
}

@Override
public View newView (Context context, Cursor cursor, ViewGroup parent) {
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(layout, null);
}

@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
TextView patternid=(TextView)view.findViewById(R.id.patternid);
TextView patternsequence=(TextView)view.findViewById(R.id.patternsequence);
TextView patternname=(TextView)view.findViewById(R.id.patternname);
TextView patternmode=(TextView)view.findViewById(R.id.patternmode);
ImageView pattternmodeic=(ImageView)view.findViewById(R.id.patternmodeic);
if(patternmode.getText().toString().equals("1")){pattternmodeic.setImageResource(R.drawable.ic_baseline_videogame_asset_24);}
else {pattternmodeic.setImageResource(R.drawable.ic_baseline_timer_24);}

TextView patternid = view.findViewById(R.id.patternid);
TextView patternsequence = view.findViewById(R.id.patternsequence);
TextView patternname = view.findViewById(R.id.patternname);
TextView patternmode = view.findViewById(R.id.patternmode);
TextView patternmodetxt = view.findViewById(R.id.patternmodetxt);
ImageView pattternmodeic = view.findViewById(R.id.patternmodeic);
if (patternmode.getText().toString().equals("1")) {
pattternmodeic.setImageResource(R.drawable.ic_baseline_videogame_asset_24);
patternmodetxt.setText(R.string.normalmode);
} else {
pattternmodeic.setImageResource(R.drawable.ic_baseline_timer_24);
patternmodetxt.setText(R.string.timedmode);
}
}

}
130 changes: 78 additions & 52 deletions app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.aditya.hopon;

import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

Expand All @@ -17,68 +15,96 @@

import java.util.List;

public class Custom_Community_Adapter extends ArrayAdapter {
private Activity mContext;
List<Patterns> patternsList;
public Custom_Community_Adapter(Activity mContext, List<Patterns> patternsList){
super(mContext,R.layout.pattern_online_layout,patternsList);
this.mContext=mContext;
this.patternsList=patternsList;
public class Custom_Community_Adapter extends ArrayAdapter<Patterns> {
final List<Patterns> patternsList;
private final Activity mContext;

public Custom_Community_Adapter(Activity mContext, List<Patterns> patternsList) {
super(mContext, R.layout.pattern_online_layout, patternsList);
this.mContext = mContext;
this.patternsList = patternsList;
}

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater=mContext.getLayoutInflater();
View listitemView=inflater.inflate(R.layout.pattern_online_layout,null,true);
Patterns pattern=patternsList.get(position);
TextView pattername=(TextView)listitemView.findViewById(R.id.patternname);
TextView authornametxt= (TextView) listitemView.findViewById(R.id.authornametxt);;
TextView idTextView = (TextView) listitemView.findViewById(R.id.patternid);
TextView sequenceTextView = (TextView) listitemView.findViewById(R.id.patternsequence);
ImageView patternmodeic=(ImageView)listitemView.findViewById(R.id.patternmodeic);
TextView patternmode = (TextView) listitemView.findViewById(R.id.patternmode);
TextView patternuid=(TextView)listitemView.findViewById(R.id.patternuid);
TextView patternpid=(TextView)listitemView.findViewById(R.id.patternpid);
LayoutInflater inflater = mContext.getLayoutInflater();
View listitemView = inflater.inflate(R.layout.pattern_online_layout, null, true);
Patterns pattern = patternsList.get(position);
TextView pattername = listitemView.findViewById(R.id.patternname);
TextView authornametxt = listitemView.findViewById(R.id.authornametxt);
TextView idTextView = listitemView.findViewById(R.id.patternid);
TextView sequenceTextView = listitemView.findViewById(R.id.patternsequence);
ImageView patternmodeic = listitemView.findViewById(R.id.patternmodeic);
TextView patternmode = listitemView.findViewById(R.id.patternmode);
TextView patternuid = listitemView.findViewById(R.id.patternuid);
TextView patternpid = listitemView.findViewById(R.id.patternpid);
pattername.setText(pattern.getName());
patternuid.setText(pattern.getUid());
patternpid.setText(pattern.getPid());
idTextView.setText(""+(position+1));
if(pattern.getMode()==1){patternmode.setText("Normal mode");patternmodeic.setImageResource(R.drawable.ic_baseline_videogame_asset_24);}
else{
patternmode.setText("Timed mode");patternmodeic.setImageResource(R.drawable.ic_baseline_timer_24);
idTextView.setText(String.valueOf(position + 1));
if (pattern.getMode() == 1) {
patternmode.setText(R.string.normalmode);
patternmodeic.setImageResource(R.drawable.ic_baseline_videogame_asset_24);
} else {
patternmode.setText(R.string.timedmode);
patternmodeic.setImageResource(R.drawable.ic_baseline_timer_24);
}
authornametxt.setText(pattern.getAuthor());
sequenceTextView.setText(pattern.getSequence());
String sequence=pattern.getSequence();
ImageView img1=(ImageView)listitemView.findViewById(R.id.pattgrid1);
ImageView img2=(ImageView)listitemView.findViewById(R.id.pattgrid2);
ImageView img3=(ImageView)listitemView.findViewById(R.id.pattgrid3);
ImageView img4=(ImageView)listitemView.findViewById(R.id.pattgrid4);
ImageView img5=(ImageView)listitemView.findViewById(R.id.pattgrid5);
ImageView img6=(ImageView)listitemView.findViewById(R.id.pattgrid6);
ImageView img7=(ImageView)listitemView.findViewById(R.id.pattgrid7);
ImageView img8=(ImageView)listitemView.findViewById(R.id.pattgrid8);
ImageView img9=(ImageView)listitemView.findViewById(R.id.pattgrid9);
ImageView imgA=(ImageView)listitemView.findViewById(R.id.pattgridA);
ImageView imgB=(ImageView)listitemView.findViewById(R.id.pattgridB);
ImageView imgC=(ImageView)listitemView.findViewById(R.id.pattgridC);
for(int i=0;i<sequence.length();i++){
if(sequence.charAt(i)=='1'){
String sequence = pattern.getSequence();
ImageView img1 = listitemView.findViewById(R.id.pattgrid1);
ImageView img2 = listitemView.findViewById(R.id.pattgrid2);
ImageView img3 = listitemView.findViewById(R.id.pattgrid3);
ImageView img4 = listitemView.findViewById(R.id.pattgrid4);
ImageView img5 = listitemView.findViewById(R.id.pattgrid5);
ImageView img6 = listitemView.findViewById(R.id.pattgrid6);
ImageView img7 = listitemView.findViewById(R.id.pattgrid7);
ImageView img8 = listitemView.findViewById(R.id.pattgrid8);
ImageView img9 = listitemView.findViewById(R.id.pattgrid9);
ImageView imgA = listitemView.findViewById(R.id.pattgridA);
ImageView imgB = listitemView.findViewById(R.id.pattgridB);
ImageView imgC = listitemView.findViewById(R.id.pattgridC);
for (int i = 0; i < sequence.length(); i++) {
if (sequence.charAt(i) == '1') {
i++;
switch(sequence.charAt(i)){
case '1':img1.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '2':img2.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '3':img3.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '4':img4.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '5':img5.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '6':img6.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '7':img7.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '8':img8.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case '9':img9.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case 'A':imgA.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case 'B':imgB.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
case 'C':imgC.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));break;
switch (sequence.charAt(i)) {
case '1':
img1.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '2':
img2.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '3':
img3.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '4':
img4.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '5':
img5.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '6':
img6.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '7':
img7.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '8':
img8.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case '9':
img9.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case 'A':
imgA.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case 'B':
imgB.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
case 'C':
imgC.setImageTintList(ColorStateList.valueOf(Color.parseColor("#FF5252")));
break;
}
}
else{
Expand Down
18 changes: 11 additions & 7 deletions app/src/main/java/com/aditya/hopon/DBManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DBManager {

private DatabaseHelper dbHelper;

private Context context;
private final Context context;

private SQLiteDatabase database;

Expand All @@ -37,21 +37,25 @@ public void insert(String name, String sequence,int mode) {
}

public Cursor fetch() {
String[] columns = new String[] { DatabaseHelper._ID, DatabaseHelper.NAME, DatabaseHelper.SEQUENCE,DatabaseHelper.MODE };
String[] columns = new String[]{DatabaseHelper._ID, DatabaseHelper.NAME, DatabaseHelper.SEQUENCE, DatabaseHelper.MODE};
Cursor cursor = database.query(DatabaseHelper.TABLE_NAME, columns, null, null, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
}

public int update(long _id, String name, String desc,int mode) {
public Cursor search(String name) {
String[] columns = new String[]{DatabaseHelper._ID, DatabaseHelper.NAME, DatabaseHelper.SEQUENCE, DatabaseHelper.MODE};
return database.rawQuery("SELECT * from Patterns where name like '" + name + "%';", null);
}

public int update(long _id, String name, String sequence, int mode) {
ContentValues contentValues = new ContentValues();
contentValues.put(DatabaseHelper.NAME, name);
contentValues.put(DatabaseHelper.SEQUENCE, desc);
contentValues.put(DatabaseHelper.MODE,mode);
int i = database.update(DatabaseHelper.TABLE_NAME, contentValues, DatabaseHelper._ID + " = " + _id, null);
return i;
contentValues.put(DatabaseHelper.SEQUENCE, sequence);
contentValues.put(DatabaseHelper.MODE, mode);
return database.update(DatabaseHelper.TABLE_NAME, contentValues, DatabaseHelper._ID + " = " + _id, null);
}

public void delete(long _id) {
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/java/com/aditya/hopon/DeleteConfirmationDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;

import androidx.annotation.NonNull;
Expand All @@ -16,18 +15,10 @@ public class DeleteConfirmationDialog extends AppCompatDialogFragment {
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
builder.setTitle("Delete Pattern").setMessage("Are you sure you want to Delete it?").setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
builder.setTitle("Delete Pattern").setMessage("Are you sure you want to Delete it?").setNegativeButton("Cancel", (dialogInterface, i) -> {

}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
listener.onYesClicked();
}
});
.setPositiveButton("Yes", (dialogInterface, i) -> listener.onYesClicked());
return builder.create();
}
public interface DeleteConfirmationDialogListener {
Expand Down
Loading

0 comments on commit 5011804

Please sign in to comment.