Commit d12ec596 authored by wanglei's avatar wanglei

...

parent 8217742d
/*
* 文件名称: SheetList.java
*
*
* 编译器: android2.2
* 时间: 下午4:13:50
*/
......@@ -18,11 +18,11 @@ import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
/**
*
* <p>
* <p>
* Read版本: Read V1.0
......@@ -33,58 +33,48 @@ import android.widget.LinearLayout;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public class SheetBar extends HorizontalScrollView implements OnClickListener
{
public class SheetBar extends HorizontalScrollView implements OnClickListener {
public SheetBar(Context context)
{
public SheetBar(Context context) {
super(context);
}
}
public SheetBar(Context context, IControl control, int minimumWidth)
{
public SheetBar(Context context, IControl control, int minimumWidth) {
super(context);
this.control = control;
this.setVerticalFadingEdgeEnabled(false);
this.setFadingEdgeLength(0);
if (minimumWidth == getResources().getDisplayMetrics().widthPixels)
{
if (minimumWidth == getResources().getDisplayMetrics().widthPixels) {
this.minimumWidth = -1;
}
else
{
} else {
this.minimumWidth = minimumWidth;
}
init();
}
/**
*
*
*/
public void onConfigurationChanged(Configuration newConfig)
{
public void onConfigurationChanged(Configuration newConfig) {
sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels
: minimumWidth);
: minimumWidth);
}
/**
*
*
*/
private void init()
{
private void init() {
Context context = this.getContext();
sheetbarFrame = new LinearLayout(context);
sheetbarFrame.setGravity(Gravity.BOTTOM);
sheetbarResManager = new SheetbarResManager(context);
// Drawable drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG);
......@@ -93,144 +83,129 @@ public class SheetBar extends HorizontalScrollView implements OnClickListener
// sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG);
sheetbarFrame.setBackground(drawable);
sheetbarFrame.setOrientation(LinearLayout.HORIZONTAL);
sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels
: minimumWidth);
sheetbarHeight = drawable.getIntrinsicHeight();
sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels : minimumWidth);
sheetbarHeight = drawable.getIntrinsicHeight();
drawable = sheetbarResManager.getDrawable((short) R.drawable.ss_sheetbar_shadow_left);
LayoutParams parmas = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// 左边shadow
View left = new View(context);
left.setBackground(drawable);
sheetbarFrame.addView(left, parmas);
// sheetButton
@ SuppressWarnings("unchecked")
Vector<String> vec = (Vector<String>)control.getActionValue(EventConstant.SS_GET_ALL_SHEET_NAME, null);
@SuppressWarnings("unchecked")
Vector<String> vec = (Vector<String>) control.getActionValue(EventConstant.SS_GET_ALL_SHEET_NAME, null);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT);
LayoutParams parmasButton = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int count = vec.size();
for (int i = 0; i < count; i++)
{
for (int i = 0; i < count; i++) {
SheetButton sb = new SheetButton(context, vec.get(i), i, sheetbarResManager);
if (currentSheet == null)
{
if (currentSheet == null) {
currentSheet = sb;
currentSheet.changeFocus(true);
}
sb.setOnClickListener(this);
sheetbarFrame.addView(sb, parmasButton);
if (i < count - 1)
{
if (i < count - 1) {
View view = new View(context);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SEPARATOR_H);
view.setBackground(drawable);
sheetbarFrame.addView(view, parmasButton);
}
}
// 右边shadow
View right = new View(context);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SHADOW_RIGHT);
right.setBackgroundDrawable(drawable);
right.setBackgroundDrawable(drawable);
sheetbarFrame.addView(right, parmas);
//
addView(sheetbarFrame, new LayoutParams(LayoutParams.WRAP_CONTENT, sheetbarHeight));
LayoutParams addLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, 70);
addView(sheetbarFrame, addLayoutParams);
}
/**
*
*
*/
public void onClick(View v)
{
public void onClick(View v) {
currentSheet.changeFocus(false);
SheetButton sb = (SheetButton)v;
SheetButton sb = (SheetButton) v;
sb.changeFocus(true);
currentSheet = sb;
control.actionEvent(EventConstant.SS_SHOW_SHEET, currentSheet.getSheetIndex());
}
/**
* set focus sheet button(called when clicked document hyperlink)
*
* @param index
*/
public void setFocusSheetButton(int index)
{
if(currentSheet.getSheetIndex() == index)
{
public void setFocusSheetButton(int index) {
if (currentSheet.getSheetIndex() == index) {
return;
}
int count = sheetbarFrame.getChildCount();
View view = null;
for(int i = 0; i < count; i++)
{
for (int i = 0; i < count; i++) {
view = sheetbarFrame.getChildAt(i);
if (view instanceof SheetButton && ((SheetButton)view).getSheetIndex() == index)
{
if (view instanceof SheetButton && ((SheetButton) view).getSheetIndex() == index) {
currentSheet.changeFocus(false);
currentSheet = (SheetButton)view;
currentSheet = (SheetButton) view;
currentSheet.changeFocus(true);
break;
}
}
//sheetbar scrolled
int screenWidth = control.getActivity().getWindowManager().getDefaultDisplay().getWidth();
int barWidth = sheetbarFrame.getWidth();
if(barWidth > screenWidth)
{
if (barWidth > screenWidth) {
int left = view.getLeft();
int right = view.getRight();
int off = (screenWidth - (right - left)) / 2;
off = left - off;
if(off < 0)
{
if (off < 0) {
off = 0;
}
else if(off + screenWidth > barWidth)
{
} else if (off + screenWidth > barWidth) {
off = barWidth - screenWidth;
}
scrollTo(off, 0);
}
}
/**
* @return Returns the sheetbarHeight.
*/
public int getSheetbarHeight()
{
public int getSheetbarHeight() {
return sheetbarHeight;
}
/**
*
*
*/
public void dispose()
{
public void dispose() {
sheetbarResManager.dispose();
sheetbarResManager = null;
currentSheet = null;
if(sheetbarFrame != null)
{
if (sheetbarFrame != null) {
int count = sheetbarFrame.getChildCount();
View v;
for(int i = 0; i < count; i++)
{
for (int i = 0; i < count; i++) {
v = sheetbarFrame.getChildAt(i);
if(v instanceof SheetButton)
{
((SheetButton)v).dispose();
if (v instanceof SheetButton) {
((SheetButton) v).dispose();
}
}
sheetbarFrame = null;
......
/*
* 文件名称: SheetButton.java
*
*
* 编译器: android2.2
* 时间: 下午6:06:50
*/
package com.cherry.lib.doc.office.ss.sheetbar;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.cherry.lib.doc.R;
/**
* sheet表名称按钮
* <p>
......@@ -26,134 +34,144 @@ import android.widget.TextView;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public class SheetButton extends LinearLayout
{
private static final int FONT_SIZE = 18;
@SuppressLint("ViewConstructor")
public class SheetButton extends LinearLayout {
private static final int FONT_SIZE = 18;
//
private static final int SHEET_BUTTON_MIN_WIDTH = 100;
/**
*
* @param context
*/
public SheetButton(Context context, String sheetName, int sheetIndex, SheetbarResManager sheetbarResManager)
{
public SheetButton(Context context, String sheetName, int sheetIndex, SheetbarResManager sheetbarResManager) {
super(context);
setOrientation(HORIZONTAL);
this.sheetIndex = sheetIndex;
this.sheetbarResManager = sheetbarResManager;
init(context, sheetName);
}
/**
*
*
*/
private void init(Context context, String sheetName)
{
private void init(Context context, String sheetName) {
//左边图标
left = new View(context);
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
Drawable leftDrawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT);
if (leftDrawable != null) {
Log.e("SheetButton", "leftDrawable=null");
} else {
Log.e("SheetButton", "leftDrawable!=null");
}
left.setBackgroundDrawable(leftDrawable);
addView(left);
//
textView = new TextView(context);
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
Drawable middleDrawable =
ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_focus_middle);
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE);
if (middleDrawable == null) {
Log.e("SheetButton", "middleDrawable=null");
} else {
Log.e("SheetButton", "middleDrawable!=null");
}
textView.setBackgroundDrawable(middleDrawable);
textView.setText(sheetName);
textView.setTextSize(FONT_SIZE);
textView.setGravity(Gravity.CENTER);
textView.setTextColor(Color.BLACK);
int w = (int)textView.getPaint().measureText(sheetName);
int w = (int) textView.getPaint().measureText(sheetName);
w = Math.max(w, SHEET_BUTTON_MIN_WIDTH);
addView(textView, new LayoutParams(w, LayoutParams.MATCH_PARENT));
// 右边图标
right = new View(context);
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
addView(right);
}
/**
*
*
*/
public boolean onTouchEvent(MotionEvent event)
{
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
switch (action)
{
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
if(!active)
{
if (!active) {
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_LEFT));
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_MIDDLE));
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_RIGHT));
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if(!active)
{
if (!active) {
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
}
}
break;
}
return super.onTouchEvent(event);
}
/**
* 选中或取消选中用到
*/
public void changeFocus(boolean gainFocus)
{
public void changeFocus(boolean gainFocus) {
active = gainFocus;
left.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
textView.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
right.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
Log.e("SheetButton", "changeFocus=" + gainFocus);
left.setBackgroundDrawable(gainFocus ?
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
textView.setBackgroundDrawable(gainFocus ?
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
right.setBackgroundDrawable(gainFocus ?
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
}
/**
*
*
*/
public int getSheetIndex()
{
public int getSheetIndex() {
return this.sheetIndex;
}
/**
*
*
*/
public void dispose()
{
public void dispose() {
sheetbarResManager = null;
left = null;
textView = null;
right = null;
}
private SheetbarResManager sheetbarResManager;
//
private int sheetIndex;;
private int sheetIndex;
;
// 左边图标
private View left;
// 中间文本
private TextView textView;
// 右边图标
private View right;
private boolean active;
}
/*
* 文件名称: ResConstant.java
*
* 编译器: android2.2
* 时间: 上午11:31:49
*/
package com.wxiwei.office.res;
/**
* 国际化的资源常量
* <p>
* <p>
* Read版本: Read V1.0
* <p>
* 作者: ljj8494
* <p>
* 日期: 2012-8-13
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* <p>
* <p>
*/
public class ResConstant
{
//
public static final String BUTTON_OK = "OK";
//
public static final String BUTTON_CANCEL = "Cancel";
//
public static final String DIALOG_ENCODING_TITLE = "Text Encoding";
//
public static final String DIALOG_LOADING = "Loading, please wait...";
//
public static final String DIALOG_INSUFFICIENT_MEMORY = "Unable to complete operation due to insufficient memory";
//
public static final String DIALOG_SYSTEM_CRASH = "System crash, terminate running";
//
public static final String DIALOG_FORMAT_ERROR = "Bad file";
//
public static final String DIALOG_OLD_DOCUMENT = "The document is too old - Office 95 or older, which is not supported";
//
public static final String DIALOG_PARSE_ERROR = "File parsing error";
//
public static final String DIALOG_RTF_FILE = "The document is really a RTF file, which is not supported";
//
public static final String DIALOG_PDF_SEARCHING = "Searching...";
//
public static final String DIALOG_FIND_NOT_FOUND = "Content not found";
//
public static final String DIALOG_FIND_TO_BEGIN = "Search to the document begin";
//
public static final String DIALOG_FIND_TO_END = "Search to the document end";
//
public static final String DIALOG_ENTER_PASSWORD = "Enter Password";
//
public static final String DIALOG_CANNOT_ENCRYPTED_FILE = "Cannot process encrypted file";
//
public static final String DIALOG_PASSWORD_INCORRECT = "Password is incorrect!";
//
public static final String EXIT_SLIDESHOW = "End of slideshow, tap to exit.";
//
public static final String SD_CARD_ERROR = "SD Card Error";
//
public static final String SD_CARD_WRITEDENIED = "SD Card write permission denied";
//
public static final String SD_CARD_NOSPACELEFT = "SD Card has no space left" ;
}
/*
* 文件名称: ResKit.java
*
* 编译器: android2.2
* 时间: 下午9:03:08
*/
package com.wxiwei.office.res;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
*
* <p>
* <p>
* Read版本: Read V1.0
* <p>
* 作者: ljj8494
* <p>
* 日期: 2012-9-20
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* <p>
* <p>
*/
public class ResKit
{
//
private static ResKit kit = new ResKit();
/**
*
*/
public ResKit()
{
try
{
res = new HashMap<String, String>();
// load "ResConstant"
Class cls = Class.forName("com.wxiwei.office.res.ResConstant");
// get all fields
Field[] fields = cls.getDeclaredFields();
for (Field field : fields)
{
res.put(field.getName(), (String)field.get(null));
}
}
catch(Exception e)
{
}
}
/**
*
*/
public static ResKit instance()
{
return kit;
}
/**
*
*/
public boolean hasResName(String resName)
{
return res.containsKey(resName);
}
/**
*
* @param resName
* @return
*/
public String getLocalString(String resName)
{
return res.get(resName);
}
//
private Map<String, String> res;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment