mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
new background preference (in progress) + tips are back
This commit is contained in:
parent
8d1d11aef3
commit
31e75b7b2d
14 changed files with 271 additions and 13 deletions
|
@ -327,6 +327,7 @@
|
|||
<service android:name="org.geometerplus.android.fbreader.httpd.DataService" android:launchMode="singleTask" android:process=":dataService" android:exported="false"/>
|
||||
<service android:name="group.pals.android.lib.ui.filechooser.services.LocalFileProvider" android:exported="false"/>
|
||||
<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.preferences.background.Chooser" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.FolderListDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.EditTagsDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.EditAuthorsDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
|
|
|
@ -327,6 +327,7 @@
|
|||
<service android:name="org.geometerplus.android.fbreader.httpd.DataService" android:launchMode="singleTask" android:process=":dataService" android:exported="false"/>
|
||||
<service android:name="group.pals.android.lib.ui.filechooser.services.LocalFileProvider" android:exported="false"/>
|
||||
<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.preferences.background.Chooser" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.FolderListDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.EditTagsDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.util.EditAuthorsDialogActivity" android:configChanges="orientation|screenSize|keyboard|keyboardHidden" android:theme="@style/FBReader.Dialog" android:exported="false"/>
|
||||
|
|
|
@ -616,6 +616,11 @@
|
|||
<node name="colors" value="Colors & wallpapers">
|
||||
<node name="summary" value="Color settings"/>
|
||||
<node name="background" value="Background">
|
||||
<node name="chooser">
|
||||
<node name="solidColor" value="Solid color…"/>
|
||||
<node name="predefined" value="Predefined image…"/>
|
||||
<node name="selectFile" value="Select file…"/>
|
||||
</node>
|
||||
<node name="solidColor" value="Solid color"/>
|
||||
<node name="leather" value="Leather"/>
|
||||
<node name="sepia" value="Sepia"/>
|
||||
|
|
24
res/layout/background_chooser_item.xml
Normal file
24
res/layout/background_chooser_item.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/background_chooser_item_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
/>
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
/>
|
||||
</LinearLayout>
|
46
res/layout/background_preference.xml
Normal file
46
res/layout/background_preference.xml
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingRight="10dip"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingBottom="10dip"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<yuku.ambilwarna.widget.AmbilWarnaPrefWidgetView
|
||||
android:id="@+id/background_preference_widget"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginLeft="13dip"
|
||||
android:gravity="center_vertical|left"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/background_preference_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/background_preference_summary"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="3"
|
||||
/>
|
||||
</LinearLayout>
|
|
@ -186,7 +186,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
//new TipRunner().start();
|
||||
new TipRunner().start();
|
||||
DictionaryUtil.init(FBReader.this, null);
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null && FBReaderIntents.Action.PLUGIN.equals(intent.getAction())) {
|
||||
|
|
|
@ -44,13 +44,14 @@ import org.geometerplus.fbreader.fbreader.*;
|
|||
import org.geometerplus.fbreader.fbreader.options.*;
|
||||
import org.geometerplus.fbreader.network.sync.SyncData;
|
||||
import org.geometerplus.fbreader.network.sync.SyncUtil;
|
||||
//import org.geometerplus.fbreader.tips.TipsManager;
|
||||
import org.geometerplus.fbreader.tips.TipsManager;
|
||||
|
||||
import org.geometerplus.android.fbreader.DictionaryUtil;
|
||||
import org.geometerplus.android.fbreader.FBReader;
|
||||
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
|
||||
import org.geometerplus.android.fbreader.network.auth.ActivityNetworkContext;
|
||||
import org.geometerplus.android.fbreader.preferences.fileChooser.FileChooserCollection;
|
||||
import org.geometerplus.android.fbreader.preferences.background.BackgroundPreference;
|
||||
import org.geometerplus.android.fbreader.sync.SyncOperations;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
@ -447,6 +448,9 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
|
||||
final Screen colorsScreen = createPreferenceScreen("colors");
|
||||
|
||||
colorsScreen.addPreference(new BackgroundPreference(
|
||||
this, profile, colorsScreen.Resource.getResource("background")
|
||||
));
|
||||
final WallpaperPreference wallpaperPreference = new WallpaperPreference(
|
||||
this, profile, colorsScreen.Resource.getResource("background")
|
||||
) {
|
||||
|
@ -681,8 +685,8 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
keyBindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions
|
||||
));
|
||||
|
||||
//final Screen tipsScreen = createPreferenceScreen("tips");
|
||||
//tipsScreen.addOption(TipsManager.Instance().ShowTipsOption, "showTips");
|
||||
final Screen tipsScreen = createPreferenceScreen("tips");
|
||||
tipsScreen.addOption(TipsManager.Instance().ShowTipsOption, "showTips");
|
||||
|
||||
final Screen aboutScreen = createPreferenceScreen("about");
|
||||
aboutScreen.addPreference(new InfoPreference(
|
||||
|
|
|
@ -40,14 +40,17 @@ class ZLColorPreference extends ColorPreference {
|
|||
myTitle = resource.getResource(resourceKey).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ZLColor getSavedColor() {
|
||||
return myOption.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveColor(ZLColor color) {
|
||||
myOption.setValue(color);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2014 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* 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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2014 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* 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<String> adapter = new ArrayAdapter<String>(
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<IFile> list = new ArrayList<IFile>();
|
||||
private void doFinish(IFile ... files) {
|
||||
final List<IFile> list = new ArrayList<IFile>();
|
||||
for (IFile f : files)
|
||||
list.add(f);
|
||||
doFinish((ArrayList<IFile>) 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue