Skip to content
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
25 changes: 25 additions & 0 deletions res/layout/settings_create_history_entries.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settings_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="6dip"
android:orientation="horizontal">

<CheckedTextView
android:id="@+id/setting_create_history_entries"
android:text="@string/setting_create_history_entries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="7dp"
android:layout_gravity="left|top"
android:layout_weight="1"
android:checked="true"
android:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
android:textSize="20sp"/>

</LinearLayout>
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<string name="action_fullscreen">Full Screen</string>
<string name="setting_use_volume_for_nav">Use volume buttons for navigation</string>
<string name="setting_auto_paste">Auto-paste from clipboard</string>
<string name="setting_create_history_entries">Create new history entries</string>
<string name="find_hint">Find in page</string>
<string name="find_next">Next</string>
<string name="find_previous">Previous</string>
Expand Down
13 changes: 13 additions & 0 deletions src/itkach/aard2/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Application extends android.app.Application {
static final String PREF_UI_THEME_DARK = "dark";
static final String PREF_USE_VOLUME_FOR_NAV = "useVolumeForNav";
static final String PREF_AUTO_PASTE = "autoPaste";
static final String PREF_CREATE_HISTORY_ENTRIES = "createHistoryEntries";

private static final String TAG = Application.class.getSimpleName();

Expand Down Expand Up @@ -346,6 +347,18 @@ void setAutoPaste(boolean value) {
editor.commit();
}

boolean createHistoryEntries() {
final SharedPreferences prefs = prefs();
return prefs.getBoolean(Application.PREF_CREATE_HISTORY_ENTRIES, true);
}

void setCreateHistoryEntries(boolean value) {
final SharedPreferences prefs = prefs();
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(Application.PREF_CREATE_HISTORY_ENTRIES, value);
editor.commit();
}


String getUrl(Blob blob) {
return String.format(CONTENT_URL_TEMPLATE,
Expand Down
4 changes: 3 additions & 1 deletion src/itkach/aard2/ArticleCollectionActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ private void updateTitle(int position) {
String dictLabel = blob.owner.getTags().get("label");
actionBar.setTitle(dictLabel);
Application app = (Application)getApplication();
app.history.add(app.getUrl(blob));
if (app.createHistoryEntries()) {
app.history.add(app.getUrl(blob));
}
}
else {
actionBar.setTitle("???");
Expand Down
36 changes: 33 additions & 3 deletions src/itkach/aard2/SettingsListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public class SettingsListAdapter extends BaseAdapter implements SharedPreference
final static int POS_FAV_RANDOM = 2;
final static int POS_USE_VOLUME_FOR_NAV = 3;
final static int POS_AUTO_PASTE = 4;
final static int POS_USER_STYLES = 5;
final static int POS_CLEAR_CACHE = 6;
final static int POS_ABOUT = 7;
final static int POS_CREATE_HISTORY_ENTRIES = 5;
final static int POS_USER_STYLES = 6;
final static int POS_CLEAR_CACHE = 7;
final static int POS_ABOUT = 8;

SettingsListAdapter(Fragment fragment) {
this.fragment = fragment;
Expand Down Expand Up @@ -102,6 +103,7 @@ public View getView(int i, View convertView, ViewGroup parent) {
case POS_FAV_RANDOM: return getFavRandomSwitchView(convertView, parent);
case POS_USE_VOLUME_FOR_NAV: return getUseVolumeForNavView(convertView, parent);
case POS_AUTO_PASTE: return getAutoPasteView(convertView, parent);
case POS_CREATE_HISTORY_ENTRIES: return getCreateHistoryEntriesView(convertView, parent);
case POS_USER_STYLES: return getUserStylesView(convertView, parent);
case POS_CLEAR_CACHE: return getClearCacheView(convertView, parent);
case POS_ABOUT: return getAboutView(convertView, parent);
Expand Down Expand Up @@ -243,6 +245,34 @@ public void onClick(View v) {
return view;
}

private View getCreateHistoryEntriesView(View convertView, ViewGroup parent) {
View view;
LayoutInflater inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final Application app = (Application)context.getApplication();
if (convertView != null) {
view = convertView;
}
else {
view = inflater.inflate(R.layout.settings_create_history_entries, parent,
false);
final CheckedTextView toggle = (CheckedTextView)view.findViewById(R.id.setting_create_history_entries);
toggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean currentValue = app.createHistoryEntries();
boolean newValue = !currentValue;
app.setCreateHistoryEntries(newValue);
toggle.setChecked(newValue);
}
});
}
boolean currentValue = app.createHistoryEntries();
CheckedTextView toggle = (CheckedTextView)view.findViewById(R.id.setting_create_history_entries);
toggle.setChecked(currentValue);
return view;
}


private View getUserStylesView(View convertView, final ViewGroup parent) {
View view;
Expand Down