History UI styles update

This commit is contained in:
serso
2015-01-26 22:06:43 +01:00
parent 13fb8203ea
commit 141741c446
30 changed files with 179 additions and 223 deletions

View File

@@ -23,13 +23,10 @@
package org.solovyev.android.calculator;
import android.support.v4.app.Fragment;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.about.CalculatorAboutFragment;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
import org.solovyev.android.calculator.history.HistoryFragment;
import org.solovyev.android.calculator.history.SavedHistoryFragment;
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
@@ -39,6 +36,8 @@ import org.solovyev.android.calculator.plot.CalculatorPlotFunctionSettingsActivi
import org.solovyev.android.calculator.plot.CalculatorPlotFunctionsActivity;
import org.solovyev.android.calculator.plot.CalculatorPlotRangeActivity;
import javax.annotation.Nonnull;
/**
* User: Solovyev_S
* Date: 03.10.12
@@ -49,8 +48,8 @@ public enum CalculatorFragmentType {
editor(CalculatorEditorFragment.class, R.layout.cpp_app_editor, R.string.editor),
//display(CalculatorHistoryFragment.class, "history", R.layout.history_fragment, R.string.c_history),
//keyboard(CalculatorHistoryFragment.class, "history", R.layout.history_fragment, R.string.c_history),
history(CalculatorHistoryFragment.class, R.layout.history_fragment, R.string.c_history),
saved_history(CalculatorSavedHistoryFragment.class, R.layout.history_fragment, R.string.c_saved_history),
history(HistoryFragment.class, R.layout.history_fragment, R.string.c_history),
saved_history(SavedHistoryFragment.class, R.layout.history_fragment, R.string.c_saved_history),
variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars),
functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions),
operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators),

View File

@@ -62,12 +62,7 @@ import java.util.List;
import static org.solovyev.android.calculator.CalculatorEventType.clear_history_requested;
/**
* User: serso
* Date: 10/15/11
* Time: 1:13 PM
*/
public abstract class AbstractCalculatorHistoryFragment extends SherlockListFragment implements CalculatorEventListener {
public abstract class BaseHistoryFragment extends SherlockListFragment implements CalculatorEventListener {
/*
**********************************************************************
@@ -115,7 +110,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
@Nonnull
private final SharedPreferences.OnSharedPreferenceChangeListener preferencesListener = new HistoryOnPreferenceChangeListener();
protected AbstractCalculatorHistoryFragment(@Nonnull CalculatorFragmentType fragmentType) {
protected BaseHistoryFragment(@Nonnull CalculatorFragmentType fragmentType) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false);
}
@@ -411,7 +406,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
if (menuItem instanceof IdentifiableMenuItem<?>) {
switch (((IdentifiableMenuItem) menuItem).getItemId()) {
case R.id.menu_history_fullscreen:
result = !fragmentHelper.isPane(AbstractCalculatorHistoryFragment.this);
result = !fragmentHelper.isPane(BaseHistoryFragment.this);
break;
}
}

View File

@@ -23,26 +23,21 @@
package org.solovyev.android.calculator.history;
import android.content.Context;
import android.text.format.DateUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import org.solovyev.android.calculator.R;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import static android.view.View.GONE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.View.*;
import static org.solovyev.android.calculator.CalculatorFragmentType.saved_history;
import static org.solovyev.android.calculator.history.AbstractCalculatorHistoryFragment.isAlreadySaved;
import static org.solovyev.android.calculator.history.BaseHistoryFragment.isAlreadySaved;
/**
* User: serso
@@ -51,6 +46,7 @@ import static org.solovyev.android.calculator.history.AbstractCalculatorHistoryF
*/
public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
private static final int DATETIME_FORMAT = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_TIME;
private boolean showDatetime;
HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @Nonnull List<CalculatorHistoryState> historyList, boolean showDatetime) {
@@ -67,25 +63,24 @@ public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
final TextView time = (TextView) result.findViewById(R.id.history_time);
if (showDatetime) {
time.setVisibility(VISIBLE);
time.setText(new SimpleDateFormat().format(new Date(state.getTime())));
time.setText(DateUtils.formatDateTime(getContext(), state.getTime(), DATETIME_FORMAT));
} else {
time.setVisibility(GONE);
time.setText(null);
}
final TextView editor = (TextView) result.findViewById(R.id.history_item);
editor.setText(AbstractCalculatorHistoryFragment.getHistoryText(state));
editor.setText(BaseHistoryFragment.getHistoryText(state));
final View commentLayout = result.findViewById(R.id.history_item_comment_layout);
final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment);
if (commentLayout != null && commentView != null) {
if (commentView != null) {
final String comment = state.getComment();
if (!Strings.isEmpty(comment)) {
commentView.setText(comment);
commentLayout.setVisibility(VISIBLE);
commentView.setVisibility(VISIBLE);
} else {
commentView.setText(null);
commentLayout.setVisibility(GONE);
commentView.setVisibility(GONE);
}
}
@@ -115,7 +110,7 @@ public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
@Override
public void notifyDataSetChanged() {
this.setNotifyOnChange(false);
this.sort(AbstractCalculatorHistoryFragment.COMPARATOR);
this.sort(BaseHistoryFragment.COMPARATOR);
this.setNotifyOnChange(true);
super.notifyDataSetChanged();
}

View File

@@ -1,68 +1,63 @@
/*
* 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
*/
package org.solovyev.android.calculator.history;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
/**
* User: serso
* Date: 12/18/11
* Time: 7:39 PM
*/
public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment {
public CalculatorHistoryFragment() {
super(CalculatorFragmentType.history);
}
@Override
protected int getItemLayoutId() {
return R.layout.history_item;
}
@Nonnull
@Override
protected List<CalculatorHistoryState> getHistoryItems() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
final boolean showIntermediateCalculations = Preferences.History.showIntermediateCalculations.getPreference(preferences);
final List<CalculatorHistoryState> historyStates = Locator.getInstance().getHistory().getStates(showIntermediateCalculations);
return new ArrayList<CalculatorHistoryState>(historyStates);
}
@Override
protected void clearHistory() {
Locator.getInstance().getHistory().clear();
getAdapter().clear();
}
}
/*
* 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
*/
package org.solovyev.android.calculator.history;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class HistoryFragment extends BaseHistoryFragment {
public HistoryFragment() {
super(CalculatorFragmentType.history);
}
@Override
protected int getItemLayoutId() {
return R.layout.history_item;
}
@Nonnull
@Override
protected List<CalculatorHistoryState> getHistoryItems() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
final boolean showIntermediateCalculations = Preferences.History.showIntermediateCalculations.getPreference(preferences);
final List<CalculatorHistoryState> historyStates = Locator.getInstance().getHistory().getStates(showIntermediateCalculations);
return new ArrayList<CalculatorHistoryState>(historyStates);
}
@Override
protected void clearHistory() {
Locator.getInstance().getHistory().clear();
getAdapter().clear();
}
}

