Skip to content

Commit

Permalink
resolves #83, #84
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmwadime committed Jul 6, 2016
1 parent ccc7f90 commit cfc47d9
Show file tree
Hide file tree
Showing 26 changed files with 19 additions and 67 deletions.
19 changes: 10 additions & 9 deletions app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Mozilla-DSO-Quiz-Application" external.system.module.version="0.1.7-SNAPSHOT" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Mozilla-DSO-Quiz-Application" external.system.module.version="0.1.8-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -64,14 +64,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
Expand All @@ -80,6 +72,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
Expand All @@ -104,6 +104,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
Expand Down
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ android {
debug {
debuggable true
minifyEnabled true
//applicationIdSuffix ".dev"
shrinkResources true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand All @@ -36,7 +35,6 @@ android {
qualityassurance {
debuggable true
minifyEnabled true
//applicationIdSuffix ".dev"
shrinkResources true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

private List<Topic> getTopics() {
List<Topic> list = new ArrayList<Topic>();
list.add(get("connect_wifi", "Connecting to WiFi", R.drawable.circular_wifi));
list.add(get("wifi", "Wi-Fi ni Noma!", R.drawable.circular_wifi));
list.add(get("connect_wifi", "Connecting to WiFi", R.drawable.circular_wifi));
list.add(get("tracking_data", "How much data are you using?", R.drawable.circular_cell));
list.add(get("data", "Using your data wisely", R.drawable.circular_money));
list.add(get("playstore", "Find new apps!", R.drawable.circular_googleplay));
list.add(get("storage", "Free up memory for new apps", R.drawable.circular_sdcard));
list.add(get("icons", "What is that icon?", R.drawable.circular_help));
list.add(get("airplane_mode", "Using Airplane Mode", R.drawable.circular_airplane));
list.add(get("accounts_passwords", "Strengthen your Passwords!", R.drawable.circular_account));

return list;
}

Expand Down Expand Up @@ -104,7 +103,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

private void needPermissionDialog(final int requestCode){
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMessage("You need to allow permission");
builder.setMessage("Jisort needs permissions.");
builder.setPositiveButton("OK",
new android.content.DialogInterface.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
public abstract class JSONHandler {

protected static Context mContext;

public JSONHandler(Context context) {
mContext = context;
}

public abstract void makeContentProviderOperations(ArrayList<ContentProviderOperation> list);

public abstract void process(JsonElement element);

public static String parseResource(Context context, int resource) throws IOException {
InputStream is = context.getResources().openRawResource(resource);
Writer writer = new StringWriter();
Expand All @@ -40,7 +36,6 @@ public static String parseResource(Context context, int resource) throws IOExcep
} finally {
is.close();
}

return writer.toString();
}
}
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/java/com/mozilla/hackathon/kiboko/io/QuizHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,27 @@
import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.mozilla.hackathon.kiboko.models.Question;
import com.mozilla.hackathon.kiboko.provider.DsoContract;
import com.mozilla.hackathon.kiboko.provider.DsoContractHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import static com.mozilla.hackathon.kiboko.utilities.LogUtils.LOGD;
import static com.mozilla.hackathon.kiboko.utilities.LogUtils.LOGW;
import static com.mozilla.hackathon.kiboko.utilities.LogUtils.makeLogTag;

/**
* Created by Brian Mwadime on 25/06/2016.
*/
public class QuizHandler extends JSONHandler {
private static final String TAG = makeLogTag(QuizHandler.class);
private HashMap<String, Question> mQuiz = new HashMap<String, Question>();


public QuizHandler(Context context) {
super(context);

}

@Override
Expand All @@ -45,15 +39,12 @@ public void process(JsonElement element) {
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
Uri uri = DsoContractHelper.setUriAsCalledFromSyncAdapter(
DsoContract.Quizes.CONTENT_URI);

// build a map of tutorial to tutorial import hashcode so we know what to update,
// what to insert, and what to delete
HashMap<String, String> tutorialHashCodes = loadQuizHashCodes();
boolean incrementalUpdate = (tutorialHashCodes != null) && (tutorialHashCodes.size() > 0);

// set of tutorials that we want to keep after the sync
HashSet<String> tutorialsToKeep = new HashSet<String>();

if (incrementalUpdate) {
LOGD(TAG, "Doing incremental update for tutorials.");
} else {
Expand All @@ -65,11 +56,9 @@ public void makeContentProviderOperations(ArrayList<ContentProviderOperation> li
for (Question question : mQuiz.values()) {
// Set the tutorial grouping order in the object, so it can be used in hash calculation
question.groupingOrder = computeTypeOrder(question);

// compute the incoming tutorial's hashcode to figure out if we need to update
String hashCode = question.getID();
tutorialsToKeep.add(question.id);

// add tutorial, if necessary
if (!incrementalUpdate || !tutorialHashCodes.containsKey(question.id) ||
!tutorialHashCodes.get(question.id).equals(hashCode)) {
Expand Down Expand Up @@ -130,7 +119,6 @@ private HashMap<String, String> loadQuizHashCodes() {
}

StringBuilder mStringBuilder = new StringBuilder();

private void buildQuiz(boolean isInsert,
Question question, ArrayList<ContentProviderOperation> list) {
ContentProviderOperation.Builder builder;
Expand All @@ -139,13 +127,11 @@ private void buildQuiz(boolean isInsert,
Uri thisQuizUri = DsoContractHelper
.setUriAsCalledFromSyncAdapter(DsoContract.Quizes.buildQuizUri(
question.id));

if (isInsert) {
builder = ContentProviderOperation.newInsert(allQuizsUri);
} else {
builder = ContentProviderOperation.newUpdate(thisQuizUri);
}

builder.withValue(DsoContract.SyncColumns.UPDATED, System.currentTimeMillis())
.withValue(DsoContract.Quizes.KEY_ID, question.id)
.withValue(DsoContract.Quizes.KEY_QUESTION, question.question)
Expand All @@ -166,7 +152,6 @@ private void buildQuiz(boolean isInsert,
private int computeTypeOrder(Question tutorial) {
int order = Integer.MAX_VALUE;
int quizOrder = -1;

return order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,28 @@
import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.mozilla.hackathon.kiboko.models.Tutorial;
import com.mozilla.hackathon.kiboko.provider.DsoContract;
import com.mozilla.hackathon.kiboko.provider.DsoContract.Tutorials;
import com.mozilla.hackathon.kiboko.provider.DsoContractHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import static com.mozilla.hackathon.kiboko.utilities.LogUtils.LOGD;
import static com.mozilla.hackathon.kiboko.utilities.LogUtils.LOGW;
import static com.mozilla.hackathon.kiboko.utilities.LogUtils.makeLogTag;

/**
* Created by Brian Mwadime on 25/06/2016.
*/
public class TutorialsHandler extends JSONHandler {
private static final String TAG = makeLogTag(TutorialsHandler.class);
private HashMap<String, Tutorial> mTutorials = new HashMap<String, Tutorial>();


public TutorialsHandler(Context context) {
super(context);

}

@Override
public void process(JsonElement element) {
for (Tutorial tutorial : new Gson().fromJson(element, Tutorial[].class)) {
Expand All @@ -46,43 +38,33 @@ public void process(JsonElement element) {
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
Uri uri = DsoContractHelper.setUriAsCalledFromSyncAdapter(
DsoContract.Tutorials.CONTENT_URI);

// build a map of tutorial to tutorial import hashcode so we know what to update,
// what to insert, and what to delete
HashMap<String, String> tutorialHashCodes = loadTutorialHashCodes();
boolean incrementalUpdate = (tutorialHashCodes != null) && (tutorialHashCodes.size() > 0);

// set of tutorials that we want to keep after the sync
HashSet<String> tutorialsToKeep = new HashSet<String>();

if (incrementalUpdate) {
LOGD(TAG, "Doing incremental update for tutorials.");
} else {
LOGD(TAG, "Doing full (non-incremental) update for tutorials.");
list.add(ContentProviderOperation.newDelete(uri).build());
}

int updatedtutorials = 0;
for (Tutorial tutorial : mTutorials.values()) {
// Set the tutorial grouping order in the object, so it can be used in hash calculation
tutorial.groupingOrder = computeTypeOrder(tutorial);

// compute the incoming tutorial's hashcode to figure out if we need to update
String hashCode = tutorial.getImportHashCode();
tutorialsToKeep.add(tutorial.id);

// add tutorial, if necessary
if (!incrementalUpdate || !tutorialHashCodes.containsKey(tutorial.id) ||
!tutorialHashCodes.get(tutorial.id).equals(hashCode)) {
++updatedtutorials;
boolean isNew = !incrementalUpdate || !tutorialHashCodes.containsKey(tutorial.id);
buildTutorial(isNew, tutorial, list);
// add relationships to speakers and track
// buildtutorialSpeakerMapping(tutorial, list);
// buildTagsMapping(tutorial, list);
}
}

int deletedtutorials = 0;
if (incrementalUpdate) {
for (String tutorialId : tutorialHashCodes.keySet()) {
Expand All @@ -92,18 +74,15 @@ public void makeContentProviderOperations(ArrayList<ContentProviderOperation> li
}
}
}

LOGD(TAG, "tutorials: " + (incrementalUpdate ? "INCREMENTAL" : "FULL") + " update. " +
updatedtutorials + " to update, " + deletedtutorials + " to delete. New total: " +
mTutorials.size());
}

private void buildDeleteOperation(String tutorialId, List<ContentProviderOperation> list) {
Uri tutorialUri = DsoContractHelper.setUriAsCalledFromSyncAdapter(
DsoContract.Tutorials.buildTutorialUri(tutorialId));
list.add(ContentProviderOperation.newDelete(tutorialUri).build());
}

private HashMap<String, String> loadTutorialHashCodes() {
Uri uri = DsoContractHelper.setUriAsCalledFromSyncAdapter(
DsoContract.Tutorials.CONTENT_URI);
Expand Down
Binary file modified app/src/main/res/drawable-nodpi/accounts5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/accounts6.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/airplanemode1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/airplanemode2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/airplanemode3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/airplanemode4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-nodpi/badimage.png
Binary file not shown.
Binary file modified app/src/main/res/drawable-nodpi/connectwifi1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/connectwifi2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/connectwifi3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/connectwifi4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-nodpi/connectwifi6.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added app/src/main/res/drawable-nodpi/load_wifi.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-nodpi/playstore2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions app/src/main/res/drawable/circular_badimage.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/src/main/res/layout/dashboard_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="@dimen/text_size_large"
style="?android:textAppearanceLarge"
android:layout_height="wrap_content"
android:text="@string/dashboard_question_text"/>
<fragment android:name="com.mozilla.hackathon.kiboko.fragments.TopicsFragment"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/raw/bootstrap_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"id": "2",
"title": "Where do I get it? Who owns it?",
"gifUrl": "wifi2",
"description": "Wi-Fi networks are created by \"hotspots\" that connect to the internet. Anyone can buy one and set it up at home, at work, or in a public space. If you can detect a Wi-Fi network on your phone, you might be able to connect to it. To learn more about connecting, read the Connecting to Wi-Fi section."
"description": "Wi-Fi networks are created by \"hotspots\" that connect to the internet. Anyone can buy one and set it up at home, at work, or in a public space. If you can detect a Wi-Fi network on your phone, you might be able to connect to it. To learn more about connecting, check out <a href=\"mozilladso:///tutorials/connect_wifi\">Connecting to Wi-Fi</a>."
}, {
"id": "3",
"title": "Saving Money",
Expand Down Expand Up @@ -59,7 +59,7 @@
"id": "6",
"title": "Entering a Password",
"gifUrl": "connectwifi6",
"description": "<i>If your phone has already connected to the correct Wi-Fi hotspot, you can skip this step, and just go enjoy the Internet. :)</i>\nSome Wi-Fi hotspots require a password. In this case, a box will appear that asks for a password. If you don’t know the password, ask for help from the owner of the hotspot. Once you have the password, use the keyboard that pops up to enter it."
"description": "<i>If your phone has already connected to the correct Wi-Fi hotspot, you can skip this step, and just go enjoy the Internet. :)</i><br>Some Wi-Fi hotspots require a password. In this case, a box will appear that asks for a password. If you don’t know the password, ask for help from the owner of the hotspot. Once you have the password, use the keyboard that pops up to enter it."
}, {
"id": "7",
"title": "Fixing Problems",
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/raw/keep.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@drawable/connectwifi1,@drawable/connectwifi2,@drawable/connectwifi3,@drawable/connectwifi4,@drawable/connectwifi5,@drawable/connectwifi6"/>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# If versions end in odd numbers they are development builds, even versions are release candidates.
# The AndroidManifest.xml must also be updated currently.
org.gradle.jvmargs=-Xmx2048M
version=0.1.7-SNAPSHOT
version=0.1.8-SNAPSHOT

# Using these variables to sync dependency version numbers across sub-projects.
android_support_lib_version = 23.4.0
Expand Down

0 comments on commit cfc47d9

Please sign in to comment.