Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard Issue & Open/Save Issue resolved. #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
}
Expand All @@ -14,7 +14,7 @@ apply plugin: 'android-apt'

android {
compileSdkVersion 'android-23'
buildToolsVersion '23.0.3'
buildToolsVersion '27.0.3'

defaultConfig {
versionCode 4
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Thu Mar 08 12:08:52 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
4 changes: 3 additions & 1 deletion src/main/java/trikita/slide/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public enum ActionType {
NEXT_PAGE,
PREV_PAGE,

SAVE_DOCUMENT,
OPEN_DOCUMENT,
LOAD_DOCUMENT,
PICK_IMAGE,
INSERT_IMAGE,
SET_COLOR_SCHEME,
CREATE_PDF,
EXPORT_PDF
EXPORT_PDF,
EXIT_APP
}
34 changes: 34 additions & 0 deletions src/main/java/trikita/slide/middleware/StorageController.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package trikita.slide.middleware;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.pdf.PdfDocument;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -30,10 +36,14 @@
import trikita.slide.State;
import trikita.slide.ui.Style;

import static android.app.Activity.RESULT_OK;

public class StorageController implements Store.Middleware<Action<ActionType, ?>, State> {
public static final int OPEN_DOCUMENT_REQUEST_CODE = 43;
public static final int SAVE_DOCUMENT_REQUEST_CODE = 43;
public static final int PICK_IMAGE_REQUEST_CODE = 44;
public static final int EXPORT_PDF_REQUEST_CODE = 46;
public static final int OPEN_PDF_REQUEST_CODE = 47;

private static final long FILE_WRITER_DELAY = 3000; // 3sec

Expand Down Expand Up @@ -74,6 +84,9 @@ public void dispatch(Store<Action<ActionType, ?>, State> store, Action<ActionTyp
} else if (action.type == ActionType.PICK_IMAGE) {
pickImage((Activity) action.value);
return;
} else if (action.type == ActionType.EXIT_APP) {
ExitApp((Activity) action.value);
return;
} else if (action.type == ActionType.INSERT_IMAGE) {
String s = store.getState().text();
int c = store.getState().cursor();
Expand All @@ -92,6 +105,11 @@ public void dispatch(Store<Action<ActionType, ?>, State> store, Action<ActionTyp
dumpToFile(false);
openDocument((Activity) action.value);
return;
//Added to call the savedoc
} else if (action.type == ActionType.SAVE_DOCUMENT) {
dumpToFile(false);
saveDoc((Activity) action.value);
return;
} else if (action.type == ActionType.LOAD_DOCUMENT) {
String doc = loadDocument((Uri) action.value);
if (doc != null) {
Expand Down Expand Up @@ -133,8 +151,24 @@ private void saveDocument() {
}
}
}
//Exiting App
private void ExitApp(Activity a)
{
a.finishAffinity();
System.exit(0);
}

//Changed CREATE TO OPEN in order to use that function for reading purposes only
private void openDocument(Activity a) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TITLE, a.getString(R.string.default_new_doc_name));
a.startActivityForResult(intent, OPEN_DOCUMENT_REQUEST_CODE);
}

//NewFunction for Saving
private void saveDoc(Activity a) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("text/plain");
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/trikita/slide/ui/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package trikita.slide.ui;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;

import java.io.File;

import trikita.jedux.Action;
import trikita.promote.Promote;
Expand All @@ -12,12 +23,20 @@
import trikita.slide.middleware.StorageController;

public class MainActivity extends Activity {

String path = "";
@Override
public void onCreate(Bundle b) {
super.onCreate(b);
setContentView(new MainLayout(this));
App.getWindowController().setWindow(getWindow());
//Fixing the keyboard Issue #10
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//Fix the keyboard Issue #2
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}

@Override
Expand Down Expand Up @@ -63,6 +82,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} else if (requestCode == StorageController.OPEN_DOCUMENT_REQUEST_CODE) {
Uri uri = data.getData();
App.dispatch(new Action<>(ActionType.LOAD_DOCUMENT, uri));
} //Adding the save function
else if (requestCode == StorageController.SAVE_DOCUMENT_REQUEST_CODE) {
Uri uri = data.getData();
App.dispatch(new Action<>(ActionType.SAVE_DOCUMENT, uri));
}
}
}
10 changes: 8 additions & 2 deletions src/main/java/trikita/slide/ui/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ private void onOpenMenu(View v) {
//} else if (item.getItemId() == R.id.menu_settings) {
} else if (item.getItemId() == R.id.menu_export_pdf) {
App.dispatch(new Action<>(ActionType.CREATE_PDF, (Activity) v.getContext()));
}
return true;
}//Extra Menu To Seperate Save&Open Function
else if (item.getItemId() == R.id.menu_save) {
App.dispatch(new Action<>(ActionType.SAVE_DOCUMENT, (Activity) v.getContext()));
} //Extra Menu to Exit App
else if (item.getItemId() == R.id.menu_exit_app) {
App.dispatch(new Action<>(ActionType.EXIT_APP, (Activity) v.getContext()));
}
return true;
});
menu.show();
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/trikita/slide/ui/Style.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package trikita.slide.ui;

import android.content.Context;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RectShape;
import android.view.Gravity;
import android.view.View;
import android.widget.SeekBar;

import static trikita.anvil.DSL.*;

Expand All @@ -27,6 +33,11 @@ public class Style {
{0xffffffff, 0xff3f51b5, R.drawable.light_round_button, 0xff333333}, // white on indigo
{0xffffffff, 0xff75507b, R.drawable.light_round_button, 0xff333333}, // white on plum
{0xffffffff, 0xffe91e63, R.drawable.light_round_button, 0xff333333}, // white on pink
{0xffffffff, 0xff00FF00, R.drawable.light_round_button, 0xff333333}, // white on limegreen
{0xffffffff, 0xff9932CC, R.drawable.light_round_button, 0xff333333}, //white on darkorchid
{0xff222222, 0xffFFDF00, R.drawable.light_round_button, 0xff333333}, //black on gold yellow
{0xff222222, 0xffD2691E, R.drawable.light_round_button, 0xff333333}, //white on chocolate brown

};

private final static int CLOSE_BUTTON = 0;
Expand Down Expand Up @@ -86,6 +97,7 @@ public static void circle(int fgColor, int bgColor) {
textColor(fgColor);
}


public static void itemNormal() {
text("A");
textSize(sip(20));
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/menu/overflow_popup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<item
android:id="@+id/menu_open"
android:title="@string/om_open"/>
<item
android:id="@+id/menu_save"
android:title="@string/om_save"/>
<item
android:id="@+id/menu_insert_image"
android:title="@string/om_insert_image"/>
Expand All @@ -15,5 +18,8 @@
<item
android:id="@+id/menu_export_pdf"
android:title="@string/om_export_pdf"/>
<item
android:id="@+id/menu_exit_app"
android:title="Exit"/>
</menu>

2 changes: 2 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
<string name="btn_ok">Ok</string>

<string name="om_open">Open</string>
<string name="om_save">Save</string>
<string name="om_insert_image">Insert image</string>
<string name="om_style">Style</string>
<string name="om_settings">Settings</string>
<string name="om_export_pdf">Export to PDF</string>
<string name="om_exit_app">Exit</string>
</resources>