Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0-Beta4'
Browse files Browse the repository at this point in the history
  • Loading branch information
pluscubed committed Jan 6, 2015
2 parents 1343a83 + 1a4e4f2 commit ac57279
Show file tree
Hide file tree
Showing 81 changed files with 1,515 additions and 837 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ local.properties
# Crashlytics plugin (for Android Studio and IntelliJ)
crashlytics.properties
crashlytics-build.properties
com_crashlytics_export_strings.xml
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 15
versionName '0.2.0-Beta3'
versionCode 16
versionName '0.2.0-Beta4'
}

if (project.hasProperty("RELEASE_STORE_FILE")) {
Expand All @@ -46,7 +46,7 @@ android {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
Expand All @@ -65,7 +65,7 @@ android {
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
}
noCrashlytics {
versionName = android.defaultConfig.versionName + "-NOCRASHLYTICS"
versionName = android.defaultConfig.versionName + "-NoPermissions"
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
Expand Down
17 changes: 2 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,13 @@
android:name="com.pluscubed.plustimer.ui.HistorySessionListActivity"
android:theme="@style/Theme.PlusTimer.WithNavDrawer" />

<activity
android:name="com.pluscubed.plustimer.ui.HistorySolveListActivity"
android:parentActivityName="com.pluscubed.plustimer.ui.HistorySessionListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.pluscubed.plustimer.ui.HistorySessionListActivity" />
</activity>
<activity android:name="com.pluscubed.plustimer.ui.HistorySolveListActivity" />

<activity android:name="com.pluscubed.plustimer.ui.SettingsActivity" />
<activity
android:name="com.pluscubed.plustimer.ui.AboutActivity"
android:launchMode="singleTop" />
<activity
android:name="com.pluscubed.plustimer.ui.LicensesActivity"
android:parentActivityName="com.pluscubed.plustimer.ui.AboutActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.pluscubed.plustimer.ui.AboutActivity" />
</activity>
<activity android:name="com.pluscubed.plustimer.ui.LicensesActivity" />
</application>

</manifest>
17 changes: 17 additions & 0 deletions app/src/main/java/com/pluscubed/plustimer/model/BldSolve.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.pluscubed.plustimer.model;

/**
* Blind solves data object
*/
public class BldSolve extends Solve {
private long mInspectionTime;

public BldSolve(ScrambleAndSvg scramble, long solveTime, long inspectionTime) {
super(scramble, solveTime + inspectionTime);
mInspectionTime = inspectionTime;
}

public long getInspectionTime() {
return mInspectionTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import android.content.Context;

import com.pluscubed.plustimer.Util;
import com.pluscubed.plustimer.utils.Util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
Expand Down Expand Up @@ -77,4 +79,19 @@ public List<Session> getList() {
public void init(Context context) {
mHistorySessionsList = Util.getSessionListFromFile(context, mFilename);
}

public void sort() {
Collections.sort(mHistorySessionsList, new Comparator<Session>() {
@Override
public int compare(Session lhs, Session rhs) {
if (lhs.getTimestamp() > rhs.getTimestamp()) {
return 1;
} else if (lhs.getTimestamp() < rhs.getTimestamp()) {
return -1;
} else {
return 0;
}
}
});
}
}
16 changes: 11 additions & 5 deletions app/src/main/java/com/pluscubed/plustimer/model/PuzzleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import com.google.gson.JsonParseException;
import com.pluscubed.plustimer.BuildConfig;
import com.pluscubed.plustimer.R;
import com.pluscubed.plustimer.Util;
import com.pluscubed.plustimer.ui.SettingsActivity;
import com.pluscubed.plustimer.utils.Util;

import net.gnehzr.tnoodle.scrambles.Puzzle;
import net.gnehzr.tnoodle.scrambles.PuzzlePlugins;
Expand Down Expand Up @@ -59,6 +59,7 @@ public enum PuzzleType {
static {
mObservers = new ArrayList<>();
}

public final String scramblerSpec;
public final boolean official;
private final String currentSessionFileName;
Expand Down Expand Up @@ -106,14 +107,14 @@ public static PuzzleType getCurrent() {
}

public static void setCurrent(PuzzleType type, Context context) {
SharedPreferences defaultSharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
defaultSharedPreferences.edit().putString(PREF_CURRENT_PUZZLETYPE,
type.name()).apply();
if (type != sCurrentPuzzleType) {
sCurrentPuzzleType = type;
notifyPuzzleTypeChanged();
}
SharedPreferences defaultSharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
defaultSharedPreferences.edit().putString(PREF_CURRENT_PUZZLETYPE,
sCurrentPuzzleType.name()).apply();
}

public static List<PuzzleType> valuesExcludeDisabled() {
Expand Down Expand Up @@ -149,6 +150,11 @@ private synchronized void init(Context context) {

//AFTER UPDATING APP////////////
int savedVersionCode = defaultSharedPreferences.getInt(Util.PREF_VERSION_CODE, 10);

if (savedVersionCode <= 15) {
Util.updateData(context, historyFileName);
}

if (savedVersionCode <= 13) {
//Version <=13: ScrambleAndSvg json structure changes
Gson gson = new GsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.pluscubed.plustimer.model;

import com.pluscubed.plustimer.Util;
import com.pluscubed.plustimer.utils.Util;

/**
* Scramble and Svg
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/pluscubed/plustimer/model/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.pluscubed.plustimer.R;
import com.pluscubed.plustimer.Util;
import com.pluscubed.plustimer.utils.Util;

import java.lang.reflect.Type;
import java.util.ArrayList;
Expand Down Expand Up @@ -216,16 +216,17 @@ public void deleteSolve(int position) {
}

public void deleteSolve(Solve i) {
notifySolveDeleted(mSolves.indexOf(i));
int position = mSolves.indexOf(i);
mSolves.remove(i);
notifySolveDeleted(position);
}

public String toString(Context context, String puzzleTypeName,
boolean current, boolean displaySolves,
boolean milliseconds, boolean sign) {
StringBuilder s = new StringBuilder();
if (displaySolves) {
s.append(puzzleTypeName).append("\n\n");
s.append(PuzzleType.valueOf(puzzleTypeName).getUiName(context)).append("\n\n");
}
s.append(context.getString(R.string.number_solves)).append
(getNumberOfSolves());
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/pluscubed/plustimer/model/Solve.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.pluscubed.plustimer.model;

import com.pluscubed.plustimer.Util;
import com.pluscubed.plustimer.utils.Util;

/**
* solve times data object
* Solve data object
*/
public class Solve {

Expand Down
48 changes: 6 additions & 42 deletions app/src/main/java/com/pluscubed/plustimer/ui/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
Expand All @@ -18,17 +17,12 @@

import com.pluscubed.plustimer.BuildConfig;
import com.pluscubed.plustimer.R;
import com.pluscubed.plustimer.model.PuzzleType;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import com.pluscubed.plustimer.utils.Util;

/**
* About Page
*/
public class AboutActivity extends ActionBarActivity {
public class AboutActivity extends ThemableActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -106,7 +100,7 @@ public void onClick(View v) {
"mailto", "[email protected]", null));
startActivity(
Intent.createChooser(intent,
"Send email to the developer using..."));
getString(R.string.send_email)));
}
});

Expand All @@ -128,41 +122,11 @@ public void onClick(View v) {
}
});

//TODO: Remove once History bug fixed
Button bug = (Button) view.findViewById(R.id.fragment_about_email_history_button);
bug.setOnClickListener(new View.OnClickListener() {
Button send = (Button) view.findViewById(R.id.fragment_about_email_history_button);
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BufferedReader r = null;
StringBuilder total = new StringBuilder();
for (PuzzleType p : PuzzleType.values()) {
try {
total.append("\n\n\n").append(p.name());
InputStream in = getActivity().openFileInput(p.name() + ".json");
r = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (r != null) {
try {
r.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Intent intent = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts(
"mailto", "[email protected]", null));
intent.putExtra(Intent.EXTRA_TEXT, total.toString());
startActivity(
Intent.createChooser(intent,
"Send email using..."));
Util.sendHistoryDataEmail(getActivity());

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
public interface CreateDialogCallback {

void createSolveDialog(String displayName, int sessionIndex,
int solveIndex);
void createSolveDisplayDialog(String displayName, int sessionIndex,
int solveIndex);

void createSolveAddDialog(String displayName, int sessionIndex);
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,36 @@ public void onNothingSelected(AdapterView<?> parent) {
} else {
displayScrambleImage.setVisible(false);
share.setVisible(true);
/*TODO: Set visible to true once dialog editing is fully
implemented*/
addSolve.setVisible(false);
addSolve.setVisible(true);
}
}
return super.onCreateOptionsMenu(menu);
}

@Override
public void createSolveDialog(String displayName, int sessionIndex,
int solveIndex) {
public void createSolveDisplayDialog(String displayName, int sessionIndex,
int solveIndex) {
DialogFragment dialog = (DialogFragment) getFragmentManager()
.findFragmentByTag(DIALOG_SOLVE_TAG);
if (dialog == null) {
SolveDialogFragment d = SolveDialogFragment.newInstance
SolveDialogFragment d = SolveDialogFragment.newInstanceDisplay
(PuzzleType.getCurrent().name(),
PuzzleType.CURRENT_SESSION, solveIndex);
d.show(getFragmentManager(), DIALOG_SOLVE_TAG);
}
}

@Override
public void createSolveAddDialog(String displayName, int sessionIndex) {
DialogFragment dialog = (DialogFragment) getFragmentManager()
.findFragmentByTag(DIALOG_SOLVE_TAG);
if (dialog == null) {
SolveDialogFragment d = SolveDialogFragment.newInstanceAdd
(PuzzleType.getCurrent().name(), PuzzleType.CURRENT_SESSION);
d.show(getFragmentManager(), DIALOG_SOLVE_TAG);
}
}

public class CurrentSessionPagerAdapter extends FragmentPagerAdapter {

private final String[] mPageTitles;
Expand Down
Loading

0 comments on commit ac57279

Please sign in to comment.