From 5011804c6e17550d88a2b913b7a8bf6e626aa986 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 15 Apr 2021 08:00:26 +0530 Subject: [PATCH] 3.1 --- app/build.gradle | 12 +- app/src/main/AndroidManifest.xml | 17 +- .../java/com/aditya/hopon/Custom_Adapter.java | 39 +- .../hopon/Custom_Community_Adapter.java | 130 ++-- .../main/java/com/aditya/hopon/DBManager.java | 18 +- .../hopon/DeleteConfirmationDialog.java | 13 +- .../java/com/aditya/hopon/MainActivity.java | 249 ++++---- .../com/aditya/hopon/UserGenActivity.java | 572 ++++++++---------- .../com/aditya/hopon/communityActivity.java | 275 +++++---- .../com/aditya/hopon/patternsActivity.java | 364 ++++++----- .../{drawable => drawable-nodpi}/grid_1.png | Bin .../{drawable => drawable-nodpi}/grid_2.png | Bin .../{drawable => drawable-nodpi}/grid_3.png | Bin .../{drawable => drawable-nodpi}/trophy.png | Bin .../res/{drawable => drawable-nodpi}/wifi.png | Bin .../drawable-v24/ic_launcher_foreground.xml | 30 - .../drawable/ic_baseline_cloud_upload_24.xml | 6 - .../res/drawable/ic_baseline_create_24.xml | 10 - .../drawable/ic_baseline_play_arrow_24.xml | 8 +- .../res/drawable/ic_baseline_search_24.xml | 10 + .../ic_baseline_system_update_alt_24.xml | 10 - .../res/drawable/ic_launcher_background.xml | 170 ------ app/src/main/res/drawable/stopwatch.png | Bin 4986 -> 0 bytes app/src/main/res/drawable/user.png | Bin 1739 -> 0 bytes app/src/main/res/layout/activity_main.xml | 151 +++-- app/src/main/res/layout/activity_pattern.xml | 12 +- app/src/main/res/layout/activity_user_gen.xml | 62 +- .../main/res/layout/pattern_online_layout.xml | 71 ++- .../main/res/layout/pattern_view_layout.xml | 48 +- app/src/main/res/layout/toolbar.xml | 7 +- app/src/main/res/menu/my_menu.xml | 5 +- app/src/main/res/menu/patterns_menu.xml | 11 + app/src/main/res/values-hi-rIN/strings.xml | 33 + app/src/main/res/values-night/strings.xml | 1 - app/src/main/res/values-night/themes.xml | 2 + app/src/main/res/values/colors.xml | 4 +- app/src/main/res/values/strings.xml | 39 +- app/src/main/res/values/themes.xml | 3 +- app/src/main/res/xml/backup_descriptor.xml | 10 + 39 files changed, 1229 insertions(+), 1163 deletions(-) rename app/src/main/res/{drawable => drawable-nodpi}/grid_1.png (100%) rename app/src/main/res/{drawable => drawable-nodpi}/grid_2.png (100%) rename app/src/main/res/{drawable => drawable-nodpi}/grid_3.png (100%) rename app/src/main/res/{drawable => drawable-nodpi}/trophy.png (100%) rename app/src/main/res/{drawable => drawable-nodpi}/wifi.png (100%) delete mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_create_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_search_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_system_update_alt_24.xml delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 app/src/main/res/drawable/stopwatch.png delete mode 100644 app/src/main/res/drawable/user.png create mode 100644 app/src/main/res/menu/patterns_menu.xml create mode 100644 app/src/main/res/values-hi-rIN/strings.xml create mode 100644 app/src/main/res/xml/backup_descriptor.xml diff --git a/app/build.gradle b/app/build.gradle index 5682c97..2dc78d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" } @@ -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' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d3d044d..6f738ca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,6 @@ - - @@ -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"> - - - + + + - diff --git a/app/src/main/java/com/aditya/hopon/Custom_Adapter.java b/app/src/main/java/com/aditya/hopon/Custom_Adapter.java index c9c0546..a937860 100644 --- a/app/src/main/java/com/aditya/hopon/Custom_Adapter.java +++ b/app/src/main/java/com/aditya/hopon/Custom_Adapter.java @@ -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); + } } } diff --git a/app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java b/app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java index 91e5a4d..f60953e 100644 --- a/app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java +++ b/app/src/main/java/com/aditya/hopon/Custom_Community_Adapter.java @@ -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; @@ -17,68 +15,96 @@ import java.util.List; -public class Custom_Community_Adapter extends ArrayAdapter { - private Activity mContext; - List patternsList; - public Custom_Community_Adapter(Activity mContext, List patternsList){ - super(mContext,R.layout.pattern_online_layout,patternsList); - this.mContext=mContext; - this.patternsList=patternsList; +public class Custom_Community_Adapter extends ArrayAdapter { + final List patternsList; + private final Activity mContext; + + public Custom_Community_Adapter(Activity mContext, List 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 { - } }) - .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 { diff --git a/app/src/main/java/com/aditya/hopon/MainActivity.java b/app/src/main/java/com/aditya/hopon/MainActivity.java index 4a13bcd..7249055 100644 --- a/app/src/main/java/com/aditya/hopon/MainActivity.java +++ b/app/src/main/java/com/aditya/hopon/MainActivity.java @@ -1,14 +1,13 @@ package com.aditya.hopon; import android.Manifest; +import android.app.Activity; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; +import android.content.IntentSender; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Color; -import android.location.LocationManager; -import android.net.ConnectivityManager; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; @@ -16,98 +15,95 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.widget.Toolbar; import androidx.cardview.widget.CardView; +import com.google.android.gms.common.api.ApiException; +import com.google.android.gms.common.api.ResolvableApiException; +import com.google.android.gms.location.LocationRequest; +import com.google.android.gms.location.LocationServices; +import com.google.android.gms.location.LocationSettingsRequest; +import com.google.android.gms.location.LocationSettingsResponse; +import com.google.android.gms.location.LocationSettingsStatusCodes; +import com.google.android.gms.tasks.Task; + public class MainActivity extends AppCompatActivity { - public static final String SHARED_PREFS="sharedPrefs"; + 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,communitycard; private ImageView wificonnectionic; - private TextView connectionstatustxt,noofpatternscreatedtxt; + private TextView connectionstatustxt; + private TextView noofpatternscreatedtxt; + private TextView connectiondesctxt; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); loadData(); - if(darkmodetoggle) { + if (darkmodetoggle) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); - } - else{ + } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); } - if (checkSelfPermission(FineLocation) != PackageManager.PERMISSION_GRANTED) - { + if (checkSelfPermission(FineLocation) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 123); } - dbManager = new DBManager(this); + DBManager 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); + 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 toolbar = findViewById(R.id.toolbar); + TextView toolbartitle = findViewById(R.id.toolbar_title); + toolbartitle.setText(R.string.app_name); 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); - noofpatternscreatedtxt=findViewById(R.id.noofpatternscreatedtxt); - patternmainlayout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent=new Intent(MainActivity.this,patternsActivity.class); - startActivity(intent); - } + LinearLayout patternmainlayout = findViewById(R.id.pattern_main_layout); + CardView custompatterncard = findViewById(R.id.custompatterncard); + CardView communitycard = findViewById(R.id.communitycard); + CardView wificonnectioncard = findViewById(R.id.wificonnectioncard); + wificonnectionic = findViewById(R.id.wificonnectionic); + connectionstatustxt = findViewById(R.id.connectionstatustxt); + connectiondesctxt = findViewById(R.id.wificonnectiondesctext); + noofpatternscreatedtxt = findViewById(R.id.noofpatternscreatedtxt); + patternmainlayout.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, patternsActivity.class); + startActivity(intent); }); - communitycard.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent=new Intent(MainActivity.this, communityActivity.class); - startActivity(intent); - } + communitycard.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, communityActivity.class); + startActivity(intent); }); - custompatterncard.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent=new Intent(MainActivity.this,UserGenActivity.class); - startActivity(intent); - } + custompatterncard.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, UserGenActivity.class); + startActivity(intent); }); - wificonnectioncard.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { + wificonnectioncard.setOnClickListener(view -> { + if (connectionstatustxt.getText().toString().equals("Disconnected")) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Connect to The HopOn board").setIcon(R.drawable.ic_baseline_wifi_24).setMessage("Select the Hopon SSID and enter the password provided in the instruction manual in the next screen"); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); - startActivity(intent); - } + builder.setPositiveButton("OK", (dialogInterface, i) -> { + Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); + startActivity(intent); }); builder.show(); } @@ -118,23 +114,9 @@ public void onClick(DialogInterface dialogInterface, int i) { protected void onStart() { super.onStart(); loadData(); - ConnectivityManager connManager = (ConnectivityManager) getBaseContext().getSystemService(Context.CONNECTIVITY_SERVICE); - final WifiManager wifiManager = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); - final WifiInfo connectionInfo = wifiManager.getConnectionInfo(); - if (connectionInfo != null) { - ssid = connectionInfo.getSSID(); - ssid = ssid.substring(1, ssid.length() - 1); - } - //Toast.makeText(MainActivity.this,ssid,Toast.LENGTH_LONG).show(); - if (ssid.equals("Hopon")) { - wificonnectionic.clearColorFilter(); - connectionstatustxt.setText("Connected"); - } else { - wificonnectionic.setColorFilter(Color.RED); - connectionstatustxt.setText("Disconnected"); - } noofpatternscreatedtxt.setText(String.valueOf(noofpatternscreated)); - loctionstatusCheck(); + wifistatuscheck(); + locationstatusCheck(); } @Override @@ -149,55 +131,90 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()){ - case R.id.enable_dark_mode_button: - if(item.isChecked()){ - item.setChecked(false); - darkmodetoggle=false; - saveData(); - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); - } - else{ - item.setChecked(true); - darkmodetoggle=true; - saveData(); - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); - } - return true; - default:return super.onOptionsItemSelected(item); + if (item.getItemId() == R.id.enable_dark_mode_button) { + if (item.isChecked()) { + item.setChecked(false); + darkmodetoggle = false; + saveData(); + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + } else { + item.setChecked(true); + darkmodetoggle = true; + saveData(); + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + } + return true; } + return super.onOptionsItemSelected(item); } - public void saveData(){ - SharedPreferences sharedPreferences=getSharedPreferences(SHARED_PREFS,MODE_PRIVATE); - SharedPreferences.Editor editor=sharedPreferences.edit(); - editor.putBoolean("enabledarkmode",darkmodetoggle); - editor.putInt("noofpatternscreated",noofpatternscreated); + + public void saveData() { + SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putBoolean("enabledarkmode", darkmodetoggle); + editor.putInt("noofpatternscreated", noofpatternscreated); editor.apply(); } - public void loadData(){ - SharedPreferences sharedPreferences=getSharedPreferences(SHARED_PREFS,MODE_PRIVATE); - darkmodetoggle=sharedPreferences.getBoolean("enabledarkmode",false); - noofpatternscreated=sharedPreferences.getInt("noofpatternscreated",3); + + public void loadData() { + SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE); + darkmodetoggle = sharedPreferences.getBoolean("enabledarkmode", false); + noofpatternscreated = sharedPreferences.getInt("noofpatternscreated", 3); } - public void loctionstatusCheck() { - final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); - if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("Location seems to be disabled,It is needed for connection to the Hopon board") - .setCancelable(false) - .setPositiveButton("Enable", new DialogInterface.OnClickListener() { - public void onClick(final DialogInterface dialog, final int id) { - startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); - } - }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - public void onClick(final DialogInterface dialog, final int id) { - dialog.cancel(); + + public void locationstatusCheck() { + LocationRequest mLocationRequest = LocationRequest.create().setPriority(LocationRequest.PRIORITY_LOW_POWER); + LocationSettingsRequest.Builder settingsBuilder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest); + settingsBuilder.setAlwaysShow(true); + Task result = LocationServices.getSettingsClient(this).checkLocationSettings(settingsBuilder.build()); + result.addOnCompleteListener(task -> { + try { + LocationSettingsResponse response = task.getResult(ApiException.class); + } catch (ApiException ex) { + switch (ex.getStatusCode()) { + case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: + try { + ResolvableApiException resolvableApiException = (ResolvableApiException) ex; + resolvableApiException.startResolutionForResult(MainActivity.this, 199); + } catch (IntentSender.SendIntentException ignored) { } - }); - final AlertDialog alert = builder.create(); - alert.show(); + break; + case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: + break; + } + } + }); + } + + public void wifistatuscheck() { + final WifiManager wifiManager = (WifiManager) getBaseContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE); + final WifiInfo connectionInfo = wifiManager.getConnectionInfo(); + if (connectionInfo != null) { + ssid = connectionInfo.getSSID(); + ssid = ssid.substring(1, ssid.length() - 1); + } + if (ssid.equals("Aditya")) { + wificonnectionic.clearColorFilter(); + connectionstatustxt.setText(R.string.connected); + connectiondesctxt.setText(R.string.wifi_network); + } else { + wificonnectionic.setColorFilter(Color.parseColor("#FF5252")); + connectionstatustxt.setText(R.string.disconnected); + connectiondesctxt.setText(R.string.tap_to_connect); } } + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + if (requestCode == 199) {// Check for the integer request code originally supplied to startResolutionForResult(). + switch (resultCode) { + case Activity.RESULT_OK: + wifistatuscheck(); + break; + case Activity.RESULT_CANCELED: + break; + } + } + super.onActivityResult(requestCode, resultCode, data); + } } \ No newline at end of file diff --git a/app/src/main/java/com/aditya/hopon/UserGenActivity.java b/app/src/main/java/com/aditya/hopon/UserGenActivity.java index 230030b..a8b9f23 100644 --- a/app/src/main/java/com/aditya/hopon/UserGenActivity.java +++ b/app/src/main/java/com/aditya/hopon/UserGenActivity.java @@ -1,69 +1,72 @@ package com.aditya.hopon; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; +import android.content.res.Resources; import android.graphics.Color; import android.os.Bundle; -import android.provider.Settings; import android.text.Editable; import android.text.TextWatcher; +import android.util.TypedValue; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.CheckedTextView; import android.widget.EditText; import android.widget.Spinner; -import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.ValueEventListener; -public class UserGenActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener{ +public class UserGenActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { private EditText nameinput; - private int gamemodechoice,noofpatternscreated; + private int gamemodechoice, noofpatternscreated; private DBManager dbManager; private DatabaseReference databaseReference; private FirebaseAuth firebaseAuth; - private String sequence="",name=""; - private Button btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btnA,btnB,btnC,submit; - private int s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0,s8=0,s9=0,sA=0,sB=0,sC=0,twotileno=0; + private String sequence = "", name = ""; + private Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btnA, btnB, btnC; + private CheckedTextView uploadcommmunitycheck; + private int s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0, s6 = 0, s7 = 0, s8 = 0, s9 = 0, sA = 0, sB = 0, sC = 0, twotileno = 0; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_gen); - Toolbar toolbar = findViewById(R.id.usergentoolbar); + Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle("Create Pattern"); - TextView toolbartitle = findViewById(R.id.toolbar_title); - toolbartitle.setText(""); setSupportActionBar(toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - nameinput=findViewById(R.id.nameinputtxt); - submit=findViewById(R.id.submitpatternbtn); - Spinner spinner=findViewById(R.id.gamemodespinner); - ArrayAdapter adapter=ArrayAdapter.createFromResource(this,R.array.gamemodes, android.R.layout.simple_spinner_item); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + nameinput = findViewById(R.id.nameinputtxt); + Button submit = findViewById(R.id.submitpatternbtn); + Spinner spinner = findViewById(R.id.gamemodespinner); + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.gamemodes, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); dbManager = new DBManager(this); dbManager.open(); - SharedPreferences sharedPreferences=getSharedPreferences("sharedPrefs",MODE_PRIVATE); - noofpatternscreated=sharedPreferences.getInt("noofpatternscreated",3); - databaseReference= FirebaseDatabase.getInstance().getReference().child("Patterns"); + SharedPreferences sharedPreferences = getSharedPreferences("sharedPrefs", MODE_PRIVATE); + noofpatternscreated = sharedPreferences.getInt("noofpatternscreated", 3); + databaseReference = FirebaseDatabase.getInstance().getReference().child("Patterns"); + TypedValue typedValue = new TypedValue(); + Resources.Theme theme = UserGenActivity.this.getTheme(); + theme.resolveAttribute(R.attr.colorOnSecondary, typedValue, true); + @ColorInt int color = typedValue.data; + uploadcommmunitycheck = findViewById(R.id.uploadcommunitycheck); + uploadcommmunitycheck.setOnClickListener(view -> uploadcommmunitycheck.setChecked(!uploadcommmunitycheck.isChecked())); nameinput.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { @@ -71,328 +74,269 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - name=nameinput.getText().toString().trim(); + name = nameinput.getText().toString().trim(); } @Override public void afterTextChanged(Editable editable) { } }); - btn1=findViewById(R.id.usergenbtn1); - btn1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s1==0){ - sequence+="11"; - btn1.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s1++; - } - else if(s1==1){ - sequence=sequence.replaceFirst("11","21"); - btn1.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s1++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("21",""); - btn1.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s1=0;twotileno--; - } + btn1 = findViewById(R.id.usergenbtn1); + btn1.setOnClickListener(view -> { + if (s1 == 0) { + sequence += "11"; + btn1.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s1++; + } else if (s1 == 1) { + sequence = sequence.replaceFirst("11", "21"); + btn1.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s1++; + twotileno++; + } else { + sequence = sequence.replaceFirst("21", ""); + btn1.setBackgroundTintList(ColorStateList.valueOf(color)); + s1 = 0; + twotileno--; } }); - btn2=findViewById(R.id.usergenbtn2); - btn2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s2==0){ - sequence+="12"; - btn2.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s2++; - } - else if(s2==1){ - sequence=sequence.replaceFirst("12","22"); - btn2.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s2++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("22",""); - btn2.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s2=0;twotileno--; - } + btn2 = findViewById(R.id.usergenbtn2); + btn2.setOnClickListener(view -> { + if (s2 == 0) { + sequence += "12"; + btn2.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s2++; + } else if (s2 == 1) { + sequence = sequence.replaceFirst("12", "22"); + btn2.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s2++; + twotileno++; + } else { + sequence = sequence.replaceFirst("22", ""); + btn2.setBackgroundTintList(ColorStateList.valueOf(color)); + s2 = 0; + twotileno--; } }); - btn3=findViewById(R.id.usergenbtn3); - btn3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s3==0){ - sequence+="13"; - btn3.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s3++; - } - else if(s3==1){ - sequence=sequence.replaceFirst("13","23"); - btn3.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s3++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("23",""); - btn3.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s3=0;twotileno--; - } + btn3 = findViewById(R.id.usergenbtn3); + btn3.setOnClickListener(view -> { + if (s3 == 0) { + sequence += "13"; + btn3.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s3++; + } else if (s3 == 1) { + sequence = sequence.replaceFirst("13", "23"); + btn3.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s3++; + twotileno++; + } else { + sequence = sequence.replaceFirst("23", ""); + btn3.setBackgroundTintList(ColorStateList.valueOf(color)); + s3 = 0; + twotileno--; } }); - btn4=findViewById(R.id.usergenbtn4); - btn4.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s4==0){ - sequence+="14"; - btn4.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s4++; - } - else if(s4==1){ - sequence=sequence.replaceFirst("14","24"); - btn4.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s4++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("24",""); - btn4.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s4=0;twotileno--; - } + btn4 = findViewById(R.id.usergenbtn4); + btn4.setOnClickListener(view -> { + if (s4 == 0) { + sequence += "14"; + btn4.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s4++; + } else if (s4 == 1) { + sequence = sequence.replaceFirst("14", "24"); + btn4.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s4++; + twotileno++; + } else { + sequence = sequence.replaceFirst("24", ""); + btn4.setBackgroundTintList(ColorStateList.valueOf(color)); + s4 = 0; + twotileno--; } }); - btn5=findViewById(R.id.usergenbtn5); - btn5.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s5==0){ - sequence+="15"; - btn5.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s5++; - } - else if(s5==1){ - sequence=sequence.replaceFirst("15","25"); - btn5.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s5++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("25",""); - btn5.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s5=0;twotileno--; - } + btn5 = findViewById(R.id.usergenbtn5); + btn5.setOnClickListener(view -> { + if (s5 == 0) { + sequence += "15"; + btn5.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s5++; + } else if (s5 == 1) { + sequence = sequence.replaceFirst("15", "25"); + btn5.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s5++; + twotileno++; + } else { + sequence = sequence.replaceFirst("25", ""); + btn5.setBackgroundTintList(ColorStateList.valueOf(color)); + s5 = 0; + twotileno--; } }); - btn6=findViewById(R.id.usergenbtn6); - btn6.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s6==0){ - sequence+="16"; - btn6.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s6++; - } - else if(s6==1){ - sequence=sequence.replaceFirst("16","26"); - btn6.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s6++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("26",""); - btn6.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s6=0;twotileno--; - } + btn6 = findViewById(R.id.usergenbtn6); + btn6.setOnClickListener(view -> { + if (s6 == 0) { + sequence += "16"; + btn6.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s6++; + } else if (s6 == 1) { + sequence = sequence.replaceFirst("16", "26"); + btn6.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s6++; + twotileno++; + } else { + sequence = sequence.replaceFirst("26", ""); + btn6.setBackgroundTintList(ColorStateList.valueOf(color)); + s6 = 0; + twotileno--; } }); - btn7=findViewById(R.id.usergenbtn7); - btn7.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s7==0){ - sequence+="17"; - btn7.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s7++; - } - else if(s7==1){ - sequence=sequence.replaceFirst("17","27"); - btn7.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s7++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("27",""); - btn7.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s7=0;twotileno--; - } + btn7 = findViewById(R.id.usergenbtn7); + btn7.setOnClickListener(view -> { + if (s7 == 0) { + sequence += "17"; + btn7.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s7++; + } else if (s7 == 1) { + sequence = sequence.replaceFirst("17", "27"); + btn7.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s7++; + twotileno++; + } else { + sequence = sequence.replaceFirst("27", ""); + btn7.setBackgroundTintList(ColorStateList.valueOf(color)); + s7 = 0; + twotileno--; } }); - btn8=findViewById(R.id.usergenbtn8); - btn8.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s8==0){ - sequence+="18"; - btn8.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s8++; - } - else if(s8==1){ - sequence=sequence.replaceFirst("18","28"); - btn8.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s8++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("28",""); - btn8.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s8=0;twotileno--; - } + btn8 = findViewById(R.id.usergenbtn8); + btn8.setOnClickListener(view -> { + if (s8 == 0) { + sequence += "18"; + btn8.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s8++; + } else if (s8 == 1) { + sequence = sequence.replaceFirst("18", "28"); + btn8.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s8++; + twotileno++; + } else { + sequence = sequence.replaceFirst("28", ""); + btn8.setBackgroundTintList(ColorStateList.valueOf(color)); + s8 = 0; + twotileno--; } }); - btn9=findViewById(R.id.usergenbtn9); - btn9.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(s9==0){ - sequence+="19"; - btn9.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - s9++; - } - else if(s9==1){ - sequence=sequence.replaceFirst("19","29"); - btn9.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - s9++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("29",""); - btn9.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - s9=0;twotileno--; - } + btn9 = findViewById(R.id.usergenbtn9); + btn9.setOnClickListener(view -> { + if (s9 == 0) { + sequence += "19"; + btn9.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + s9++; + } else if (s9 == 1) { + sequence = sequence.replaceFirst("19", "29"); + btn9.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + s9++; + twotileno++; + } else { + sequence = sequence.replaceFirst("29", ""); + btn9.setBackgroundTintList(ColorStateList.valueOf(color)); + s9 = 0; + twotileno--; } }); - btnA=findViewById(R.id.usergenbtnA); - btnA.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(sA==0){ - sequence+="1A"; - btnA.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - sA++; - } - else if(sA==1){ - sequence=sequence.replaceFirst("1A","2A"); - btnA.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - sA++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("2A",""); - btnA.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - sA=0;twotileno--; - } + btnA = findViewById(R.id.usergenbtnA); + btnA.setOnClickListener(view -> { + if (sA == 0) { + sequence += "1A"; + btnA.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + sA++; + } else if (sA == 1) { + sequence = sequence.replaceFirst("1A", "2A"); + btnA.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + sA++; + twotileno++; + } else { + sequence = sequence.replaceFirst("2A", ""); + btnA.setBackgroundTintList(ColorStateList.valueOf(color)); + sA = 0; + twotileno--; } }); - btnB=findViewById(R.id.usergenbtnB); - btnB.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(sB==0){ - sequence+="1B"; - btnB.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - sB++; - } - else if(sB==1){ - sequence=sequence.replaceFirst("1B","2B"); - btnB.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - sB++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("2B",""); - btnB.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - sB=0;twotileno--; - } + btnB = findViewById(R.id.usergenbtnB); + btnB.setOnClickListener(view -> { + if (sB == 0) { + sequence += "1B"; + btnB.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + sB++; + } else if (sB == 1) { + sequence = sequence.replaceFirst("1B", "2B"); + btnB.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + sB++; + twotileno++; + } else { + sequence = sequence.replaceFirst("2B", ""); + btnB.setBackgroundTintList(ColorStateList.valueOf(color)); + sB = 0; + twotileno--; } }); - btnC=findViewById(R.id.usergenbtnC); - btnC.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(sC==0){ - sequence+="1C"; - btnC.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); - sC++; - } - else if(sC==1){ - sequence=sequence.replaceFirst("1C","2C"); - btnC.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); - sC++;twotileno++; - } - else{ - sequence=sequence.replaceFirst("2C",""); - btnC.setBackgroundTintList(ColorStateList.valueOf(0xFFFFFFFF)); - sC=0;twotileno--; - } + btnC = findViewById(R.id.usergenbtnC); + btnC.setOnClickListener(view -> { + if (sC == 0) { + sequence += "1C"; + btnC.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FF5252"))); + sC++; + } else if (sC == 1) { + sequence = sequence.replaceFirst("1C", "2C"); + btnC.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#536DFE"))); + sC++; + twotileno++; + } else { + sequence = sequence.replaceFirst("2C", ""); + btnC.setBackgroundTintList(ColorStateList.valueOf(color)); + sC = 0; + twotileno--; } }); - submit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(name.equals("")){ - Toast.makeText(UserGenActivity.this, "Please Enter the name of the pattern", Toast.LENGTH_SHORT).show(); - } - else if(sequence.equals("")) { - Toast.makeText(UserGenActivity.this, "Please Make The Pattern", Toast.LENGTH_SHORT).show(); - } - else if(twotileno%2==1){ - Toast.makeText(UserGenActivity.this, "Invalid Number of Double Tiles", Toast.LENGTH_SHORT).show(); - } - else{ - dbManager.insert(name, sequence, gamemodechoice); - AlertDialog.Builder builder = new AlertDialog.Builder(UserGenActivity.this); - builder.setTitle("Upload to Community").setIcon(R.drawable.ic_baseline_cloud_upload_24).setMessage("Do you want to Upload this custom pattern to the community?"); - builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - //check firebase authentication - firebaseAuth= FirebaseAuth.getInstance(); - FirebaseUser firebaseUser=firebaseAuth.getCurrentUser(); - //write to firebase - if(firebaseUser!=null) { - String pid=databaseReference.push().getKey(); - Patterns pattern = new Patterns(gamemodechoice, name, sequence, firebaseUser.getDisplayName(),firebaseUser.getUid(),pid); - databaseReference.child(pid).setValue(pattern); - //databaseReference.child(String.valueOf(maxId+1)).setValue(pattern); - Toast.makeText(UserGenActivity.this, "Custom Pattern Uploaded Successfully", Toast.LENGTH_SHORT).show(); - } - else { - Toast.makeText(UserGenActivity.this, "Custom Pattern Added but couldn't upload to Community", Toast.LENGTH_SHORT).show(); - } - noofpatternscreated++; - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putInt("noofpatternscreated", noofpatternscreated); - editor.apply(); - finish(); + submit.setOnClickListener(view -> { + if (name.equals("")) { + Toast.makeText(UserGenActivity.this, "Please Enter the name of the pattern", Toast.LENGTH_SHORT).show(); + } else if (sequence.equals("")) { + Toast.makeText(UserGenActivity.this, "Please Make The Pattern", Toast.LENGTH_SHORT).show(); + } else if (twotileno % 2 == 1) { + Toast.makeText(UserGenActivity.this, "Invalid Number of Double Tiles", Toast.LENGTH_SHORT).show(); + } else { + dbManager.insert(name, sequence, gamemodechoice); + if (uploadcommmunitycheck.isChecked()) { + firebaseAuth = FirebaseAuth.getInstance(); + FirebaseUser firebaseUser = firebaseAuth.getCurrentUser(); + //write to firebase + if (firebaseUser != null) { + String pid = databaseReference.push().getKey(); + Patterns pattern = new Patterns(gamemodechoice, name, sequence, firebaseUser.getDisplayName(), firebaseUser.getUid(), pid); + if (pid != null) { + databaseReference.child(pid).setValue(pattern); } - }); - builder.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - noofpatternscreated++; - SharedPreferences.Editor editor=sharedPreferences.edit(); - editor.putInt("noofpatternscreated",noofpatternscreated); - editor.apply(); - Toast.makeText(UserGenActivity.this, "Custom Pattern Added", Toast.LENGTH_SHORT).show(); - finish(); - } - }); - builder.show(); - } + //databaseReference.child(String.valueOf(maxId+1)).setValue(pattern); + Toast.makeText(UserGenActivity.this, "Custom Pattern Uploaded Successfully", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(UserGenActivity.this, "Custom Pattern Added but couldn't upload to Community", Toast.LENGTH_SHORT).show(); + } + } + noofpatternscreated++; + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt("noofpatternscreated", noofpatternscreated); + editor.apply(); + Toast.makeText(UserGenActivity.this, "Custom Pattern Added", Toast.LENGTH_SHORT).show(); + finish(); } }); } @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; + if (item.getItemId() == android.R.id.home) { + finish(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/com/aditya/hopon/communityActivity.java b/app/src/main/java/com/aditya/hopon/communityActivity.java index 7c0220f..ca62c3b 100644 --- a/app/src/main/java/com/aditya/hopon/communityActivity.java +++ b/app/src/main/java/com/aditya/hopon/communityActivity.java @@ -1,44 +1,36 @@ package com.aditya.hopon; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import androidx.cardview.widget.CardView; -import androidx.recyclerview.widget.RecyclerView; -import androidx.transition.AutoTransition; -import androidx.transition.TransitionManager; - import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.ListAdapter; import android.widget.ListView; +import android.widget.RelativeLayout; +import android.widget.SearchView; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.constraintlayout.widget.ConstraintLayout; + import com.google.android.gms.auth.api.signin.GoogleSignIn; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.auth.api.signin.GoogleSignInClient; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.common.api.ApiException; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.Task; +import com.google.android.material.snackbar.BaseTransientBottomBar; +import com.google.android.material.snackbar.Snackbar; import com.google.firebase.auth.AuthCredential; -import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.auth.GoogleAuthProvider; -import com.google.firebase.database.ChildEventListener; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; @@ -51,60 +43,64 @@ public class communityActivity extends AppCompatActivity { private int opened=0,noofpatternscreated;View v=null; private SharedPreferences sharedPreferences; - private TextView toolbartitle; + RelativeLayout relativeLayout; private ListView listView; private DBManager dbManager; private DatabaseReference databaseReference; - private GoogleSignInClient googleSignInClient; + private Custom_Community_Adapter adapter; private FirebaseAuth firebaseAuth; private List patternslist; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pattern); - Toolbar toolbar = findViewById(R.id.pattern_toolbar); + Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle("Community"); - toolbartitle = findViewById(R.id.toolbar_title); - toolbartitle.setText(""); setSupportActionBar(toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - listView = (ListView) findViewById(R.id.patterns_list); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + relativeLayout = findViewById(R.id.relativelistlayout); + listView = findViewById(R.id.patterns_list); listView.setEmptyView(findViewById(R.id.emptytextpattern)); dbManager = new DBManager(this); dbManager.open(); - patternslist=new ArrayList<>(); - sharedPreferences=getSharedPreferences("sharedPrefs",MODE_PRIVATE); - noofpatternscreated=sharedPreferences.getInt("noofpatternscreated",3); - GoogleSignInOptions googleSignInOptions=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) + patternslist = new ArrayList<>(); + sharedPreferences = getSharedPreferences("sharedPrefs", MODE_PRIVATE); + noofpatternscreated = sharedPreferences.getInt("noofpatternscreated", 3); + GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken("233640760574-d18montuoivkeukg6umbfmfsh0h3rmkr.apps.googleusercontent.com") .requestEmail() .build(); - googleSignInClient= GoogleSignIn.getClient(communityActivity.this,googleSignInOptions); - firebaseAuth=FirebaseAuth.getInstance(); - FirebaseUser firebaseUser=firebaseAuth.getCurrentUser(); - if(firebaseUser==null){ + GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(communityActivity.this, googleSignInOptions); + firebaseAuth = FirebaseAuth.getInstance(); + FirebaseUser firebaseUser = firebaseAuth.getCurrentUser(); + if (firebaseUser == null) { //sign-in intent - Intent intent=googleSignInClient.getSignInIntent(); - startActivityForResult(intent,100); - } - else{ + Intent intent = googleSignInClient.getSignInIntent(); + startActivityForResult(intent, 100); + } else { communitydisplay(); } } - private void communitydisplay(){ - firebaseAuth=FirebaseAuth.getInstance(); - FirebaseUser firebaseUser=firebaseAuth.getCurrentUser(); - Toast.makeText(this,"Welcome "+ firebaseUser.getDisplayName(), Toast.LENGTH_SHORT).show(); - databaseReference= FirebaseDatabase.getInstance().getReference("Patterns"); + + private void communitydisplay() { + firebaseAuth = FirebaseAuth.getInstance(); + FirebaseUser firebaseUser = firebaseAuth.getCurrentUser(); + if (firebaseUser != null) { + Snackbar snackbar = Snackbar.make(relativeLayout, "Welcome " + firebaseUser.getDisplayName(), BaseTransientBottomBar.LENGTH_SHORT); + snackbar.show(); + } + databaseReference = FirebaseDatabase.getInstance().getReference("Patterns"); databaseReference.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { patternslist.clear(); - for(DataSnapshot patternDatasnap:snapshot.getChildren()){ - Patterns patterns=patternDatasnap.getValue(Patterns.class); + for (DataSnapshot patternDatasnap : snapshot.getChildren()) { + Patterns patterns = patternDatasnap.getValue(Patterns.class); patternslist.add(patterns); } - Custom_Community_Adapter adapter=new Custom_Community_Adapter(communityActivity.this,patternslist); + adapter = new Custom_Community_Adapter(communityActivity.this, patternslist); listView.setAdapter(adapter); } @@ -113,70 +109,58 @@ public void onCancelled(@NonNull DatabaseError error) { } }); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long viewId) { - TextView nameTextView = (TextView) view.findViewById(R.id.patternname); - TextView sequenceTextView = (TextView) view.findViewById(R.id.patternsequence); - TextView patternmode = (TextView) view.findViewById(R.id.patternmode); - Button downloadbtn=(Button)view.findViewById(R.id.patterndownloadbutton); - LinearLayout hiddendownloadlayout=(LinearLayout)view.findViewById(R.id.hiddendownloadlayout); - TextView patternuid=(TextView)view.findViewById(R.id.patternuid); - TextView patternpid=(TextView)view.findViewById(R.id.patternpid); - String uid=patternuid.getText().toString(); - if(uid.equals(firebaseUser.getUid())) { - downloadbtn.setText("Delete"); - downloadbtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_baseline_delete_24,0,0,0); - } - //none of the patterns are opened - if(opened==0 && hiddendownloadlayout.getVisibility()==View.GONE){ - v=view; - hiddendownloadlayout.setVisibility(View.VISIBLE);opened=1; - } - //current pattern is the only pattern opened - else if(opened==1 && hiddendownloadlayout.getVisibility()==View.VISIBLE){ - hiddendownloadlayout.setVisibility(View.GONE);opened=0; - } - //some other pattern is already open - else if(opened==1 && hiddendownloadlayout.getVisibility()==View.GONE){ - v.findViewById(R.id.hiddendownloadlayout).setVisibility(View.GONE); - hiddendownloadlayout.setVisibility(View.VISIBLE); - v=view; - } - downloadbtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(uid.equals(firebaseUser.getUid())){ - downloadbtn.setText("Delete"); - DatabaseReference dbdelete=databaseReference.child(patternpid.getText().toString()); - Task mTask=dbdelete.removeValue(); - mTask.addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(Void aVoid) { - noofpatternscreated--; - Toast.makeText(communityActivity.this, "Deleted From The Community!", Toast.LENGTH_SHORT).show(); - } - }); - mTask.addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(@NonNull Exception e) { - Toast.makeText(communityActivity.this, "Unknown Error,Couldn't Delete!", Toast.LENGTH_SHORT).show(); - } - }); - } - else{ - int gamemode=1; - if(patternmode.getText().toString().equals("Timed mode"))gamemode=2; - dbManager.insert(nameTextView.getText().toString(),sequenceTextView.getText().toString(),gamemode); - noofpatternscreated++; - SharedPreferences.Editor editor = sharedPreferences.edit(); - editor.putInt("noofpatternscreated", noofpatternscreated); - editor.apply(); - Toast.makeText(communityActivity.this, "Pattern Downloaded Successfully!", Toast.LENGTH_SHORT).show(); - } - } - }); + listView.setOnItemClickListener((parent, view, position, viewId) -> { + TextView nameTextView = view.findViewById(R.id.patternname); + TextView sequenceTextView = view.findViewById(R.id.patternsequence); + TextView patternmode = view.findViewById(R.id.patternmode); + Button downloadbtn = view.findViewById(R.id.patterndownloadbutton); + ConstraintLayout hiddendownloadlayout = view.findViewById(R.id.hiddendownloadlayout); + TextView patternuid = view.findViewById(R.id.patternuid); + TextView patternpid = view.findViewById(R.id.patternpid); + String uid = patternuid.getText().toString(); + assert firebaseUser != null; + if (uid.equals(firebaseUser.getUid())) { + downloadbtn.setText(R.string.delete); + downloadbtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_baseline_delete_24, 0, 0, 0); + } + //none of the patterns are opened + if (opened == 0 && hiddendownloadlayout.getVisibility() == View.GONE) { + v = view; + hiddendownloadlayout.setVisibility(View.VISIBLE); + opened = 1; + } + //current pattern is the only pattern opened + else if (opened == 1 && hiddendownloadlayout.getVisibility() == View.VISIBLE) { + hiddendownloadlayout.setVisibility(View.GONE); + opened = 0; } + //some other pattern is already open + else if (opened == 1 && hiddendownloadlayout.getVisibility() == View.GONE) { + v.findViewById(R.id.hiddendownloadlayout).setVisibility(View.GONE); + hiddendownloadlayout.setVisibility(View.VISIBLE); + v = view; + } + downloadbtn.setOnClickListener(view1 -> { + if (uid.equals(firebaseUser.getUid())) { + downloadbtn.setText(R.string.delete); + DatabaseReference dbdelete = databaseReference.child(patternpid.getText().toString()); + Task mTask = dbdelete.removeValue(); + mTask.addOnSuccessListener(aVoid -> { + noofpatternscreated--; + Toast.makeText(communityActivity.this, "Deleted From The Community!", Toast.LENGTH_SHORT).show(); + }); + mTask.addOnFailureListener(e -> Toast.makeText(communityActivity.this, "Unknown Error,Couldn't Delete!", Toast.LENGTH_SHORT).show()); + } else { + int gamemode = 1; + if (patternmode.getText().toString().equals("Timed mode")) gamemode = 2; + dbManager.insert(nameTextView.getText().toString(), sequenceTextView.getText().toString(), gamemode); + noofpatternscreated++; + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putInt("noofpatternscreated", noofpatternscreated); + editor.apply(); + Toast.makeText(communityActivity.this, "Pattern Downloaded Successfully!", Toast.LENGTH_SHORT).show(); + } + }); }); } @@ -186,36 +170,69 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten if(requestCode==100){ Task signInAccountTask=GoogleSignIn.getSignedInAccountFromIntent(data); if(signInAccountTask.isSuccessful()){ - try{ - GoogleSignInAccount googleSignInAccount=signInAccountTask.getResult(ApiException.class); - if(googleSignInAccount!=null){ - AuthCredential authCredential= GoogleAuthProvider.getCredential(googleSignInAccount.getIdToken(),null); - firebaseAuth.signInWithCredential(authCredential).addOnCompleteListener(this, new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if(task.isSuccessful()){ - //write logged in code here - communitydisplay(); - } - else{ - Toast.makeText(communityActivity.this, "Login Failed!", Toast.LENGTH_SHORT).show(); - } + try { + GoogleSignInAccount googleSignInAccount = signInAccountTask.getResult(ApiException.class); + if (googleSignInAccount != null) { + AuthCredential authCredential = GoogleAuthProvider.getCredential(googleSignInAccount.getIdToken(), null); + firebaseAuth.signInWithCredential(authCredential).addOnCompleteListener(this, task -> { + if (task.isSuccessful()) { + //write logged in code here + communitydisplay(); + } else { + Toast.makeText(communityActivity.this, "Login Failed!", Toast.LENGTH_SHORT).show(); } }); } - } - catch(ApiException e){ + } catch (ApiException ignored) { } } } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.patterns_menu, menu); + MenuItem menuItem = menu.findItem(R.id.action_search); + SearchView searchView = (SearchView) menuItem.getActionView(); + searchView.setIconified(false); + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String s) { + return false; + } + + @Override + public boolean onQueryTextChange(String s) { + //firebase search here + DatabaseReference searchref = FirebaseDatabase.getInstance().getReference("Patterns"); + searchref.orderByChild("name").startAt(s).endAt(s + "\uf8ff").addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + patternslist.clear(); + for (DataSnapshot patternDatasnap : snapshot.getChildren()) { + Patterns patterns = patternDatasnap.getValue(Patterns.class); + patternslist.add(patterns); + } + adapter = new Custom_Community_Adapter(communityActivity.this, patternslist); + listView.setAdapter(adapter); + } + + @Override + public void onCancelled(@NonNull DatabaseError error) { + + } + }); + return false; + } + }); + return super.onCreateOptionsMenu(menu); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; + if (item.getItemId() == android.R.id.home) { + finish(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/com/aditya/hopon/patternsActivity.java b/app/src/main/java/com/aditya/hopon/patternsActivity.java index 0a82aee..52d8746 100644 --- a/app/src/main/java/com/aditya/hopon/patternsActivity.java +++ b/app/src/main/java/com/aditya/hopon/patternsActivity.java @@ -1,40 +1,28 @@ package com.aditya.hopon; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import androidx.cardview.widget.CardView; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.core.content.ContextCompat; -import androidx.core.content.res.ResourcesCompat; -import androidx.cursoradapter.widget.SimpleCursorAdapter; -import androidx.transition.AutoTransition; -import androidx.transition.TransitionManager; - -import android.content.ContentValues; import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.database.Cursor; import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.transition.Transition; -import android.util.Log; +import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListAdapter; import android.widget.ListView; +import android.widget.SearchView; import android.widget.TextView; import android.widget.Toast; -import org.w3c.dom.Text; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.cardview.widget.CardView; +import androidx.transition.AutoTransition; +import androidx.transition.TransitionManager; public class patternsActivity extends AppCompatActivity implements DeleteConfirmationDialog.DeleteConfirmationDialogListener{ - private TextView toolbartitle; private DBManager dbManager; private ListView listView; private Custom_Adapter adapter; @@ -48,150 +36,236 @@ public class patternsActivity extends AppCompatActivity implements DeleteConfirm protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pattern); - Toolbar toolbar = findViewById(R.id.pattern_toolbar); + Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle("Patterns"); - toolbartitle = findViewById(R.id.toolbar_title); - toolbartitle.setText(""); setSupportActionBar(toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } dbManager = new DBManager(this); dbManager.open(); cursor = dbManager.fetch(); - listView = (ListView) findViewById(R.id.patterns_list); + listView = findViewById(R.id.patterns_list); listView.setEmptyView(findViewById(R.id.emptytextpattern)); - adapter=new Custom_Adapter(this, R.layout.pattern_view_layout, cursor, from, to, 0); + adapter = new Custom_Adapter(this, R.layout.pattern_view_layout, cursor, from, to, 0); adapter.notifyDataSetChanged(); listView.setAdapter(adapter); //OnCLickListener for List - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long viewId) { - TextView idTextView = (TextView) view.findViewById(R.id.patternid); - TextView sequenceTextView = (TextView) view.findViewById(R.id.patternsequence); - TextView patternmode = (TextView) view.findViewById(R.id.patternmode); - id = idTextView.getText().toString(); - String sequence = sequenceTextView.getText().toString(); - - //pattern display - ImageView img1=(ImageView)view.findViewById(R.id.pattgrid1); - ImageView img2=(ImageView)view.findViewById(R.id.pattgrid2); - ImageView img3=(ImageView)view.findViewById(R.id.pattgrid3); - ImageView img4=(ImageView)view.findViewById(R.id.pattgrid4); - ImageView img5=(ImageView)view.findViewById(R.id.pattgrid5); - ImageView img6=(ImageView)view.findViewById(R.id.pattgrid6); - ImageView img7=(ImageView)view.findViewById(R.id.pattgrid7); - ImageView img8=(ImageView)view.findViewById(R.id.pattgrid8); - ImageView img9=(ImageView)view.findViewById(R.id.pattgrid9); - ImageView imgA=(ImageView)view.findViewById(R.id.pattgridA); - ImageView imgB=(ImageView)view.findViewById(R.id.pattgridB); - ImageView imgC=(ImageView)view.findViewById(R.id.pattgridC); - for(int i=0;i { + TextView idTextView = view.findViewById(R.id.patternid); + TextView sequenceTextView = view.findViewById(R.id.patternsequence); + TextView patternmodetxt = view.findViewById(R.id.patternmodetxt); + id = idTextView.getText().toString(); + String sequence = sequenceTextView.getText().toString(); + //pattern display + ImageView img1 = view.findViewById(R.id.pattgrid1); + ImageView img2 = view.findViewById(R.id.pattgrid2); + ImageView img3 = view.findViewById(R.id.pattgrid3); + ImageView img4 = view.findViewById(R.id.pattgrid4); + ImageView img5 = view.findViewById(R.id.pattgrid5); + ImageView img6 = view.findViewById(R.id.pattgrid6); + ImageView img7 = view.findViewById(R.id.pattgrid7); + ImageView img8 = view.findViewById(R.id.pattgrid8); + ImageView img9 = view.findViewById(R.id.pattgrid9); + ImageView imgA = view.findViewById(R.id.pattgridA); + ImageView imgB = view.findViewById(R.id.pattgridB); + ImageView imgC = view.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; - } + } 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; } - } - //pattern display ends here - //button handling starts here - Button patternplaybutton=(Button) view.findViewById(R.id.patternplaybutton); - Button patterndeletebutton=(Button)view.findViewById(R.id.patterndeletebutton); - if(id.equals("1")){ patterndeletebutton.setEnabled(false);} - patterndeletebutton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - DeleteConfirmationDialog dialog=new DeleteConfirmationDialog(); - dialog.show(getSupportFragmentManager(),"delete"); + 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; } - }); - //button handling ends here - //hidden layout handling - LinearLayout hiddenpatternlayout=(LinearLayout)view.findViewById(R.id.hiddenpatternlayout); - CardView patterncardview=(CardView)view.findViewById(R.id.patterncardview); - //none of the patterns are opened - if(opened==0 && hiddenpatternlayout.getVisibility()==View.GONE){ - v=view; - if(patternmode.getText().toString().equals("1"))patternmode.setText("Normal Mode"); - else if(patternmode.getText().toString().equals("2")){ patternmode.setText("Timed Mode");} - patternmode.setVisibility(View.VISIBLE); - TransitionManager.beginDelayedTransition(patterncardview, new AutoTransition()); - hiddenpatternlayout.setVisibility(View.VISIBLE);opened=1; } - //this is the only pattern opened - else if(opened==1 && hiddenpatternlayout.getVisibility()==View.VISIBLE){ - if(patternmode.getText().toString().equals("Normal Mode")){patternmode.setText("1");} - else{patternmode.setText("2");} - patternmode.setVisibility(View.INVISIBLE); - TransitionManager.beginDelayedTransition(patterncardview, new AutoTransition()); - hiddenpatternlayout.setVisibility(View.GONE);opened=0; - } - //some other pattern is already open - else if(opened==1 && hiddenpatternlayout.getVisibility()==View.GONE){ - TextView temp=(TextView)v.findViewById(R.id.patternmode); - if(temp.getText().toString().equals("Normal Mode")){temp.setText("1");} - else{temp.setText("2");} - temp.setVisibility(View.INVISIBLE); - v.findViewById(R.id.hiddenpatternlayout).setVisibility(View.GONE); - if(patternmode.getText().toString().equals("1"))patternmode.setText("Normal Mode"); - else if(patternmode.getText().toString().equals("2")){ patternmode.setText("Timed Mode"); } - patternmode.setVisibility(View.VISIBLE); - hiddenpatternlayout.setVisibility(View.VISIBLE); - v=view; - } - //hidden layout handling ends here + } + //pattern display ends here + //button handling starts here + Button patternplaybutton = view.findViewById(R.id.patternplaybutton); + Button patterndeletebutton = view.findViewById(R.id.patterndeletebutton); + if (id.equals("1")) {//first pattern cannot be deleted + patterndeletebutton.setEnabled(false); + patterndeletebutton.setBackgroundTintList(ColorStateList.valueOf(Color.GRAY)); + patterndeletebutton.setAlpha(.5f); + } + patterndeletebutton.setOnClickListener(view1 -> { + DeleteConfirmationDialog dialog = new DeleteConfirmationDialog(); + dialog.show(getSupportFragmentManager(), "delete"); + }); + //button handling ends here + //hidden layout handling + LinearLayout hiddenpatternlayout = view.findViewById(R.id.hiddenpatternlayout); + CardView patterncardview = view.findViewById(R.id.patterncardview); + //none of the patterns are opened + if (opened == 0 && hiddenpatternlayout.getVisibility() == View.GONE) { + v = view; + patternmodetxt.setVisibility(View.VISIBLE); + TransitionManager.beginDelayedTransition(patterncardview, new AutoTransition()); + hiddenpatternlayout.setVisibility(View.VISIBLE); + opened = 1; + } + //this is the only pattern opened + else if (opened == 1 && hiddenpatternlayout.getVisibility() == View.VISIBLE) { + patternmodetxt.setVisibility(View.INVISIBLE); + TransitionManager.beginDelayedTransition(patterncardview, new AutoTransition()); + hiddenpatternlayout.setVisibility(View.GONE); + opened = 0; + } + //some other pattern is already open + else if (opened == 1 && hiddenpatternlayout.getVisibility() == View.GONE) { + TextView temp = v.findViewById(R.id.patternmodetxt); + temp.setVisibility(View.INVISIBLE); + v.findViewById(R.id.hiddenpatternlayout).setVisibility(View.GONE); + patternmodetxt.setVisibility(View.VISIBLE); + hiddenpatternlayout.setVisibility(View.VISIBLE); + v = view; + } + //hidden layout handling ends here + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.patterns_menu, menu); + MenuItem menuItem = menu.findItem(R.id.action_search); + SearchView searchView = (SearchView) menuItem.getActionView(); + searchView.setIconified(false); + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String s) { + return false; + } + + @Override + public boolean onQueryTextChange(String s) { + cursor = dbManager.search(s); + adapter = new Custom_Adapter(patternsActivity.this, R.layout.pattern_view_layout, cursor, from, to, 0); + adapter.notifyDataSetChanged(); + listView.setAdapter(adapter); + return false; } }); + return super.onCreateOptionsMenu(menu); } + @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; + if (item.getItemId() == android.R.id.home) { + finish(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/res/drawable/grid_1.png b/app/src/main/res/drawable-nodpi/grid_1.png similarity index 100% rename from app/src/main/res/drawable/grid_1.png rename to app/src/main/res/drawable-nodpi/grid_1.png diff --git a/app/src/main/res/drawable/grid_2.png b/app/src/main/res/drawable-nodpi/grid_2.png similarity index 100% rename from app/src/main/res/drawable/grid_2.png rename to app/src/main/res/drawable-nodpi/grid_2.png diff --git a/app/src/main/res/drawable/grid_3.png b/app/src/main/res/drawable-nodpi/grid_3.png similarity index 100% rename from app/src/main/res/drawable/grid_3.png rename to app/src/main/res/drawable-nodpi/grid_3.png diff --git a/app/src/main/res/drawable/trophy.png b/app/src/main/res/drawable-nodpi/trophy.png similarity index 100% rename from app/src/main/res/drawable/trophy.png rename to app/src/main/res/drawable-nodpi/trophy.png diff --git a/app/src/main/res/drawable/wifi.png b/app/src/main/res/drawable-nodpi/wifi.png similarity index 100% rename from app/src/main/res/drawable/wifi.png rename to app/src/main/res/drawable-nodpi/wifi.png diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml b/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml deleted file mode 100644 index 512e350..0000000 --- a/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_create_24.xml b/app/src/main/res/drawable/ic_baseline_create_24.xml deleted file mode 100644 index 2844baf..0000000 --- a/app/src/main/res/drawable/ic_baseline_create_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml b/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml index 13c137a..490fc3e 100644 --- a/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml +++ b/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> - + android:tint="@color/white"> + diff --git a/app/src/main/res/drawable/ic_baseline_search_24.xml b/app/src/main/res/drawable/ic_baseline_search_24.xml new file mode 100644 index 0000000..cbf0cc7 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_search_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_system_update_alt_24.xml b/app/src/main/res/drawable/ic_baseline_system_update_alt_24.xml deleted file mode 100644 index 2f7e2b0..0000000 --- a/app/src/main/res/drawable/ic_baseline_system_update_alt_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/stopwatch.png b/app/src/main/res/drawable/stopwatch.png deleted file mode 100644 index 4e4ce6a8d8f810fcb5437d6ad6ea1bf2a34434fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4986 zcmV-=6NT)FP)_*xpIMYt3-9Qu?Az=`(A&|jD2w})PR)!ky zeSh3ksDw(Y3Tf6`Z}qp~jkKga6>BV&(j>QM1Pd?n{jFZTHiN zl2#+iL!x~_M%(_g@v9jj8wEiza6+=a`q5dTPpqCBJ!F1H@W7mzp-+rY(pLkr zC?GG%3Vz9rI)C6OAnW`z((?IPa{lHO@}E~MayZ~e{x3zr)AOT8Ia+>UX7HZg~2+_Wc`W`~Hox`J30}#F#LzqCoVfBG-#E6|Jus zJM6-QWPR;N2OItAr3>sl)Z};T5PfY+yIm-{(z>}9byI-3{R}$3dO3&Wfe~E~d{iQ9 z?wRiRx)u+j;HEgB_>yTnKx(4yRbXNtq8X`!wSNRSQ(+q0i_HH3tXeXS_{flJ9^O4U zmBg4ZfJ9)4JKJuG11f5*egHnQ^seJx;k;?xuB!&AKL)s1W6`=$ zw^49Y9Dpnf05-ewzb}LtL|*_|=@vZ^1L)$TLg{DF^{T_0DDZJ-(2YQBgvL~I$?T{0 z^I7D$m-6Xem$D5e>l}cAVd{?JOXi-B{Q&$leVgrwg8TpQE+|p(9$X?qeNWuW$Z7tb#Pa(Pt)c1h~9%*9hYi-MctfRreGjzO!E^NQNS z=1vIevi$Ij3=Yr8=#u;8gaGo3+rkW5l^hqTd&GsRCg8``4l~D!F7#QZO7v_jxG4^J zVdtfSMVY~`ivoOhxGA$Yxz7)`WQqbT%naP{>L*uIH$o zqbLK_pMVxO@_HbnpTTEigV8pmFTv0NRasq&eK~LdXmuen9ymNOJeVK0tzyd;2N4ih zHaC+1o!>RWJN6!Pj0L5@Pr|lwPU@xDVLg(@1a7Rrz>- zWg0ry+78z`VIJ@-aEqgmVZi}R3=d&wPyh)AJ^g$&1ZvdSWf_y*PF07Qa$_5(8k#v) z+rZhTZb4Oq(vLsubi}K`69CS3^yY-VqQDym1feW7hsXQtcq2`r>c2i#;OvBlfZwCE zJdrv-<`0Tt-k@m0{d~PB3NE&_^Vx+fe0c66O%|);_HN)gU|Vl?43CTCyG_dp)L-RM zeMNyc4p+tj$ql)1n!89V)gMe9ItBxAT=b2pw7yBg2hu(S+`>krI%_QGs1Ro z9RX_K5nw5h3>U)DUGi$R`K+SGYCE!BBm@OWa1J8AB|F?AmF1C5kwIIffK(S3c%P6MaalV zl8jxlBTGtWk!==g4{W3Mz+aJV7DfaI@@D!Nf;DPBJa>`j|5emwkGsk{pvrozn*+Ly z0k)$%&g{%R!j!b(^b6>_wfwbyOdCIf%+X1t-un!N7b^K%`DJwJ_Yxj>9z#kt+Nhxj zlAXBXm#H208?5SJm%0Q|KtMng!3Py;Ya?N2H*$W+O2Q}S5HK{03p*a8ps|{J4jg00 z?P)BEAHc=74&E*;2Vm=yi``b<6`ZMXB*@DbOd034^3KruYIrecJ^=4jn|LpJCgD>a zRVptCgzZ_vuI=v=lJ}IyIz#fFV%PQ$2;03FK@jkZN+x01`}jsAaL(99PX0;Ec8Mp3 zCo(!D2!KDl+iRw+PdGc^RR8IZ-qvBZc&%jO$V31xHC!cwq9Eeyt425BK?DK5*?owh zmQ!wZ1sV(4x91Ro0J?Gaq0wj%MG+rED1+|bf;uRY(+$nMTu_2a5Lll&96yzcU3q8N zbF|2<{+@7lfTpg=DA??MFEjgutn^(`6w&yq0fDOiv&c$M!eo)KfAefN@zmFfNqw#R znn%iAO}kklD?N#-=(z|2Xf$d>Q9vCSLG04k5md?;aJ0680eT(xCB_2q)So}|+GJ-3 zoCNsx*jcZY8~&~YXrjd4Q_P_(>E|RYXtK2SGwI-t2JHS zAuQ{^0eJCLF?Lzz!Nfrr)IJoPuj0_@GOuiRcECpftN!#6_06spVXo0(wy<`~P5^>O z%_QvW1w>SS)lJ5zPoi=5PFnPdZuPb36KR~i6Qe$<+x_VB?ZoWAAAqpi?n50I!A~u% zD8r7^4m6*mtOyzrVVYfKTth&{pD=F|H8Yd=kxj)7Z7?CH}GZB=MCWAo%zadfNj4 zy!%rH0CQub0r=a&0@_U-9_#PP144nXfN|a!sf|t{_MVLd2kQyRdx~#%AHrmjn3^?$ z#@Rc)QPl;twVBYvtI7TQKQUP(^nN1QGbT|p@fF%^YV0N>#V=)p&BERpnMCWf%>DK- zCCx^@{o}(-N*(4>Z%-c3Gb1E&9XSG7mJmd+s)MPT^cT|Cd_-18683C&J6zX7kR@VD zHc_$RcE0?4A7-mWc4jhZ&wNegZJV+C_#+A;DnA2;AsNU(UUfYH&l1Me8ZK`f5+#=bpQ-c z2xic{)l@~!=_V(tL?oMpE^Z7hh5I;O*T{mn7;fno2*8n&iy+xRbidYfmiU#U@+Wt! z^O^}3Unr#Z$WFpD+-}C8vbPhE`v^x4okSF1V&)i39VT{vcN$5C{{4K(n74?Ep-)mJ zT${@jJD1qHXeB9i-q;2}oI$bqa$Pe>c8?t3+yxc@y!!Z(>t=!tC%^RQoq*gNa`zs? z*lwe_&Bi}=A7lT4)2Mv}X3a`x@KgIJPg#xRqVfPjXD?L;^#`D`Ls>aSXq9NKZ)pd+ z%WZ&b;OwF?0Mo|zwJGZw4kp-I{x6O{kqmGR!Ewg%{F4CW{c#8;i^SwLWoR`bnX9)` z6`1P!oldMM4mi)(rGl z)6h%hdxI>yPO(U`?6Cu!BcKS#{N~sh=1%g?5C;=93{E3y*>*S5FlIt3Uw@Uylr>jb zTWUrcReikU98t0?V>VlmOiHrFzms{kb*9V=S`DtZ7O#bK1bhJS^yZIgXle84W$4ZX z`;DIE(L42%-ryIrGKdWEB_deEtl1gV-To(!%XGB7rKu8t$j-iBYf|UyWWL$o(79ARHBa^Md-LYJu1{DYN^hCi|B0SdtWW@ z3Q}jn#B{k3fcVZqyS#HYNQ@2z!81DJ>;M~ZC-ApRH4PIMt?|4?0PLn#YV$uNY{Ei< z+KZ5K*CI^c;1U1t3x@VGgxxC;roO1~3qa}|;oHt12ViW7l4v>8sO%*Siw(!qUB8|a zSle>^@7RH7K6Q$Eq*>0k+$%xKZ z&BT;}pt^ns06YlXni3by{x{d)=O+JtEi0_#eE$W6_gK^t^g}U$F24HEzKmc}CTtSj$=1drh&R6Xb3xwV~$~^$%aMRpe}HfAKN0sG|13U$Hhf*ilv5bx+vyB)R(w5O%L{`@X#Aw~FlE?nzXO)ru_3n64C4`_HWi zz?xf<5e0#r<(H^6nHf7cipitmp)(Ed33_vYXGFR$$jYCHD_^oduLP||M3~xrOgR2T z@--A!n7SUFugLyG#q_`Y8L|u(ixpXtu(s52VaMahb{mTm29g%mj|Q`aH;RKDYy5z0A>-~UiVi^a;!v?P9!mINv_h@KyO=}q!IfHhloV!FCD z?H10gFlf|FWLc)}zusley?0ZezTRU!_31A&=ia-io&KH@_LU|4v}Gx#>M{lg__KN9 zXf&e8jEIfaitVh<7d-M#gol8zv=$RiJ5E4$* z7{wq-P;)MM6-K)bi`k0JWiSwaIC+q;h4866+`;*0%J4kV4~L&ha?lH-|o z%dPAfG>?;k$+TZQjbC_z*PEkthqhyFQnt$%Ck$leh#_c1k$sgltT=WWvt8nMOS5@q zah5`Sd<}ipsJNnAC`LIW(C7JpDwG3BYfw&Qc#JK@=QvPR$D0$Ys0fVbfloff zF3T8_Z$lS58g0xl)Peo+(FY^hEXXzs=DKoBl_j*69igr4Fp^bit;7I-*4&azT4%m* zM_C206qI0>WqxzVgwDzf;H!6=%`7ahbbRbOW9M$N6o9F4eT*q zec@r?&6K!kzJKR=k4aI7+0w-bpB*)nMezf;)Yd_MO+6>-8#&j~#+CLC+H7`Yz~4tj zluk>0fS$1-!K6oo5Uo>=$e8UCJIgPzsjv*A)kcuskFCpp$-MMoiut}ek4R6Wv7Nz- ze@|0u2Po$T%fNjE{47Rz*Q$+teEt$yk>SMXwJeB>>Ds|@hst&nyDF~m{<(`?>-?E% zNo>lQr3`qY3N$*87d`9W&vjIOFP)VK_YN2WKaUX>HyfF}`#VMi2ap!lkKw@q#QN)r z@bg9QAKqZQ3d{mrjXy#Nyv&Zl0eAV1BVJP=c9mAB-37yK+O65h* ze-2bp)5u-VzJ*yyoNffVow0T2fD=I0;nStexy`%T(7_0A9TH9M%MWqjbUFEF&vWWr zB{fa0R5!L#*V2y7F5$1$5E0~0Vst3OV#Ap=Bf-=9WG+r@0P+I=3XWyc- zz6F$lZ)H!JfBPV~F=rN!-j#iIpptA#&R({Gr{%sDNX@nCqDaM<+y*zv(eFTF;Y|*Mrs$GZ$-`D6XjDi$eu` znP1=-@FbM5Ux||PyDo$Q-_y%4y?VPwCq&7YKK`9--@nnT_io^|2jy3#Hw0?n0pL5J zu8%@nQGOA!3~*kP{<|w{1PW0$cUJ%jH>%?Q!T)#sFLaRBmd!S4J^%m!07*qoM6N<$ Ef?Lmxd;kCd diff --git a/app/src/main/res/drawable/user.png b/app/src/main/res/drawable/user.png deleted file mode 100644 index e435a3c7ae3e39c07243af07feced6baba954b6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1739 zcmV;+1~mDJP) ztj2EF-JO}8x%WPPXqxEu-r1R*=g!vtKHhWYfB*NNGv}T;&lyown!-r`N{BXtdo{&g1-GG6-_t%yLAyOjL*WuEn{xsPgc&5QmjT z-bR_5lp<-3l@SEVYnRRSAoQN6JTbK5wBn8`}Uz`qzLw59CaBfpDhy zt@2B|9<0g6zmxaKajQP>e4-Sq_v zt;Pe0{BFQ++)91Kq3*EIX*_^f)*JY!|F&Vc)Wy9r&AxmW2qR z_Yg2+qE!RV&-I#VnW)^h>wQ!PO|<5~1^M@KTlNi^=~)ReQ{Dr5+)OV4=e&xj>o(Oi zQ`+2Dzz?>7X0k325tY`KtybUt^Vn{RuG{$mPQDEM-BMOW)NgJ7VSaP}E0(&D#kTk@ z55A4>-vGRAAt%nO1T8JM2VdE@-$HLT*%U_B?figJD61!3hOMD9T8{O_iu(wK;-_`xX=|9knb|LpZ_%^3%9|EuJm*p#v!7#i|e z{MVasYyduvxaDDS>YAurY6m7%ki<~A#zKV-N0@jU#088Q25ca+nAV-vGZ(tn(M}=IXYfsMOq)vL%SAnSk7?wXdhuc z`gH}+`x|bG;UMto8b5Mcl^x6e!i#-<#Pt|ke}E1`p83ZVcZX4JHHVHo)19q+cet0s zwce-Z0D2Cw5#d$l@#auCiSoEOemS^})bBUI#%EboDso`Fz%Avd{(Curt2+7iu^wuw zCf5`|&#$=($8q5DdJWBDLg5brCs0m|6&O1+$>(BaO*!II<%s3eGc1l9oR?dC!Yews zcBGe+bM>9GpmFCAxh}_HZT#T@77KI(-3SzC;B-SXL^7oif3n1z0v}PTfA!`ZVqGym zR=B~=UUQfzvGj|N^TJ&Hss?cH?`T7~&(2nJ8833j`iHBJ@~Qy@MZTl3#MV~xC{+mD z68ft3New_iG{&R=xsXhj=&9D88o>7taU;SidrQq_qD1G$1AI2EJv9L5xH%h3%_j`G zC#@|t0M$z;fKr%#UNJEMId|N}r2c*}P^j?9w6??mdJnM@{`a^0|1-rh`R>Q)N@`0C zAQZ07)>88c+qg05dh#3~tjyHS0-#~?n;>}(h%dbnps+gWdfEuc^u*^v5Jn`PWlA0a zlHGaVg+i6Kr0a4rt*z!Dz>@a#U7^(dfT!-_CDq!B3l}q8i+FRmhv(ATt8R+s^V|=dHh0w|T64^J zIW|`7Q#FA7U*l{XvleLDpP8*#(#EM3t$coTd-YOWJ+;AaAUpxdKPu+K`)AXGf8d#0+8I)^)U_NFW4ZsPs1{CuFV}aw{!12et huI002ovPDHLkV1k6tRr~+| diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1b91080..1a130bf 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,14 +4,13 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/colorOnPrimary" tools:context=".MainActivity"> + - + android:layout_height="match_parent" + android:layout_weight="1.7"> + + android:src="@drawable/grid_2" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toLeftOf="@id/imgpattern1" + app:layout_constraintTop_toTopOf="parent" /> + + android:src="@drawable/grid_1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toRightOf="@id/imgpattern2" + app:layout_constraintRight_toLeftOf="@id/imgpattern3" + app:layout_constraintTop_toTopOf="parent" /> + - + android:src="@drawable/grid_3" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toRightOf="@id/imgpattern1" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + + android:textColor="@color/white" /> @@ -105,37 +117,39 @@ android:layout_marginTop="16dp" android:layout_marginBottom="16dp" app:cardElevation="8dp" + android:focusable="true" app:cardCornerRadius="8dp"> + + + app:layout_constraintLeft_toLeftOf="parent" /> + + android:text="@string/patterns" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toRightOf="@id/onlinepatterncounttxt" /> + + + app:layout_constraintLeft_toLeftOf="parent" /> @@ -259,37 +276,39 @@ android:layout_marginTop="16dp" android:layout_marginBottom="16dp" app:cardElevation="8dp" + android:focusable="true" app:cardCornerRadius="8dp"> + + + app:layout_constraintLeft_toLeftOf="parent" /> @@ -333,22 +352,24 @@ android:clickable="true" android:layout_marginBottom="16dp" app:cardElevation="8dp" + android:focusable="true" app:cardCornerRadius="8dp"> + @@ -371,6 +392,7 @@ app:layout_constraintTop_toBottomOf="@+id/wificonnectiondesctext" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"/> + - t"/> + app:layout_constraintLeft_toLeftOf="parent" /> diff --git a/app/src/main/res/layout/activity_pattern.xml b/app/src/main/res/layout/activity_pattern.xml index 5bcebce..e1abcfa 100644 --- a/app/src/main/res/layout/activity_pattern.xml +++ b/app/src/main/res/layout/activity_pattern.xml @@ -1,25 +1,27 @@ + + + + android:text="@string/no_patterns" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_user_gen.xml b/app/src/main/res/layout/activity_user_gen.xml index 92cdb7d..a4f4432 100644 --- a/app/src/main/res/layout/activity_user_gen.xml +++ b/app/src/main/res/layout/activity_user_gen.xml @@ -1,11 +1,13 @@ - + + + + android:hint="@string/enter_the_name_of_the_pattern" + app:layout_constraintTop_toBottomOf="@id/toolbar" /> + + app:layout_constraintRight_toLeftOf="@id/gamemodespinner" + app:layout_constraintTop_toBottomOf="@+id/nameinputtxt" /> + app:layout_constraintTop_toTopOf="@+id/gamemodestringtxt" /> + + @@ -61,20 +62,22 @@ android:textStyle="bold" android:textColor="?android:attr/textColorPrimary" android:layout_height="wrap_content" /> + + + android:layout_alignParentEnd="true" /> - + android:visibility="gone"> + + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + app:layout_constraintBottom_toBottomOf="@+id/createdbytxt" + app:layout_constraintRight_toLeftOf="@id/patterndownloadbutton" + app:layout_constraintStart_toEndOf="@+id/createdbytxt" + app:layout_constraintTop_toTopOf="@+id/createdbytxt" /> +