mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
UIUtil splitted to UIUtil & UIMessageUtil
This commit is contained in:
parent
8e93c438f9
commit
e509bf81a3
14 changed files with 77 additions and 48 deletions
|
@ -45,6 +45,7 @@ import org.geometerplus.fbreader.network.opds.OPDSBookItem;
|
|||
import org.geometerplus.fbreader.network.urlInfo.BookUrlInfo;
|
||||
import org.geometerplus.fbreader.network.urlInfo.UrlInfo;
|
||||
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
class DisplayBookPopupAction extends FBAndroidAction {
|
||||
|
@ -159,7 +160,7 @@ class DisplayBookPopupAction extends FBAndroidAction {
|
|||
new QuietNetworkContext().downloadToFile(bookInfo.Url, file);
|
||||
openBook(popup, Reader.Collection.getBookByFile(fileName));
|
||||
} catch (ZLNetworkException e) {
|
||||
UIUtil.showErrorMessage(BaseActivity, "downloadFailed");
|
||||
UIMessageUtil.showErrorMessage(BaseActivity, "downloadFailed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
if (file.getPhysicalFile() != null) {
|
||||
file = file.getPhysicalFile();
|
||||
}
|
||||
UIUtil.showErrorMessage(this, "fileNotFound", file.getPath());
|
||||
UIMessageUtil.showErrorMessage(this, "fileNotFound", file.getPath());
|
||||
myBook = null;
|
||||
} else {
|
||||
NotificationUtil.drop(this, myBook);
|
||||
|
@ -391,7 +391,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
} else {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UIUtil.showErrorMessage(FBReader.this, "textNotFound");
|
||||
UIMessageUtil.showErrorMessage(FBReader.this, "textNotFound");
|
||||
popup.StartPosition = null;
|
||||
}
|
||||
});
|
||||
|
@ -949,12 +949,12 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
// methods from ZLApplicationWindow interface
|
||||
@Override
|
||||
public void showErrorMessage(String key) {
|
||||
UIUtil.showErrorMessage(this, key);
|
||||
UIMessageUtil.showErrorMessage(this, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showErrorMessage(String key, String parameter) {
|
||||
UIUtil.showErrorMessage(this, key, parameter);
|
||||
UIMessageUtil.showErrorMessage(this, key, parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.geometerplus.zlibrary.text.view.ZLTextVideoRegionSoul;
|
|||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
|
||||
import org.geometerplus.android.fbreader.httpd.DataUtil;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
|
||||
class OpenVideoAction extends FBAndroidAction {
|
||||
OpenVideoAction(FBReader baseActivity, FBReaderApp fbreader) {
|
||||
|
@ -56,7 +56,7 @@ class OpenVideoAction extends FBAndroidAction {
|
|||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
final String url = DataUtil.buildUrl(BaseActivity.DataConnection, mime, path);
|
||||
if (url == null) {
|
||||
UIUtil.showErrorMessage(BaseActivity, "videoServiceNotWorking");
|
||||
UIMessageUtil.showErrorMessage(BaseActivity, "videoServiceNotWorking");
|
||||
return;
|
||||
}
|
||||
intent.setDataAndType(Uri.parse(url), mime);
|
||||
|
@ -69,7 +69,7 @@ class OpenVideoAction extends FBAndroidAction {
|
|||
}
|
||||
}
|
||||
if (playerNotFound) {
|
||||
UIUtil.showErrorMessage(BaseActivity, "videoPlayerNotFound");
|
||||
UIMessageUtil.showErrorMessage(BaseActivity, "videoPlayerNotFound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.geometerplus.android.fbreader.dict.DictionaryUtil;
|
|||
import org.geometerplus.android.fbreader.image.ImageViewActivity;
|
||||
import org.geometerplus.android.fbreader.network.*;
|
||||
import org.geometerplus.android.fbreader.network.auth.ActivityNetworkContext;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
|
||||
class ProcessHyperlinkAction extends FBAndroidAction {
|
||||
ProcessHyperlinkAction(FBReader baseActivity, FBReaderApp fbreader) {
|
||||
|
@ -184,7 +184,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
|
|||
nLibrary.initialize(new ActivityNetworkContext(BaseActivity));
|
||||
} catch (ZLNetworkException e) {
|
||||
e.printStackTrace();
|
||||
UIUtil.showMessageText(BaseActivity, e.getMessage());
|
||||
UIMessageUtil.showMessageText(BaseActivity, e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|||
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
|
||||
public class SelectionCopyAction extends FBAndroidAction {
|
||||
SelectionCopyAction(FBReader baseActivity, FBReaderApp fbreader) {
|
||||
|
@ -41,7 +41,7 @@ public class SelectionCopyAction extends FBAndroidAction {
|
|||
final ClipboardManager clipboard =
|
||||
(ClipboardManager)BaseActivity.getApplication().getSystemService(Application.CLIPBOARD_SERVICE);
|
||||
clipboard.setText(text);
|
||||
UIUtil.showMessageText(
|
||||
UIMessageUtil.showMessageText(
|
||||
BaseActivity,
|
||||
ZLResource.resource("selection").getResource("textInBuffer").getValue().replace("%s", clipboard.getText())
|
||||
);
|
||||
|
|
|
@ -242,7 +242,7 @@ public class BookmarksActivity extends Activity implements IBookCollection.Liste
|
|||
}
|
||||
mySearchResultsAdapter.addAll(bookmarks);
|
||||
} else {
|
||||
UIUtil.showErrorMessage(this, "bookmarkNotFound");
|
||||
UIMessageUtil.showErrorMessage(this, "bookmarkNotFound");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ public class BookmarksActivity extends Activity implements IBookCollection.Liste
|
|||
if (book != null) {
|
||||
FBReader.openBookActivity(this, book, bookmark);
|
||||
} else {
|
||||
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
||||
UIMessageUtil.showErrorMessage(this, "cannotOpenBook");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ import org.geometerplus.zlibrary.text.view.ZLTextWord;
|
|||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
|
||||
import org.geometerplus.android.fbreader.FBReader;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
import org.geometerplus.android.util.PackageUtil;
|
||||
|
||||
public abstract class DictionaryUtil {
|
||||
|
@ -510,7 +510,7 @@ public abstract class DictionaryUtil {
|
|||
|
||||
private static void installDictionary(Activity activity, PackageInfo dictionaryInfo) {
|
||||
if (!PackageUtil.installFromMarket(activity, dictionaryInfo.get("package"))) {
|
||||
UIUtil.showErrorMessage(activity, "cannotRunAndroidMarket", dictionaryInfo.getTitle());
|
||||
UIMessageUtil.showErrorMessage(activity, "cannotRunAndroidMarket", dictionaryInfo.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ public class LibraryActivity extends TreeActivity<LibraryTree> implements MenuIt
|
|||
if (found) {
|
||||
openSearchResults();
|
||||
} else {
|
||||
UIUtil.showErrorMessage(LibraryActivity.this, "bookNotFound");
|
||||
UIMessageUtil.showErrorMessage(LibraryActivity.this, "bookNotFound");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.geometerplus.android.fbreader.network.action.NetworkBookActions;
|
|||
import org.geometerplus.android.fbreader.network.action.OpenCatalogAction;
|
||||
import org.geometerplus.android.fbreader.network.auth.ActivityNetworkContext;
|
||||
import org.geometerplus.android.fbreader.util.AndroidImageSynchronizer;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.ChangeListener {
|
||||
|
@ -140,7 +141,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
|
|||
uri.toString().replace("litres-book://", "http://")
|
||||
);
|
||||
} catch (ZLNetworkException e) {
|
||||
UIUtil.showMessageText(NetworkBookInfoActivity.this, e.getMessage());
|
||||
UIMessageUtil.showMessageText(NetworkBookInfoActivity.this, e.getMessage());
|
||||
}
|
||||
if (myBook != null) {
|
||||
myTree = library.getFakeBookTree(myBook);
|
||||
|
@ -445,7 +446,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
|
|||
|
||||
public void onLibraryChanged(NetworkLibrary.ChangeListener.Code code, Object[] params) {
|
||||
if (code == NetworkLibrary.ChangeListener.Code.InitializationFailed) {
|
||||
UIUtil.showMessageText(this, (String)params[0]);
|
||||
UIMessageUtil.showMessageText(this, (String)params[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.geometerplus.android.fbreader.network.action.*;
|
|||
import org.geometerplus.android.fbreader.network.auth.ActivityNetworkContext;
|
||||
import org.geometerplus.android.fbreader.tree.TreeActivity;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
|
||||
public abstract class NetworkLibraryActivity extends TreeActivity<NetworkTree> implements ListView.OnScrollListener, NetworkLibrary.ChangeListener {
|
||||
public static final int REQUEST_MANAGE_CATALOGS = 1;
|
||||
|
@ -420,14 +420,14 @@ public abstract class NetworkLibraryActivity extends TreeActivity<NetworkTree> i
|
|||
openTree((NetworkTree)params[0]);
|
||||
break;
|
||||
case NotFound:
|
||||
UIUtil.showErrorMessage(NetworkLibraryActivity.this, "emptyNetworkSearchResults");
|
||||
UIMessageUtil.showErrorMessage(NetworkLibraryActivity.this, "emptyNetworkSearchResults");
|
||||
getListView().invalidateViews();
|
||||
break;
|
||||
case EmptyCatalog:
|
||||
UIUtil.showErrorMessage(NetworkLibraryActivity.this, "emptyCatalog");
|
||||
UIMessageUtil.showErrorMessage(NetworkLibraryActivity.this, "emptyCatalog");
|
||||
break;
|
||||
case NetworkError:
|
||||
UIUtil.showMessageText(NetworkLibraryActivity.this, (String)params[0]);
|
||||
UIMessageUtil.showMessageText(NetworkLibraryActivity.this, (String)params[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
|
||||
import org.geometerplus.android.util.UIMessageUtil;
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
@ -214,7 +215,7 @@ public abstract class TreeActivity<T extends FBTree> extends ListActivity {
|
|||
);
|
||||
break;
|
||||
case CANNOT_OPEN:
|
||||
UIUtil.showErrorMessage(TreeActivity.this, tree.getOpeningStatusMessage());
|
||||
UIMessageUtil.showErrorMessage(TreeActivity.this, tree.getOpeningStatusMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class FolderListDialogActivity extends ListActivity {
|
|||
}
|
||||
((DirectoriesAdapter)getListAdapter()).notifyDataSetChanged();
|
||||
} else if (existing != index - 1) {
|
||||
UIUtil.showMessageText(
|
||||
UIMessageUtil.showMessageText(
|
||||
this, myResource.getResource("duplicate").getValue().replace("%s", path)
|
||||
);
|
||||
}
|
||||
|
|
49
src/org/geometerplus/android/util/UIMessageUtil.java
Normal file
49
src/org/geometerplus/android/util/UIMessageUtil.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2015 FBReader.ORG Limited <contact@fbreader.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.android.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
public abstract class UIMessageUtil {
|
||||
public static void showMessageText(final Activity activity, final String text) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showErrorMessage(Activity activity, String resourceKey) {
|
||||
showMessageText(
|
||||
activity,
|
||||
ZLResource.resource("errorMessage").getResource(resourceKey).getValue()
|
||||
);
|
||||
}
|
||||
|
||||
public static void showErrorMessage(Activity activity, String resourceKey, String parameter) {
|
||||
showMessageText(
|
||||
activity,
|
||||
ZLResource.resource("errorMessage").getResource(resourceKey).getValue().replace("%s", parameter)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ import android.app.ProgressDialog;
|
|||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
@ -174,26 +173,4 @@ public abstract class UIUtil {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void showMessageText(final Activity activity, final String text) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showErrorMessage(Activity activity, String resourceKey) {
|
||||
showMessageText(
|
||||
activity,
|
||||
ZLResource.resource("errorMessage").getResource(resourceKey).getValue()
|
||||
);
|
||||
}
|
||||
|
||||
public static void showErrorMessage(Activity activity, String resourceKey, String parameter) {
|
||||
showMessageText(
|
||||
activity,
|
||||
ZLResource.resource("errorMessage").getResource(resourceKey).getValue().replace("%s", parameter)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue