diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd45b12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea/caches/build_file_checksums.ser +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..0b0f57a --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,126 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e0d5b93 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..677afbe --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.example.joshh.sprint1" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'com.android.support:support-v4:28.0.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'android.arch.lifecycle:extensions:1.1.1' + implementation 'android.arch.lifecycle:viewmodel:1.1.1' + implementation 'com.android.support:design:28.0.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/example/joshh/sprint1/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/joshh/sprint1/ExampleInstrumentedTest.java new file mode 100644 index 0000000..57a72da --- /dev/null +++ b/app/src/androidTest/java/com/example/joshh/sprint1/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.joshh.sprint1; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.joshh.sprint1", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..bd18d17 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..9ac5b5d Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/example/joshh/sprint1/AppCompatPreferenceActivity.java b/app/src/main/java/com/example/joshh/sprint1/AppCompatPreferenceActivity.java new file mode 100644 index 0000000..313e4c7 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/AppCompatPreferenceActivity.java @@ -0,0 +1,109 @@ +package com.example.joshh.sprint1; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.widget.Toolbar; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls + * to be used with AppCompat. + */ +public abstract class AppCompatPreferenceActivity extends PreferenceActivity { + + private AppCompatDelegate mDelegate; + + @Override + protected void onCreate(Bundle savedInstanceState) { + getDelegate().installViewFactory(); + getDelegate().onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getDelegate().onPostCreate(savedInstanceState); + } + + public ActionBar getSupportActionBar() { + return getDelegate().getSupportActionBar(); + } + + public void setSupportActionBar(@Nullable Toolbar toolbar) { + getDelegate().setSupportActionBar(toolbar); + } + + @Override + public MenuInflater getMenuInflater() { + return getDelegate().getMenuInflater(); + } + + @Override + public void setContentView(@LayoutRes int layoutResID) { + getDelegate().setContentView(layoutResID); + } + + @Override + public void setContentView(View view) { + getDelegate().setContentView(view); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().setContentView(view, params); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().addContentView(view, params); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + + @Override + protected void onStop() { + super.onStop(); + getDelegate().onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + + public void invalidateOptionsMenu() { + getDelegate().invalidateOptionsMenu(); + } + + private AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = AppCompatDelegate.create(this, null); + } + return mDelegate; + } +} diff --git a/app/src/main/java/com/example/joshh/sprint1/EditActivity.java b/app/src/main/java/com/example/joshh/sprint1/EditActivity.java new file mode 100644 index 0000000..d802a56 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/EditActivity.java @@ -0,0 +1,78 @@ +package com.example.joshh.sprint1; + +import android.app.Activity; +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.Switch; + +public class EditActivity extends AppCompatActivity { + + public static final String EDIT_MOVIE_KEY = "edit_movie"; + + private LinearLayout buttonParent, titleSwitchParent; + private Button addMovie, deleteMovie; + private Switch watchedSwitch; + private EditText title; + private Movie movie; + + @Override + protected void onCreate(Bundle savedInstanceState) { + ThemeUtils.onActivityCreateSetTheme(this); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_edit); + buttonParent = findViewById(R.id.button_parent); + titleSwitchParent = findViewById(R.id.title_switch_parent); + addMovie = findViewById(R.id.save_movie_button); + deleteMovie = findViewById(R.id.delete_movie_button); + watchedSwitch = findViewById(R.id.watched_switch); + title = findViewById(R.id.movie_title); + movie = (Movie) getIntent().getSerializableExtra(EDIT_MOVIE_KEY); + if(movie == null){ + movie = new Movie(Movie.NO_ID); + } + title.setText(movie.getTitle()); + watchedSwitch.setChecked(movie.isWatched()); + + } + + @Override + public void onBackPressed() { + Result(); + super.onBackPressed(); + } + + @Override + protected void onResume() { + super.onResume(); + addMovie.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Result(); + finish(); + } + }); + deleteMovie.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + movie.setId(Movie.NO_ID); + finish(); + } + }); + } + + private void Result(){ + movie.setTitle(title.getText().toString()); + movie.setWatched(watchedSwitch.isChecked()); + Intent resultIntent = new Intent(); + resultIntent.putExtra(EDIT_MOVIE_KEY, movie); + setResult(Activity.RESULT_OK, resultIntent); + } + + + +} diff --git a/app/src/main/java/com/example/joshh/sprint1/MainActivity.java b/app/src/main/java/com/example/joshh/sprint1/MainActivity.java new file mode 100644 index 0000000..518f655 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/MainActivity.java @@ -0,0 +1,137 @@ +package com.example.joshh.sprint1; + +import android.app.Activity; +import android.arch.lifecycle.Observer; +import android.arch.lifecycle.ViewModelProviders; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.graphics.Paint; +import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; + +public class MainActivity extends AppCompatActivity { + + public static final int EDIT_MOVIE_REQUEST_CODE = 2; + private Context context; + private LinearLayout ll; + private Button addMovieButton; + private MovieViewModel viewModel; + private FloatingActionButton fab; + private int themeId; + private Activity activity; + public static SharedPreferences preferences; + + @Override + protected void onCreate(Bundle savedInstanceState) { + ThemeUtils.onActivityCreateSetTheme(this); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + preferences = this.getPreferences(Context.MODE_PRIVATE); + ll = findViewById(R.id.scroll_view_layout); + addMovieButton = findViewById(R.id.add_movie_button); + fab = findViewById(R.id.floating_action_button); + context = this; + activity = this; + } + + @Override + public void setTheme(int resid) { + themeId = resid; + super.setTheme(resid); + + } + + @Override + protected void onStart() { + if(!ThemeUtils.checkTheme(activity, themeId)){ + ThemeUtils.refreshActivity(activity); + } + super.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + + viewModel =ViewModelProviders.of(this).get(MovieViewModel.class); + final Observer> observer = new Observer>() { + @Override + public void onChanged(@Nullable ArrayList movies) { + if(movies != null){ + refreshListView(movies); + } + } + }; + viewModel.getMovieList().observe(this, observer); + + addMovieButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, EditActivity.class); + Movie newMovie = new Movie(Movie.NO_ID); + intent.putExtra(EditActivity.EDIT_MOVIE_KEY, newMovie); + startActivityForResult(intent, EDIT_MOVIE_REQUEST_CODE); + } + }); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, SettingsActivity.class); + startActivity(intent); + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if(resultCode == RESULT_OK){ + if(requestCode == EDIT_MOVIE_REQUEST_CODE){ + if(data != null){ + Movie returnedMovie = (Movie) data.getSerializableExtra(EditActivity.EDIT_MOVIE_KEY); + viewModel.addMovie(returnedMovie); + } + } + } + } + + private void refreshListView(ArrayList movies){ + ll.removeAllViews(); + for(Movie m : movies){ + ll.addView(createDefaultTextView(m)); + } + } + + private TextView createDefaultTextView(final Movie movie){ + TextView tv = new TextView(context); + tv.setTextSize(getResources().getDimension(R.dimen.list_movie_text_size)); + tv.setWidth(getResources().getDimensionPixelOffset(R.dimen.list_movie_width)); + tv.setPadding(getResources().getDimensionPixelOffset(R.dimen.list_movie_padding_left), 0, 0, 0); + tv.setTextColor(getResources().getColor(R.color.text_color)); + tv.setText(movie.getTitle()); + if(movie.isWatched()){ + tv.setTextColor(Color.GREEN); + tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + } + tv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewModel.removeMovie(movie); + Intent editMovieIntent = new Intent(context, EditActivity.class); + editMovieIntent.putExtra(EditActivity.EDIT_MOVIE_KEY, movie); + startActivityForResult(editMovieIntent, EDIT_MOVIE_REQUEST_CODE); + } + }); + return tv; + } +} diff --git a/app/src/main/java/com/example/joshh/sprint1/Movie.java b/app/src/main/java/com/example/joshh/sprint1/Movie.java new file mode 100644 index 0000000..aadeee9 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/Movie.java @@ -0,0 +1,46 @@ +package com.example.joshh.sprint1; + +import java.io.Serializable; + +public class Movie implements Serializable { + + public static final int NO_ID = -1; + + private String title; + private boolean isWatched; + private int id; + + public Movie(int id, String title, boolean isWatched){ + this.id = id; + this.title = title; + this.isWatched = isWatched; + } + public Movie(int id){ + this.id = id; + } + + + public String getTitle() { + return title; + } + + public boolean isWatched() { + return isWatched; + } + + public int getId() { + return id; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setWatched(boolean watched) { + isWatched = watched; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/app/src/main/java/com/example/joshh/sprint1/MovieRepository.java b/app/src/main/java/com/example/joshh/sprint1/MovieRepository.java new file mode 100644 index 0000000..e713cdf --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/MovieRepository.java @@ -0,0 +1,38 @@ +package com.example.joshh.sprint1; + +import android.arch.lifecycle.MutableLiveData; + +import java.util.ArrayList; + +public class MovieRepository { + + private ArrayList movies; + + public MovieRepository() { + this.movies = new ArrayList<>(); + } + + public MutableLiveData> getMovies() { + MutableLiveData> liveDataList = new MutableLiveData<>(); + liveDataList.setValue(movies); + return liveDataList; + } + + public ArrayList addMovie(Movie movie) { + if(movie.getId() == Movie.NO_ID){ + int movieIndex = movies.size(); + movie.setId(movieIndex); + } + movies.add(movie); + return movies; + } + + public ArrayList removeMovie(Movie movie){ + for(int i = movies.size() - 1; i >= 0; i--){ + if(movies.get(i).getId() == movie.getId()){ + movies.remove(i); + } + } + return movies; + } +} diff --git a/app/src/main/java/com/example/joshh/sprint1/MovieViewModel.java b/app/src/main/java/com/example/joshh/sprint1/MovieViewModel.java new file mode 100644 index 0000000..fac78f5 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/MovieViewModel.java @@ -0,0 +1,37 @@ +package com.example.joshh.sprint1; + +import android.arch.lifecycle.LiveData; +import android.arch.lifecycle.MutableLiveData; +import android.arch.lifecycle.ViewModel; + +import java.util.ArrayList; + +public class MovieViewModel extends ViewModel { + private MovieRepository repo; + private MutableLiveData> movieList; + + public LiveData> getMovieList(){ + if(movieList == null){ + loadList(); + } + return movieList; + } + + private void loadList(){ + repo = new MovieRepository(); + movieList = repo.getMovies(); + } + + public void addMovie(Movie movie){ + if(movieList != null){ + movieList.setValue(repo.addMovie(movie)); + } + } + + public void removeMovie(Movie movie){ + if(movieList != null){ + movieList.setValue(repo.removeMovie(movie)); + } + } + +} diff --git a/app/src/main/java/com/example/joshh/sprint1/SettingsActivity.java b/app/src/main/java/com/example/joshh/sprint1/SettingsActivity.java new file mode 100644 index 0000000..be64589 --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/SettingsActivity.java @@ -0,0 +1,277 @@ +package com.example.joshh.sprint1; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.res.Configuration; +import android.media.Ringtone; +import android.media.RingtoneManager; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.support.v7.app.ActionBar; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.preference.RingtonePreference; +import android.text.TextUtils; +import android.view.MenuItem; + +import com.example.joshh.sprint1.AppCompatPreferenceActivity; +import com.example.joshh.sprint1.R; +import com.example.joshh.sprint1.ThemeUtils; + +import java.util.List; + +/** + * A {@link PreferenceActivity} that presents a set of application settings. On + * handset devices, settings are presented as a single list. On tablets, + * settings are split by category, with category headers shown to the left of + * the list of settings. + *

+ * See + * Android Design: Settings for design guidelines and the Settings + * API Guide for more information on developing a Settings UI. + */ +public class SettingsActivity extends AppCompatPreferenceActivity { + private Activity activity; + private int currentTheme; + /** + * A preference value change listener that updates the preference's summary + * to reflect its new value. + */ + private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object value) { + String stringValue = value.toString(); + + if (preference instanceof ListPreference) { + // For list preferences, look up the correct display value in + // the preference's 'entries' list. + ListPreference listPreference = (ListPreference) preference; + int index = listPreference.findIndexOfValue(stringValue); + + // Set the summary to reflect the new value. + preference.setSummary( + index >= 0 + ? listPreference.getEntries()[index] + : null); + + } else if (preference instanceof RingtonePreference) { + // For ringtone preferences, look up the correct display value + // using RingtoneManager. + if (TextUtils.isEmpty(stringValue)) { + // Empty values correspond to 'silent' (no ringtone). + preference.setSummary(R.string.pref_ringtone_silent); + + } else { + Ringtone ringtone = RingtoneManager.getRingtone( + preference.getContext(), Uri.parse(stringValue)); + + if (ringtone == null) { + // Clear the summary if there was a lookup error. + preference.setSummary(null); + } else { + // Set the summary to reflect the new ringtone display + // name. + String name = ringtone.getTitle(preference.getContext()); + preference.setSummary(name); + } + } + + } else { + // For all other preferences, set the summary to the value's + // simple string representation. + preference.setSummary(stringValue); + } + return true; + } + }; + + /** + * Helper method to determine if the device has an extra-large screen. For + * example, 10" tablets are extra-large. + */ + private static boolean isXLargeTablet(Context context) { + return (context.getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; + } + + /** + * Binds a preference's summary to its value. More specifically, when the + * preference's value is changed, its summary (line of text below the + * preference title) is updated to reflect the value. The summary is also + * immediately updated upon calling this method. The exact display format is + * dependent on the type of preference. + * + * @see #sBindPreferenceSummaryToValueListener + */ + private static void bindPreferenceSummaryToValue(Preference preference) { + // Set the listener to watch for value changes. + preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); + + // Trigger the listener immediately with the preference's + // current value. + sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, + PreferenceManager + .getDefaultSharedPreferences(preference.getContext()) + .getString(preference.getKey(), "")); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + ThemeUtils.onActivityCreateSetTheme(this); + super.onCreate(savedInstanceState); + activity = this; + setupActionBar(); + } + + @Override + public void setTheme(int resid) { + currentTheme = resid; + super.setTheme(resid); + + } + + @Override + protected void onStart() { + if(!ThemeUtils.checkTheme(activity, currentTheme)){ + ThemeUtils.refreshActivity(activity); + } + super.onStart(); + } + + /** + * Set up the {@link android.app.ActionBar}, if the API is available. + */ + private void setupActionBar() { + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + // Show the Up button in the action bar. + actionBar.setDisplayHomeAsUpEnabled(true); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean onIsMultiPane() { + return isXLargeTablet(this); + } + + /** + * {@inheritDoc} + */ + @Override + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public void onBuildHeaders(List

target) { + loadHeadersFromResource(R.xml.pref_headers, target); + } + + /** + * This method stops fragment injection in malicious applications. + * Make sure to deny any unknown fragments here. + */ + protected boolean isValidFragment(String fragmentName) { + return PreferenceFragment.class.getName().equals(fragmentName) + || GeneralPreferenceFragment.class.getName().equals(fragmentName) + || DataSyncPreferenceFragment.class.getName().equals(fragmentName) + || NotificationPreferenceFragment.class.getName().equals(fragmentName); + } + + /** + * This fragment shows general preferences only. It is used when the + * activity is showing a two-pane settings UI. + */ + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static class GeneralPreferenceFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_general); + setHasOptionsMenu(true); + + // Bind the summaries of EditText/List/Dialog/Ringtone preferences + // to their values. When their values change, their summaries are + // updated to reflect the new value, per the Android Design + // guidelines. + bindPreferenceSummaryToValue(findPreference("example_text")); + bindPreferenceSummaryToValue(findPreference("example_list")); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + startActivity(new Intent(getActivity(), SettingsActivity.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + } + + /** + * This fragment shows notification preferences only. It is used when the + * activity is showing a two-pane settings UI. + */ + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static class NotificationPreferenceFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_notification); + setHasOptionsMenu(true); + + // Bind the summaries of EditText/List/Dialog/Ringtone preferences + // to their values. When their values change, their summaries are + // updated to reflect the new value, per the Android Design + // guidelines. + bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + startActivity(new Intent(getActivity(), SettingsActivity.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + } + + /** + * This fragment shows data and sync preferences only. It is used when the + * activity is showing a two-pane settings UI. + */ + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static class DataSyncPreferenceFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_data_sync); + setHasOptionsMenu(true); + + // Bind the summaries of EditText/List/Dialog/Ringtone preferences + // to their values. When their values change, their summaries are + // updated to reflect the new value, per the Android Design + // guidelines. + bindPreferenceSummaryToValue(findPreference("sync_frequency")); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + startActivity(new Intent(getActivity(), SettingsActivity.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + } +} diff --git a/app/src/main/java/com/example/joshh/sprint1/ThemeUtils.java b/app/src/main/java/com/example/joshh/sprint1/ThemeUtils.java new file mode 100644 index 0000000..20e371e --- /dev/null +++ b/app/src/main/java/com/example/joshh/sprint1/ThemeUtils.java @@ -0,0 +1,33 @@ +package com.example.joshh.sprint1; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + +public class ThemeUtils { + static int getSelectedTheme(Activity activity){ + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); + boolean darkTheme = preferences.getBoolean(activity.getResources().getString(R.string.theme_switch_key), false); + int selectedThemeId = darkTheme ? R.style.AppDarkTheme : R.style.AppTheme; + return selectedThemeId; + } + + public static void onActivityCreateSetTheme(Activity activity){ + activity.setTheme(getSelectedTheme(activity)); + } + + public static void refreshActivity(Activity activity){ + Intent intent = activity.getIntent(); + activity.finish(); + activity.startActivity(intent); + } + + public static Boolean checkTheme(Activity activity, int activeTheme){ + if(getSelectedTheme(activity) == activeTheme){ + return true; + }else{ + return false; + } + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_action_name.png b/app/src/main/res/drawable-hdpi/ic_action_name.png new file mode 100644 index 0000000..1a42b35 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_name.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_name.png b/app/src/main/res/drawable-mdpi/ic_action_name.png new file mode 100644 index 0000000..19a8f88 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_name.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_name.png b/app/src/main/res/drawable-xhdpi/ic_action_name.png new file mode 100644 index 0000000..fa74275 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_name.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_name.png b/app/src/main/res/drawable-xxhdpi/ic_action_name.png new file mode 100644 index 0000000..7dc4d19 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_name.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_name.png b/app/src/main/res/drawable-xxxhdpi/ic_action_name.png new file mode 100644 index 0000000..6a0768c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_name.png differ diff --git a/app/src/main/res/drawable/ic_info_black_24dp.xml b/app/src/main/res/drawable/ic_info_black_24dp.xml new file mode 100644 index 0000000..158e2a7 --- /dev/null +++ b/app/src/main/res/drawable/ic_info_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..2408e30 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..95eb1ae --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_local_movies_black_24dp.xml b/app/src/main/res/drawable/ic_local_movies_black_24dp.xml new file mode 100644 index 0000000..50fb5e6 --- /dev/null +++ b/app/src/main/res/drawable/ic_local_movies_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..81db489 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_sync_black_24dp.xml b/app/src/main/res/drawable/ic_sync_black_24dp.xml new file mode 100644 index 0000000..5ede6fb --- /dev/null +++ b/app/src/main/res/drawable/ic_sync_black_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml new file mode 100644 index 0000000..87d0976 --- /dev/null +++ b/app/src/main/res/layout/activity_edit.xml @@ -0,0 +1,71 @@ + + + + + + + +