Skip to content

Commit

Permalink
Add Lost Pig to starting list of stories. Add welcome message with sh…
Browse files Browse the repository at this point in the history
…ared prefrences saving to remove. README has more details on incomplete features.
  • Loading branch information
WakeRealityDev committed Feb 25, 2017
1 parent 15379a7 commit df46b78
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ A suggested developer ToDo list:
6. Document how to turn it into a 'publish your interactive fiction story as an Android app' like the documentation steps of AndroidIF here: https://github.com/SimonChris/AndroidIF -- both apps are built on MIT license so you can swap code between them. NOTE: AndroidIF's step 4 isn't needed, Incant runs off-the-shelf Glulx binaries with no special extensions.
7. The game Six in the room "The Giant Garden Bed" (go north 4 times), the layout of the 3-line status window is broken on a 5" Android phone. Even if you rotate the phone (starting from) Portrait to Landscape, it does not reflow the status window content.
8. (Menu) option to Mute the beep on speech input may also end up muting the speech output. Needs work.
9. Saves files to /sdcard/ without use of Android API's. Probably doesn't work well on Android 4.4 for this reason.
10. Sending story files to Thunderword, add content provider for secure exchange and to avoid /sdcard/ path usage. Suggest library: https://github.com/commonsguy/cwac-provider
11. Thunderword screen size and layout (Activity) picking user interface.
12. Some way to pick story files other than download/open (outside app) or internal picking off list. Similarly scan folders / storage for stories.

Discussion topic here on forums: http://www.intfiction.org/forum/viewtopic.php?f=38&t=21075
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
minSdkVersion 15
targetSdkVersion 25

versionCode 6
versionName "0.4.6"
versionCode 7
versionName "0.4.7"

signingConfig signingConfigs.WakeReality_androidB
}
Expand Down
24 changes: 23 additions & 1 deletion app/src/main/java/com/yrek/incant/Incant.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ public class Incant extends Activity {
private Handler handler;
private HandlerThread handlerThread;
private LruCache<String,Bitmap> coverImageCache;
protected SharedPreferences spref;

protected static HashSet<String> downloading = new HashSet<String>();
protected static boolean useStyledIntroStrings = true;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

spref = PreferenceManager.getDefaultSharedPreferences(this);

if (Build.VERSION.SDK_INT >= 23) {
getPermissionToUseStorage();
}
Expand All @@ -91,6 +95,14 @@ public void onCreate(Bundle savedInstanceState) {
downloadTimeStyle = new TextAppearanceSpan(this, R.style.story_download_time);

coverImageCache = new LruCache<String,Bitmap>(10);

if (useStyledIntroStrings) {
// Android does not seem to have a way to getText() directly from XML, so try here in code.
((TextView) findViewById(R.id.main_top_intro_title0)).setText(getText(R.string.main_intro_title0_styled));
((TextView) findViewById(R.id.main_top_intro_message0)).setText(getText(R.string.main_intro_message0_styled));
// ((TextView) findViewById(R.id.main_top_intro_message1)).setText(getText(R.string.main_intro_message1_styled));
((TextView) findViewById(R.id.main_top_intro_message1)).setVisibility(View.GONE);
}
}


Expand Down Expand Up @@ -259,6 +271,10 @@ public void run() {
};

private void refreshStoryList() {
if (spref.getBoolean("intro_dismiss", false)) {
findViewById(R.id.main_top_intro).setVisibility(View.GONE);
}

storyListAdapter.setNotifyOnChange(false);
storyListAdapter.clear();
try {
Expand Down Expand Up @@ -330,6 +346,13 @@ private SpannableStringBuilder makeStoryExtra0(Story story)
return sb;
}

public void hideIntroMessage(View view) {
SharedPreferences.Editor sprefEditor = spref.edit();
sprefEditor.putBoolean("intro_dismiss", true);
sprefEditor.commit();
refreshStoryList();
}


private class StoryListAdapter extends ArrayAdapter<Story> {
private Thread downloadingObserver = null;
Expand Down Expand Up @@ -570,7 +593,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor sprefEditor = spref.edit();

switch (id)
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<LinearLayout
android:id="@+id/main_top_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:background="#C8E6C9"
>
<TextView
android:id="@+id/main_top_intro_title0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_intro_title0"
/>
<TextView
android:id="@+id/main_top_intro_message0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_intro_message0"
/>
<TextView
android:id="@+id/main_top_intro_message1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_intro_message1"
/>
<TextView
android:id="@+id/main_top_intro_button_label0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/main_intro_button_label0"
android:onClick="hideIntroMessage"
/>
</LinearLayout>

<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/initial_story_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
<item/>
<item/>
-->



<item>Lost Pig</item>
<item>Grunk / Admiral Jota</item>
<item>And Place Under Ground</item>
<item>Winner, Best Game; Winner, Best Writing; Nominee, Best Setting; Nominee, Best Puzzles; Nominee, Best NPCs; Winner, Best Individual NPC; Winner, Best Individual PC; Nominee, Best Use of Medium - 2007 XYZZY Awards</item>
<item>http://mirror.ifarchive.org/if-archive/games/zcode/LostPig.zblorb</item>
<item/>
<item/>

</string-array>


Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@
<string name="app_intro3">This app is entire free software and the source code is available on GitHub. You are encouraged to further refine and utilize this app\'s Java source code for Android:</string>
<string name="about_intro2">This app variation, \'Incant! for Thunderword\', was extended by Wake Reality to serve as a technical demonstration of a third-party story download and launcher app for Thunderword\'s internal Glulx and Z-Machine interpreter engines.</string>
<string name="app_intro4">Special note about story data files, works of Interactive Fiction: No works are included with the download of this app. Incant!\'s opening menu is only a description and link to the stories off various public websites. Only once a story is picked from the menu is it downloaded live off the internet website. Incant! does not distribute the copyrighted story data files on it\'s own. You can long-press the menu entry to see a link to information about the story author.</string>

<string name="main_intro_title0">Welcome to Incant! for Thunderword</string>
<string name="main_intro_title0_styled">Welcome to <b>Incant! for Thunderword</b></string>
<string name="main_intro_message0">You can pick from the list below to download stories, or you can use Chrome / Firefox / Opera / Silk / other web browsers to download and open story files. This is open source, free software, published on github.com. Thank you!</string>
<string name="main_intro_message1">TIP: Long-press entries to access additional options, including Thunderword launch.</string>
<string name="main_intro_message0_styled">You can pick from the list below to download stories, or you can use Chrome / Firefox / Opera / Silk / other web browsers to download and open story files. This is open source, free software, published on github.com. Thank you!  <b>TIP:</b> Long-press entries to access additional options, including <i>Thunderword</i> launch.</string>
<string name="main_intro_message1_styled"></string>
<string name="main_intro_button_label0">[ Hide this message ]</string>
</resources>

0 comments on commit df46b78

Please # to comment.