diff --git a/app/build.gradle b/app/build.gradle index 4b30b7c..19e8fe4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { - applicationId "com.mogician.cardreader" + applicationId "com.wolfaonliu.cardreader" minSdkVersion 23 targetSdkVersion 26 versionCode 1 - versionName "1.2.5" + versionName "1.3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -18,9 +18,10 @@ android { } android.applicationVariants.all { - variant -> variant.outputs.all { - outputFileName = "NCR_${variant.name}_v${variant.versionName}.apk" - } + variant -> + variant.outputs.all { + outputFileName = "NCR_${variant.name}_v${variant.versionName}.apk" + } } } @@ -29,6 +30,7 @@ dependencies { implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:26.1.0' + implementation 'com.android.support:support-v4:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' diff --git a/app/src/androidTest/java/com/mogician/cardreader/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/wolfaonliu/cardreader/ExampleInstrumentedTest.java similarity index 89% rename from app/src/androidTest/java/com/mogician/cardreader/ExampleInstrumentedTest.java rename to app/src/androidTest/java/com/wolfaonliu/cardreader/ExampleInstrumentedTest.java index f099232..cd7525c 100644 --- a/app/src/androidTest/java/com/mogician/cardreader/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/wolfaonliu/cardreader/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -7,7 +7,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Instrumented test, which will execute on an Android device. diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94e63e7..5e62ab6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.wolfaonliu.cardreader"> @@ -12,7 +12,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar"> - + @@ -55,6 +55,7 @@ android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" /> + \ No newline at end of file diff --git a/app/src/main/java/com/wolfaonliu/cardreader/AboutActivity.java b/app/src/main/java/com/wolfaonliu/cardreader/AboutActivity.java new file mode 100644 index 0000000..a28ab34 --- /dev/null +++ b/app/src/main/java/com/wolfaonliu/cardreader/AboutActivity.java @@ -0,0 +1,116 @@ +package com.wolfaonliu.cardreader; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ListView; + +import java.util.ArrayList; +import java.util.Arrays; + +public class AboutActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { + + Toolbar toolbar; + + + private ListView mView; + + private AboutAdapter mAdapter; + + private RecyclerView.LayoutManager mLayoutManager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_about); + + toolbar = findViewById(R.id.about_toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + initData(); + initView(); + } + + + private void initData() { + mAdapter = new AboutAdapter(getSet(), this); + } + + private ArrayList getSet() { + ArrayList settings = new ArrayList<>(); + String[][] s = new String[4][2]; + s[0][0] = getString(R.string.version); + s[0][1] = Util.getVersion(this.getApplicationContext()); + s[1][0] = getString(R.string.developer); + s[1][1] = "wolfaonliu"; + s[2][0] = getString(R.string.contact); + s[2][1] = "wolfaonliu@gmail.com"; + s[3][0] = getString(R.string.github); + s[3][1] = "https://github.com/liuyanyi/NewcapecCardReader"; + settings.addAll(Arrays.asList(s)); + return settings; + } + + private void initView() { + mView = findViewById(R.id.set_list); + // 设置adapter + mView.setAdapter(mAdapter); + mView.setOnItemClickListener(this); + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Uri uri; + Intent intent; + switch (position) { + case 2: +// uri = Uri.parse("wolfaonliu@gmail.com"); +// intent = new Intent(Intent.ACTION_SENDTO, uri); +//// intent.putExtra(Intent.EXTRA_SUBJECT, "Newcapec Card Reader Report"); +// startActivity(intent); + showEmailDialog(); + break; + case 3: + uri = Uri.parse("https://github.com/liuyanyi/NewcapecCardReader"); + intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + break; + default: + break; + } +// Toast.makeText(this, "你点击了第" + position + "项", Toast.LENGTH_SHORT).show(); + } + + + private void showEmailDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.Report) + .setMessage(R.string.report_atten); + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Intent email = new Intent(Intent.ACTION_SEND); + email.setType("message/rfc822"); + email.putExtra(Intent.EXTRA_EMAIL, new String[]{"wolfaonliu@gmail.com"}); + email.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + getString(R.string.report)); + startActivity(Intent.createChooser(email, getString(R.string.email_clint))); + } + }); + builder.setNegativeButton(R.string.no, null); + + builder.show(); + } +} diff --git a/app/src/main/java/com/wolfaonliu/cardreader/AboutAdapter.java b/app/src/main/java/com/wolfaonliu/cardreader/AboutAdapter.java new file mode 100644 index 0000000..bc4edd0 --- /dev/null +++ b/app/src/main/java/com/wolfaonliu/cardreader/AboutAdapter.java @@ -0,0 +1,60 @@ +package com.wolfaonliu.cardreader; + +import android.app.Activity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.ArrayList; + +/** + * Created by Mogician on 2018/3/14. + */ + +public class AboutAdapter extends BaseAdapter { + + private ArrayList mData; + private Activity activity; + + private TextView setting; + private TextView settingsub; + + + public AboutAdapter(ArrayList data, Activity activity) { + this.mData = data; + this.activity = activity; + } + + @Override + public int getCount() { + return mData.size(); + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + convertView = LayoutInflater.from(activity).inflate(R.layout.about_item, parent, false); + + setting = convertView.findViewById(R.id.setting); + settingsub = convertView.findViewById(R.id.settingsub); + +// + setting.setText(mData.get(position)[0]); + settingsub.setText(mData.get(position)[1]); + return convertView; + + } + + +} diff --git a/app/src/main/java/com/mogician/cardreader/CardInfo.java b/app/src/main/java/com/wolfaonliu/cardreader/CardInfo.java similarity index 90% rename from app/src/main/java/com/mogician/cardreader/CardInfo.java rename to app/src/main/java/com/wolfaonliu/cardreader/CardInfo.java index d425b44..5667e45 100644 --- a/app/src/main/java/com/mogician/cardreader/CardInfo.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/CardInfo.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.app.Activity; import android.graphics.Color; @@ -95,7 +95,7 @@ public void setPersonId(String personId) { public void setCardBalance(String cardBalance) { if (cardBalance != null) isNewcapecCard = true; - this.cardBalance = cardBalance + "元"; + this.cardBalance = cardBalance + mainActivity.getString(R.string.yuan); } public void setStudentDept(String studentDept) { @@ -114,13 +114,13 @@ public void onFinish(boolean isFull) { pgBar.setVisibility(View.GONE); if (!isFull) { //未能复现…… - atten.setText("警告,读取内容不全,请重新放置卡片"); + atten.setText(mainActivity.getString(R.string.reading_alert)); pgI.setColorFilter(Color.parseColor("#259b24")); } else if (isNewcapecCard) { - atten.setText("成功"); + atten.setText(mainActivity.getString(R.string.success)); pgI.setColorFilter(Color.parseColor("#259b24")); } else { - atten.setText("失败,非校园卡"); + atten.setText(mainActivity.getString(R.string.failed)); pgI.setColorFilter(Color.parseColor("#e51c23")); } } @@ -146,7 +146,7 @@ public void showInLog() { public boolean show() { if (isNewcapecCard) { - isCard.setText("校园卡"); + isCard.setText(mainActivity.getString(R.string.isStuCard)); name.setText(studentName); @@ -164,7 +164,7 @@ public boolean show() { dealCard.setVisibility(View.VISIBLE); // 设置adapter - mAdapter = new DealAdapter(getTradeList()); + mAdapter = new DealAdapter(getTradeList(), mainActivity); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new ItemDivider(mainActivity, LinearLayoutManager.VERTICAL)); } @@ -173,7 +173,7 @@ public boolean show() { return false; } else { - isCard.setText("非校园卡"); + isCard.setText(mainActivity.getString(R.string.unsupport)); hardware.setText(hardwareId); diff --git a/app/src/main/java/com/mogician/cardreader/CardReader.java b/app/src/main/java/com/wolfaonliu/cardreader/CardReader.java similarity index 98% rename from app/src/main/java/com/mogician/cardreader/CardReader.java rename to app/src/main/java/com/wolfaonliu/cardreader/CardReader.java index c8396ad..8b0f87d 100644 --- a/app/src/main/java/com/mogician/cardreader/CardReader.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/CardReader.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.app.Activity; import android.content.Intent; @@ -49,7 +49,7 @@ public static CardInfo readCard(Activity activity, Intent intent) { if (transceive != null && g.c(transceive)) { transceive = isoDep.transceive(g.a(fInts.d)); if (transceive == null || !g.c(transceive)) { - Util.aToast("读卡失败!", activity); + Util.aToast(activity.getString(R.string.read_failed), activity); } else { byte[] a; @@ -96,7 +96,7 @@ public static CardInfo readCard(Activity activity, Intent intent) { a = g.a(transceive); g.a(a, 0, transceive, 0, transceive.length - 2); action = g.a(a, 0, a.length, "GB18030").trim(); - Log.d("***", action); +// Log.d("***", action); if (Util.d(action) || Util.a(action) || action.contains("000000")) { // bVar.d(action); // Log.d("学院******", action); diff --git a/app/src/main/java/com/mogician/cardreader/DealAdapter.java b/app/src/main/java/com/wolfaonliu/cardreader/DealAdapter.java similarity index 65% rename from app/src/main/java/com/mogician/cardreader/DealAdapter.java rename to app/src/main/java/com/wolfaonliu/cardreader/DealAdapter.java index 9f08382..5671740 100644 --- a/app/src/main/java/com/mogician/cardreader/DealAdapter.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/DealAdapter.java @@ -1,5 +1,6 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; +import android.app.Activity; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -15,9 +16,11 @@ public class DealAdapter extends RecyclerView.Adapter { private ArrayList mData; + private Activity activity; - public DealAdapter(ArrayList data) { + public DealAdapter(ArrayList data, Activity activity) { this.mData = data; + this.activity = activity; } public void updateData(ArrayList data) { @@ -37,10 +40,20 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public void onBindViewHolder(ViewHolder holder, int position) { // 绑定数据 String m = mData.get(position).getTradingMoney(); - String t = mData.get(position).getTradingType(); + int t = mData.get(position).getTradingType(); holder.time.setText(mData.get(position).getTradingDateTime()); holder.money.setText(m); - holder.type.setText(t); + switch (t) { + case 2: + holder.type.setText(activity.getString(R.string.recharge)); + break; + case 6: + holder.type.setText(activity.getString(R.string.consumption)); + break; + default: + holder.type.setText(t); + break; + } } @Override @@ -56,9 +69,9 @@ public static class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View itemView) { super(itemView); - type = (TextView) itemView.findViewById(R.id.type); - money = (TextView) itemView.findViewById(R.id.deal); - time = (TextView) itemView.findViewById(R.id.time); + type = itemView.findViewById(R.id.type); + money = itemView.findViewById(R.id.deal); + time = itemView.findViewById(R.id.time); } } } diff --git a/app/src/main/java/com/mogician/cardreader/ItemDivider.java b/app/src/main/java/com/wolfaonliu/cardreader/ItemDivider.java similarity index 99% rename from app/src/main/java/com/mogician/cardreader/ItemDivider.java rename to app/src/main/java/com/wolfaonliu/cardreader/ItemDivider.java index 5d320e4..ca665bc 100644 --- a/app/src/main/java/com/mogician/cardreader/ItemDivider.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/ItemDivider.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.content.Context; import android.content.res.TypedArray; diff --git a/app/src/main/java/com/mogician/cardreader/MainActivity.java b/app/src/main/java/com/wolfaonliu/cardreader/MainActivity.java similarity index 90% rename from app/src/main/java/com/mogician/cardreader/MainActivity.java rename to app/src/main/java/com/wolfaonliu/cardreader/MainActivity.java index 3625792..64726ef 100644 --- a/app/src/main/java/com/mogician/cardreader/MainActivity.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/MainActivity.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.app.PendingIntent; import android.content.Intent; @@ -71,10 +71,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { } else if (id == R.id.nav_share) { Intent textIntent = new Intent(Intent.ACTION_SEND); textIntent.setType("text/plain"); - textIntent.putExtra(Intent.EXTRA_TEXT, "Newcapec Card Reader : https://github.com/liuyanyi/NewcapecCardReader"); - startActivity(Intent.createChooser(textIntent, "分享Newcapec Card Reader")); + textIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_name) + " : https://www.coolapk.com/apk/com.wolfaonliu.cardreader"); + startActivity(Intent.createChooser(textIntent, getString(R.string.share) + getString(R.string.app_name))); } else if (id == R.id.nav_about) { - + Intent intent = new Intent(MainActivity.this, AboutActivity.class); + startActivity(intent); } DrawerLayout drawer = findViewById(R.id.drawer_layout); diff --git a/app/src/main/java/com/mogician/cardreader/TradingRecordInfo.java b/app/src/main/java/com/wolfaonliu/cardreader/TradingRecordInfo.java similarity index 74% rename from app/src/main/java/com/mogician/cardreader/TradingRecordInfo.java rename to app/src/main/java/com/wolfaonliu/cardreader/TradingRecordInfo.java index ec37cda..317f8da 100644 --- a/app/src/main/java/com/mogician/cardreader/TradingRecordInfo.java +++ b/app/src/main/java/com/wolfaonliu/cardreader/TradingRecordInfo.java @@ -1,4 +1,4 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import android.support.annotation.NonNull; @@ -11,7 +11,7 @@ public class TradingRecordInfo implements Serializable, Comparable + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..962b667 --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/app/src/main/res/layout/app_bar_about.xml b/app/src/main/res/layout/app_bar_about.xml new file mode 100644 index 0000000..b28d911 --- /dev/null +++ b/app/src/main/res/layout/app_bar_about.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index f922221..42d707b 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.mogician.cardreader.MainActivity"> + tools:context="com.wolfaonliu.cardreader.MainActivity"> + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 36802ca..03a9812 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context="com.mogician.cardreader.MainActivity" + tools:context="com.wolfaonliu.cardreader.MainActivity" tools:showIn="@layout/app_bar_main"> @@ -74,8 +74,8 @@ + android:layout_height="1.2dp" + android:background="?attr/colorButtonNormal" /> + android:layout_height="1.2dp" + android:background="?attr/colorButtonNormal" /> diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 463dc29..df36b53 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -9,19 +9,19 @@ android:checkable="true" android:checked="true" android:icon="@drawable/ic_menu_nfc" - android:title="读卡" /> + android:title="@string/readCard" /> - + + android:title="@string/share" /> + android:title="@string/about" /> diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml new file mode 100644 index 0000000..16e3a2c --- /dev/null +++ b/app/src/main/res/values-en/strings.xml @@ -0,0 +1,48 @@ + + + Newcapec Card Reader + Newcapec Card Reader + Place the card in the reader area + Category + Name + Stu ID + Balance + Hardware ID + Department + Preson ID + Deal list + Type + Time + Deal + background + NFC_Icon + Open navigation drawer + Close navigation drawer + Failed! + Warning, please re-place the card + Success + Failed,unsupported card + Newcapec Card + Unsupported card + yuan + Consumption + Recharge + Share + Read Card + About + Other + About + Version + Developer + Github + Contact + Email Report + Feedback can be provided to developers via email, which will evoke email application. + Yes + No + Choose an Email Client + " Report" + In theory, it applies to all campus cards provided by the Newcapec Company. + Only tested on campus card of NEU. + Donate + \ No newline at end of file diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml new file mode 100644 index 0000000..f4a9579 --- /dev/null +++ b/app/src/main/res/values-zh/strings.xml @@ -0,0 +1,51 @@ + + + + Open navigation drawer + Close navigation drawer + + background + NFC_Icon + + 新开普读卡器 + 新开普读卡器 + 将卡片放置到读卡区 + 卡类型 + 姓名 + 学号 + 余额 + 硬件ID + 学院 + 身份证号 + 交易记录 + Type + Time + Deal + 读卡失败! + 警告,请重新放置卡片 + 失败,不支持的卡片 + 成功 + 校园卡 + 不支持的卡片 + + 消费 + 充值 + 分享 + 读卡 + 关于 + 其他 + 关于 + 版本号 + 开发者 + Github + 捐赠 + 联系方式 + 邮件反馈 + 可以通过邮件向开发者反馈,该操作会唤起邮件应用。 + + + 选择邮件客户端 + 反馈 + 理论上适用于所有新开普公司提供的校园卡 + 目前仅在东北大学校园卡测试通过 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0c57372..563ace7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,12 +1,10 @@ - Newcapec Card Reader - Main2Activity + 新开普读卡器 Open navigation drawer Close navigation drawer - Settings - Newcapec Card Reader + 新开普读卡器 background NFC_Icon 将卡片放置到读卡区 @@ -21,4 +19,33 @@ Type Time Deal + 读卡失败! + 警告,请重新放置卡片 + 成功 + 失败,不支持的卡片 + 校园卡 + 不支持的卡片 + + 消费 + 充值 + 分享 + 读卡 + 关于 + 关于 + + 其他 + 版本号 + 开发者 + Github + 捐赠 + 联系方式 + 邮件反馈 + 可以通过邮件向开发者反馈,该操作会唤起邮件应用。 + + + 选择邮件客户端 + 反馈 + 理论上适用于所有新开普公司提供的校园卡。 + 目前仅在东北大学校园卡测试通过。 + diff --git a/app/src/test/java/com/mogician/cardreader/ExampleUnitTest.java b/app/src/test/java/com/wolfaonliu/cardreader/ExampleUnitTest.java similarity index 81% rename from app/src/test/java/com/mogician/cardreader/ExampleUnitTest.java rename to app/src/test/java/com/wolfaonliu/cardreader/ExampleUnitTest.java index 27c16e5..efe7615 100644 --- a/app/src/test/java/com/mogician/cardreader/ExampleUnitTest.java +++ b/app/src/test/java/com/wolfaonliu/cardreader/ExampleUnitTest.java @@ -1,8 +1,8 @@ -package com.mogician.cardreader; +package com.wolfaonliu.cardreader; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Example local unit test, which will execute on the development machine (host).