Skip to content

Commit

Permalink
3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya committed Apr 4, 2021
1 parent 854a64e commit abba219
Show file tree
Hide file tree
Showing 17 changed files with 742 additions and 53 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
Expand Down Expand Up @@ -35,6 +36,9 @@ dependencies {
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.firebase:firebase-database:19.7.0'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
<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"/>
<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" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HopOn">
<activity android:name=".patternsActivity"></activity>
<activity android:name=".communityActivity"></activity>
<activity android:name=".patternsActivity" />
<activity android:name=".UserGenActivity" />
<activity android:name=".MainActivity">
<intent-filter>
Expand Down
119 changes: 119 additions & 0 deletions app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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;
}

@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);
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);
}
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'){
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;
}
}
else{
i++;
switch(sequence.charAt(i)){
case '1':img1.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '2':img2.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '3':img3.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '4':img4.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '5':img5.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '6':img6.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '7':img7.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '8':img8.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '9':img9.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'A':imgA.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'B':imgB.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'C':imgC.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
}
i+=2;
switch(sequence.charAt(i)){
case '1':img1.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '2':img2.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '3':img3.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '4':img4.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '5':img5.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '6':img6.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '7':img7.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '8':img8.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case '9':img9.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'A':imgA.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'B':imgB.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
case 'C':imgC.setImageTintList(ColorStateList.valueOf(Color.parseColor("#536DFE")));break;
}
}
}
return listitemView;
}
}
31 changes: 23 additions & 8 deletions app/src/main/java/com/aditya/hopon/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.graphics.Color;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
Expand All @@ -18,30 +17,26 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.DialogTitle;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;

import com.google.android.gms.location.LocationRequest;

public class MainActivity extends AppCompatActivity {
public static final String SHARED_PREFS="sharedPrefs";
private boolean darkmodetoggle;
private int noofpatternscreated;
private DBManager dbManager;
private LinearLayout patternmainlayout;
private String ssid = null;
final String FineLocation = Manifest.permission.ACCESS_FINE_LOCATION;
private CardView custompatterncard,wificonnectioncard;
private CardView custompatterncard,wificonnectioncard,communitycard;
private ImageView wificonnectionic;
private TextView connectionstatustxt,noofpatternscreatedtxt;
@Override
Expand All @@ -59,11 +54,24 @@ protected void onCreate(Bundle savedInstanceState) {
{
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 123);
}
dbManager = new DBManager(this);
dbManager.open();
SharedPreferences sharedPreferences=getSharedPreferences("sharedPrefs",MODE_PRIVATE);
boolean firstStart=sharedPreferences.getBoolean("firstStart",true);
if(firstStart){
dbManager.insert("Regular","122426182A2C",1);
dbManager.insert("Single Jumps","1214181C",2);
dbManager.insert("Multiplex","212315172A2C",1);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putBoolean("firstStart",false);
editor.apply();
}
Toolbar toolbar=findViewById(R.id.main_toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
patternmainlayout=findViewById(R.id.pattern_main_layout);
custompatterncard=findViewById(R.id.custompatterncard);
communitycard=findViewById(R.id.communitycard);
wificonnectioncard=findViewById(R.id.wificonnectioncard);
wificonnectionic=findViewById(R.id.wificonnectionic);
connectionstatustxt=findViewById(R.id.connectionstatustxt);
Expand All @@ -75,6 +83,13 @@ public void onClick(View view) {
startActivity(intent);
}
});
communitycard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this, communityActivity.class);
startActivity(intent);
}
});
custompatterncard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -162,7 +177,7 @@ public void saveData(){
public void loadData(){
SharedPreferences sharedPreferences=getSharedPreferences(SHARED_PREFS,MODE_PRIVATE);
darkmodetoggle=sharedPreferences.getBoolean("enabledarkmode",false);
noofpatternscreated=sharedPreferences.getInt("noofpatternscreated",2);
noofpatternscreated=sharedPreferences.getInt("noofpatternscreated",3);
}
public void loctionstatusCheck() {
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/aditya/hopon/Patterns.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.aditya.hopon;

public class Patterns {
int mode;
String name;
String sequence;
String author;
String uid;
String pid;
public Patterns(){}
public Patterns(int mode, String name, String sequence, String author,String uid,String pid) {
this.mode = mode;
this.name = name;
this.sequence = sequence;
this.author = author;
this.uid=uid;
this.pid=pid;
}

public String getUid(){return uid;}

public String getPid(){return pid;}

public int getMode() {
return mode;
}

public String getName() {
return name;
}

public String getSequence() {
return sequence;
}

public String getAuthor() {
return author;
}
}
Loading

0 comments on commit abba219

Please sign in to comment.