This commit is contained in:
serso 2016-01-16 15:32:21 +01:00
parent 4323c688c5
commit 45a71817c8
35 changed files with 384 additions and 354 deletions

View File

@ -101,6 +101,7 @@ dependencies {
compile 'commons-cli:commons-cli:1.2' compile 'commons-cli:commons-cli:1.2'
compile 'com.squareup:otto:1.3.8' compile 'com.squareup:otto:1.3.8'
compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton:butterknife:7.0.1'
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
compile 'com.google.dagger:dagger:2.0.2' compile 'com.google.dagger:dagger:2.0.2'
apt "com.google.dagger:dagger-compiler:2.0.2" apt "com.google.dagger:dagger-compiler:2.0.2"

View File

@ -50,8 +50,8 @@ public enum CalculatorFragmentType {
editor(CalculatorEditorFragment.class, R.layout.cpp_app_editor, R.string.editor), editor(CalculatorEditorFragment.class, R.layout.cpp_app_editor, R.string.editor),
//display(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history), //display(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history),
//keyboard(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history), //keyboard(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history),
history(RecentHistoryFragment.class, R.layout.fragment_history, R.string.c_history), history(RecentHistoryFragment.class, R.layout.fragment_history, R.string.cpp_history_tab_recent),
saved_history(SavedHistoryFragment.class, R.layout.fragment_history, R.string.c_saved_history), saved_history(SavedHistoryFragment.class, R.layout.fragment_history, R.string.cpp_history_tab_saved),
variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars), variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars),
functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions), functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions),
operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators), operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators),

View File

@ -26,36 +26,53 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.format.DateUtils;
import android.view.*; import android.view.*;
import android.widget.AdapterView; import android.widget.TextView;
import android.widget.ArrayAdapter; import butterknife.Bind;
import android.widget.ListView; import butterknife.ButterKnife;
import com.melnykov.fab.FloatingActionButton; import com.melnykov.fab.FloatingActionButton;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.views.llm.DividerItemDecoration;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class BaseHistoryFragment extends ListFragment { import static android.view.Menu.NONE;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
public abstract class BaseHistoryFragment extends Fragment {
private final boolean recentHistory;
@Inject @Inject
History history; History history;
@Inject @Inject
Bus bus; Bus bus;
private HistoryArrayAdapter adapter; @Bind(R.id.history_recyclerview)
RecyclerView recyclerView;
@Bind(R.id.history_fab)
FloatingActionButton fab;
@Nonnull @Nonnull
private FragmentUi ui; private FragmentUi ui;
private HistoryAdapter adapter;
protected BaseHistoryFragment(@Nonnull CalculatorFragmentType type) { protected BaseHistoryFragment(@Nonnull CalculatorFragmentType type) {
recentHistory = type == CalculatorFragmentType.history;
ui = new FragmentUi(type.getDefaultLayoutId(), type.getDefaultTitleResId(), false); ui = new FragmentUi(type.getDefaultLayoutId(), type.getDefaultTitleResId(), false);
} }
@ -81,46 +98,33 @@ public abstract class BaseHistoryFragment extends ListFragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
((CalculatorApplication) getActivity().getApplication()).getComponent().inject(this); ((CalculatorApplication) getActivity().getApplication()).getComponent().inject(this);
bus.register(this);
ui.onCreate(this); ui.onCreate(this);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return ui.onCreateView(this, inflater, container); final View view = ui.onCreateView(this, inflater, container);
} ButterKnife.bind(this, view);
final Context context = inflater.getContext();
@Override adapter = new HistoryAdapter(context);
public void onViewCreated(View root, Bundle savedInstanceState) { bus.register(adapter);
super.onViewCreated(root, savedInstanceState); recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
ui.onViewCreated(this, root); recyclerView.addItemDecoration(new DividerItemDecoration(context, null));
fab.attachToRecyclerView(recyclerView);
adapter = new HistoryArrayAdapter(this.getActivity(), getItemLayoutId(), R.id.history_item, new ArrayList<HistoryState>());
setListAdapter(adapter);
final ListView lv = getListView();
lv.setTextFilterEnabled(true);
final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
fab.attachToListView(lv);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
showClearHistoryDialog(); showClearHistoryDialog();
} }
}); });
return view;
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(final AdapterView<?> parent,
final View view,
final int position,
final long id) {
useState((HistoryState) parent.getItemAtPosition(position));
} }
});
registerForContextMenu(lv); @Override
public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
ui.onViewCreated(this, root);
} }
private void showClearHistoryDialog() { private void showClearHistoryDialog() {
@ -130,7 +134,11 @@ public abstract class BaseHistoryFragment extends ListFragment {
.setPositiveButton(R.string.cpp_clear_history, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.cpp_clear_history, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
clearHistory(); if (recentHistory) {
history.clearRecent();
} else {
history.clearSaved();
}
} }
}) })
.setNegativeButton(R.string.c_cancel, null) .setNegativeButton(R.string.c_cancel, null)
@ -142,33 +150,8 @@ public abstract class BaseHistoryFragment extends ListFragment {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
ui.onResume(this); ui.onResume(this);
updateAdapter();
} }
@Override
public final void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
final HistoryState state = (HistoryState) getListView().getItemAtPosition(info.position);
onCreateContextMenu(menu, state);
}
protected abstract void onCreateContextMenu(@Nonnull ContextMenu menu, @Nonnull HistoryState state);
@Override
public final boolean onContextItemSelected(MenuItem item) {
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
final HistoryState state = (HistoryState) getListView().getItemAtPosition(info.position);
if (onContextItemSelected(item, state)) {
return true;
}
return super.onContextItemSelected(item);
}
protected abstract boolean onContextItemSelected(@Nonnull MenuItem item, @Nonnull HistoryState state);
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected final void copyResult(@Nonnull HistoryState state) { protected final void copyResult(@Nonnull HistoryState state) {
final Context context = getActivity(); final Context context = getActivity();
@ -203,53 +186,188 @@ public abstract class BaseHistoryFragment extends ListFragment {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
bus.unregister(adapter);
ui.onDestroyView(this); ui.onDestroyView(this);
super.onDestroyView(); super.onDestroyView();
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
bus.unregister(this);
ui.onDestroy(this); ui.onDestroy(this);
super.onDestroy(); super.onDestroy();
} }
protected abstract int getItemLayoutId(); public class HistoryViewHolder extends RecyclerView.ViewHolder implements View.OnCreateContextMenuListener, View.OnClickListener, MenuItem.OnMenuItemClickListener {
private void updateAdapter() { private static final int DATETIME_FORMAT = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_TIME;
final List<HistoryState> historyList = getHistoryItems(); @Bind(R.id.history_item_value)
TextView valueView;
@Bind(R.id.history_item_comment)
TextView commentView;
@Bind(R.id.history_item_time)
TextView timeView;
@Nullable
private HistoryState state;
final ArrayAdapter<HistoryState> adapter = getAdapter(); public HistoryViewHolder(View view) {
try { super(view);
adapter.setNotifyOnChange(false); ButterKnife.bind(this, view);
adapter.clear(); view.setOnCreateContextMenuListener(this);
for (HistoryState historyState : historyList) { view.setOnClickListener(this);
adapter.add(historyState);
}
} finally {
adapter.setNotifyOnChange(true);
} }
adapter.notifyDataSetChanged(); void bind(@Nonnull HistoryState state) {
this.state = state;
valueView.setText(BaseHistoryFragment.getHistoryText(state));
timeView.setText(DateUtils.formatDateTime(getContext(), state.getTime(), DATETIME_FORMAT));
final String comment = state.getComment();
if (!Strings.isEmpty(comment)) {
commentView.setText(comment);
commentView.setVisibility(VISIBLE);
} else {
commentView.setText(null);
commentView.setVisibility(GONE);
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
Check.isNotNull(state);
if (recentHistory) {
addMenu(menu, R.string.c_use);
addMenu(menu, R.string.c_copy_expression);
if (shouldHaveCopyResult(state)) {
addMenu(menu, R.string.c_copy_result);
}
addMenu(menu, R.string.c_save);
} else {
addMenu(menu, R.string.c_use);
addMenu(menu, R.string.c_copy_expression);
if (shouldHaveCopyResult(state)) {
addMenu(menu, R.string.c_copy_result);
}
addMenu(menu, R.string.c_edit);
addMenu(menu, R.string.c_remove);
}
} }
@Nonnull @Nonnull
protected abstract List<HistoryState> getHistoryItems(); private MenuItem addMenu(@Nonnull ContextMenu menu, @StringRes int label) {
return menu.add(NONE, label, NONE, label).setOnMenuItemClickListener(this);
}
protected abstract void clearHistory(); @Override
public void onClick(View v) {
Check.isNotNull(state);
useState(state);
}
@Nonnull @Override
protected HistoryArrayAdapter getAdapter() { public boolean onMenuItemClick(MenuItem item) {
return adapter; Check.isNotNull(state);
switch (item.getItemId()) {
case R.string.c_use:
useState(state);
return true;
case R.string.c_copy_expression:
copyExpression(state);
return true;
case R.string.c_copy_result:
copyResult(state);
return true;
case R.string.c_edit:
EditHistoryFragment.show(state, false, getFragmentManager());
return true;
case R.string.c_save:
EditHistoryFragment.show(state, true, getFragmentManager());
return true;
case R.string.c_remove:
history.removeSaved(state);
return true;
}
return false;
}
}
public class HistoryAdapter extends RecyclerView.Adapter<HistoryViewHolder> {
@NonNull
private final LayoutInflater inflater;
@NonNull
private final List<HistoryState> list;
public HistoryAdapter(@NonNull Context context) {
inflater = LayoutInflater.from(context);
list = loadHistory();
setHasStableIds(true);
}
@NonNull
private List<HistoryState> loadHistory() {
return recentHistory ? history.getRecent() : history.getSaved();
}
@Override
public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new HistoryViewHolder(inflater.inflate(R.layout.fragment_history_item, parent, false));
}
@Override
public void onBindViewHolder(HistoryViewHolder holder, int position) {
holder.bind(list.get(position));
}
@Override
public long getItemId(int position) {
return list.get(position).hashCode();
}
@Override
public int getItemCount() {
return list.size();
} }
@Subscribe @Subscribe
void onHistoryChanged(@Nonnull History.ChangedEvent e) { public void onHistoryCleared(@Nonnull History.ClearedEvent e) {
if (e.recent != isRecentHistory()) { if (e.recent != recentHistory) {
return; return;
} }
updateAdapter(); list.clear();
notifyDataSetChanged();
} }
protected abstract boolean isRecentHistory(); @Subscribe
public void onHistoryAdded(@Nonnull History.AddedEvent e) {
if (e.recent != recentHistory) {
return;
}
list.add(e.state);
notifyItemInserted(0);
}
@Subscribe
public void onHistoryUpdated(@Nonnull History.UpdatedEvent e) {
if (e.recent != recentHistory) {
return;
}
final int i = list.indexOf(e.state);
if (i >= 0) {
list.set(i, e.state);
notifyItemChanged(i);
}
}
@Subscribe
public void onHistoryRemoved(@Nonnull History.RemovedEvent e) {
if (e.recent != recentHistory) {
return;
}
final int i = list.indexOf(e.state);
if (i >= 0) {
list.remove(i);
notifyItemRemoved(i);
}
}
}
} }

