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