Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/IstrajI/Insight
Browse files Browse the repository at this point in the history
# Conflicts:
#	.idea/modules.xml
#	MyApplication/dependencies.gradle
#	app/build.gradle
#	app/src/main/java/com/npgames/insight/ui/book/top_panel/TopPanelView.java
#	build.gradle
#	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
IstrajI committed Jun 1, 2019
2 parents e903232 + 6dde3b6 commit 60e3ad5
Show file tree
Hide file tree
Showing 76 changed files with 1,506 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ dependencies {
implementation 'com.android.support:multidex:1.0.0'

//Moxy lib
implementation 'com.arello-mobile:moxy:1.5.1'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.1'
implementation 'com.arello-mobile:moxy:1.5.5'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.5'
implementation 'com.arello-mobile:moxy-android:1.5.5'

//ButterKnife lib
implementation 'com.jakewharton:butterknife:8.5.1'
Expand All @@ -53,4 +54,7 @@ dependencies {

implementation 'com.uncopt:android.justified:1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

//MaterialTapTargetPrompt
implementation 'uk.co.samuelwall:material-tap-target-prompt:2.14.0'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<activity android:name=".ui.player.CreatePlayerActivity" android:noHistory="true"/>
<activity android:name=".ui.book.armory.ArmoryActivity" android:noHistory="true"/>
<activity android:name=".ui.home.authors.AuthorsActivity" android:noHistory="true"/>

<activity android:name=".ui.directory.DirectoryActivity" android:noHistory="true"/>
<service android:name=".application.MusicService"/>
</application>

Expand Down
96 changes: 96 additions & 0 deletions app/src/main/java/com/npgames/insight/MvpDialogFragmentCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.npgames.insight;

import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;

import com.arellomobile.mvp.MvpDelegate;
import com.arellomobile.mvp.MvpDialogFragment;

public class MvpDialogFragmentCompat extends DialogFragment {
private boolean mIsStateSaved;
private MvpDelegate<? extends MvpDialogFragmentCompat> mMvpDelegate;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getMvpDelegate().onCreate(savedInstanceState);
}

public void onResume() {
super.onResume();

mIsStateSaved = false;

getMvpDelegate().onAttach();
}

public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

mIsStateSaved = true;

getMvpDelegate().onSaveInstanceState(outState);
getMvpDelegate().onDetach();
}

@Override
public void onStop() {
super.onStop();

getMvpDelegate().onDetach();
}

@Override
public void onDestroyView() {
super.onDestroyView();

getMvpDelegate().onDetach();
getMvpDelegate().onDestroyView();
}

@Override
public void onDestroy() {
super.onDestroy();

//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}

// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}

// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;

if (Build.VERSION.SDK_INT >= 17) {
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
}

if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}

/**
* @return The {@link MvpDelegate} being used by this Fragment.
*/
public MvpDelegate getMvpDelegate() {
if (mMvpDelegate == null) {
mMvpDelegate = new MvpDelegate<>(this);
}

return mMvpDelegate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.npgames.insight.data.model.BlockArea;
import com.npgames.insight.data.model.BlockButton;
import com.npgames.insight.data.model.BlockText;
import com.npgames.insight.data.model.create_player.BlockCreatePlayerDex;

import java.util.ArrayList;
import java.util.Formatter;
Expand Down Expand Up @@ -67,15 +68,35 @@ public static List<BlockArea> parse(final String paragraphText) {

final String substringText = paragraphText.substring(lastMatchEndPosition, matchStartPosition);

final String textBlockText = cutExtremalSpaces(substringText);
final BlockText textBlock = new BlockText(textBlockText);
paragraphBlocks.add(textBlock);
paragraphBlocks.add(clickBlock);
//Kostil
final Pattern createPanelPattern = Pattern.compile("\\$create_panel\\$");
final Matcher createPanelMatcher = createPanelPattern.matcher(paragraphText);

boolean createPanelFound = createPanelMatcher.find();
if (createPanelFound) {
Log.d("TestPish", "found");
final int createPanelStartPosition = createPanelMatcher.start();
final int createPanelEndPosition = createPanelMatcher.end();

final String firstBlockText = cutExtremalSpaces(substringText.substring(0, createPanelStartPosition));
final String secondBlockText = cutExtremalSpaces(substringText.substring(createPanelEndPosition));

paragraphBlocks.add(new BlockText(firstBlockText));
paragraphBlocks.add(new BlockCreatePlayerDex());
paragraphBlocks.add(new BlockText(secondBlockText));
paragraphBlocks.add(clickBlock);
} else {

final String textBlockText = cutExtremalSpaces(substringText);
final BlockText textBlock = new BlockText(textBlockText);
paragraphBlocks.add(textBlock);
paragraphBlocks.add(clickBlock);
}

lastMatchEndPosition = matchEndPosition;
}

final String tail = paragraphText.substring(lastMatchEndPosition, paragraphText.length());
final String tail = paragraphText.substring(lastMatchEndPosition);

if (tail.length() != 0) {
final BlockText textBlock = new BlockText(tail);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.npgames.insight.data.directory;

public class DirectoryItem {
public String title;
public String content;
public boolean isOpen;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.npgames.insight.data.directory;

import android.content.Context;
import android.content.res.Resources;
import android.util.Pair;

import java.util.ArrayList;
import java.util.List;

public class DirectoryRepository {
private static DirectoryRepository directoryRepository;
private final Resources resources;
private final String packageName;

private DirectoryRepository(final Context context) {
this.resources = context.getResources();
this.packageName = context.getPackageName();
}

public static DirectoryRepository getInstance(final Context context) {
if (directoryRepository == null) {
directoryRepository = new DirectoryRepository(context);
}
return directoryRepository;
}

public List<DirectoryItem> getDirectoryList() {
final List<DirectoryItem> directoryItems = new ArrayList<>();

int counter = 1;
Pair<Integer, Integer> directoryResources = getDirectoryResources(counter);
int directoryTitleResId = directoryResources.first;
int directoryContentResId = directoryResources.second;

while (directoryTitleResId != 0 && directoryContentResId != 0) {
final DirectoryItem directoryItem = new DirectoryItem();

try {
directoryItem.title = resources.getString(directoryTitleResId);
directoryItem.content = resources.getString(directoryContentResId);
directoryItems.add(directoryItem);
} catch (Resources.NotFoundException ex) {

}

counter++;
directoryResources = getDirectoryResources(counter);
directoryTitleResId = directoryResources.first;
directoryContentResId = directoryResources.second;
}

return directoryItems;
}

private Pair<Integer, Integer> getDirectoryResources(final int number) {
final String directoryTitleResName = formatTitleResName(number);
final String directoryContentResName = formatTitleResContent(number);

final int directoryTitleResId = resources.getIdentifier(directoryTitleResName, "string", packageName);
final int directoryContentResId = resources.getIdentifier(directoryContentResName, "string", packageName);

return new Pair<>(directoryTitleResId, directoryContentResId);
}

final String DIRECTORY_TITLE_RES_STRING = "directory_title_";
final String DIRECTORY_CONTENT_RES_STRING = "directory_description_";

private String formatTitleResName(final int number) {
return DIRECTORY_TITLE_RES_STRING + number;
}

private String formatTitleResContent(final int number) {
return DIRECTORY_CONTENT_RES_STRING + number;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ List<Equipment> loadEquipment() {
equipments.add(new Equipment(TYPE.POWER_SHIELD, powerShieldTakeOnStatsChanger, powerShieldTakeOffStatsChanger, powerShieldOwner, powerShieldName, powerShieldDescription));

//Targeter Shield
final Stats targeterTakeOnStatsChanger = Stats.builder().setPrc(-2).build();
final Stats targeterTakeOffStatsChanger = Stats.builder().setDex(2).build();
final Stats targeterTakeOnStatsChanger = Stats.builder().setPrc(3).setDex(-1).build();
final Stats targeterTakeOffStatsChanger = Stats.builder().setPrc(-3).setDex(1).build();
final @Equipment.Owner String targeterOwner = preferences.getString(TYPE.TARGETTER, String.valueOf(Equipment.Owner.ARRMORY));
final String targeterName = resources.getString(R.string.armory_equipment_targeter_title);
final String targeterDescription = resources.getString(R.string.armory_equipment_targeter_description);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.npgames.insight.data.model;

import android.util.Log;

import java.io.Serializable;

import static com.npgames.insight.data.model.BlockArea.BlockType.BUTTON;
Expand All @@ -23,6 +25,7 @@ public int getViewHeight() {
}

public void setEnable(final boolean isEnable) {
Log.d("TestPishCheck", "number" +paragraphNumber +" isEnable = " +isEnable);
this.isEnable = isEnable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public BlockCreatePlayerDex(){

@Override
public int getViewHeight() {
return 210;
return 450;
}

public int getDexPoints() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.npgames.insight.data.model.BlockArea;
import com.npgames.insight.data.model.BlockButton;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -12,9 +14,19 @@
*/

public class Paragraph {
@Retention(RetentionPolicy.SOURCE)
public @interface AvailableActions {
String DISABLED_ALL = "DISABLED_ALL";
String AVAILABLE_ALL = "AVAILABLE_ALL";
String AVAILABLE_FIND = "AVAILABLE_FIND";
String DISABLED_ARMORY = "DISABLED_ARMORY";
String DISABLED_MEDBAY = "DISABLED_MEDBAY";
}

public int paragraphNumber;
public boolean wasActionPressed;
public final List<Page> pages;
public @AvailableActions String availableState;

public Paragraph() {
pages = new ArrayList<>();
Expand All @@ -38,7 +50,7 @@ public List<BlockButton> getJumps() {
final List<BlockArea> blockAreas = getBlockAreas();
final List<BlockButton> blockJumps = new ArrayList();

for (final BlockArea blockArea: blockAreas) {
for (final BlockArea blockArea : blockAreas) {
if (blockArea.type == BlockArea.BlockType.BUTTON) {
blockJumps.add((BlockButton) blockArea);
}
Expand All @@ -50,7 +62,7 @@ public List<BlockButton> getJumps() {
public List<BlockAction> getActions() {
final List<BlockAction> blockActions = new ArrayList<>();

for (final BlockArea blockArea: getBlockAreas()) {
for (final BlockArea blockArea : getBlockAreas()) {
if (blockArea.type == BlockArea.BlockType.ACTION) {
blockActions.add((BlockAction) blockArea);
}
Expand All @@ -60,7 +72,7 @@ public List<BlockAction> getActions() {
}

public boolean hasActions() {
for (final BlockArea blockArea: getBlockAreas()) {
for (final BlockArea blockArea : getBlockAreas()) {
if (blockArea.type == BlockArea.BlockType.ACTION || blockArea.type == BlockArea.BlockType.CREATE_PLAYER_DEX) {
return true;
}
Expand Down
Loading

0 comments on commit 60e3ad5

Please sign in to comment.