Skip to content

Commit

Permalink
Merge pull request #39 from CaptainHuangsh/16-12-24-hours
Browse files Browse the repository at this point in the history
16 12 24 hours
  • Loading branch information
CaptainHuangsh authored May 19, 2017
2 parents a86c978 + b2a6cc8 commit 0866681
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class WatchActivity extends AutoLayoutActivity {
//将字体文件保存在assets/fonts/目录下,创建Typeface对象
Typeface typeFace;
String textColor;
boolean is24Hours;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -74,18 +76,19 @@ public void init() {
WATCH_STATUS = 1;
PreferenceManager.setDefaultValues(this, R.xml.pref_settings, false);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
textColor = preferences.getString("pref_text_color","#ff00ddff");
textColor = preferences.getString("pref_text_color", "#ff00ddff");
typeFace = Typeface.createFromAsset(getAssets(), "fonts/digifaw.ttf");
is24Hours = preferences.getBoolean("hours_12_24", true);
//字体
mVTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// if (DoubleClick.check()) {
if (mDay.getVisibility() == View.GONE) {
mDay.setVisibility(View.VISIBLE);
} else {
mDay.setVisibility(View.GONE);
}
if (mDay.getVisibility() == View.GONE) {
mDay.setVisibility(View.VISIBLE);
} else {
mDay.setVisibility(View.GONE);
}
// }
}
});
Expand Down Expand Up @@ -126,12 +129,16 @@ public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_KEY_1:
long sysTime = System.currentTimeMillis();
CharSequence sysTimeStr = DateFormat.format("HH:mm", sysTime);
// CharSequence sysTimeStr = DateFormat.format("hh:mm", sysTime);
//12小时制
CharSequence sysTimeStrsec = DateFormat.format("ss", sysTime);
CharSequence sysTimeStr;
if (is24Hours) {
sysTimeStr = DateFormat.format("HH:mm", sysTime);
} else {
sysTimeStr = DateFormat.format("hh:mm", sysTime);
//12小时制
}
CharSequence sysTimeStrSec = DateFormat.format("ss", sysTime);
mVTime.setText(sysTimeStr + "");
mSec.setText(" " + sysTimeStrsec);
mSec.setText(" " + sysTimeStrSec);
mDay.setText(mDateDay.StringData() + "");
mVTime.setTypeface(typeFace);
mSec.setTypeface(typeFace);
Expand Down Expand Up @@ -170,7 +177,7 @@ protected void onDestroy() {
@Override
public void onBackPressed() {
if (!DoubleClick.check()) {
Toast.makeText(this,"再按一次退出",Toast.LENGTH_SHORT).show();
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show();
} else {
finish();
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/pref_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
android:key="pref_advance_one"
android:defaultValue="false"
android:title="@string/pref_advance_one"/>
<CheckBoxPreference
android:key="hours_12_24"
android:defaultValue="true"
android:title="使用24小时制"/>

</PreferenceScreen>

0 comments on commit 0866681

Please sign in to comment.