forked from CyanogenMod/android_packages_apps_Calculator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from jogrimst/cm-13.0
#50 Personalize available operators
- Loading branch information
Showing
6 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/android/calculator2/receiver/StudentUpdatedReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.android.calculator2.receiver; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.preference.PreferenceManager; | ||
import android.util.Log; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class StudentUpdatedReceiver extends BroadcastReceiver { | ||
|
||
public static final String PREF_STUDENT_NUMBERS = "pref_student_numbers"; | ||
public static final String PREF_STUDENT_NUMERACY_SKILLS = "pref_student_numeracy_skills"; | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Log.i(getClass().getName(), "onReceive"); | ||
|
||
// Customize the user interface to match the current Student's level | ||
|
||
ArrayList<String> availableNumbers = intent.getStringArrayListExtra("availableNumbers"); | ||
Log.i(getClass().getName(), "availableNumbers: " + availableNumbers); | ||
|
||
ArrayList<String> availableNumeracySkills = intent.getStringArrayListExtra("availableNumeracySkills"); | ||
Log.i(getClass().getName(), "availableNumeracySkills: " + availableNumeracySkills); | ||
|
||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | ||
|
||
if (availableNumbers != null) { | ||
Set<String> availableNumberSet = new HashSet<>(); | ||
for (String availableNumber : availableNumbers) { | ||
availableNumberSet.add(availableNumber); | ||
} | ||
Log.i(getClass().getName(), "Storing availableNumbersSet: " + availableNumberSet); | ||
sharedPreferences.edit().putStringSet(PREF_STUDENT_NUMBERS, availableNumberSet).commit(); | ||
} | ||
|
||
if (availableNumeracySkills != null) { | ||
Set<String> availableNumeracySkillSet = new HashSet<>(); | ||
for (String availableNumeracySkill : availableNumeracySkills) { | ||
availableNumeracySkillSet.add(availableNumeracySkill); | ||
} | ||
Log.i(getClass().getName(), "Storing availableNumeracySkillSet: " + availableNumeracySkillSet); | ||
sharedPreferences.edit().putStringSet(PREF_STUDENT_NUMERACY_SKILLS, availableNumeracySkillSet).commit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters