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

Compile problems solved and little capabilities added #518

Open
wants to merge 18 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
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ buildscript {
apply from: 'versions.gradle'

repositories {
maven {
url = uri("https://repo.grails.org/grails/core")
}
maven { url "https://jitpack.io" }
mavenCentral()
google()
jcenter()
//jcenter()
}

dependencies {
Expand All @@ -29,10 +34,10 @@ allprojects {
}

repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral() // Replaced jcenter with mavenCentral
google()
mavenLocal()
}
}

Expand Down
7 changes: 5 additions & 2 deletions folioreader/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.folioreader">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
<uses-permission android:name="android.permission.INTERNET" />

<uses-sdk tools:overrideLibrary="org.readium.r2.streamer, org.readium.r2.shared" />
Expand All @@ -21,14 +21,17 @@
<activity
android:name="com.folioreader.ui.activity.FolioActivity"
android:label="@string/app_name"
android:exported="true"
android:theme="@style/FolioActivityDayTheme" />

<activity
android:name="com.folioreader.ui.activity.ContentHighlightActivity"
android:exported="true"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name="com.folioreader.ui.activity.SearchActivity"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
Expand All @@ -40,4 +43,4 @@

</application>

</manifest>
</manifest>
10 changes: 8 additions & 2 deletions folioreader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ dependencies {
implementation "com.squareup.retrofit2:converter-jackson:$versions.retrofit"
implementation "com.squareup.retrofit2:converter-gson:$versions.retrofit"


implementation("com.github.kittinunf.fuel:fuel:2.2.3")
implementation("com.github.kittinunf.fuel:fuel-android:2.2.3")

// R2 modules
api("com.github.codetoart:r2-shared-kotlin:$versions.r2SharedKotlin") {
implementation("com.github.codetoart:r2-shared-kotlin:$versions.r2SharedKotlin") {
changing = true
}
api("com.github.codetoart:r2-streamer-kotlin:$versions.r2StreamerKotlin") {
implementation("com.github.codetoart:r2-streamer-kotlin:$versions.r2StreamerKotlin") {
exclude group: "org.slf4j", module: "slf4j-api"
changing = true
}
Expand All @@ -119,4 +123,6 @@ dependencies {
// Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:$versions.lifecycle"
}


apply from: '../folioreader/bintray/bintrayv1.gradle'
4 changes: 2 additions & 2 deletions folioreader/res/layout/progress_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/android:progressBarStyle" />
/>

<TextView
android:id="@+id/label_loading"
Expand All @@ -25,4 +25,4 @@
android:textColor="@android:color/white"
android:text="@string/loading" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
16 changes: 14 additions & 2 deletions folioreader/src/main/java/com/folioreader/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Config implements Parcelable {
public static final String CONFIG_IS_NIGHT_MODE = "is_night_mode";
public static final String CONFIG_THEME_COLOR_INT = "theme_color_int";
public static final String CONFIG_IS_TTS = "is_tts";
public static final String CONFIG_IS_SEARCH = "is_search";
public static final String CONFIG_ALLOWED_DIRECTION = "allowed_direction";
public static final String CONFIG_DIRECTION = "direction";
private static final AllowedDirection DEFAULT_ALLOWED_DIRECTION = AllowedDirection.ONLY_VERTICAL;
Expand All @@ -38,6 +39,7 @@ public class Config implements Parcelable {
private boolean showTts = true;
private AllowedDirection allowedDirection = DEFAULT_ALLOWED_DIRECTION;
private Direction direction = DEFAULT_DIRECTION;
private boolean showSearch = true;

/**
* Reading modes available
Expand Down Expand Up @@ -77,6 +79,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) (nightMode ? 1 : 0));
dest.writeInt(themeColor);
dest.writeByte((byte) (showTts ? 1 : 0));
dest.writeByte((byte) (showSearch ? 1 : 0));
dest.writeString(allowedDirection.toString());
dest.writeString(direction.toString());
}
Expand All @@ -87,6 +90,7 @@ protected Config(Parcel in) {
nightMode = in.readByte() != 0;
themeColor = in.readInt();
showTts = in.readByte() != 0;
showSearch = in.readByte() != 0;
allowedDirection = getAllowedDirectionFromString(LOG_TAG, in.readString());
direction = getDirectionFromString(LOG_TAG, in.readString());
}
Expand All @@ -100,6 +104,7 @@ public Config(JSONObject jsonObject) {
nightMode = jsonObject.optBoolean(CONFIG_IS_NIGHT_MODE);
themeColor = getValidColorInt(jsonObject.optInt(CONFIG_THEME_COLOR_INT));
showTts = jsonObject.optBoolean(CONFIG_IS_TTS);
showSearch = jsonObject.optBoolean(CONFIG_IS_SEARCH);
allowedDirection = getAllowedDirectionFromString(LOG_TAG,
jsonObject.optString(CONFIG_ALLOWED_DIRECTION));
direction = getDirectionFromString(LOG_TAG, jsonObject.optString(CONFIG_DIRECTION));
Expand Down Expand Up @@ -205,6 +210,14 @@ public Config setShowTts(boolean showTts) {
return this;
}

public boolean isShowSearch() {
return showSearch;
}

public void setShowSearch(boolean showSearch) {
this.showSearch = showSearch;
}

public AllowedDirection getAllowedDirection() {
return allowedDirection;
}
Expand Down Expand Up @@ -288,10 +301,9 @@ public String toString() {
", nightMode=" + nightMode +
", themeColor=" + themeColor +
", showTts=" + showTts +
", showSearch=" + showSearch +
", allowedDirection=" + allowedDirection +
", direction=" + direction +
'}';
}
}


1 change: 1 addition & 0 deletions folioreader/src/main/java/com/folioreader/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Constants {
public static final int WRITE_EXTERNAL_STORAGE_REQUEST = 102;
public static final String CHAPTER_ID = "id";
public static final String HREF = "href";
public static final String LAST_READ_LOCATOR = "com.folioreader.model.locators.last_read_locator";

public static String[] getWriteExternalStoragePerms() {
return new String[]{
Expand Down
99 changes: 72 additions & 27 deletions folioreader/src/main/java/com/folioreader/FolioReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.folioreader.model.HighLight;
import com.folioreader.model.HighlightImpl;
import com.folioreader.model.locators.ReadLocator;
Expand All @@ -17,16 +21,18 @@
import com.folioreader.ui.activity.FolioActivity;
import com.folioreader.ui.base.OnSaveHighlight;
import com.folioreader.ui.base.SaveReceivedHighlightTask;
import com.folioreader.util.DefaultReadLocatorManager;
import com.folioreader.util.OnHighlightListener;
import com.folioreader.util.ReadLocatorListener;

import java.util.List;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* Created by avez raj on 9/13/2017.
*/
Expand Down Expand Up @@ -121,41 +127,62 @@ private FolioReader(Context context) {
DbAdapter.initialize(context);

LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
localBroadcastManager.registerReceiver(highlightReceiver,
new IntentFilter(HighlightImpl.BROADCAST_EVENT));
localBroadcastManager.registerReceiver(readLocatorReceiver,
new IntentFilter(ACTION_SAVE_READ_LOCATOR));
localBroadcastManager.registerReceiver(closedReceiver,
new IntentFilter(ACTION_FOLIOREADER_CLOSED));
localBroadcastManager.registerReceiver(
highlightReceiver,
new IntentFilter(HighlightImpl.BROADCAST_EVENT)
);
localBroadcastManager.registerReceiver(
readLocatorReceiver,
new IntentFilter(ACTION_SAVE_READ_LOCATOR)
);
localBroadcastManager.registerReceiver(
closedReceiver,
new IntentFilter(ACTION_FOLIOREADER_CLOSED)
);
}

public FolioReader openBook(String deviceStoragePath, boolean isInternalStorage) {
Intent intent = getIntentFromUrl(deviceStoragePath, 0, isInternalStorage);
context.startActivity(intent);
return singleton;
}

public FolioReader openBook(String assetOrSdcardPath) {
Intent intent = getIntentFromUrl(assetOrSdcardPath, 0);
public FolioReader openBook(String assetPath) {
Intent intent = getIntentFromUrl(assetPath, 0, true);
context.startActivity(intent);
return singleton;
}

public FolioReader openBook(int rawId) {
Intent intent = getIntentFromUrl(null, rawId);
public FolioReader openBook(@RawRes int rawId) {
Intent intent = getIntentFromUrl(null, rawId, true);
context.startActivity(intent);
return singleton;
}

public FolioReader openBook(String assetOrSdcardPath, String bookId) {
Intent intent = getIntentFromUrl(assetOrSdcardPath, 0);
public FolioReader openBook(String assetPath, String bookId) {
Intent intent = getIntentFromUrl(assetPath, 0, true);
intent.putExtra(EXTRA_BOOK_ID, bookId);
context.startActivity(intent);
return singleton;
}


public FolioReader openBook(String deviceStoragePath, boolean isInternalStorage, String bookId) {
Intent intent = getIntentFromUrl(deviceStoragePath, 0, isInternalStorage);
intent.putExtra(EXTRA_BOOK_ID, bookId);
context.startActivity(intent);
return singleton;
}


public FolioReader openBook(int rawId, String bookId) {
Intent intent = getIntentFromUrl(null, rawId);
Intent intent = getIntentFromUrl(null, rawId, true);
intent.putExtra(EXTRA_BOOK_ID, bookId);
context.startActivity(intent);
return singleton;
}

private Intent getIntentFromUrl(String assetOrSdcardPath, int rawId) {
private Intent getIntentFromUrl(String path, int rawId, boolean isInternalStorage) {

Intent intent = new Intent(context, FolioActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand All @@ -166,18 +193,27 @@ private Intent getIntentFromUrl(String assetOrSdcardPath, int rawId) {

if (rawId != 0) {
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, rawId);
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.RAW);
} else if (assetOrSdcardPath.contains(Constants.ASSET)) {
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, assetOrSdcardPath);
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.ASSETS);
intent.putExtra(
FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.RAW
);
} else if (path.contains(Constants.ASSET)) {
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, path);
intent.putExtra(
FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.ASSETS
);
} else {
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, assetOrSdcardPath);
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.SD_CARD);
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, path);
intent.putExtra(
FolioActivity.INTENT_EPUB_SOURCE_TYPE,
FolioActivity.EpubSourceType.DEVICE_STORAGE
);
}

intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_STORAGE_TYPE, isInternalStorage);


return intent;
}

Expand Down Expand Up @@ -215,7 +251,8 @@ public static void initRetrofit(String streamerUrl) {
.baseUrl(streamerUrl)
.addConverterFactory(new QualifiedTypeConverterFactory(
JacksonConverterFactory.create(),
GsonConverterFactory.create()))
GsonConverterFactory.create()
))
.client(client)
.build();

Expand All @@ -232,6 +269,14 @@ public FolioReader setReadLocatorListener(ReadLocatorListener readLocatorListene
return singleton;
}


public FolioReader defaultReadLocator(@NonNull final Context context) {
DefaultReadLocatorManager defaultReadLocatorManager = new DefaultReadLocatorManager(context);
setReadLocatorListener(defaultReadLocatorManager);
setReadLocator(defaultReadLocatorManager.getLastReadLocator());
return singleton;
}

public FolioReader setOnClosedListener(OnClosedListener onClosedListener) {
this.onClosedListener = onClosedListener;
return singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,27 @@ public void setTextToSpeech(final Context context) {
mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.setSpeechRate(0.70f);
}
if (mTextToSpeech != null) {
if (status != TextToSpeech.ERROR) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.setSpeechRate(0.70f);
}

mTextToSpeech.setOnUtteranceCompletedListener(
new TextToSpeech.OnUtteranceCompletedListener() {
@Override
public void onUtteranceCompleted(String utteranceId) {
((AppCompatActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (mIsSpeaking) {
callbacks.highLightTTS();
mTextToSpeech.setOnUtteranceCompletedListener(
new TextToSpeech.OnUtteranceCompletedListener() {
@Override
public void onUtteranceCompleted(String utteranceId) {
((AppCompatActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (mIsSpeaking) {
callbacks.highLightTTS();
}
}
}
});
}
});
});
}
});
}
}
});
}
Expand Down
Loading