History changes
This commit is contained in:
parent
77ae5dad9d
commit
4323c688c5
@ -279,11 +279,6 @@ public class ActivityUi extends BaseUi {
|
|||||||
this.layoutId = layoutId;
|
this.layoutId = layoutId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public Preferences.Gui.Theme getTheme() {
|
|
||||||
return theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Language getLanguage() {
|
public Language getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -143,6 +143,11 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public Preferences.Gui.Theme getTheme() {
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
|
||||||
public void logError(@Nonnull String message) {
|
public void logError(@Nonnull String message) {
|
||||||
Log.e(logTag, message);
|
Log.e(logTag, message);
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ import javax.annotation.Nonnull;
|
|||||||
public enum CalculatorFragmentType {
|
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.history_fragment, R.string.c_history),
|
//display(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history),
|
||||||
//keyboard(CalculatorHistoryFragment.class, "history", R.layout.history_fragment, R.string.c_history),
|
//keyboard(CalculatorHistoryFragment.class, "history", R.layout.fragment_history, R.string.c_history),
|
||||||
history(RecentHistoryFragment.class, R.layout.history_fragment, R.string.c_history),
|
history(RecentHistoryFragment.class, R.layout.fragment_history, R.string.c_history),
|
||||||
saved_history(SavedHistoryFragment.class, R.layout.history_fragment, R.string.c_saved_history),
|
saved_history(SavedHistoryFragment.class, R.layout.fragment_history, R.string.c_saved_history),
|
||||||
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),
|
||||||
|
@ -28,22 +28,15 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.solovyev.android.checkout.ActivityCheckout;
|
import org.solovyev.android.checkout.ActivityCheckout;
|
||||||
import org.solovyev.android.checkout.Checkout;
|
import org.solovyev.android.checkout.Checkout;
|
||||||
import org.solovyev.android.checkout.Inventory;
|
import org.solovyev.android.checkout.Inventory;
|
||||||
import org.solovyev.android.checkout.ProductTypes;
|
import org.solovyev.android.checkout.ProductTypes;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 9/26/12
|
|
||||||
* Time: 10:14 PM
|
|
||||||
*/
|
|
||||||
public class FragmentUi extends BaseUi {
|
public class FragmentUi extends BaseUi {
|
||||||
|
|
||||||
private ActivityCheckout checkout;
|
private ActivityCheckout checkout;
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
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.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -42,24 +42,11 @@ import org.solovyev.android.calculator.jscl.JsclOperation;
|
|||||||
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class BaseHistoryFragment extends ListFragment {
|
public abstract class BaseHistoryFragment extends ListFragment {
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final DialogInterface.OnClickListener clearDialogListener = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
|
||||||
clearHistory();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@Inject
|
@Inject
|
||||||
History history;
|
History history;
|
||||||
@Inject
|
@Inject
|
||||||
@ -67,11 +54,9 @@ public abstract class BaseHistoryFragment extends ListFragment {
|
|||||||
private HistoryArrayAdapter adapter;
|
private HistoryArrayAdapter adapter;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private FragmentUi ui;
|
private FragmentUi ui;
|
||||||
@Nullable
|
|
||||||
private AlertDialog clearDialog;
|
|
||||||
|
|
||||||
protected BaseHistoryFragment(@Nonnull CalculatorFragmentType fragmentType) {
|
protected BaseHistoryFragment(@Nonnull CalculatorFragmentType type) {
|
||||||
ui = new FragmentUi(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false);
|
ui = new FragmentUi(type.getDefaultLayoutId(), type.getDefaultTitleResId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -95,7 +80,6 @@ public abstract class BaseHistoryFragment extends ListFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
bus.register(this);
|
||||||
ui.onCreate(this);
|
ui.onCreate(this);
|
||||||
@ -123,12 +107,7 @@ public abstract class BaseHistoryFragment extends ListFragment {
|
|||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
clearDialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.cpp_clear_history_title)
|
showClearHistoryDialog();
|
||||||
.setMessage(R.string.cpp_clear_history_message)
|
|
||||||
.setPositiveButton(R.string.cpp_clear_history, clearDialogListener)
|
|
||||||
.setNegativeButton(R.string.c_cancel, clearDialogListener)
|
|
||||||
.create();
|
|
||||||
clearDialog.show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -144,6 +123,21 @@ public abstract class BaseHistoryFragment extends ListFragment {
|
|||||||
registerForContextMenu(lv);
|
registerForContextMenu(lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showClearHistoryDialog() {
|
||||||
|
new AlertDialog.Builder(getActivity(), ui.getTheme().alertDialogTheme)
|
||||||
|
.setTitle(R.string.cpp_clear_history_title)
|
||||||
|
.setMessage(R.string.cpp_clear_history_message)
|
||||||
|
.setPositiveButton(R.string.cpp_clear_history, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.c_cancel, null)
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -216,12 +210,7 @@ public abstract class BaseHistoryFragment extends ListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
bus.unregister(this);
|
bus.unregister(this);
|
||||||
if (clearDialog != null) {
|
|
||||||
clearDialog.dismiss();
|
|
||||||
clearDialog = null;
|
|
||||||
}
|
|
||||||
ui.onDestroy(this);
|
ui.onDestroy(this);
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class EditHistoryFragment extends BaseDialogFragment {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.history_edit, null);
|
final View view = inflater.inflate(R.layout.fragment_history_edit, null);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
expressionView.setText(BaseHistoryFragment.getHistoryText(state));
|
expressionView.setText(BaseHistoryFragment.getHistoryText(state));
|
||||||
|
@ -40,7 +40,7 @@ public class RecentHistoryFragment extends BaseHistoryFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getItemLayoutId() {
|
protected int getItemLayoutId() {
|
||||||
return R.layout.history_item;
|
return R.layout.fragment_history_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
Loading…
Reference in New Issue
Block a user