View File

@ -78,11 +78,8 @@ public class EditHistoryFragment extends BaseDialogFragment {
builder.setPositiveButton(R.string.c_save, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.c_save, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
final HistoryState.Builder b = HistoryState.builder(state) final HistoryState.Builder b = HistoryState.builder(state, newState)
.withComment(commentView.getText().toString()); .withComment(commentView.getText().toString());
if (newState) {
b.withNowTime();
}
history.updateSaved(b.build()); history.updateSaved(b.build());
} }
}); });

View File

@ -27,25 +27,22 @@ import android.content.SharedPreferences;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.AppModule;
import org.solovyev.android.calculator.Display;
import org.solovyev.android.calculator.DisplayState;
import org.solovyev.android.calculator.Editor;
import org.solovyev.android.calculator.EditorState;
import org.solovyev.android.calculator.ErrorReporter;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences; import org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences;
import org.solovyev.android.io.FileLoader; import org.solovyev.android.io.FileLoader;
import org.solovyev.android.io.FileSaver; import org.solovyev.android.io.FileSaver;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,12 +51,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import static android.text.TextUtils.isEmpty; import static android.text.TextUtils.isEmpty;
@Singleton @Singleton
@ -67,8 +58,8 @@ public class History {
public static final String TAG = App.subTag("History"); public static final String TAG = App.subTag("History");
public static final String OLD_HISTORY_PREFS_KEY = "org.solovyev.android.calculator.CalculatorModel_history"; public static final String OLD_HISTORY_PREFS_KEY = "org.solovyev.android.calculator.CalculatorModel_history";
private static final ChangedEvent CHANGED_EVENT_RECENT = new ChangedEvent(true); private static final ClearedEvent CLEARED_EVENT_RECENT = new ClearedEvent(true);
private static final ChangedEvent CHANGED_EVENT_SAVED = new ChangedEvent(false); private static final ClearedEvent CLEARED_EVENT_SAVED = new ClearedEvent(false);
private static final int MAX_INTERMEDIATE_STREAK = 5; private static final int MAX_INTERMEDIATE_STREAK = 5;
@NonNull @NonNull
private final Runnable writeRecent = new WriteTask(true); private final Runnable writeRecent = new WriteTask(true);
@ -246,7 +237,7 @@ public class History {
public void addRecent(@Nonnull HistoryState state) { public void addRecent(@Nonnull HistoryState state) {
Check.isMainThread(); Check.isMainThread();
recent.add(state); recent.add(state);
onRecentChanged(); onRecentChanged(new AddedEvent(state, true));
} }
public void updateSaved(@Nonnull HistoryState state) { public void updateSaved(@Nonnull HistoryState state) {
@ -254,22 +245,23 @@ public class History {
final int i = saved.indexOf(state); final int i = saved.indexOf(state);
if(i >= 0) { if(i >= 0) {
saved.set(i, state); saved.set(i, state);
onSavedChanged(new UpdatedEvent(state, false));
} else { } else {
saved.add(state); saved.add(state);
onSavedChanged(new AddedEvent(state, false));
} }
onSavedChanged();
} }
private void onRecentChanged() { private void onRecentChanged(@Nonnull Object event) {
handler.removeCallbacks(writeRecent); handler.removeCallbacks(writeRecent);
handler.postDelayed(writeRecent, 500); handler.postDelayed(writeRecent, 500);
bus.post(CHANGED_EVENT_RECENT); bus.post(event);
} }
private void onSavedChanged() { private void onSavedChanged(@Nonnull Object event) {
handler.removeCallbacks(writeSaved); handler.removeCallbacks(writeSaved);
handler.postDelayed(writeSaved, 500); handler.postDelayed(writeSaved, 500);
bus.post(CHANGED_EVENT_SAVED); bus.post(event);
} }
@Nonnull @Nonnull
@ -314,13 +306,13 @@ public class History {
public void clearRecent() { public void clearRecent() {
Check.isMainThread(); Check.isMainThread();
recent.clear(); recent.clear();
onRecentChanged(); onRecentChanged(CLEARED_EVENT_RECENT);
} }
public void clearSaved() { public void clearSaved() {
Check.isMainThread(); Check.isMainThread();
saved.clear(); saved.clear();
onSavedChanged(); onSavedChanged(CLEARED_EVENT_SAVED);
} }
public void undo() { public void undo() {
@ -347,13 +339,13 @@ public class History {
public void removeSaved(@Nonnull HistoryState state) { public void removeSaved(@Nonnull HistoryState state) {
Check.isMainThread(); Check.isMainThread();
saved.remove(state); saved.remove(state);
onSavedChanged(); onSavedChanged(new RemovedEvent(state, false));
} }
public void removeRecent(@Nonnull HistoryState state) { public void removeRecent(@Nonnull HistoryState state) {
Check.isMainThread(); Check.isMainThread();
recent.remove(state); recent.remove(state);
onRecentChanged(); onSavedChanged(new RemovedEvent(state, true));
} }
@Subscribe @Subscribe
@ -366,10 +358,39 @@ public class History {
addRecent(HistoryState.builder(editorState, displayState).build()); addRecent(HistoryState.builder(editorState, displayState).build());
} }
public static class ChangedEvent { public static class ClearedEvent {
public final boolean recent; public final boolean recent;
public ChangedEvent(boolean recent) { ClearedEvent(boolean recent) {
this.recent = recent;
}
}
public static class RemovedEvent extends StateEvent {
RemovedEvent(@Nonnull HistoryState state, boolean recent) {
super(state, recent);
}
}
public static class AddedEvent extends StateEvent {
AddedEvent(@Nonnull HistoryState state, boolean recent) {
super(state, recent);
}
}
public static class UpdatedEvent extends StateEvent {
UpdatedEvent(@Nonnull HistoryState state, boolean recent) {
super(state, recent);
}
}
public abstract static class StateEvent {
@Nonnull
public final HistoryState state;
public final boolean recent;
protected StateEvent(@Nonnull HistoryState state, boolean recent) {
this.state = state;
this.recent = recent; this.recent = recent;
} }
} }

View File

@ -51,10 +51,10 @@ public class HistoryArrayAdapter extends ArrayAdapter<HistoryState> {
final HistoryState state = getItem(position); final HistoryState state = getItem(position);
final TextView time = (TextView) result.findViewById(R.id.history_time); final TextView time = (TextView) result.findViewById(R.id.history_item_time);
time.setText(DateUtils.formatDateTime(getContext(), state.getTime(), DATETIME_FORMAT)); time.setText(DateUtils.formatDateTime(getContext(), state.getTime(), DATETIME_FORMAT));
final TextView editor = (TextView) result.findViewById(R.id.history_item); final TextView editor = (TextView) result.findViewById(R.id.history_item_value);
editor.setText(BaseHistoryFragment.getHistoryText(state)); editor.setText(BaseHistoryFragment.getHistoryText(state));
final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment); final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment);

View File

@ -3,7 +3,6 @@ package org.solovyev.android.calculator.history;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.solovyev.android.Check; import org.solovyev.android.Check;
@ -37,7 +36,7 @@ public class HistoryState implements Parcelable {
public final EditorState editor; public final EditorState editor;
@Nonnull @Nonnull
public final DisplayState display; public final DisplayState display;
protected long time; protected long time = now();
@Nonnull @Nonnull
protected String comment = ""; protected String comment = "";
@ -47,8 +46,8 @@ public class HistoryState implements Parcelable {
this.display = display; this.display = display;
} }
private HistoryState(@Nonnull HistoryState state) { private HistoryState(@Nonnull HistoryState state, boolean newState) {
this.id = state.id; this.id = newState ? System.identityHashCode(this) : state.id;
this.editor = state.editor; this.editor = state.editor;
this.display = state.display; this.display = state.display;
this.time = state.time; this.time = state.time;
@ -75,8 +74,8 @@ public class HistoryState implements Parcelable {
} }
@Nonnull @Nonnull
public static Builder builder(@Nonnull HistoryState state) { public static Builder builder(@Nonnull HistoryState state, boolean newState) {
return new Builder(state); return new Builder(state, newState);
} }
@Nonnull @Nonnull
@ -84,6 +83,10 @@ public class HistoryState implements Parcelable {
return new HistoryState(json); return new HistoryState(json);
} }
private static long now() {
return System.currentTimeMillis();
}
@Nonnull @Nonnull
public JSONObject toJson() throws JSONException { public JSONObject toJson() throws JSONException {
final JSONObject json = new JSONObject(); final JSONObject json = new JSONObject();
@ -122,7 +125,7 @@ public class HistoryState implements Parcelable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || !(o instanceof HistoryState)) return false;
final HistoryState that = (HistoryState) o; final HistoryState that = (HistoryState) o;
@ -167,16 +170,13 @@ public class HistoryState implements Parcelable {
private Builder(@Nonnull EditorState editor, @Nonnull DisplayState display) { private Builder(@Nonnull EditorState editor, @Nonnull DisplayState display) {
super(editor, display); super(editor, display);
withNowTime();
} }
private Builder(@Nonnull HistoryState state) { private Builder(@Nonnull HistoryState state, boolean newState) {
super(state); super(state, newState);
if (newState) {
withTime(now());
} }
@Nonnull
public Builder withNowTime() {
return withTime(System.currentTimeMillis());
} }
@Nonnull @Nonnull

View File

@ -37,53 +37,4 @@ public class RecentHistoryFragment extends BaseHistoryFragment {
public RecentHistoryFragment() { public RecentHistoryFragment() {
super(CalculatorFragmentType.history); super(CalculatorFragmentType.history);
} }
@Override
protected int getItemLayoutId() {
return R.layout.fragment_history_item;
}
@Nonnull
@Override
protected List<HistoryState> getHistoryItems() {
return history.getRecent();
}
@Override
protected void clearHistory() {
history.clearRecent();
getAdapter().clear();
}
@Override
protected boolean isRecentHistory() {
return true;
}
protected void onCreateContextMenu(@Nonnull ContextMenu menu, @Nonnull HistoryState state) {
menu.add(NONE, R.string.c_use, NONE, R.string.c_use);
menu.add(NONE, R.string.c_copy_expression, NONE, R.string.c_copy_expression);
if (shouldHaveCopyResult(state)) {
menu.add(NONE, R.string.c_copy_result, NONE, R.string.c_copy_result);
}
menu.add(NONE, R.string.c_save, NONE, R.string.c_save);
}
protected boolean onContextItemSelected(@Nonnull MenuItem item, @Nonnull HistoryState state) {
switch (item.getItemId()) {
case R.string.c_use:
useState(state);
return true;
case R.string.c_copy_expression:
copyExpression(state);
return true;
case R.string.c_copy_result:
copyResult(state);
return true;
case R.string.c_save:
EditHistoryFragment.show(state, true, getFragmentManager());
return true;
}
return false;
}
} }

View File

@ -22,73 +22,11 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import android.view.ContextMenu;
import android.view.MenuItem;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import java.util.List;
import static android.view.Menu.NONE;
public class SavedHistoryFragment extends BaseHistoryFragment { public class SavedHistoryFragment extends BaseHistoryFragment {
public SavedHistoryFragment() { public SavedHistoryFragment() {
super(CalculatorFragmentType.saved_history); super(CalculatorFragmentType.saved_history);
} }
@Override
protected int getItemLayoutId() {
return R.layout.saved_history_item;
}
@Nonnull
@Override
protected List<HistoryState> getHistoryItems() {
return history.getSaved();
}
@Override
protected void clearHistory() {
history.clearSaved();
getAdapter().clear();
}
@Override
protected boolean isRecentHistory() {
return false;
}
protected void onCreateContextMenu(@Nonnull ContextMenu menu, @Nonnull HistoryState state) {
menu.add(NONE, R.string.c_use, NONE, R.string.c_use);
menu.add(NONE, R.string.c_copy_expression, NONE, R.string.c_copy_expression);
if (shouldHaveCopyResult(state)) {
menu.add(NONE, R.string.c_copy_result, NONE, R.string.c_copy_result);
}
menu.add(NONE, R.string.c_edit, NONE, R.string.c_edit);
menu.add(NONE, R.string.c_remove, NONE, R.string.c_remove);
}
protected boolean onContextItemSelected(@Nonnull MenuItem item, @Nonnull HistoryState state) {
switch (item.getItemId()) {
case R.string.c_use:
useState(state);
return true;
case R.string.c_copy_expression:
copyExpression(state);
return true;
case R.string.c_copy_result:
copyResult(state);
return true;
case R.string.c_edit:
EditHistoryFragment.show(state, false, getFragmentManager());
return true;
case R.string.c_remove:
history.removeSaved(state);
return true;
}
return false;
}
} }

View File

@ -23,9 +23,9 @@
--> -->
<LinearLayout <LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/main_fragment_layout" a:id="@+id/main_fragment_layout"
style="@style/CppFragment" style="@style/CppFragment"
xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">
@ -41,10 +41,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent"> a:layout_height="match_parent">
<ListView style="@style/CppListView" /> <android.support.v7.widget.RecyclerView
a:id="@+id/history_recyclerview"
a:layout_width="match_parent"
a:layout_height="match_parent" />
<com.melnykov.fab.FloatingActionButton <com.melnykov.fab.FloatingActionButton
a:id="@+id/fab" a:id="@+id/history_fab"
style="@style/CppFab" style="@style/CppFab"
a:src="@drawable/ic_delete_white_36dp" /> a:src="@drawable/ic_delete_white_36dp" />
</FrameLayout> </FrameLayout>

View File

@ -23,20 +23,29 @@
--> -->
<LinearLayout <LinearLayout
style="@style/CppListItem.TwoLines"
xmlns:a="http://schemas.android.com/apk/res/android" xmlns:a="http://schemas.android.com/apk/res/android"
style="@style/CppListViewItem"
a:orientation="vertical"> a:orientation="vertical">
<TextView <TextView
a:id="@+id/history_item" a:id="@+id/history_item_value"
style="@style/CppListViewItemTextPrimary.History" style="@style/CppListItemText.Primary"
a:layout_width="fill_parent" a:layout_width="match_parent"
a:layout_height="fill_parent" /> a:layout_height="wrap_content"
a:ellipsize="end"
a:maxLines="2" />
<TextView <TextView
a:id="@+id/history_time" a:id="@+id/history_item_comment"
style="@style/CppListViewItemTextSecondary" style="@style/CppListItemText.Secondary.OneLine"
a:layout_width="fill_parent" a:layout_width="match_parent"
a:layout_height="fill_parent" /> a:layout_height="wrap_content" />
<TextView
a:id="@+id/history_item_time"
style="@style/CppListItemText.Secondary.OneLine"
a:layout_width="match_parent"
a:layout_height="wrap_content"
a:textSize="@dimen/list_item_text_size_small"
a:gravity="center_vertical|end"/>
</LinearLayout> </LinearLayout>

View File

@ -24,14 +24,14 @@
<LinearLayout <LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android" xmlns:a="http://schemas.android.com/apk/res/android"
style="@style/CppListViewItem" style="@style/CppListItem"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:orientation="vertical"> a:orientation="vertical">
<TextView <TextView
a:id="@+id/math_entity_text" a:id="@+id/math_entity_text"
style="@style/CppListViewItemTextPrimary" style="@style/CppListItemText.Primary"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="wrap_content" /> a:layout_height="wrap_content" />

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android"
style="@style/CppListViewItem"
a:orientation="vertical">
<TextView
a:id="@+id/history_item"
style="@style/CppListViewItemTextPrimary.History"
a:layout_width="fill_parent"
a:layout_height="fill_parent" />
<TextView
a:id="@+id/history_item_comment"
style="@style/CppListViewItemTextSecondary"
a:layout_width="fill_parent"
a:layout_height="fill_parent" />
<TextView
a:id="@+id/history_time"
style="@style/CppListViewItemTextSecondary"
a:layout_width="fill_parent"
a:layout_height="fill_parent" />
</LinearLayout>

View File

@ -104,7 +104,7 @@
<string name="c_save_history">سجل المحفوظات</string> <string name="c_save_history">سجل المحفوظات</string>
<string name="c_edit_history">سجل التعديلات</string> <string name="c_edit_history">سجل التعديلات</string>
<string name="c_edit">تعديل</string> <string name="c_edit">تعديل</string>
<string name="c_saved_history">السجل المحفوظ</string> <string name="cpp_history_tab_saved">السجل المحفوظ</string>
<string name="c_history_already_saved">السجل محفوظ مسبقاً!</string> <string name="c_history_already_saved">السجل محفوظ مسبقاً!</string>
<string name="c_history_must_be_saved">يجب أن يتم حفظ السجل قبل التعديل!</string> <string name="c_history_must_be_saved">يجب أن يتم حفظ السجل قبل التعديل!</string>
<string name="c_history_was_removed">تمت إزالة السجل بنجاح!</string> <string name="c_history_was_removed">تمت إزالة السجل بنجاح!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Uložit historii</string> <string name="c_save_history">Uložit historii</string>
<string name="c_edit_history">Upravit historii</string> <string name="c_edit_history">Upravit historii</string>
<string name="c_edit">Upravit</string> <string name="c_edit">Upravit</string>
<string name="c_saved_history">Uložená historie</string> <string name="cpp_history_tab_saved">Uložená historie</string>
<string name="c_history_already_saved">Historie již byla uložena!</string> <string name="c_history_already_saved">Historie již byla uložena!</string>
<string name="c_history_must_be_saved">Historie musí být uložena před úpravou!</string> <string name="c_history_must_be_saved">Historie musí být uložena před úpravou!</string>
<string name="c_history_was_removed">Historie byla úspěšně odebrána!</string> <string name="c_history_was_removed">Historie byla úspěšně odebrána!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Verlauf speichern</string> <string name="c_save_history">Verlauf speichern</string>
<string name="c_edit_history">Verlauf ändern</string> <string name="c_edit_history">Verlauf ändern</string>
<string name="c_edit">Ändern</string> <string name="c_edit">Ändern</string>
<string name="c_saved_history">Gespeicherter Verlauf</string> <string name="cpp_history_tab_saved">Gespeicherter Verlauf</string>
<string name="c_history_already_saved">Verlauf wurde bereits gespeichert!</string> <string name="c_history_already_saved">Verlauf wurde bereits gespeichert!</string>
<string name="c_history_must_be_saved">Verlauf muss vor der Bearbeitung gespeichert werden!</string> <string name="c_history_must_be_saved">Verlauf muss vor der Bearbeitung gespeichert werden!</string>
<string name="c_history_was_removed">Verlauf wurde erfolgreich gelöscht!</string> <string name="c_history_was_removed">Verlauf wurde erfolgreich gelöscht!</string>

View File

@ -106,7 +106,7 @@
<string name="c_save_history">Guardar el historial de</string> <string name="c_save_history">Guardar el historial de</string>
<string name="c_edit_history">Modificar la historia</string> <string name="c_edit_history">Modificar la historia</string>
<string name="c_edit">modificar</string> <string name="c_edit">modificar</string>
<string name="c_saved_history">La historia guardada</string> <string name="cpp_history_tab_saved">La historia guardada</string>
<string name="c_history_already_saved">La historia se salvó ya!</string> <string name="c_history_already_saved">La historia se salvó ya!</string>
<string name="c_history_must_be_saved">La historia debe ser salvado antes de editar!</string> <string name="c_history_must_be_saved">La historia debe ser salvado antes de editar!</string>
<string name="c_history_was_removed">¡El historial se ha eliminado satisfactoriamente!</string> <string name="c_history_was_removed">¡El historial se ha eliminado satisfactoriamente!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Tallenna historia</string> <string name="c_save_history">Tallenna historia</string>
<string name="c_edit_history">Muokkaa historia</string> <string name="c_edit_history">Muokkaa historia</string>
<string name="c_edit">Mukauta</string> <string name="c_edit">Mukauta</string>
<string name="c_saved_history">Tallenna historia</string> <string name="cpp_history_tab_saved">Tallenna historia</string>
<string name="c_history_already_saved">Historia on jo tallennettu!</string> <string name="c_history_already_saved">Historia on jo tallennettu!</string>
<string name="c_history_must_be_saved">Historia on tallennettava ennen muokkaamista!</string> <string name="c_history_must_be_saved">Historia on tallennettava ennen muokkaamista!</string>
<string name="c_history_was_removed">Historia on poistettu!</string> <string name="c_history_was_removed">Historia on poistettu!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Enregistrer l\'historique</string> <string name="c_save_history">Enregistrer l\'historique</string>
<string name="c_edit_history">Modifier l\'historique</string> <string name="c_edit_history">Modifier l\'historique</string>
<string name="c_edit">Modifier</string> <string name="c_edit">Modifier</string>
<string name="c_saved_history">Historique enregistré</string> <string name="cpp_history_tab_saved">Historique enregistré</string>
<string name="c_history_already_saved">L\'historique est déjà enregistré !</string> <string name="c_history_already_saved">L\'historique est déjà enregistré !</string>
<string name="c_history_must_be_saved">L\'historique doit être enregistré avant modification !</string> <string name="c_history_must_be_saved">L\'historique doit être enregistré avant modification !</string>
<string name="c_history_was_removed">L\'historique a été supprimé avec succès !</string> <string name="c_history_was_removed">L\'historique a été supprimé avec succès !</string>

View File

@ -110,7 +110,7 @@
<string name="c_save_history">Salva storia</string> <string name="c_save_history">Salva storia</string>
<string name="c_edit_history">Modificare la storia</string> <string name="c_edit_history">Modificare la storia</string>
<string name="c_edit">Modificare</string> <string name="c_edit">Modificare</string>
<string name="c_saved_history">Storia salvati</string> <string name="cpp_history_tab_saved">Storia salvati</string>
<string name="c_history_already_saved">La storia era già salvato!</string> <string name="c_history_already_saved">La storia era già salvato!</string>
<string name="c_history_must_be_saved">La storia deve essere salvato prima di modificare!</string> <string name="c_history_must_be_saved">La storia deve essere salvato prima di modificare!</string>
<string name="c_history_was_removed">La cronologia è stata rimossa con successo!</string> <string name="c_history_was_removed">La cronologia è stata rimossa con successo!</string>

View File

@ -106,7 +106,7 @@
<string name="c_save_history">履歴を保存</string> <string name="c_save_history">履歴を保存</string>
<string name="c_edit_history">履歴を編集</string> <string name="c_edit_history">履歴を編集</string>
<string name="c_edit">編集</string> <string name="c_edit">編集</string>
<string name="c_saved_history">保存された履歴</string> <string name="cpp_history_tab_saved">保存された履歴</string>
<string name="c_history_already_saved">履歴はすでに保存されています!</string> <string name="c_history_already_saved">履歴はすでに保存されています!</string>
<string name="c_history_must_be_saved">履歴を編集する前に保存してください!</string> <string name="c_history_must_be_saved">履歴を編集する前に保存してください!</string>
<string name="c_history_was_removed">履歴は正常に削除されました!</string> <string name="c_history_was_removed">履歴は正常に削除されました!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Geschiedenis opslaan</string> <string name="c_save_history">Geschiedenis opslaan</string>
<string name="c_edit_history">Geschiedenis wijzigen</string> <string name="c_edit_history">Geschiedenis wijzigen</string>
<string name="c_edit">Wijzigen</string> <string name="c_edit">Wijzigen</string>
<string name="c_saved_history">Opgeslagen geschiedenis</string> <string name="cpp_history_tab_saved">Opgeslagen geschiedenis</string>
<string name="c_history_already_saved">Geschiedenis was al opgeslaan!</string> <string name="c_history_already_saved">Geschiedenis was al opgeslaan!</string>
<string name="c_history_must_be_saved">Geschiedenis moet eerst worden opgeslagen om te bewerken!</string> <string name="c_history_must_be_saved">Geschiedenis moet eerst worden opgeslagen om te bewerken!</string>
<string name="c_history_was_removed">Geschiedenis is succesvol verwijderd!</string> <string name="c_history_was_removed">Geschiedenis is succesvol verwijderd!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Zapisz historię</string> <string name="c_save_history">Zapisz historię</string>
<string name="c_edit_history">Modyfikuj historię</string> <string name="c_edit_history">Modyfikuj historię</string>
<string name="c_edit">Modyfikuj</string> <string name="c_edit">Modyfikuj</string>
<string name="c_saved_history">Zapisana historia</string> <string name="cpp_history_tab_saved">Zapisana historia</string>
<string name="c_history_already_saved">Historia została już zachowana!</string> <string name="c_history_already_saved">Historia została już zachowana!</string>
<string name="c_history_must_be_saved">Historia musi być zapisana przed edycją!</string> <string name="c_history_must_be_saved">Historia musi być zapisana przed edycją!</string>
<string name="c_history_was_removed">Historia została pomyślnie usunięta!</string> <string name="c_history_was_removed">Historia została pomyślnie usunięta!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Salvar histórico</string> <string name="c_save_history">Salvar histórico</string>
<string name="c_edit_history">Modificar histórico</string> <string name="c_edit_history">Modificar histórico</string>
<string name="c_edit">Modificar</string> <string name="c_edit">Modificar</string>
<string name="c_saved_history">Salvar no histórico</string> <string name="cpp_history_tab_saved">Salvar no histórico</string>
<string name="c_history_already_saved">O histórico já foi salvo!</string> <string name="c_history_already_saved">O histórico já foi salvo!</string>
<string name="c_history_must_be_saved">O histórico deve ser salvo antes de ser editado!</string> <string name="c_history_must_be_saved">O histórico deve ser salvo antes de ser editado!</string>
<string name="c_history_was_removed">O histórico foi removido com sucesso!</string> <string name="c_history_was_removed">O histórico foi removido com sucesso!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Guardar histórico</string> <string name="c_save_history">Guardar histórico</string>
<string name="c_edit_history">Modificar histórico</string> <string name="c_edit_history">Modificar histórico</string>
<string name="c_edit">Modificar</string> <string name="c_edit">Modificar</string>
<string name="c_saved_history">Histórico guardado</string> <string name="cpp_history_tab_saved">Histórico guardado</string>
<string name="c_history_already_saved">O histórico já foi guardado!</string> <string name="c_history_already_saved">O histórico já foi guardado!</string>
<string name="c_history_must_be_saved">O histórico deve ser guardado antes de ser alterado!</string> <string name="c_history_must_be_saved">O histórico deve ser guardado antes de ser alterado!</string>
<string name="c_history_was_removed">O histórico foi removido com sucesso!</string> <string name="c_history_was_removed">O histórico foi removido com sucesso!</string>

View File

@ -117,7 +117,7 @@
<string name="c_save_history">Сохранить</string> <string name="c_save_history">Сохранить</string>
<string name="c_edit_history">Изменить</string> <string name="c_edit_history">Изменить</string>
<string name="c_edit">Изменить</string> <string name="c_edit">Изменить</string>
<string name="c_saved_history">Сохранённая история</string> <string name="cpp_history_tab_saved">Сохранённая история</string>
<string name="c_history_already_saved">История уже была сохранена!</string> <string name="c_history_already_saved">История уже была сохранена!</string>
<string name="c_history_must_be_saved">История должна быть сохранена перед редактированием!</string> <string name="c_history_must_be_saved">История должна быть сохранена перед редактированием!</string>
<string name="c_history_was_removed">История успешно удалена!</string> <string name="c_history_was_removed">История успешно удалена!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Geçmişi kaydet</string> <string name="c_save_history">Geçmişi kaydet</string>
<string name="c_edit_history">Geçmişi düzenle</string> <string name="c_edit_history">Geçmişi düzenle</string>
<string name="c_edit">Düzenle</string> <string name="c_edit">Düzenle</string>
<string name="c_saved_history">Kayıtlı geçmiş</string> <string name="cpp_history_tab_saved">Kayıtlı geçmiş</string>
<string name="c_history_already_saved">Geçmiş zaten kaydedildi!</string> <string name="c_history_already_saved">Geçmiş zaten kaydedildi!</string>
<string name="c_history_must_be_saved">Geçmiş düzenlenmeden önce kaydedilmelidir!</string> <string name="c_history_must_be_saved">Geçmiş düzenlenmeden önce kaydedilmelidir!</string>
<string name="c_history_was_removed">Geçmiş başarıyla silindi!</string> <string name="c_history_was_removed">Geçmiş başarıyla silindi!</string>

View File

@ -108,7 +108,7 @@
<string name="c_save_history">Зберегти історію</string> <string name="c_save_history">Зберегти історію</string>
<string name="c_edit_history">Змінити історію</string> <string name="c_edit_history">Змінити історію</string>
<string name="c_edit">Змінити</string> <string name="c_edit">Змінити</string>
<string name="c_saved_history">Збережена історія</string> <string name="cpp_history_tab_saved">Збережена історія</string>
<string name="c_history_already_saved">Історія вже збережена!</string> <string name="c_history_already_saved">Історія вже збережена!</string>
<string name="c_history_must_be_saved">Історію необхідно зберегти перед редагуванням!</string> <string name="c_history_must_be_saved">Історію необхідно зберегти перед редагуванням!</string>
<string name="c_history_was_removed">Історія успішно видалена!</string> <string name="c_history_was_removed">Історія успішно видалена!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">Lưu lịch sử</string> <string name="c_save_history">Lưu lịch sử</string>
<string name="c_edit_history">Sửa đổi lịch sử</string> <string name="c_edit_history">Sửa đổi lịch sử</string>
<string name="c_edit">Điều chỉnh</string> <string name="c_edit">Điều chỉnh</string>
<string name="c_saved_history">Lịch sử đã lưu</string> <string name="cpp_history_tab_saved">Lịch sử đã lưu</string>
<string name="c_history_already_saved">Lịch sử đã được lưu!</string> <string name="c_history_already_saved">Lịch sử đã được lưu!</string>
<string name="c_history_must_be_saved">Lịch sử phải được lưu trước khi chỉnh sửa!</string> <string name="c_history_must_be_saved">Lịch sử phải được lưu trước khi chỉnh sửa!</string>
<string name="c_history_was_removed">Lịch sử đã được loại bỏ thành công!</string> <string name="c_history_was_removed">Lịch sử đã được loại bỏ thành công!</string>

View File

@ -104,7 +104,7 @@
<string name="c_save_history">保存历史记录</string> <string name="c_save_history">保存历史记录</string>
<string name="c_edit_history">修改历史记录</string> <string name="c_edit_history">修改历史记录</string>
<string name="c_edit">修改</string> <string name="c_edit">修改</string>
<string name="c_saved_history">已保存历史记录</string> <string name="cpp_history_tab_saved">已保存历史记录</string>
<string name="c_history_already_saved">记录已保存!</string> <string name="c_history_already_saved">记录已保存!</string>
<string name="c_history_must_be_saved">编辑之前必须先保存!</string> <string name="c_history_must_be_saved">编辑之前必须先保存!</string>
<string name="c_history_was_removed">已成功删除历史记录!</string> <string name="c_history_was_removed">已成功删除历史记录!</string>

View File

@ -103,7 +103,7 @@
<string name="c_save_history">儲存歷史紀錄</string> <string name="c_save_history">儲存歷史紀錄</string>
<string name="c_edit_history">修改歷史紀錄</string> <string name="c_edit_history">修改歷史紀錄</string>
<string name="c_edit">修改</string> <string name="c_edit">修改</string>
<string name="c_saved_history">已儲存的歷史紀錄</string> <string name="cpp_history_tab_saved">已儲存的歷史紀錄</string>
<string name="c_history_already_saved">歷史紀錄已經儲存!</string> <string name="c_history_already_saved">歷史紀錄已經儲存!</string>
<string name="c_history_must_be_saved">編輯歷史紀錄之前必須先儲存!</string> <string name="c_history_must_be_saved">編輯歷史紀錄之前必須先儲存!</string>
<string name="c_history_was_removed">成功刪除歷史紀錄!</string> <string name="c_history_was_removed">成功刪除歷史紀錄!</string>

View File

@ -29,14 +29,14 @@
<color name="cpp_button_text">#ffffffff</color> <color name="cpp_button_text">#ffffffff</color>
<color name="cpp_button_text_operator">#ffffff99</color> <color name="cpp_button_text_operator">#ffffff99</color>
<color name="cpp_selected_angle_unit_text">#ffffff99</color> <color name="cpp_selected_angle_unit_text">#ffffff99</color>
<color name="cpp_main_bg">#101010</color> <color name="cpp_main_bg">@color/grey_950</color>
<color name="cpp_main_bg_light">#fff6f1ef</color> <color name="cpp_main_bg_light">#fff6f1ef</color>
<color name="cpp_wizard_button_normal">#424242</color> <color name="cpp_wizard_button_normal">#424242</color>
<color name="cpp_wizard_button_disabled">#616161</color> <color name="cpp_wizard_button_disabled">#616161</color>
<color name="cpp_wizard_button_pressed">#757575</color> <color name="cpp_wizard_button_pressed">#757575</color>
<color name="cpp_metro_button_dark">#ff000000</color> <color name="cpp_metro_button_dark">#ff000000</color>
<color name="cpp_metro_button">@color/cpp_material_grey</color> <color name="cpp_metro_button">@color/grey_900</color>
<color name="cpp_metro_button_light">@color/cpp_material_grey_light</color> <color name="cpp_metro_button_light">@color/grey_800</color>
<color name="cpp_metro_blue">#10648c</color> <color name="cpp_metro_blue">#10648c</color>
<color name="cpp_material_blue">#ff0d4663</color> <color name="cpp_material_blue">#ff0d4663</color>
<color name="cpp_material_blue_lighter">#ff0d668d</color> <color name="cpp_material_blue_lighter">#ff0d668d</color>
@ -53,12 +53,15 @@
<color name="cpp_wizard_disabled_text">#66ffffff</color> <color name="cpp_wizard_disabled_text">#66ffffff</color>
<color name="cpp_material_accent">#FAFAFA</color> <color name="cpp_material_accent">#FAFAFA</color>
<color name="cpp_material_grey">#212121</color> <color name="cpp_material_actionbar">@color/grey_900</color>
<color name="cpp_material_grey_light">#393939</color> <color name="cpp_material_actionbar_light">@color/grey_800</color>
<color name="cpp_material_actionbar">@color/cpp_material_grey</color>
<color name="cpp_material_actionbar_light">@color/cpp_material_grey_light</color>
<color name="cpp_pane_bg">@color/cpp_material_grey</color> <color name="cpp_pane_bg">@color/grey_900</color>
<color name="cpp_pane_bg_light">#ffeae5e3</color> <color name="cpp_pane_bg_light">#ffeae5e3</color>
<color name="grey_900">#212121</color>
<color name="grey_950">#101010</color>
<color name="grey_600">#757575</color>
<color name="grey_800">#424242</color>
<color name="blue_grey_800">#37474F</color>
</resources> </resources>

View File

@ -253,15 +253,23 @@
<item name="android:layout_gravity">center_horizontal</item> <item name="android:layout_gravity">center_horizontal</item>
</style> </style>
<style name="CppListViewItem"> <style name="CppListItem.OneLine" parent="CppListItem">
<item name="android:minHeight">48dp</item>
</style>
<style name="CppListItem.TwoLines" parent="CppListItem">
<item name="android:minHeight">72dp</item>
</style>
<style name="CppListItem">
<item name="android:paddingLeft">16dp</item> <item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item> <item name="android:paddingRight">16dp</item>
<item name="android:paddingBottom">20dp</item> <item name="android:paddingBottom">8dp</item>
<item name="android:paddingTop">20dp</item> <item name="android:paddingTop">8dp</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:minHeight">72dp</item>
<item name="android:gravity">center_vertical|left</item> <item name="android:gravity">center_vertical|left</item>
<item name="android:background">?android:attr/selectableItemBackground</item>
</style> </style>
<style name="CppFab"> <style name="CppFab">
@ -274,10 +282,23 @@
<item name="fab_colorRipple">?attr/colorControlHighlight</item> <item name="fab_colorRipple">?attr/colorControlHighlight</item>
</style> </style>
<style name="CppListViewItemTextPrimary"> <style name="CppListItemText">
<item name="android:textAppearance">@style/TextAppearance.AppCompat</item> <item name="android:textSize">@dimen/list_item_text_size</item>
</style>
<style name="CppListItemText.Primary" parent="CppListItemText">
<item name="android:textColor">?android:attr/textColorPrimary</item> <item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textSize">@dimen/cpp_li_text_size</item> </style>
<style name="CppListItemText.Secondary" parent="CppListItemText">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="CppListItemText.Secondary.OneLine" parent="CppListItemText.Secondary">
<item name="android:singleLine">true</item>
<item name="android:minLines">1</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
</style> </style>
<style name="CppListViewItemTextSecondary"> <style name="CppListViewItemTextSecondary">
@ -286,7 +307,7 @@
<item name="android:textSize">@dimen/cpp_li_secondary_text_size</item> <item name="android:textSize">@dimen/cpp_li_secondary_text_size</item>
</style> </style>
<style name="CppListViewItemTextPrimary.History" parent="CppListViewItemTextPrimary"> <style name="CppListViewItemTextPrimary.History" parent="CppListItemText.Primary">
<item name="android:maxLines">2</item> <item name="android:maxLines">2</item>
<item name="android:ellipsize">end</item> <item name="android:ellipsize">end</item>
</style> </style>
@ -321,4 +342,6 @@
<item name="android:backgroundSplit">@color/cpp_material_actionbar_light</item> <item name="android:backgroundSplit">@color/cpp_material_actionbar_light</item>
</style> </style>
<dimen name="list_item_text_size">16sp</dimen>
<dimen name="list_item_text_size_small">14sp</dimen>
</resources> </resources>

View File

@ -103,7 +103,8 @@
<string name="c_save_history">Save history</string> <string name="c_save_history">Save history</string>
<string name="c_edit_history">Modify history</string> <string name="c_edit_history">Modify history</string>
<string name="c_edit">Modify</string> <string name="c_edit">Modify</string>
<string name="c_saved_history">Saved history</string> <string name="cpp_history_tab_saved">Saved</string>
<string name="cpp_history_tab_recent">Recent</string>
<string name="c_history_already_saved">History was already saved!</string> <string name="c_history_already_saved">History was already saved!</string>
<string name="c_history_must_be_saved">History must be saved before editing!</string> <string name="c_history_must_be_saved">History must be saved before editing!</string>
<string name="c_history_was_removed">History has been successfully removed!</string> <string name="c_history_was_removed">History has been successfully removed!</string>

View File

@ -33,9 +33,11 @@
<item name="cpp_main_bg">@color/cpp_main_bg</item> <item name="cpp_main_bg">@color/cpp_main_bg</item>
<item name="cpp_pane_bg">@drawable/pane</item> <item name="cpp_pane_bg">@drawable/pane</item>
<item name="cpp_fab_bg">@color/cpp_material_grey</item> <item name="cpp_fab_bg">@color/grey_900</item>
<item name="cpp_text_color">@color/cpp_text</item> <item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item> <item name="cpp_text_color_error">@color/cpp_text_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Dialog" parent="@style/Theme.AppCompat.Dialog"> <style name="Cpp.Theme.Dialog" parent="@style/Theme.AppCompat.Dialog">
@ -50,9 +52,11 @@
<item name="cpp_main_bg">@color/cpp_main_bg</item> <item name="cpp_main_bg">@color/cpp_main_bg</item>
<item name="cpp_pane_bg">@drawable/pane</item> <item name="cpp_pane_bg">@drawable/pane</item>
<item name="cpp_fab_bg">@color/cpp_material_grey</item> <item name="cpp_fab_bg">@color/grey_900</item>
<item name="cpp_text_color">@color/cpp_text</item> <item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item> <item name="cpp_text_color_error">@color/cpp_text_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Dialog.Alert" parent="@style/Theme.AppCompat.Dialog.Alert"> <style name="Cpp.Theme.Dialog.Alert" parent="@style/Theme.AppCompat.Dialog.Alert">
@ -62,9 +66,11 @@
<item name="cpp_main_bg">@color/cpp_main_bg</item> <item name="cpp_main_bg">@color/cpp_main_bg</item>
<item name="cpp_pane_bg">@drawable/pane</item> <item name="cpp_pane_bg">@drawable/pane</item>
<item name="cpp_fab_bg">@color/cpp_material_grey</item> <item name="cpp_fab_bg">@color/grey_900</item>
<item name="cpp_text_color">@color/cpp_text</item> <item name="cpp_text_color">@color/cpp_text</item>
<item name="cpp_text_color_error">@color/cpp_text_error</item> <item name="cpp_text_color_error">@color/cpp_text_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Light" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <style name="Cpp.Theme.Light" parent="@style/Theme.AppCompat.Light.DarkActionBar">
@ -81,6 +87,8 @@
<item name="cpp_fab_bg">@color/cpp_material_light</item> <item name="cpp_fab_bg">@color/cpp_material_light</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item> <item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item> <item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Light.Dialog" parent="@style/Theme.AppCompat.Light.Dialog"> <style name="Cpp.Theme.Light.Dialog" parent="@style/Theme.AppCompat.Light.Dialog">
@ -98,6 +106,8 @@
<item name="cpp_fab_bg">@color/cpp_material_light</item> <item name="cpp_fab_bg">@color/cpp_material_light</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item> <item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item> <item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Light.Dialog.Alert" parent="@style/Theme.AppCompat.Light.Dialog.Alert"> <style name="Cpp.Theme.Light.Dialog.Alert" parent="@style/Theme.AppCompat.Light.Dialog.Alert">
@ -110,6 +120,8 @@
<item name="cpp_fab_bg">@color/cpp_material_light</item> <item name="cpp_fab_bg">@color/cpp_material_light</item>
<item name="cpp_text_color">@color/cpp_text_inverse</item> <item name="cpp_text_color">@color/cpp_text_inverse</item>
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item> <item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
<item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Wizard" parent="Cpp.Theme.Material"> <style name="Cpp.Theme.Wizard" parent="Cpp.Theme.Material">