View File

@@ -50,7 +50,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
use(R.string.c_use) {
@Override
public void onClick(@Nonnull HistoryItemMenuData data, @Nonnull Context context) {
AbstractCalculatorHistoryFragment.useHistoryItem(data.getHistoryState());
BaseHistoryFragment.useHistoryItem(data.getHistoryState());
}
},
@@ -123,7 +123,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View editView = layoutInflater.inflate(R.layout.history_edit, null);
final TextView historyExpression = (TextView) editView.findViewById(R.id.history_edit_expression);
historyExpression.setText(AbstractCalculatorHistoryFragment.getHistoryText(historyState));
historyExpression.setText(BaseHistoryFragment.getHistoryText(historyState));
final EditText comment = (EditText) editView.findViewById(R.id.history_edit_comment);
comment.setText(historyState.getComment());

View File

@@ -1,61 +1,55 @@
/*
* 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
*/
package org.solovyev.android.calculator.history;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import java.util.ArrayList;
import java.util.List;
/**
* User: serso
* Date: 12/18/11
* Time: 7:40 PM
*/
public class CalculatorSavedHistoryFragment extends AbstractCalculatorHistoryFragment {
public CalculatorSavedHistoryFragment() {
super(CalculatorFragmentType.saved_history);
}
@Override
protected int getItemLayoutId() {
return R.layout.saved_history_item;
}
@Nonnull
@Override
protected List<CalculatorHistoryState> getHistoryItems() {
return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory());
}
@Override
protected void clearHistory() {
Locator.getInstance().getHistory().clearSavedHistory();
getAdapter().clear();
}
}
/*
* 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
*/
package org.solovyev.android.calculator.history;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class SavedHistoryFragment extends BaseHistoryFragment {
public SavedHistoryFragment() {
super(CalculatorFragmentType.saved_history);
}
@Override
protected int getItemLayoutId() {
return R.layout.saved_history_item;
}
@Nonnull
@Override
protected List<CalculatorHistoryState> getHistoryItems() {
return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory());
}
@Override
protected void clearHistory() {
Locator.getInstance().getHistory().clearSavedHistory();
getAdapter().clear();
}
}