MP5
This commit is contained in:
parent
802b2f46ee
commit
0aa458b1f4
3
Assignments/CriminalIntent13/.idea/.gitignore
generated
vendored
Normal file
3
Assignments/CriminalIntent13/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
26
Assignments/CriminalIntent13/.idea/appInsightsSettings.xml
generated
Normal file
26
Assignments/CriminalIntent13/.idea/appInsightsSettings.xml
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="tabSettings">
|
||||||
|
<map>
|
||||||
|
<entry key="Firebase Crashlytics">
|
||||||
|
<value>
|
||||||
|
<InsightsFilterSettings>
|
||||||
|
<option name="connection">
|
||||||
|
<ConnectionSetting>
|
||||||
|
<option name="appId" value="PLACEHOLDER" />
|
||||||
|
<option name="mobileSdkAppId" value="" />
|
||||||
|
<option name="projectId" value="" />
|
||||||
|
<option name="projectNumber" value="" />
|
||||||
|
</ConnectionSetting>
|
||||||
|
</option>
|
||||||
|
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||||
|
<option name="timeIntervalDays" value="THIRTY_DAYS" />
|
||||||
|
<option name="visibilityType" value="ALL" />
|
||||||
|
</InsightsFilterSettings>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
Assignments/CriminalIntent13/.idea/compiler.xml
generated
Normal file
6
Assignments/CriminalIntent13/.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="17" />
|
||||||
|
</component>
|
||||||
|
</project>
|
10
Assignments/CriminalIntent13/.idea/deploymentTargetDropDown.xml
generated
Normal file
10
Assignments/CriminalIntent13/.idea/deploymentTargetDropDown.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<value>
|
||||||
|
<entry key="app">
|
||||||
|
<State />
|
||||||
|
</entry>
|
||||||
|
</value>
|
||||||
|
</component>
|
||||||
|
</project>
|
7
Assignments/CriminalIntent13/.idea/discord.xml
generated
Normal file
7
Assignments/CriminalIntent13/.idea/discord.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="ASK" />
|
||||||
|
<option name="description" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
19
Assignments/CriminalIntent13/.idea/gradle.xml
generated
Normal file
19
Assignments/CriminalIntent13/.idea/gradle.xml
generated
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveExternalAnnotations" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
Assignments/CriminalIntent13/.idea/migrations.xml
generated
Normal file
10
Assignments/CriminalIntent13/.idea/migrations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
Assignments/CriminalIntent13/.idea/misc.xml
generated
Normal file
10
Assignments/CriminalIntent13/.idea/misc.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
Assignments/CriminalIntent13/.idea/vcs.xml
generated
Normal file
6
Assignments/CriminalIntent13/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -15,7 +15,6 @@ import asdv.lisset.criminalintent.database.CrimeDbSchema;
|
|||||||
|
|
||||||
public class CrimeLab {
|
public class CrimeLab {
|
||||||
private static CrimeLab crimeLab;
|
private static CrimeLab crimeLab;
|
||||||
private List<Crime> crimes;
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SQLiteDatabase mDatabase;
|
private SQLiteDatabase mDatabase;
|
||||||
public static CrimeLab get(Context context) {
|
public static CrimeLab get(Context context) {
|
||||||
@ -58,11 +57,11 @@ public class CrimeLab {
|
|||||||
if (cursor.getCount() == 0) {
|
if (cursor.getCount() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
cursor.moveToFirst();
|
||||||
|
return cursor.getCrime();
|
||||||
} finally {
|
} finally {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
cursor.moveToFirst();
|
|
||||||
return cursor.getCrime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCrime(Crime crime) {
|
public void updateCrime(Crime crime) {
|
||||||
@ -97,4 +96,8 @@ public class CrimeLab {
|
|||||||
crime.isSolved() ? 1 : 0);
|
crime.isSolved() ? 1 : 0);
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteCrime(Crime crime) {
|
||||||
|
mDatabase.delete(CrimeDbSchema.CrimeTable.NAME, "uuid = ?", new String[]{String.valueOf(crime.getId())});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package asdv.lisset.criminalintent;
|
package asdv.lisset.criminalintent;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -14,17 +17,38 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CrimeListFragment extends Fragment {
|
public class CrimeListFragment extends Fragment {
|
||||||
private RecyclerView crimeRecyclerView;
|
private RecyclerView crimeRecyclerView;
|
||||||
private CrimeAdapter adapter;
|
private CrimeAdapter adapter;
|
||||||
private boolean subtitleVisible;
|
private boolean subtitleVisible = true;
|
||||||
|
private Context context;
|
||||||
|
private boolean inDeleteMode;
|
||||||
|
private void showConfirmationDialog(Crime crime) {
|
||||||
|
AlertDialog confirmDialog = new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle("Title")
|
||||||
|
.setMessage("Do you really want to delete this crime?")
|
||||||
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
// Delete the crime
|
||||||
|
CrimeLab.get(requireContext()).deleteCrime(crime);
|
||||||
|
updateUI(); // Update the UI after deletion
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
private static final String SAVED_SUBTITLE_VISIBLE = "subtitle";
|
private static final String SAVED_SUBTITLE_VISIBLE = "subtitle";
|
||||||
|
|
||||||
@ -66,6 +90,7 @@ public class CrimeListFragment extends Fragment {
|
|||||||
View view =
|
View view =
|
||||||
inflater.inflate(R.layout.fragment_crime_list,
|
inflater.inflate(R.layout.fragment_crime_list,
|
||||||
container, false);
|
container, false);
|
||||||
|
context = requireContext();
|
||||||
crimeRecyclerView = (RecyclerView) view
|
crimeRecyclerView = (RecyclerView) view
|
||||||
.findViewById(R.id.crime_recycler_view);
|
.findViewById(R.id.crime_recycler_view);
|
||||||
crimeRecyclerView.setLayoutManager(
|
crimeRecyclerView.setLayoutManager(
|
||||||
@ -100,6 +125,8 @@ public class CrimeListFragment extends Fragment {
|
|||||||
private TextView titleTextView;
|
private TextView titleTextView;
|
||||||
private TextView dateTextView;
|
private TextView dateTextView;
|
||||||
private ImageView solvedImageView;
|
private ImageView solvedImageView;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
public void bind(Crime crime){
|
public void bind(Crime crime){
|
||||||
this.crime = crime;
|
this.crime = crime;
|
||||||
titleTextView.setText(this.crime.getTitle());
|
titleTextView.setText(this.crime.getTitle());
|
||||||
@ -113,28 +140,27 @@ public class CrimeListFragment extends Fragment {
|
|||||||
dateTextView = itemView.findViewById(R.id.crime_date);
|
dateTextView = itemView.findViewById(R.id.crime_date);
|
||||||
solvedImageView =itemView.findViewById(R.id.imageView_green_cross);
|
solvedImageView =itemView.findViewById(R.id.imageView_green_cross);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
//CHAPTER10
|
if (inDeleteMode) {
|
||||||
// Intent intent = CrimeActivity.newIntent(getActivity(),
|
// Invoke confirmation dialog
|
||||||
// crime.getId());
|
showConfirmationDialog(crime);
|
||||||
|
inDeleteMode = false;
|
||||||
//CHAPTER11
|
ActionBar actionBar = ((AppCompatActivity) requireActivity()).getSupportActionBar();
|
||||||
|
actionBar.setTitle("Select an crime to remove.");
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(requireContext(), R.color.black)));
|
||||||
|
}
|
||||||
|
actionBar.setTitle("CriminalIntent");
|
||||||
|
} else {
|
||||||
Intent intent =
|
Intent intent =
|
||||||
CrimePagerActivity.newIntent(getActivity(),
|
CrimePagerActivity.newIntent(getActivity(),
|
||||||
crime.getId());
|
crime.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//CHAPTER8
|
|
||||||
// Intent intent = new Intent(getActivity(), CrimeActivity.class);
|
|
||||||
// startActivity(intent);
|
|
||||||
// Toast.makeText(getActivity(),
|
|
||||||
// this.crime.getTitle() + " clicked!",
|
|
||||||
// Toast.LENGTH_SHORT)
|
|
||||||
// .show();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//ADAPTER
|
//ADAPTER
|
||||||
private class CrimeAdapter extends RecyclerView.Adapter<CrimeHolder>{
|
private class CrimeAdapter extends RecyclerView.Adapter<CrimeHolder>{
|
||||||
@ -174,6 +200,8 @@ public class CrimeListFragment extends Fragment {
|
|||||||
inflater.inflate(R.menu.fragment_crime_list,menu);
|
inflater.inflate(R.menu.fragment_crime_list,menu);
|
||||||
MenuItem subtitleItem =
|
MenuItem subtitleItem =
|
||||||
menu.findItem(R.id.show_subtitle);
|
menu.findItem(R.id.show_subtitle);
|
||||||
|
ActionBar actionBar = ((AppCompatActivity) requireActivity()).getSupportActionBar();
|
||||||
|
actionBar.setTitle("CriminalIntent");
|
||||||
if (subtitleVisible) {
|
if (subtitleVisible) {
|
||||||
subtitleItem.setTitle(R.string.hide_subtitle);
|
subtitleItem.setTitle(R.string.hide_subtitle);
|
||||||
} else {
|
} else {
|
||||||
@ -193,6 +221,15 @@ public class CrimeListFragment extends Fragment {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (item.getItemId() == R.id.remove_crime) {
|
||||||
|
ActionBar actionBar = ((AppCompatActivity) requireActivity()).getSupportActionBar();
|
||||||
|
actionBar.setTitle("Select a crime to remove.");
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(requireContext(), R.color.red)));
|
||||||
|
}
|
||||||
|
inDeleteMode = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if(item.getItemId() == R.id.show_subtitle)
|
else if(item.getItemId() == R.id.show_subtitle)
|
||||||
{
|
{
|
||||||
subtitleVisible = !subtitleVisible;
|
subtitleVisible = !subtitleVisible;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package asdv.lisset.criminalintent;
|
package asdv.lisset.criminalintent;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
@ -3,6 +3,8 @@ package asdv.lisset.criminalintent.database;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import asdv.lisset.criminalintent.database.CrimeDbSchema;
|
import asdv.lisset.criminalintent.database.CrimeDbSchema;
|
||||||
|
|
||||||
public class CrimeBaseHelper extends SQLiteOpenHelper {
|
public class CrimeBaseHelper extends SQLiteOpenHelper {
|
||||||
@ -14,12 +16,13 @@ public class CrimeBaseHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
String executionString = "create table " + CrimeDbSchema.CrimeTable.NAME;
|
String executionString = "CREATE TABLE " + CrimeDbSchema.CrimeTable.NAME;
|
||||||
executionString += " _id integer primary key autoincrement" +
|
executionString += "( _id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||||
CrimeDbSchema.CrimeTable.Cols.UUID + ", " +
|
CrimeDbSchema.CrimeTable.Cols.UUID + " TEXT, " +
|
||||||
CrimeDbSchema.CrimeTable.Cols.TITLE + ", " +
|
CrimeDbSchema.CrimeTable.Cols.TITLE + " TEXT, " +
|
||||||
CrimeDbSchema.CrimeTable.Cols.DATE + ", " +
|
CrimeDbSchema.CrimeTable.Cols.DATE + " DATE, " +
|
||||||
CrimeDbSchema.CrimeTable.Cols.SOLVED;
|
CrimeDbSchema.CrimeTable.Cols.SOLVED + " BOOLEAN);";
|
||||||
|
Log.println(Log.INFO, "CriminalIntent", "SQL String: " + executionString);
|
||||||
db.execSQL(executionString);
|
db.execSQL(executionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="#FFFFFF"
|
||||||
|
android:alpha="0.8">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M200,510L200,450L760,450L760,510L200,510Z"/>
|
||||||
|
</vector>
|
@ -1,7 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu
|
<menu
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/toolbar">
|
||||||
|
<item
|
||||||
|
android:id="@+id/remove_crime"
|
||||||
|
android:icon="@drawable/ic_menu_remove"
|
||||||
|
android:title="@string/remove_crime"
|
||||||
|
app:showAsAction="ifRoom|withText"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/new_crime"
|
android:id="@+id/new_crime"
|
||||||
android:icon="@drawable/ic_menu_add"
|
android:icon="@drawable/ic_menu_add"
|
||||||
@ -9,6 +15,5 @@
|
|||||||
app:showAsAction="ifRoom|withText"/>
|
app:showAsAction="ifRoom|withText"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/show_subtitle"
|
android:id="@+id/show_subtitle"
|
||||||
android:title="@string/show_subtitle"
|
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
</menu>
|
</menu>
|
@ -2,4 +2,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="red">#FF0000</color>
|
||||||
</resources>
|
</resources>
|
@ -7,6 +7,7 @@
|
|||||||
<string name="date_picker_title">Date of crime:</string>
|
<string name="date_picker_title">Date of crime:</string>
|
||||||
<string name="time_picker_title">Time of crime:</string>
|
<string name="time_picker_title">Time of crime:</string>
|
||||||
<string name="new_crime">New Crime</string>
|
<string name="new_crime">New Crime</string>
|
||||||
|
<string name="remove_crime">Remove Crime</string>
|
||||||
<string name="show_subtitle">Show Subtitle</string>
|
<string name="show_subtitle">Show Subtitle</string>
|
||||||
<string name="hide_subtitle">Hide Subtitle</string>
|
<string name="hide_subtitle">Hide Subtitle</string>
|
||||||
<string name="subtitle_format">%1$d crimes</string>
|
<string name="subtitle_format">%1$d crimes</string>
|
||||||
|
BIN
ZIPs/CriminalIntent-MP5_CalebFontenot.zip
Normal file
BIN
ZIPs/CriminalIntent-MP5_CalebFontenot.zip
Normal file
Binary file not shown.
BIN
crimeBase.db
Normal file
BIN
crimeBase.db
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user