diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b1edcea66..ad2723ce3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -327,6 +327,7 @@
+
diff --git a/AndroidManifest.xml.pattern b/AndroidManifest.xml.pattern
index 764c9665e..4f489882a 100644
--- a/AndroidManifest.xml.pattern
+++ b/AndroidManifest.xml.pattern
@@ -327,6 +327,7 @@
+
diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml
index 9360939e1..c5cfe937f 100644
--- a/assets/resources/application/en.xml
+++ b/assets/resources/application/en.xml
@@ -616,6 +616,11 @@
+
+
+
+
+
diff --git a/res/layout/background_chooser_item.xml b/res/layout/background_chooser_item.xml
new file mode 100644
index 000000000..f3165cb7e
--- /dev/null
+++ b/res/layout/background_chooser_item.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
diff --git a/res/layout/background_preference.xml b/res/layout/background_preference.xml
new file mode 100644
index 000000000..fdb5154a6
--- /dev/null
+++ b/res/layout/background_preference.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/color_preference.xml b/res/layout/color_preference.xml
index ed242fa03..8fc88d622 100644
--- a/res/layout/color_preference.xml
+++ b/res/layout/color_preference.xml
@@ -8,8 +8,8 @@
android:paddingBottom="10dip"
android:orientation="horizontal"
>
-
+ *
+ * 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.fbreader.preferences.background;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.BitmapDrawable;
+import android.preference.Preference;
+import android.view.View;
+import android.widget.TextView;
+
+import org.geometerplus.zlibrary.core.filesystem.ZLFile;
+import org.geometerplus.zlibrary.core.options.ZLStringOption;
+import org.geometerplus.zlibrary.core.resources.ZLResource;
+import org.geometerplus.zlibrary.ui.android.R;
+import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
+
+import org.geometerplus.fbreader.fbreader.options.ColorProfile;
+
+public class BackgroundPreference extends Preference {
+ private final ZLResource myResource;
+ private final ColorProfile myProfile;
+
+ public BackgroundPreference(Context context, ColorProfile profile, ZLResource resource) {
+ super(context);
+ setWidgetLayoutResource(R.layout.background_preference);
+
+ myResource = resource;
+ myProfile = profile;
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+
+ final TextView titleView =
+ (TextView)view.findViewById(R.id.background_preference_title);
+ titleView.setText(myResource.getValue());
+
+ final TextView summaryView =
+ (TextView)view.findViewById(R.id.background_preference_summary);
+ final View previewWidget = view.findViewById(R.id.background_preference_widget);
+ final String value = myProfile.WallpaperOption.getValue();
+ if (value.length() == 0) {
+ summaryView.setText(myResource.getResource("solidColor").getValue());
+ previewWidget.setBackgroundColor(
+ ZLAndroidColorUtil.rgb(myProfile.BackgroundOption.getValue())
+ );
+ } else {
+ if (value.startsWith("/")) {
+ summaryView.setText(value.substring(value.lastIndexOf("/") + 1));
+ } else {
+ final String key =
+ value.substring(value.lastIndexOf("/") + 1, value.lastIndexOf("."));
+ summaryView.setText(myResource.getResource(key).getValue());
+ }
+ try {
+ previewWidget.setBackgroundDrawable(
+ new BitmapDrawable(
+ getContext().getResources(),
+ ZLFile.createFileByPath(value).getInputStream()
+ )
+ );
+ } catch (Throwable t) {
+ // ignore
+ }
+ }
+ }
+
+ @Override
+ protected void onClick() {
+ ((Activity)getContext()).startActivity(new Intent(getContext(), Chooser.class));
+ }
+}
diff --git a/src/org/geometerplus/android/fbreader/preferences/background/Chooser.java b/src/org/geometerplus/android/fbreader/preferences/background/Chooser.java
new file mode 100644
index 000000000..347160b09
--- /dev/null
+++ b/src/org/geometerplus/android/fbreader/preferences/background/Chooser.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009-2014 Geometer Plus
+ *
+ * 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.fbreader.preferences.background;
+
+import android.app.ListActivity;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+
+import org.geometerplus.zlibrary.core.resources.ZLResource;
+import org.geometerplus.zlibrary.ui.android.R;
+
+import org.geometerplus.android.util.FileChooserUtil;
+
+public class Chooser extends ListActivity implements AdapterView.OnItemClickListener {
+ private final ZLResource myResource = ZLResource.resource("Preferences").getResource("colors").getResource("background");
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ setTitle(myResource.getValue());
+ final ArrayAdapter adapter = new ArrayAdapter(
+ this, R.layout.background_chooser_item, R.id.background_chooser_item_title
+ );
+ final ZLResource chooserResource = myResource.getResource("chooser");
+ adapter.add(chooserResource.getResource("solidColor").getValue());
+ adapter.add(chooserResource.getResource("predefined").getValue());
+ adapter.add(chooserResource.getResource("selectFile").getValue());
+ setListAdapter(adapter);
+ getListView().setOnItemClickListener(this);
+ }
+
+ public final void onItemClick(AdapterView> parent, View view, int position, long id) {
+ System.err.println("CLICKED:" + position);
+ switch (position) {
+ case 0:
+ break;
+ case 1:
+ break;
+ case 2:
+ FileChooserUtil.runFileChooser(this, 2, myResource.getValue(), "");
+ break;
+ }
+ }
+}
diff --git a/src/org/geometerplus/android/util/FileChooserUtil.java b/src/org/geometerplus/android/util/FileChooserUtil.java
index 959c8afae..9abcbf7be 100644
--- a/src/org/geometerplus/android/util/FileChooserUtil.java
+++ b/src/org/geometerplus/android/util/FileChooserUtil.java
@@ -51,6 +51,25 @@ public abstract class FileChooserUtil {
activity.startActivityForResult(intent, requestCode);
}
+ public static void runFileChooser(
+ Activity activity,
+ int requestCode,
+ String title,
+ String initialValue
+ ) {
+ final Intent intent = new Intent(activity, FileChooserActivity.class);
+ intent.putExtra(FileChooserActivity._TextResources, textResources(title));
+ intent.putExtra(FileChooserActivity._Rootpath, (Parcelable)new LocalFile(initialValue));
+ intent.putExtra(FileChooserActivity._ActionBar, true);
+ intent.putExtra(FileChooserActivity._SaveLastLocation, false);
+ intent.putExtra(FileChooserActivity._DisplayHiddenFiles, false);
+ intent.putExtra(
+ FileChooserActivity._FilterMode,
+ IFileProvider.FilterMode.FilesOnly
+ );
+ activity.startActivityForResult(intent, requestCode);
+ }
+
public static void runDirectoryChooser(
Activity activity,
int requestCode,
diff --git a/src/org/geometerplus/fbreader/tips/TipsManager.java b/src/org/geometerplus/fbreader/tips/TipsManager.java
index 57e0c67b5..dde122b33 100644
--- a/src/org/geometerplus/fbreader/tips/TipsManager.java
+++ b/src/org/geometerplus/fbreader/tips/TipsManager.java
@@ -139,7 +139,8 @@ public class TipsManager {
? Action.None : Action.Download;
}
} else if (!TipsAreInitializedOption.getValue()) {
- return Action.Initialize;
+ //return Action.Initialize;
+ return Action.None;
}
return Action.None;
}
diff --git a/third-party/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/FileChooserActivity.java b/third-party/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/FileChooserActivity.java
index 27fc8ec92..aae30b763 100755
--- a/third-party/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/FileChooserActivity.java
+++ b/third-party/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/FileChooserActivity.java
@@ -789,10 +789,10 @@ public class FileChooserActivity extends Activity {
if(mIsActionBar){
viewGroupFooterContainer.setVisibility(View.VISIBLE);
viewGroupFooterBottom.setVisibility(View.VISIBLE);
- if(mFileProvider.getFilterMode() != IFileProvider.FilterMode.FilesOnly){
+ if (mFileProvider.getFilterMode() != IFileProvider.FilterMode.FilesOnly) {
mBtnOk.setVisibility(View.VISIBLE);
mBtnOk.setOnClickListener(mBtnOk_ActionBar_OnClickListener);
- }else{
+ } else {
mBtnOk.setVisibility(View.GONE);
}
mBtnCancel.setVisibility(View.VISIBLE);
@@ -1465,8 +1465,8 @@ public class FileChooserActivity extends Activity {
* @param files
* list of {@link IFile}
*/
- private void doFinish(IFile... files) {
- List list = new ArrayList();
+ private void doFinish(IFile ... files) {
+ final List list = new ArrayList();
for (IFile f : files)
list.add(f);
doFinish((ArrayList) list);
@@ -1483,7 +1483,7 @@ public class FileChooserActivity extends Activity {
// set results
switch(mFileProvider.getFilterMode()){
case FilesOnly:
- if(files == null || files.isEmpty()){
+ if (files == null || files.isEmpty()) {
setResult(RESULT_CANCELED);
finish();
return;