history improvements
This commit is contained in:
parent
e1b0679263
commit
3a67f465ea
@ -7,10 +7,17 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:orientation="horizontal"
|
||||
style="?cpp_fragment_list_view_item_style"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="wrap_content">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
a:orientation="vertical"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/history_time"
|
||||
@ -25,22 +32,15 @@
|
||||
a:textColor="@color/cpp_button_operator_text_color"
|
||||
style="@style/history_item"/>
|
||||
|
||||
<LinearLayout
|
||||
a:orientation="horizontal"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
<ImageView a:id="@+id/history_item_status_icon"
|
||||
a:layout_gravity="center_vertical"
|
||||
a:scaleType="centerInside"
|
||||
a:padding="6dp"
|
||||
a:src="@drawable/kb_disk"
|
||||
a:visibility="invisible"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="fill_parent"
|
||||
a:text="@string/c_history_item_status"
|
||||
style="@style/history_item_label" />
|
||||
|
||||
<TextView
|
||||
a:id="@+id/history_item_status"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
style="@style/history_item" />
|
||||
</LinearLayout>
|
||||
a:layout_height="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
@ -26,6 +26,7 @@
|
||||
style="@style/history_item" />
|
||||
|
||||
<LinearLayout
|
||||
a:id="@+id/history_item_comment_layout"
|
||||
a:orientation="horizontal"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
|
@ -234,7 +234,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
for (int i = 0; i < actionBar.getTabCount(); i++) {
|
||||
final ActionBar.Tab tab = actionBar.getTabAt(i);
|
||||
if (tab != null && CalculatorFragmentType.plotter.getFragmentTag().equals(tab.getTag())) {
|
||||
if (tab != null && fragmentType.getFragmentTag().equals(tab.getTag())) {
|
||||
actionBar.setSelectedNavigationItem(i);
|
||||
break;
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.solovyev.android.calculator.*;
|
||||
|
||||
import static org.solovyev.android.calculator.CalculatorFragmentType.history;
|
||||
import static org.solovyev.android.calculator.CalculatorFragmentType.saved_history;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
@ -28,8 +31,8 @@ public class CalculatorHistoryActivity extends SherlockFragmentActivity implemen
|
||||
|
||||
activityHelper.onCreate(this, savedInstanceState);
|
||||
|
||||
activityHelper.addTab(this, CalculatorFragmentType.history, null, R.id.main_layout);
|
||||
activityHelper.addTab(this, CalculatorFragmentType.saved_history, null, R.id.main_layout);
|
||||
activityHelper.addTab(this, history, null, R.id.main_layout);
|
||||
activityHelper.addTab(this, saved_history, null, R.id.main_layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,4 +70,9 @@ public class CalculatorHistoryActivity extends SherlockFragmentActivity implemen
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
CalculatorActivityHelper getActivityHelper() {
|
||||
return activityHelper;
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,12 @@ import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.solovyev.android.calculator.CalculatorActivityLauncher;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
@ -19,6 +23,11 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.solovyev.android.calculator.CalculatorFragmentType.saved_history;
|
||||
import static org.solovyev.android.calculator.history.AbstractCalculatorHistoryFragment.isAlreadySaved;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
@ -42,27 +51,38 @@ public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
|
||||
final TextView editor = (TextView) result.findViewById(R.id.history_item);
|
||||
editor.setText(AbstractCalculatorHistoryFragment.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 (commentView != null) {
|
||||
if (commentLayout != null && commentView != null) {
|
||||
final String comment = state.getComment();
|
||||
if (!Strings.isEmpty(comment)) {
|
||||
commentView.setText(comment);
|
||||
commentLayout.setVisibility(VISIBLE);
|
||||
} else {
|
||||
commentView.setText("");
|
||||
commentView.setText(null);
|
||||
commentLayout.setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
final TextView status = (TextView) result.findViewById(R.id.history_item_status);
|
||||
final ImageView status = (ImageView) result.findViewById(R.id.history_item_status_icon);
|
||||
if (status != null) {
|
||||
if (state.isSaved()) {
|
||||
status.setText(getContext().getString(R.string.c_history_item_saved));
|
||||
} else {
|
||||
if (AbstractCalculatorHistoryFragment.isAlreadySaved(state)) {
|
||||
status.setText(getContext().getString(R.string.c_history_item_already_saved));
|
||||
} else {
|
||||
status.setText(getContext().getString(R.string.c_history_item_not_saved));
|
||||
if (state.isSaved() || isAlreadySaved(state)) {
|
||||
status.getDrawable().setAlpha(180);
|
||||
status.setVisibility(VISIBLE);
|
||||
status.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final Context context = getContext();
|
||||
if(context instanceof CalculatorHistoryActivity) {
|
||||
final CalculatorHistoryActivity activity = (CalculatorHistoryActivity) context;
|
||||
activity.getActivityHelper().selectTab(activity, saved_history);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
status.setVisibility(INVISIBLE);
|
||||
status.setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user