Refactored into MVC architecture
This commit is contained in:
parent
af3d8a8761
commit
e178a2750c
@ -13,17 +13,17 @@
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".dataActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:name=".Views.dataActivity"
|
||||
android:parentActivityName=".Views.MainActivity"
|
||||
android:label="Data Activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:name=".Views.SettingsActivity"
|
||||
android:parentActivityName=".Views.MainActivity"
|
||||
android:label="Settings Activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".Views.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Controllers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
@ -1,9 +1,11 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Controllers;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.example.assignment1.Models.CounterButtonNames;
|
||||
|
||||
|
||||
public class CounterButtonSharedPreferenceHelper {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Models;
|
||||
|
||||
// There are only 3 buttons available to select
|
||||
// so Enum seemed to be the suitable choice of data structure here
|
@ -1,4 +1,4 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -9,6 +9,11 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.assignment1.Controllers.CountSharedPreferenceHelper;
|
||||
import com.example.assignment1.Models.CounterButtonNames;
|
||||
import com.example.assignment1.Controllers.CounterButtonSharedPreferenceHelper;
|
||||
import com.example.assignment1.R;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
protected CounterButtonSharedPreferenceHelper counterButtonSharedPrefHelper;
|
||||
@ -89,7 +94,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (counterButtonSharedPrefHelper.getCounterButtonName(CounterButtonNames.FIRST).trim().isEmpty() ||
|
||||
counterButtonSharedPrefHelper.getCounterButtonName(CounterButtonNames.SECOND).trim().isEmpty() ||
|
||||
counterButtonSharedPrefHelper.getCounterButtonName(CounterButtonNames.THIRD).trim().isEmpty()) {
|
||||
Toast.makeText(getApplicationContext(), "Event Button(s) can not be empty", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), "Event Button(s) Names can not be empty", Toast.LENGTH_SHORT).show();
|
||||
goToSettingsActivity();
|
||||
|
||||
// everything field is good, no edit needed
|
@ -1,4 +1,4 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Views;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
@ -12,6 +12,11 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.example.assignment1.Controllers.CountSharedPreferenceHelper;
|
||||
import com.example.assignment1.Models.CounterButtonNames;
|
||||
import com.example.assignment1.Controllers.CounterButtonSharedPreferenceHelper;
|
||||
import com.example.assignment1.R;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
protected Button saveButton;
|
||||
@ -111,6 +116,11 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
saveButton.setVisibility(View.VISIBLE);
|
||||
|
||||
counter_1_name_edit_text.setHint("");
|
||||
counter_2_name_edit_text.setHint("");
|
||||
counter_3_name_edit_text.setHint("");
|
||||
maximum_counts_edit_text.setHint("");
|
||||
|
||||
counter_1_name_edit_text.setEnabled(true);
|
||||
counter_2_name_edit_text.setEnabled(true);
|
||||
counter_3_name_edit_text.setEnabled(true);
|
@ -1,4 +1,4 @@
|
||||
package com.example.assignment1;
|
||||
package com.example.assignment1.Views;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -11,6 +11,11 @@ import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.example.assignment1.Controllers.CountSharedPreferenceHelper;
|
||||
import com.example.assignment1.Models.CounterButtonNames;
|
||||
import com.example.assignment1.Controllers.CounterButtonSharedPreferenceHelper;
|
||||
import com.example.assignment1.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingsActivity">
|
||||
tools:context=".Views.SettingsActivity">
|
||||
|
||||
<!-- Action Bar -->
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
|
@ -11,7 +11,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
tools:context=".MainActivity">
|
||||
tools:context=".Views.MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/settings_button"
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingsActivity">
|
||||
tools:context=".Views.SettingsActivity">
|
||||
|
||||
<!-- Action Bar -->
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
|
Loading…
x
Reference in New Issue
Block a user