Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a dope ass checkbox to the checklist item view #61

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
//noinspection GroovyMissingReturnStatement
defaultConfig {
applicationId "com.g11x.checklistapp.rst"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
versionCode 3
versionName "2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resValue("string", "content_provider_authority", "com.g11x.checklistapp.provider")
}
Expand Down
42 changes: 42 additions & 0 deletions app/google-services-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "842466790122",
"firebase_url": "https://rst-checklist.firebaseio.com",
"project_id": "rst-checklist",
"storage_bucket": "rst-checklist.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:842466790122:android:262ecc79e734b009",
"android_client_info": {
"package_name": "com.g11x.checklistapp.rst"
}
},
"oauth_client": [
{
"client_id": "842466790122-2vgb19k35qnjqgnpl7rv4b06ctc3su7s.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCvo1PP43J_OFbQob_xPKTtYTNVppYm2tI"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
19 changes: 12 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2016 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,20 +18,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.g11x.checklistapp">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".ChecklistActivity">
<activity
android:name=".MainActivity"
android:noHistory="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ChecklistActivity"/>
<activity
android:name=".ChecklistItemActivity"
android:parentActivityName=".ChecklistActivity"/>
Expand All @@ -52,10 +56,12 @@
<activity
android:name=".ImportantInformationItemActivity"
android:parentActivityName=".ImportantInformationActivity"/>

<provider
android:authorities="@string/content_provider_authority"
android:name=".LocalRepository"
android:exported="false" />
android:authorities="@string/content_provider_authority"
android:exported="false"/>

<service
android:name=".services.NotificationService"
android:exported="false">
Expand All @@ -64,5 +70,4 @@
</intent-filter>
</service>
</application>
</manifest>

</manifest>
31 changes: 16 additions & 15 deletions app/src/main/java/com/g11x/checklistapp/AppPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.g11x.checklistapp.language.Language;

Expand All @@ -33,26 +32,16 @@
public class AppPreferences {

private static final String PREF_PREFERRED_LANGUAGE = "PREF_PREFERRED_LANGUAGE";

/**
* Returns whether the user has chosen to override the system's default language.
*
* @param context component context used to retrieve shared preferences
*/
public static boolean isLanguageOverriden(@NonNull Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
String value = sp.getString(PREF_PREFERRED_LANGUAGE, null);
return TextUtils.isEmpty(value);
}
private static final String HAS_SEEN_WELCOME_SCREEN = "HAS_SEEN_WELCOME_SCREEN";

/**
* Saves the user's language preference which overrides the system default.
*
* @param context component context used to retrieve shared preferences
* @param language the language identifier or null to unset
*/
public static void setLanguageOverride(@NonNull Context context,
@Nullable Language language) {
static void setLanguageOverride(@NonNull Context context,
@Nullable Language language) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sp.edit();
if (language == null || language.equals(Language.SystemDefault)) {
Expand Down Expand Up @@ -106,7 +95,19 @@ void unregister(@NonNull Context context) {
sp.unregisterOnSharedPreferenceChangeListener(listener);
}

abstract void onChanged(@NonNull Language newLangauge);
abstract void onChanged(@NonNull Language newLanguage);
}

static boolean hasSeenWelcomeScreen(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
String value = sp.getString(HAS_SEEN_WELCOME_SCREEN, "false");
return value.equals("true");
}

static void setHasSeenWelcomeScreen(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sp.edit();
editor.putString(HAS_SEEN_WELCOME_SCREEN, "true");
editor.apply();
}
}
16 changes: 15 additions & 1 deletion app/src/main/java/com/g11x/checklistapp/ChecklistActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import com.firebase.ui.database.FirebaseRecyclerAdapter;
Expand Down Expand Up @@ -74,7 +75,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
protected void populateViewHolder(
final ChecklistItemHolder itemHolder, ChecklistItem model, final int position) {
final ChecklistItemHolder itemHolder, final ChecklistItem model, final int position) {
Boolean isDone = isDoneMapping.get(model.getHash());
if (isDoneMapping.get(model.getHash()) == null) {
isDone = false;
Expand All @@ -90,6 +91,12 @@ public void onClick(View view) {
startActivity(intent);
}
});
itemHolder.setCheckBoxOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
model.setDone(getContentResolver(), !model.isDone(getContentResolver()));
}
});
}
};
recyclerView.setAdapter(checklistAdapter);
Expand Down Expand Up @@ -124,6 +131,8 @@ public void markDone(boolean done) {
} else {
textView.setPaintFlags(textView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
}
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
checkBox.setChecked(done);
}

public void setText(String title) {
Expand All @@ -139,6 +148,11 @@ public void setOnClickListener(View.OnClickListener listener) {
TextView textView = (TextView) view.findViewById(R.id.info_text);
textView.setOnClickListener(listener);
}

void setCheckBoxOnClickListener(View.OnClickListener listener) {
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
checkBox.setOnClickListener(listener);
}
}

@Override
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/java/com/g11x/checklistapp/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright © 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.g11x.checklistapp;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (AppPreferences.hasSeenWelcomeScreen(this)) {
goToChecklist();
return;
}

setContentView(R.layout.activity_main);

Button button = (Button) findViewById(R.id.letsgo);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppPreferences.setHasSeenWelcomeScreen(MainActivity.this);
goToChecklist();
}
});
}

private void goToChecklist() {
startActivity(new Intent(MainActivity.this, ChecklistActivity.class));
}
}
26 changes: 26 additions & 0 deletions app/src/main/res/drawable/ic_chevron_right_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
~ Copyright © 2016 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/primary"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
</vector>
Binary file added app/src/main/res/drawable/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2016 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<android.support.constraint.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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.g11x.checklistapp.MainActivity">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/splash"
app:layout_constraintBottom_toBottomOf="@+id/activity_main"
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main"
app:layout_constraintTop_toTopOf="@+id/activity_main"
tools:ignore="ContentDescription"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/activity_main"
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main"
app:layout_constraintTop_toTopOf="@+id/activity_main">

<TextView
android:id="@+id/welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Welcome to Austin!"
android:textAppearance="@android:style/TextAppearance.Material.Headline"
android:textColor="@color/primary"
tools:targetApi="lollipop"/>

<TextView
style="@style/AppDescriptionTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/welcome"
android:padding="20dp"
android:text="We're happy you're here! We'd like to help you get settled in your new home, so we've put together a list of tasks to complete, and we'll send you occaisional updates from Refugee Services of Texas."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*occasional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u 🎸 mike #64

android:textColor="@color/primary_dark"
/>
</RelativeLayout>

<Button
android:id="@+id/letsgo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="20dp"
android:text="Let's go!"
app:layout_constraintBottom_toBottomOf="@+id/activity_main"
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main"/>
</android.support.constraint.ConstraintLayout>
Loading