Commit 04b868ae by zhengnw@sobot.com

widget 1.2.9

parent e700e43c
......@@ -229,28 +229,28 @@ public class MainActivity extends SobotBaseActivity {
map1.put("way", "10");
map1.put("ack", "1");
map1.put("version", "3.3.9");
SobotLoginTools.getInstance().doLogin(MainActivity.this, getSobotBaseContext(), true, "https://api-c-test.sobot.com/text", "https://api-c-test.sobot.com/text", "zengzhi@zhichi.com", "Xiaoxin818", "",map1, new SobotResultBlock() {
@Override
public void resultBolok(SobotResultCode code, String msg, Object obj) {
if(code==SobotResultCode.CODE_SUCCEEDED) {
SobotLoginTools.getInstance().checkExpiresToken();
// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken() + "");
SobotLogUtils.i(SobotLoginTools.getInstance().getToken() + "");
SobotLogUtils.i(SobotLoginTools.getInstance().getServiceInfo().getStatus() + "====登录状态======");
if (obj instanceof SobotServiceInfoModel) {
SobotLogUtils.i("默认登录状态====" + ((SobotServiceInfoModel) obj).getDefaultAppLoginStatus());
}
}else{
SobotLogUtils.i("code =" + code+",msg="+msg+",obj="+obj);
}
// SobotLoginTools.getInstance().logOut(MainActivity.this, "https://test-branche1.sobot.com/text", "zhengnw@zhichi.com", new SobotResultBlock() {
// SobotLoginTools.getInstance().doLogin(MainActivity.this, getSobotBaseContext(), true, "https://api-c-test.sobot.com/text", "https://api-c-test.sobot.com/text", "zengzhi@zhichi.com", "Xiaoxin818", "",map1, new SobotResultBlock() {
// @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) {
//
// if(code==SobotResultCode.CODE_SUCCEEDED) {
// SobotLoginTools.getInstance().checkExpiresToken();
//// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken() + "");
// SobotLogUtils.i(SobotLoginTools.getInstance().getToken() + "");
// SobotLogUtils.i(SobotLoginTools.getInstance().getServiceInfo().getStatus() + "====登录状态======");
// if (obj instanceof SobotServiceInfoModel) {
// SobotLogUtils.i("默认登录状态====" + ((SobotServiceInfoModel) obj).getDefaultAppLoginStatus());
// }
// }else{
// SobotLogUtils.i("code =" + code+",msg="+msg+",obj="+obj);
// }
//// SobotLoginTools.getInstance().logOut(MainActivity.this, "https://test-branche1.sobot.com/text", "zhengnw@zhichi.com", new SobotResultBlock() {
//// @Override
//// public void resultBolok(SobotResultCode code, String msg, Object obj) {
////
//// }
//// });
// }
// });
}
});
// SobotLoginTools.getInstance().loginWithAppkey(MainActivity.this, getSobotBaseContext(), true, "https://api-c.sobot.com/text", "https://api-c.soboten.com/text", "zhengnw@zhichi.com", "b83B6E072W29", "4ce7ca987fcf43beb17ed1eca84dd760", map1, new SobotResultBlock() {
// @Override
......
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.2.8.2' //版本号
PUBLISH_VERSION = '1.2.9' //版本号
}
......
package com.sobot.widget.popwindow;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
import androidx.annotation.RequiresApi;
public class SobotBasePopupWindow {
private Context mContext;
private int mWidth;
private int mHeight;
private boolean mIsFocusable = true;
private boolean mIsOutside = true;
private int mResLayoutId = -1;
private View mContentView;
private PopupWindow mPopupWindow;
private int mAnimationStyle = -1;
private boolean mClippEnable = true;//default is true
private boolean mIgnoreCheekPress = false;
private int mInputMode = -1;
private PopupWindow.OnDismissListener mOnDismissListener;
private int mSoftInputMode = -1;
private boolean mTouchable = true;//default is ture
private View.OnTouchListener mOnTouchListener;
private SobotBasePopupWindow(Context context) {
mContext = context;
}
public int getWidth() {
return mWidth;
}
public int getHeight() {
return mHeight;
}
public boolean isShow() {
return mPopupWindow != null && mPopupWindow.isShowing();
}
/**
* @param anchor
* @param xOff
* @param yOff
* @return
*/
public SobotBasePopupWindow showAsDropDown(View anchor, int xOff, int yOff) {
if (mPopupWindow != null) {
mPopupWindow.showAsDropDown(anchor, xOff, yOff);
}
return this;
}
public SobotBasePopupWindow showAsDropDown(View anchor) {
if (mPopupWindow != null) {
//兼容7.1以上手机失效问题
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Rect rect = new Rect();
anchor.getGlobalVisibleRect(rect);
//测量
DisplayMetrics dm = new DisplayMetrics();
WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getRealMetrics(dm);
int heightPixels = dm.heightPixels;
int h = heightPixels - rect.bottom;
mPopupWindow.setHeight(h);
}
mPopupWindow.showAsDropDown(anchor);
}
return this;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public SobotBasePopupWindow showAsDropDown(View anchor, int xOff, int yOff, int gravity) {
if (mPopupWindow != null) {
mPopupWindow.showAsDropDown(anchor, xOff, yOff, gravity);
}
return this;
}
/**
* 相对于父控件的位置(通过设置Gravity.CENTER,下方Gravity.BOTTOM等 ),可以设置具体位置坐标
*
* @param parent
* @param gravity
* @param x the popup's x location offset
* @param y the popup's y location offset
* @return
*/
public SobotBasePopupWindow showAtLocation(View parent, int gravity, int x, int y) {
if (mPopupWindow != null) {
mPopupWindow.showAtLocation(parent, gravity, x, y);
}
return this;
}
/**
* 添加一些属性设置
*
* @param popupWindow
*/
private void apply(PopupWindow popupWindow) {
popupWindow.setClippingEnabled(mClippEnable);
if (mIgnoreCheekPress) {
popupWindow.setIgnoreCheekPress();
}
if (mInputMode != -1) {
popupWindow.setInputMethodMode(mInputMode);
}
if (mSoftInputMode != -1) {
popupWindow.setSoftInputMode(mSoftInputMode);
}
if (mOnDismissListener != null) {
popupWindow.setOnDismissListener(mOnDismissListener);
}
if (mOnTouchListener != null) {
popupWindow.setTouchInterceptor(mOnTouchListener);
}
popupWindow.setTouchable(mTouchable);
}
private PopupWindow build() {
if (mContentView == null) {
mContentView = LayoutInflater.from(mContext).inflate(mResLayoutId, null);
}
if (mWidth != 0 && mHeight != 0) {
mPopupWindow = new PopupWindow(mContentView, mWidth, mHeight);
} else {
mPopupWindow = new PopupWindow(mContentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
if (mAnimationStyle != -1) {
mPopupWindow.setAnimationStyle(mAnimationStyle);
}
apply(mPopupWindow);//设置一些属性
mPopupWindow.setFocusable(mIsFocusable);
mPopupWindow.setBackgroundDrawable(new ColorDrawable());
mPopupWindow.setOutsideTouchable(mIsOutside);
if (mWidth == 0 || mHeight == 0) {
mPopupWindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
//如果外面没有设置宽高的情况下,计算宽高并赋值
mWidth = mPopupWindow.getContentView().getMeasuredWidth();
mHeight = mPopupWindow.getContentView().getMeasuredHeight();
}
mPopupWindow.update();
return mPopupWindow;
}
public View getmContentView() {
return mContentView;
}
public void setmContentView(View mContentView) {
this.mContentView = mContentView;
}
/**
* 关闭popWindow
*/
public void dissmiss() {
if (mPopupWindow != null) {
mPopupWindow.dismiss();
}
}
public static class PopupWindowBuilder {
private SobotBasePopupWindow mHwbPopWindow;
public PopupWindowBuilder(Context context) {
mHwbPopWindow = new SobotBasePopupWindow(context);
}
public PopupWindowBuilder size(int width, int height) {
mHwbPopWindow.mWidth = width;
mHwbPopWindow.mHeight = height;
return this;
}
public PopupWindowBuilder setFocusable(boolean focusable) {
mHwbPopWindow.mIsFocusable = focusable;
return this;
}
public PopupWindowBuilder setView(int resLayoutId) {
mHwbPopWindow.mResLayoutId = resLayoutId;
mHwbPopWindow.mContentView = null;
return this;
}
public PopupWindowBuilder setView(View view) {
mHwbPopWindow.mContentView = view;
mHwbPopWindow.mResLayoutId = -1;
return this;
}
public PopupWindowBuilder setOutsideTouchable(boolean outsideTouchable) {
mHwbPopWindow.mIsOutside = outsideTouchable;
return this;
}
/**
* 设置弹窗动画
*
* @param animationStyle
* @return
*/
public PopupWindowBuilder setAnimationStyle(int animationStyle) {
mHwbPopWindow.mAnimationStyle = animationStyle;
return this;
}
public PopupWindowBuilder setClippingEnable(boolean enable) {
mHwbPopWindow.mClippEnable = enable;
return this;
}
public PopupWindowBuilder setIgnoreCheekPress(boolean ignoreCheekPress) {
mHwbPopWindow.mIgnoreCheekPress = ignoreCheekPress;
return this;
}
public PopupWindowBuilder setInputMethodMode(int mode) {
mHwbPopWindow.mInputMode = mode;
return this;
}
public PopupWindowBuilder setOnDissmissListener(PopupWindow.OnDismissListener onDissmissListener) {
mHwbPopWindow.mOnDismissListener = onDissmissListener;
return this;
}
public PopupWindowBuilder setSoftInputMode(int softInputMode) {
mHwbPopWindow.mSoftInputMode = softInputMode;
return this;
}
public PopupWindowBuilder setTouchable(boolean touchable) {
mHwbPopWindow.mTouchable = touchable;
return this;
}
public PopupWindowBuilder setTouchIntercepter(View.OnTouchListener touchIntercepter) {
mHwbPopWindow.mOnTouchListener = touchIntercepter;
return this;
}
public SobotBasePopupWindow create() {
//构建PopWindow
mHwbPopWindow.build();
return mHwbPopWindow;
}
}
}
\ No newline at end of file
......@@ -210,7 +210,8 @@ public class ClassicsHeader extends ClassicsAbstract<ClassicsHeader> implements
} else {
mTextUpdate = context.getString(R.string.sobot_srl_header_update);
}
mLastUpdateFormat = new SimpleDateFormat(mTextUpdate, Locale.getDefault());
mLastUpdateFormat = new SimpleDateFormat("MM-dd HH:mm");
ta.recycle();
......@@ -299,7 +300,7 @@ public class ClassicsHeader extends ClassicsAbstract<ClassicsHeader> implements
public ClassicsHeader setLastUpdateTime(Date time) {
final View thisView = this;
mLastTime = time;
mLastUpdateText.setText(mLastUpdateFormat.format(time));
mLastUpdateText.setText( String.format(mTextUpdate, mLastUpdateFormat.format(time)));
if (mShared != null && !thisView.isInEditMode()) {
mShared.edit().putLong(KEY_LAST_UPDATE_TIME, time.getTime()).apply();
}
......@@ -309,7 +310,7 @@ public class ClassicsHeader extends ClassicsAbstract<ClassicsHeader> implements
public ClassicsHeader setTimeFormat(DateFormat format) {
mLastUpdateFormat = format;
if (mLastTime != null) {
mLastUpdateText.setText(mLastUpdateFormat.format(mLastTime));
mLastUpdateText.setText(String.format(mTextUpdate, mLastUpdateFormat.format(mLastTime)));
}
return this;
}
......
......@@ -19,13 +19,12 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
......@@ -126,7 +125,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
if (view instanceof WebView && view.getParent() instanceof LinearLayout) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
layoutParams.rightMargin = (rect.right > 110 ? 110 : rect.right) + 14;
layoutParams.leftMargin = (rect.right > 110 ? 110 : rect.right) + 14;
layoutParams.leftMargin = (Math.min(rect.right, 110)) + 14;
view.setLayoutParams(layoutParams);
} else if (view instanceof WebView && view.getParent() instanceof RelativeLayout) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
......@@ -180,7 +179,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
public void changeAppLanguage() {
try {
Locale locale = (Locale) SobotSharedPreferencesUtil.getInstance(getSobotBaseContext()).get("SobotLanguage", Locale.class);
Locale locale = (Locale) SobotSharedPreferencesUtil.getInstance(getSobotBaseActivity()).get("SobotLanguage", Locale.class);
if (locale == null) {
//获取系统语言
locale = getSysPreferredLocale();
......@@ -273,6 +272,10 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return findViewById(getResId("sobot_tv_right"));
}
protected ImageView getRightIcon() {
return findViewById(getResId("call_icon"));
}
protected View getTitleView() {
return findViewById(getResId("sobot_text_title"));
}
......@@ -633,6 +636,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
intent.putExtra("selectType", selectType);
startActivityForResult(intent, SobotBaseConstant.REQUEST_CODE_PICTURE);
}
/**
* 检查存储权限
*
......
......@@ -634,7 +634,6 @@ public final class CalendarUtil {
if (calendarDate.equals(currentDate)) {
calendarDate.setCurrentDay(true);
}
LunarCalendar.setupLunarCalendar(calendarDate);
mItems.add(calendarDate);
}
return mItems;
......@@ -701,7 +700,6 @@ public final class CalendarUtil {
if (selectCalendar.equals(mDelegate.getCurrentDay())) {
selectCalendar.setCurrentDay(true);
}
LunarCalendar.setupLunarCalendar(selectCalendar);
selectCalendar.setCurrentMonth(true);
mItems.add(selectCalendar);
......@@ -715,7 +713,6 @@ public final class CalendarUtil {
if (calendarDate.equals(mDelegate.getCurrentDay())) {
calendarDate.setCurrentDay(true);
}
LunarCalendar.setupLunarCalendar(calendarDate);
calendarDate.setCurrentMonth(true);
mItems.add(calendarDate);
}
......@@ -808,7 +805,6 @@ public final class CalendarUtil {
calendar.setCurrentMonth(calendar.getYear() == delegate.getCurrentDay().getYear() &&
calendar.getMonth() == delegate.getCurrentDay().getMonth());
calendar.setCurrentDay(calendar.equals(delegate.getCurrentDay()));
LunarCalendar.setupLunarCalendar(calendar);
return calendar;
}
......
......@@ -424,7 +424,6 @@ final class CalendarViewDelegate {
CalendarViewDelegate(Context context, @Nullable AttributeSet attrs) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Sobot_CalendarView);
LunarCalendar.init(context);
mCalendarPadding = (int) array.getDimension(R.styleable.Sobot_CalendarView_sobot_calendar_padding, 0);
mCalendarPaddingLeft = (int) array.getDimension(R.styleable.Sobot_CalendarView_sobot_calendar_padding_left, 0);
......@@ -557,7 +556,6 @@ final class CalendarViewDelegate {
mCurrentDate.setMonth(CalendarUtil.getDate("MM", d));
mCurrentDate.setDay(CalendarUtil.getDate("dd", d));
mCurrentDate.setCurrentDay(true);
LunarCalendar.setupLunarCalendar(mCurrentDate);
setRange(mMinYear, mMinYearMonth, mMaxYear, mMaxYearMonth);
try {
......@@ -969,7 +967,6 @@ final class CalendarViewDelegate {
mCurrentDate.setYear(CalendarUtil.getDate("yyyy", d));
mCurrentDate.setMonth(CalendarUtil.getDate("MM", d));
mCurrentDate.setDay(CalendarUtil.getDate("dd", d));
LunarCalendar.setupLunarCalendar(mCurrentDate);
}
@SuppressWarnings("unused")
......@@ -1068,7 +1065,6 @@ final class CalendarViewDelegate {
calendar.setMonth(mCurrentDate.getMonth());
calendar.setDay(mCurrentDate.getDay());
calendar.setCurrentDay(true);
LunarCalendar.setupLunarCalendar(calendar);
return calendar;
}
......@@ -1078,7 +1074,6 @@ final class CalendarViewDelegate {
calendar.setMonth(mMinYearMonth);
calendar.setDay(mMinYearDay);
calendar.setCurrentDay(calendar.equals(mCurrentDate));
LunarCalendar.setupLunarCalendar(calendar);
return calendar;
}
......@@ -1089,7 +1084,6 @@ final class CalendarViewDelegate {
calendar.setMonth(mMaxYearMonth);
calendar.setDay(mMaxYearDay);
calendar.setCurrentDay(calendar.equals(mCurrentDate));
LunarCalendar.setupLunarCalendar(calendar);
return calendar;
}
......@@ -1183,7 +1177,6 @@ final class CalendarViewDelegate {
calendar.setYear(date.get(java.util.Calendar.YEAR));
calendar.setMonth(date.get(java.util.Calendar.MONTH) + 1);
calendar.setDay(date.get(java.util.Calendar.DAY_OF_MONTH));
LunarCalendar.setupLunarCalendar(calendar);
updateCalendarScheme(calendar);
if (mCalendarInterceptListener != null &&
mCalendarInterceptListener.onCalendarIntercept(calendar)) {
......
......@@ -38,25 +38,46 @@ public class CustomWeekBar extends WeekBar {
@Override
protected void onWeekStartChange(int weekStart) {
for (int i = 0; i < getChildCount(); i++) {
((TextView) getChildAt(i)).setText(getWeekString(i, weekStart));
int receId =0;
if (weekStart == 1) {
//周日开始
if(i==0){
receId= R.string.calendar_day;
}else if(i==1) {
receId = R.string.calendar_one;
}else if(i==2) {
receId = R.string.calendar_two;
}else if(i==3) {
receId = R.string.calendar_three;
}else if(i==4) {
receId = R.string.calendar_four;
}else if(i==5) {
receId = R.string.calendar_five;
}else if(i==6) {
receId = R.string.calendar_six;
}
}else if (weekStart == 2) {
//周一开始
if(i==0) {
receId = R.string.calendar_one;
}else if(i==1) {
receId = R.string.calendar_two;
}else if(i==2) {
receId = R.string.calendar_three;
}else if(i==3) {
receId = R.string.calendar_four;
}else if(i==4) {
receId = R.string.calendar_five;
}else if(i==5) {
receId = R.string.calendar_six;
}else if(i==6) {
receId = R.string.calendar_day;
}
/**
* 或者周文本,这个方法仅供父类使用
* @param index index
* @param weekStart weekStart
* @return 或者周文本
*/
private String getWeekString(int index, int weekStart) {
String[] weeks = getContext().getResources().getStringArray(R.array.sobot_week_string_array);
if (weekStart == 1) {
return weeks[index];
}
if (weekStart == 2) {
return weeks[index == 6 ? 0 : index + 1];
if(receId != 0) {
((TextView) getChildAt(i)).setText(receId);
}
return weeks[index == 0 ? 6 : index - 1];
}
}
}
......@@ -305,7 +305,6 @@ public final class MonthViewPager extends ViewPager {
calendar.setMonth(month);
calendar.setDay(day);
calendar.setCurrentDay(calendar.equals(mDelegate.getCurrentDay()));
LunarCalendar.setupLunarCalendar(calendar);
mDelegate.mIndexCalendar = calendar;
mDelegate.mSelectedCalendar = calendar;
mDelegate.updateSelectCalendarScheme();
......
......@@ -27,15 +27,6 @@ import com.sobot.widget.R;
public final class SolarTermUtil {
static void init(Context context) {
SOLAR_TERMS = context.getResources().getStringArray(R.array.sobot_solar_term);
}
/**
* 24节气
*/
private static String SOLAR_TERMS[] = null;
/**
* 每弧度的角秒数
*/
......@@ -573,66 +564,6 @@ public final class SolarTermUtil {
}
/**
* 获得某一年24节气
*
* @param year 年
* @return 24节气
*/
public static String[] getSolarTerms(int year) {
String[] solarTerms = new String[24];
String[] preOffset = getSolarTermsPreOffset(year - 1);
String[] nextOffset = getSolarTermsNextOffset(year - 1);
System.arraycopy(preOffset, 0, solarTerms, 0, preOffset.length);
System.arraycopy(nextOffset, 0, solarTerms, 22, nextOffset.length);
double jd = 365.2422 * (year - 2000), q;
for (int i = 0; i < 19; i++) {
q = getTimeFromAngle(jd + i * 15.2, i * 15, 0);
q = q + J2000 + (double) 8 / 24; // 计算第i个节气(i=0是春分),结果转为北京时
Time time = setFromJulian(q, true);
solarTerms[i + 3] = time.toString() + SOLAR_TERMS[i];
}
return solarTerms;
}
/**
* 要获得2018年24节气需要传入2017年
*
* @param year 要获得2018年24节气需要传入2017年
* @return 返回 立春 雨水 惊蛰
*/
private static String[] getSolarTermsPreOffset(int year) {
String[] solarTerms = new String[3];
double jd = 365.2422 * (year - 2000), q;
for (int i = 21; i < 24; i++) {
q = getTimeFromAngle(jd + i * 15.2, i * 15, 0);
q = q + J2000 + (double) 8 / 24; // 计算第i个节气(i=0是春分)
Time time = setFromJulian(q, true);
solarTerms[i - 21] = time.toString() + SOLAR_TERMS[i];
}
return solarTerms;
}
/**
* 要获得2018年24节气需要传入2017年
*
* @param year 要获得2018年24节气需要传入2017年
* @return 返回 小寒大寒
*/
private static String[] getSolarTermsNextOffset(int year) {
String[] solarTerms = new String[2];
double jd = 365.2422 * (year - 2000), q;
for (int i = 19; i < 21; i++) {
q = getTimeFromAngle(jd + i * 15.2, i * 15, 0);
q = q + J2000 + (double) 8 / 24; // 计算第i个节气(i=0是春分)
Time time = setFromJulian(q, true);
solarTerms[i - 19] = time.toString() + SOLAR_TERMS[i];
}
return solarTerms;
}
/**
* 章动
......
package com.sobot.widget.ui.calenderview;
import android.content.Context;
import com.sobot.widget.R;
/**
* 干支纪年算法
*/
@SuppressWarnings("unused")
public final class TrunkBranchAnnals {
/**
* 天干字符串
*/
private static String[] TRUNK_STR = null;
/**
* 地支字符串
*/
private static String[] BRANCH_STR = null;
/**
* 单独使用请先调用这个方法
* @param context context
*/
public static void init(Context context) {
if (TRUNK_STR != null) {
return;
}
TRUNK_STR = context.getResources().getStringArray(R.array.sobot_trunk_string_array);
BRANCH_STR = context.getResources().getStringArray(R.array.sobot_branch_string_array);
}
/**
* 获取某一年对应天干文字
*
* @param year 年份
* @return 天干由甲到癸,每10一轮回
*/
@SuppressWarnings("all")
public static String getTrunkString(int year) {
return TRUNK_STR[getTrunkInt(year)];
}
/**
* 获取某一年对应天干,
*
* @param year 年份
* @return 4 5 6 7 8 9 10 1 2 3
*/
@SuppressWarnings("all")
public static int getTrunkInt(int year) {
int trunk = year % 10;
return trunk == 0 ? 9 : trunk - 1;
}
/**
* 获取某一年对应地支文字
*
* @param year 年份
* @return 地支由子到亥,每12一轮回
*/
@SuppressWarnings("all")
public static String getBranchString(int year) {
return BRANCH_STR[getBranchInt(year)];
}
/**
* 获取某一年对应地支
*
* @param year 年份
* @return 4 5 6 7 8 9 10 11 12 1 2 3
*/
@SuppressWarnings("all")
public static int getBranchInt(int year) {
int branch = year % 12;
return branch == 0 ? 11 : branch - 1;
}
/**
* 获取干支纪年
*
* @param year 年份
* @return 干支纪年
*/
public static String getTrunkBranchYear(int year) {
return String.format("%s%s", getTrunkString(year), getBranchString(year));
}
}
......@@ -96,7 +96,45 @@ public class WeekBar extends LinearLayout {
return;
}
for (int i = 0; i < getChildCount(); i++) {
((TextView) getChildAt(i)).setText(getWeekString(i, weekStart));
int receId =0;
if (weekStart == 1) {
//周日开始
if(i==0){
receId= R.string.calendar_day;
}else if(i==1) {
receId = R.string.calendar_one;
}else if(i==2) {
receId = R.string.calendar_two;
}else if(i==3) {
receId = R.string.calendar_three;
}else if(i==4) {
receId = R.string.calendar_four;
}else if(i==5) {
receId = R.string.calendar_five;
}else if(i==6) {
receId = R.string.calendar_six;
}
}else if (weekStart == 2) {
//周一开始
if(i==0) {
receId = R.string.calendar_one;
}else if(i==1) {
receId = R.string.calendar_two;
}else if(i==2) {
receId = R.string.calendar_three;
}else if(i==3) {
receId = R.string.calendar_four;
}else if(i==4) {
receId = R.string.calendar_five;
}else if(i==5) {
receId = R.string.calendar_six;
}else if(i==6) {
receId = R.string.calendar_day;
}
}
if(receId != 0) {
((TextView) getChildAt(i)).setText(receId);
}
}
}
......@@ -119,25 +157,6 @@ public class WeekBar extends LinearLayout {
return week == CalendarViewDelegate.WEEK_START_WITH_SAT ? 0 : week;
}
/**
* 或者周文本,这个方法仅供父类使用
*
* @param index index
* @param weekStart weekStart
* @return 或者周文本
*/
private String getWeekString(int index, int weekStart) {
String[] weeks = getContext().getResources().getStringArray(R.array.sobot_week_string_array);
if (weekStart == CalendarViewDelegate.WEEK_START_WITH_SUN) {
return weeks[index];
}
if (weekStart == CalendarViewDelegate.WEEK_START_WITH_MON) {
return weeks[index == 6 ? 0 : index + 1];
}
return weeks[index == 0 ? 6 : index - 1];
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mDelegate != null) {
......
......@@ -184,7 +184,6 @@ public final class WeekViewPager extends ViewPager {
calendar.setMonth(month);
calendar.setDay(day);
calendar.setCurrentDay(calendar.equals(mDelegate.getCurrentDay()));
LunarCalendar.setupLunarCalendar(calendar);
mDelegate.mIndexCalendar = calendar;
mDelegate.mSelectedCalendar = calendar;
mDelegate.updateSelectCalendarScheme();
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sobot_layout_titlebar"
android:layout_width="match_parent"
android:layout_height="@dimen/sobot_titlebar_height"
android:orientation="vertical"
android:background="@color/sobot_color_title_bar_bg">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:orientation="horizontal">
<TextView
......@@ -27,13 +27,9 @@
<LinearLayout
android:id="@+id/sobot_header_center_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="80dp"
android:layout_marginLeft="80dp"
android:layout_marginEnd="80dp"
android:layout_marginRight="80dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1"
android:orientation="horizontal">
<com.sobot.widget.ui.image.SobotRCImageView
......@@ -52,8 +48,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginLeft="6dp"
android:layout_toEndOf="@id/sobot_avatar_iv"
android:layout_toRightOf="@id/sobot_avatar_iv"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/sobot_color_title_bar_title"
......@@ -67,8 +61,6 @@
android:id="@+id/sobot_tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:orientation="horizontal">
......@@ -76,6 +68,9 @@
android:id="@+id/sobot_tv_close"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:maxWidth="80dp"
android:lines="1"
android:ellipsize="end"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
......@@ -90,6 +85,9 @@
android:id="@+id/sobot_tv_right_third"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:maxWidth="80dp"
android:lines="1"
android:ellipsize="end"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
......@@ -102,6 +100,9 @@
android:id="@+id/sobot_tv_right_second"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:maxWidth="80dp"
android:lines="1"
android:ellipsize="end"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:gravity="center_vertical"
......@@ -114,6 +115,9 @@
android:id="@+id/sobot_tv_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="80dp"
android:lines="1"
android:ellipsize="end"
android:drawablePadding="5dp"
android:gravity="center_vertical|end"
android:paddingEnd="10dp"
......@@ -121,9 +125,17 @@
android:textColor="@color/sobot_color_title_bar_menu_text"
android:textSize="@dimen/sobot_titlebar_title_size"
android:visibility="gone" />
<ImageView
android:id="@+id/call_icon"
android:layout_width="36dp"
android:layout_height="36dp"
android:gravity="center_vertical|end"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:scaleType="centerInside"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/sobot_title_line"
......@@ -132,4 +144,4 @@
android:layout_alignParentBottom="true"
android:background="@color/sobot_common_line_gray" />
</RelativeLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -16,7 +16,7 @@
<string name="sobot_srl_header_loading">Wait For Loading…</string>
<string name="sobot_srl_header_finish">Refresh Success</string>
<string name="sobot_srl_header_failed">Refresh Failed</string>
<string name="sobot_srl_header_update">\'Last Update\' M-d HH:mm</string>
<string name="sobot_srl_header_update">\'Last Update\' %s</string>
<string name="sobot_srl_header_secondary">Release To Second Floor</string>
<string name="sobot_no_data_string">No data</string>
......@@ -51,5 +51,11 @@
<string name="sobot_str_goto_setting_info">Currently, only partial access to photos or videos is allowed</string>
<string name="sobot_str_goto_setting_allow">Allow all></string>
<string name="sobot_button_send">Send</string>
<string name="calendar_one">Mon.</string>
<string name="calendar_two">Tue.</string>
<string name="calendar_three">Wed.</string>
<string name="calendar_four">Thu.</string>
<string name="calendar_five">Fri.</string>
<string name="calendar_six">Sat.</string>
<string name="calendar_day">Sun.</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string-array name="sobot_lunar_first_of_month">
<item>春节</item>
<item>二月</item>
<item>三月</item>
<item>四月</item>
<item>五月</item>
<item>六月</item>
<item>七月</item>
<item>八月</item>
<item>九月</item>
<item>十月</item>
<item>冬月</item>
<item>腊月</item>
</string-array>
<string-array name="sobot_tradition_festival">
<item>除夕</item>
<item>0101春节</item>
<item>0115元宵</item>
<item>0505端午</item>
<item>0707七夕</item>
<item>0815中秋</item>
<item>0909重阳</item>
</string-array>
<string-array name="sobot_lunar_str">
<item>初一</item>
<item>初二</item>
<item>初三</item>
<item>初四</item>
<item>初五</item>
<item>初六</item>
<item>初七</item>
<item>初八</item>
<item>初九</item>
<item>初十</item>
<item>十一</item>
<item>十二</item>
<item>十三</item>
<item>十四</item>
<item>十五</item>
<item>十六</item>
<item>十七</item>
<item>十八</item>
<item>十九</item>
<item>二十</item>
<item>廿一</item>
<item>廿二</item>
<item>廿三</item>
<item>廿四</item>
<item>廿五</item>
<item>廿六</item>
<item>廿七</item>
<item>廿八</item>
<item>廿九</item>
<item>三十</item>
</string-array>
<string-array name="sobot_solar_festival" tools:ignore="InconsistentArrays">
<item>0101元旦</item>
<item>0214情人节</item>
<item>0308妇女节</item>
<item>0312植树节</item>
<item>0315消权日</item>
<item>0401愚人节</item>
<item>0422地球日</item>
<item>0501劳动节</item>
<item>0504青年节</item>
<item>0601儿童节</item>
<item>0701建党节</item>
<item>0801建军节</item>
<item>0910教师节</item>
<item>1001国庆节</item>
<item>1031万圣节</item>
<item>1111光棍节</item>
<item>1224平安夜</item>
<item>1225圣诞节</item>
</string-array>
<string-array name="sobot_solar_term">
<item>春分</item>
<item>清明</item>
<item>谷雨</item>
<item>立夏</item>
<item>小满</item>
<item>芒种</item>
<item>夏至</item>
<item>小暑</item>
<item>大暑</item>
<item>立秋</item>
<item>处暑</item>
<item>白露</item>
<item>秋分</item>
<item>寒露</item>
<item>霜降</item>
<item>立冬</item>
<item>小雪</item>
<item>大雪</item>
<item>冬至</item>
<item>小寒</item>
<item>大寒</item>
<item>立春</item>
<item>雨水</item>
<item>惊蛰</item>
</string-array>
<string-array name="sobot_special_festivals">
<item>母亲节</item>
<item>父亲节</item>
<item>感恩节</item>
</string-array>
<string name="sobot_sun">Sun</string>
<string name="sobot_mon">Mon</string>
......@@ -120,16 +9,6 @@
<string name="sobot_fri">Fri</string>
<string name="sobot_sat">Sat</string>
<string-array name="sobot_week_string_array">
<item>Sun</item>
<item>Mon</item>
<item>Tue</item>
<item>Wed</item>
<item>Thu</item>
<item>Fri</item>
<item>Sat</item>
</string-array>
<string-array name="sobot_year_view_week_string_array">
<item>S</item>
<item>M</item>
......@@ -169,18 +48,6 @@
</integer-array>
<string-array name="sobot_trunk_string_array">
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
</string-array>
<integer-array name="sobot_branch_integer_array">
<item>1</item>
......@@ -197,19 +64,5 @@
<item>12</item>
</integer-array>
<string-array name="sobot_branch_string_array">
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
</string-array>
</resources>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<string name="sobot_srl_header_release">释放立即刷新</string>
<string name="sobot_srl_header_finish">刷新完成</string>
<string name="sobot_srl_header_failed">刷新失败</string>
<string name="sobot_srl_header_update">上次更新 M-d HH:mm</string>
<string name="sobot_srl_header_update">上次更新 %s</string>
<string name="sobot_srl_header_secondary">释放进入二楼</string>
<string name="sobot_srl_footer_pulling">上拉加载更多</string>
......@@ -51,4 +51,12 @@
<string name="sobot_str_goto_setting_info">当前仅允许访问部分照片或视频</string>
<string name="sobot_str_goto_setting_allow">允许全部 ></string>
<string name="sobot_button_send">发送</string>
<string name="calendar_day"></string>
<string name="calendar_one"></string>
<string name="calendar_two"></string>
<string name="calendar_three"></string>
<string name="calendar_four"></string>
<string name="calendar_five"></string>
<string name="calendar_six"></string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string-array name="sobot_lunar_first_of_month">
<item>春节</item>
<item>二月</item>
<item>三月</item>
<item>四月</item>
<item>五月</item>
<item>六月</item>
<item>七月</item>
<item>八月</item>
<item>九月</item>
<item>十月</item>
<item>冬月</item>
<item>腊月</item>
</string-array>
<string-array name="sobot_tradition_festival">
<item>除夕</item>
<item>0101春节</item>
<item>0115元宵</item>
<item>0505端午</item>
<item>0707七夕</item>
<item>0815中秋</item>
<item>0909重阳</item>
</string-array>
<string-array name="sobot_lunar_str">
<item>初一</item>
<item>初二</item>
<item>初三</item>
<item>初四</item>
<item>初五</item>
<item>初六</item>
<item>初七</item>
<item>初八</item>
<item>初九</item>
<item>初十</item>
<item>十一</item>
<item>十二</item>
<item>十三</item>
<item>十四</item>
<item>十五</item>
<item>十六</item>
<item>十七</item>
<item>十八</item>
<item>十九</item>
<item>二十</item>
<item>廿一</item>
<item>廿二</item>
<item>廿三</item>
<item>廿四</item>
<item>廿五</item>
<item>廿六</item>
<item>廿七</item>
<item>廿八</item>
<item>廿九</item>
<item>三十</item>
</string-array>
<string-array name="sobot_solar_festival" tools:ignore="InconsistentArrays">
<item>0101元旦</item>
<item>0214情人节</item>
<item>0308妇女节</item>
<item>0312植树节</item>
<item>0315消权日</item>
<item>0401愚人节</item>
<item>0422地球日</item>
<item>0501劳动节</item>
<item>0504青年节</item>
<item>0601儿童节</item>
<item>0701建党节</item>
<item>0801建军节</item>
<item>0910教师节</item>
<item>1001国庆节</item>
<item>1031万圣节</item>
<item>1111光棍节</item>
<item>1224平安夜</item>
<item>1225圣诞节</item>
</string-array>
<string-array name="sobot_solar_term">
<item>春分</item>
<item>清明</item>
<item>谷雨</item>
<item>立夏</item>
<item>小满</item>
<item>芒种</item>
<item>夏至</item>
<item>小暑</item>
<item>大暑</item>
<item>立秋</item>
<item>处暑</item>
<item>白露</item>
<item>秋分</item>
<item>寒露</item>
<item>霜降</item>
<item>立冬</item>
<item>小雪</item>
<item>大雪</item>
<item>冬至</item>
<item>小寒</item>
<item>大寒</item>
<item>立春</item>
<item>雨水</item>
<item>惊蛰</item>
</string-array>
<string-array name="sobot_special_festivals">
<item>母亲节</item>
<item>父亲节</item>
<item>感恩节</item>
</string-array>
<string name="sobot_sun"></string>
<string name="sobot_mon"></string>
......@@ -121,16 +10,6 @@
<string name="sobot_sat"></string>
<string-array name="sobot_week_string_array">
<item>周日</item>
<item>周一</item>
<item>周二</item>
<item>周三</item>
<item>周四</item>
<item>周五</item>
<item>周六</item>
</string-array>
<string-array name="sobot_year_view_week_string_array">
<item></item>
<item></item>
......@@ -170,18 +49,6 @@
</integer-array>
<string-array name="sobot_trunk_string_array">
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
</string-array>
<integer-array name="sobot_branch_integer_array">
<item>1</item>
......@@ -197,20 +64,4 @@
<item>11</item>
<item>12</item>
</integer-array>
<string-array name="sobot_branch_string_array">
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
<item></item>
</string-array>
</resources>
\ No newline at end of file
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