initial commit
This commit is contained in:
parent
3d9f175ce0
commit
b167a0a0cb
@ -10,10 +10,15 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Assignment1"
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".dataActivity"
|
||||||
|
android:parentActivityName=".MainActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name=".SettingsActivity"
|
||||||
|
android:parentActivityName=".MainActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
@ -9,9 +9,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
protected EventButtonSharedPreferenceHelper firstEventButton;
|
protected CounterButtonSharedPreferenceHelper firstEventButton;
|
||||||
protected EventButtonSharedPreferenceHelper secondEventButton;
|
protected CounterButtonSharedPreferenceHelper secondEventButton;
|
||||||
protected EventButtonSharedPreferenceHelper thirdEventButton;
|
protected CounterButtonSharedPreferenceHelper thirdEventButton;
|
||||||
|
|
||||||
protected Button settingsButton = null;
|
protected Button settingsButton = null;
|
||||||
|
|
||||||
@ -22,9 +22,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
settingsButton = findViewById(R.id.settings_button);
|
settingsButton = findViewById(R.id.settings_button);
|
||||||
|
|
||||||
firstEventButton = new EventButtonSharedPreferenceHelper(MainActivity.this, EventButton.FIRST);
|
firstEventButton = new CounterButtonSharedPreferenceHelper(MainActivity.this, CounterButton.FIRST);
|
||||||
secondEventButton = new EventButtonSharedPreferenceHelper(MainActivity.this, EventButton.SECOND);
|
secondEventButton = new CounterButtonSharedPreferenceHelper(MainActivity.this, CounterButton.SECOND);
|
||||||
thirdEventButton = new EventButtonSharedPreferenceHelper(MainActivity.this, EventButton.THIRD);
|
thirdEventButton = new CounterButtonSharedPreferenceHelper(MainActivity.this, CounterButton.THIRD);
|
||||||
|
|
||||||
settingsButton.setOnClickListener(new View.OnClickListener() {
|
settingsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -35,14 +35,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if(
|
if(
|
||||||
firstEventButton.getEventButtonName(EventButton.FIRST) == null ||
|
firstEventButton.getCounterButtonName(CounterButton.FIRST) == null ||
|
||||||
secondEventButton.getEventButtonName(EventButton.SECOND) == null ||
|
secondEventButton.getCounterButtonName(CounterButton.SECOND) == null ||
|
||||||
thirdEventButton.getEventButtonName(EventButton.THIRD) == null) {
|
thirdEventButton.getCounterButtonName(CounterButton.THIRD) == null) {
|
||||||
|
|
||||||
goToSettingsActivity();
|
goToSettingsActivity();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,70 @@
|
|||||||
package com.example.assignment1;
|
package com.example.assignment1;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
protected Button saveButton;
|
||||||
|
protected Toolbar myToolbar;
|
||||||
|
|
||||||
|
protected CounterButtonSharedPreferenceHelper firstEventButton;
|
||||||
|
protected CounterButtonSharedPreferenceHelper secondEventButton;
|
||||||
|
protected CounterButtonSharedPreferenceHelper thirdEventButton;
|
||||||
|
protected EditText counter_1_name_edit_text;
|
||||||
|
protected EditText counter_2_name_edit_text;
|
||||||
|
protected EditText counter_3_name_edit_text;
|
||||||
|
|
||||||
|
protected EditText maximum_counts_edit_text;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_settings);
|
setContentView(R.layout.activity_settings);
|
||||||
|
|
||||||
|
myToolbar = (Toolbar) findViewById(R.id.settings_toolbar);
|
||||||
|
saveButton = (Button) findViewById(R.id.saveButton);
|
||||||
|
|
||||||
|
counter_1_name_edit_text = (EditText) findViewById(R.id.counter_1_edit_text);
|
||||||
|
counter_2_name_edit_text = (EditText) findViewById(R.id.counter_2_edit_text);
|
||||||
|
counter_3_name_edit_text = (EditText) findViewById(R.id.counter_3_edit_text);
|
||||||
|
maximum_counts_edit_text = (EditText) findViewById(R.id.maximum_counts_edit_text);
|
||||||
|
|
||||||
|
firstEventButton = new CounterButtonSharedPreferenceHelper(SettingsActivity.this, CounterButton.FIRST);
|
||||||
|
secondEventButton = new CounterButtonSharedPreferenceHelper(SettingsActivity.this, CounterButton.SECOND);
|
||||||
|
thirdEventButton = new CounterButtonSharedPreferenceHelper(SettingsActivity.this, CounterButton.THIRD);
|
||||||
|
|
||||||
|
// enable toolbar/actionbar
|
||||||
|
setSupportActionBar(myToolbar);
|
||||||
|
|
||||||
|
assert getSupportActionBar() != null;
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); //show back button
|
||||||
|
|
||||||
|
// no save button in Display Mode
|
||||||
|
saveButton.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
// in DISPLAY mode, it's not possible to edit counter button names
|
||||||
|
counter_1_name_edit_text.setEnabled(false);
|
||||||
|
counter_2_name_edit_text.setEnabled(false);
|
||||||
|
counter_3_name_edit_text.setEnabled(false);
|
||||||
|
maximum_counts_edit_text.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.settings_activity_menu, menu);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
14
app/src/main/java/com/example/assignment1/dataActivity.java
Normal file
14
app/src/main/java/com/example/assignment1/dataActivity.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.example.assignment1;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class dataActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_data);
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/layout/activity_data.xml
Normal file
9
app/src/main/res/layout/activity_data.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".dataActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -29,7 +29,7 @@
|
|||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:text="@string/FirstEventButton"
|
android:text="@string/counter_1_name"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
android:id="@+id/SecondEventButton"
|
android:id="@+id/SecondEventButton"
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="@string/SecondEventButton"
|
android:text="@string/counter_2_name"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -50,7 +50,7 @@
|
|||||||
android:id="@+id/ThirdEventButton"
|
android:id="@+id/ThirdEventButton"
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="@string/ThirdEventButton"
|
android:text="@string/counter_3_name"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -1,9 +1,138 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".SettingsActivity">
|
tools:context=".SettingsActivity">
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<!-- Action Bar -->
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/settings_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:elevation="4dp"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>
|
||||||
|
|
||||||
|
<!-- Content Layout -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="125dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<!-- Text Views -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/counter_1_text_view"
|
||||||
|
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
|
||||||
|
android:text="@string/counter_1_string" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/counter_1_edit_text"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
|
||||||
|
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||||
|
android:hint="@string/counter_1_name"
|
||||||
|
android:inputType="text"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
|
||||||
|
android:text="@string/counter_2_string" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/counter_2_edit_text"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
|
||||||
|
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||||
|
android:hint="@string/counter_2_name"
|
||||||
|
android:inputType="text"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
|
||||||
|
android:text="@string/counter_3_string" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/counter_3_edit_text"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
|
||||||
|
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
|
||||||
|
android:hint="@string/counter_3_name"
|
||||||
|
android:inputType="text"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/maximum_counts_text_view"
|
||||||
|
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
|
||||||
|
android:text="@string/maximum_counts_text" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/maximum_counts_edit_text"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
|
||||||
|
android:digits="0123456789"
|
||||||
|
android:hint="@string/maximum_counts"
|
||||||
|
android:inputType="number"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Save Button -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/saveButton"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="50dp"
|
||||||
|
android:text="@string/save_button_string" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
6
app/src/main/res/menu/settings_activity_menu.xml
Normal file
6
app/src/main/res/menu/settings_activity_menu.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/edit_settings"
|
||||||
|
android:title="@string/edit_settings" />
|
||||||
|
</menu>
|
@ -1,10 +1,17 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">assignment1</string>
|
<string name="app_name">assignment1</string>
|
||||||
<string name="settings_btn_string">SETTINGS</string>
|
<string name="settings_btn_string">SETTINGS</string>
|
||||||
<string name="FirstEventButton"></string>
|
<string name="counter_1_name"/>
|
||||||
<string name="SecondEventButton"></string>
|
<string name="counter_2_name"/>
|
||||||
<string name="ThirdEventButton"></string>
|
<string name="counter_3_name"/>
|
||||||
<string name="total_count_text_view_string">Total Count:</string>
|
<string name="total_count_text_view_string">Total Count:</string>
|
||||||
<string name="total_count_number_text_view_string">0</string>
|
<string name="total_count_number_text_view_string">0</string>
|
||||||
<string name="show_my_counts_btn_string">SHOW MY COUNTS</string>
|
<string name="show_my_counts_btn_string">SHOW MY COUNTS</string>
|
||||||
|
<string name="edit_settings">Edit Settings</string>
|
||||||
|
<string name="counter_3_string">Counter 3 Name</string>
|
||||||
|
<string name="counter_2_string">Counter 2 Name</string>
|
||||||
|
<string name="counter_1_string">Counter 1 Name</string>
|
||||||
|
<string name="save_button_string">Save</string>
|
||||||
|
<string name="maximum_counts_text">Maximum Counts</string>
|
||||||
|
<string name="maximum_counts"/>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user