Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Commit

Permalink
Merge pull request #56 from NKUST-ITC/feature/nkust-version
Browse files Browse the repository at this point in the history
Feature/nkust version
  • Loading branch information
hearsilent authored Feb 14, 2019
2 parents 4936d3f + 10376c1 commit 5da684f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,16 @@ public class LogoutActivity extends SilentActivity {

List<NewsModel> newsList = new ArrayList<>();

String mTitle, mContent, mURL;
Boolean hasNews, isBusSaved;
Boolean hasNews = true, isBusSaved;

AlertDialog mProgressDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mTitle = Memory.getString(this, Constant.PREF_NEWS_TITLE, "");
mContent = Memory.getString(this, Constant.PREF_NEWS_CONTENT, "");
mURL = Memory.getString(this, Constant.PREF_NEWS_URL, "");
hasNews = mContent.length() > 0;

if (!hasNews) {
setContentView(R.layout.activity_logout);
init(news, R.layout.activity_logout);
} else {
setContentView(R.layout.activity_logout_news);
init(news, R.layout.activity_logout_news);
}
setContentView(R.layout.activity_logout_news);
init(news, R.layout.activity_logout_news);

initGA("Logout Screen");
restoreArgs(savedInstanceState);
Expand Down Expand Up @@ -223,7 +212,15 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
false);
if (isLogin) {
if (menuItem.getItemId() == R.id.nav_bus) {
startActivity(new Intent(LogoutActivity.this, BusActivity.class));
if (Memory.getBoolean(LogoutActivity.this, Constant.PREF_BUS_ENABLE,
true)) {
startActivity(
new Intent(LogoutActivity.this, BusActivity.class));
} else {
Toast.makeText(LogoutActivity.this, R.string.can_not_use_bus,
Toast.LENGTH_SHORT).show();
return false;
}
} else if (menuItem.getItemId() == R.id.nav_course) {
startActivity(
new Intent(LogoutActivity.this, CourseActivity.class));
Expand Down Expand Up @@ -320,6 +317,7 @@ public void getNews() {
public void onSuccess(List<NewsModel> modelList) {
super.onSuccess(modelList);
newsList = modelList;
hasNews = newsList.size() != 0;
setUpViews();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public void onSuccess(UserInfoModel userInfoModel) {
userInfoModel.student_name_cht);
Memory.setString(SilentActivity.this, Constant.PREF_USER_ID,
userInfoModel.student_id);
Memory.setInt(SilentActivity.this, Constant.PREF_USER_STATUS,
userInfoModel.status);
if (userInfoModel.message != null) {
Memory.setString(SilentActivity.this, Constant.PREF_USER_MESSAGE,
userInfoModel.message);
}
((TextView) headerView.findViewById(R.id.textView_name))
.setText(userInfoModel.student_name_cht);
((TextView) headerView.findViewById(R.id.textView_schoolID))
Expand Down Expand Up @@ -176,7 +182,13 @@ public void onSuccess(String data) {
}

public void showUserInfo() {
startActivity(new Intent(this, UserInfoActivity.class));
if (Memory.getInt(SilentActivity.this, Constant.PREF_USER_STATUS, 200) == 200) {
startActivity(new Intent(this, UserInfoActivity.class));
} else {
Toast.makeText(SilentActivity.this,
Memory.getString(SilentActivity.this, Constant.PREF_USER_MESSAGE, ""),
Toast.LENGTH_SHORT).show();
}
}

public void setUpMenuDrawer(int selectItem) {
Expand Down Expand Up @@ -352,7 +364,13 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.nav_messages) {
startActivity(new Intent(this, MessagesActivity.class));
} else if (menuItem.getItemId() == R.id.nav_bus) {
startActivity(new Intent(this, BusActivity.class));
if (Memory.getBoolean(SilentActivity.this, Constant.PREF_BUS_ENABLE, true)) {
startActivity(new Intent(SilentActivity.this, BusActivity.class));
} else {
Toast.makeText(SilentActivity.this, R.string.can_not_use_bus,
Toast.LENGTH_SHORT).show();
return false;
}
} else if (menuItem.getItemId() == R.id.nav_course) {
startActivity(new Intent(this, CourseActivity.class));
} else if (menuItem.getItemId() == R.id.nav_about) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ public class Constant {
public static final String PREF_NEWS_URL = "pref_news_url";

public static final String PREF_IS_LOGIN = "pref_is_login";
public static final String PREF_BUS_ENABLE = "pref_bus_enable";

public static final String PREF_SEMESTER = "pref_semester";
public static final String PREF_SEMESTER_SELECTED = "pref_semester_selected";

public static final String PREF_USER_PIC = "pref_user_pic";
public static final String PREF_USER_NAME = "pref_user_name";
public static final String PREF_USER_ID = "pref_user_id";
public static final String PREF_USER_STATUS = "pref_user_status";
public static final String PREF_USER_MESSAGE = "pref_user_message";

public static final String PREF_HEAD_PHOTO = "pref_head_photo";
public static final String PREF_COURSE_NOTIFY = "pref_course_notify";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

public class Helper {

public static final String SERVER_HOST = "kuas.grd.idv.tw";
public static final int SERVER_PORT = 14769;
public static final String SERVER_HOST = "nkust-ap-api.rainvisitor.me";
public static final int SERVER_PORT = 2087;
public static final String BASE_URL = "https://" + SERVER_HOST + ":" + SERVER_PORT;
public static final String SERVER_STATUS_URL = BASE_URL + "/latest/servers/status";
public static final String APP_VERSION_URL = BASE_URL + "/latest/versions/android";
Expand Down Expand Up @@ -145,6 +145,14 @@ public static void login(final Context context, String user, String pwd,
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
if (statusCode == 200 && response != null && response.has("auth_token")) {
if (response.has("is_login")) {
try {
Memory.setBoolean(context, Constant.PREF_BUS_ENABLE,
response.getJSONObject("is_login").getBoolean("bus"));
} catch (JSONException e) {
e.printStackTrace();
}
}
if (callback != null) {
callback.onSuccess();
}
Expand Down Expand Up @@ -407,6 +415,8 @@ public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
model.student_id = response.getString("student_id");
model.student_name_cht = response.getString("student_name_cht");
model.student_name_eng = response.getString("student_name_eng");
model.status = response.getInt("status");
model.message = response.getString("message");
if (callback != null) {
callback.onSuccess(model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public class UserInfoModel {
public String student_class;
public String student_name_cht;
public String education_system;
public int status = 200;
public String message;
}
17 changes: 9 additions & 8 deletions KUAS-AP-Material/app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">高應校務通</string>
<string name="app_name">高科校務通</string>

<string name="update_note_title">更新日誌 %s</string>
<string name="update_note_content">更新:\n  - 修正閃退</string>
Expand All @@ -11,7 +11,7 @@
<string name="continue_to_use">繼續使用</string>
<string name="logout">登出</string>
<string name="click_to_view">立即前往</string>
<string name="login_success">成功登入高應大校務系統\n點擊左側選單,開始瀏覽</string>
<string name="login_success">成功登入高科大校務系統\n點擊左側選單,開始瀏覽</string>
<string name="something_error">發生錯誤</string>
<string name="timeout_message">連線逾時,請稍候再試</string>
<string name="login_first">請先登入</string>
Expand Down Expand Up @@ -70,7 +70,7 @@
<string name="leave_no_leave">Oops!本學期沒有任何缺曠課紀錄哦~\n請選擇其他學期 %s</string>
<string name="token_expired_title">重新登入</string>
<string name="token_expired_content">登入資訊過期,請重新登入!</string>
<string name="update_content">高應校務通 在 Google Play 有新版本喲!</string>
<string name="update_content">高科校務通 在 Google Play 有新版本喲!</string>
<string name="update_title">版本更新</string>
<string name="update">更新</string>
<string name="function_not_open">此功能尚未開放,敬啟期待~\n贊助我們可以提前使用此功能!</string>
Expand All @@ -79,10 +79,10 @@
<string name="easter_egg_juke">這不是彩蛋</string>
<string name="skip">稍後再說</string>
<string name="share_to">分享至…</string>
<string name="send_from">Send from 高應校務通 Android</string>
<string name="send_from">Send from 高科校務通 Android</string>
<string name="donate_title">Donate</string>
<string name="donate_content">貢獻一點心力支持作者,\n可以提早使用未開放功能!</string>
<string name="donate_error">哎呀!發生了點錯誤 :(\n不過沒關係到 Google Play\n搜尋「高應校務通
<string name="donate_error">哎呀!發生了點錯誤 :(\n不過沒關係到 Google Play\n搜尋「高科校務通
Donate」\n一樣可以支持喔!</string>
<string name="bus_notify_hint">校車預約將於發車前三十分鐘提醒!\n若在網頁預約或取消校車請重登入此App。</string>
<string name="bus_notify_content" formatted="false">親,您有一班 %s 從%s出發的校車!</string>
Expand Down Expand Up @@ -113,16 +113,16 @@
<string name="feedback_via_facebook">私訊給粉絲專頁</string>
<string name="app_version">App 版本</string>

<string name="about_detail">史上最強高應大校務系統APP\n「高 應 校 務
通」\n\n你是新生嗎?\n不知道學校的消息、電話、行事曆嗎?\n你是舊生嗎?\n每次開課表、查成績、定校車都一肚子氣?\n\n沒有問題,以後沒有這種問題了!\n\n高應校務通讓你不管是新手老手,\n從此一手掌握你的高應人生!\n\n從你的手機看課表,成績,缺曠課紀錄!\n加上預定/取消校車,校園消息!\n\n\n\n簡單、方便、直覺!\n\n尊爵、不凡、你,值得擁有。</string>
<string name="about_detail">史上最強高科大校務系統APP\n「高 應 校 務
通」\n\n你是新生嗎?\n不知道學校的消息、電話、行事曆嗎?\n你是舊生嗎?\n每次開課表、查成績、定校車都一肚子氣?\n\n沒有問題,以後沒有這種問題了!\n\n高科校務通讓你不管是新手老手,\n從此一手掌握你的高科人生!\n\n從你的手機看課表,成績,缺曠課紀錄!\n加上預定/取消校車,校園消息!\n\n\n\n簡單、方便、直覺!\n\n尊爵、不凡、你,值得擁有。</string>
<string name="about_author_title">作者群</string>
<string name="about_author_content">呂紹榕(Louie Lu), 姜尚德(JohnThunder), \nregisterAutumn, 詹濬鍵(Evans), \n陳建霖(HearSilent)</string>
<string name="about_us">「不要問為何沒有人做這個,\n先承認你就是『沒有人』」。\n因為,「沒有人」是萬能的。\n\n因為沒有人做這些,所以我們跳下來做。\n先後完成了高應無線通、高應校務通,到後來的高應美食通、模擬選課等等.......\n無非是希望帶給大家更便利的校園生活!</string>
<string name="about_recruit_title">We Need You !</string>
<string name="about_recruit_content">如果你是 Objective-C、Swift 高手,或是 Java 神手,又或是對 Coding
充滿著熱誠!\n\n歡迎私訊我們粉絲專頁!\n你的程式碼將有機會出現在周遭同學的手中~</string>
<string name="about_itc_content">在103學年度,\n我們也成立了高應大資訊研習社!\n\n如果你對資訊有熱誠或是對我們作品有興趣,歡迎來社課或是講座,也可以來找我們聊聊天。</string>
<string name="about_itc_title">高應資研社</string>
<string name="about_itc_title">高科資研社</string>
<string name="about_contact_us">聯繫我們</string>
<string name="about_open_source_title">開放原始碼授權</string>
<string name="about_open_source_content">https://github.com/hearsilent/KUAS-AP-Material\n\n本專案採
Expand Down Expand Up @@ -390,4 +390,5 @@
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</string>
<string name="can_not_use_bus">此帳號無法使用此功能</string>
</resources>
21 changes: 11 additions & 10 deletions KUAS-AP-Material/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">KUAS AP</string>
<string name="app_name">NKUST AP</string>

<string name="update_note_title">Update Notes %s</string>
<string name="update_note_content">Update:\n  - Fix crash</string>
Expand Down Expand Up @@ -70,7 +70,7 @@
<string name="leave_no_leave">Oops! No absent record for this semester~\nPlease choose another semester %s</string>
<string name="token_expired_title">Re-login Required</string>
<string name="token_expired_content">Cookie has expired, please re-login!</string>
<string name="update_content">Update available for KUAS AP!</string>
<string name="update_content">Update available for NKUST AP!</string>
<string name="update_title">Updated</string>
<string name="update">Update</string>
<string name="function_not_open">Coming Soon~\nDonate to use this feature now!</string>
Expand All @@ -80,10 +80,10 @@
<string name="easter_egg_juke">This is not an easter egg</string>
<string name="skip">Skip</string>
<string name="share_to">Share to…</string>
<string name="send_from">Sent from KUAS AP Android</string>
<string name="send_from">Sent from NKUST AP Android</string>
<string name="donate_title">Donate</string>
<string name="donate_content">Help and support the programmer\nto use new features!</string>
<string name="donate_error">Oops!Something went wrong :(\nGO to Google Play\n search for KUAS AP
<string name="donate_error">Oops!Something went wrong :(\nGO to Google Play\n search for NKUST AP
Donate \n to support the author!</string>
<string name="bus_notify_hint">Reminder will pop up 30 mins before reserved bus !\nIf you
reserved or canceled the seat via website, please restart the app.</string>
Expand Down Expand Up @@ -115,11 +115,11 @@
<string name="feedback_via_facebook">Message to Facebook Page</string>
<string name="app_version">App Version</string>

<string name="about_detail">The best KUAS Campus App\nKUAS AP\n\nAre you a
<string name="about_detail">The best NKUST Campus App\nNKUST AP\n\nAre you a
freshman?\nDon\'t know about school info, telephone numbers, or up coming events?\nBeen
here a few years?\nHave checking class schedule, report card and reserving bus seats
drove you crazy?\n\nNo more, no more worries, anymore!\n\nKUAS AP lets no matter old or new
fellow\nhave control over your life in KUAS!\n\nFrom checking class schedule, report card to
drove you crazy?\n\nNo more, no more worries, anymore!\n\nNKUST AP lets no matter old or new
fellow\nhave control over your life in NKUST!\n\nFrom checking class schedule, report card to
your absence records!\nPlus reserving/canceling bus seats with newest school feeds!\n\n\n\nMuch Simple, Many Convenient, Very instinct, wow!\n\n☆FABULOUS☆</string>
<string name="about_author_title">Made by</string>
<string name="about_author_content">呂紹榕(Louie Lu), 姜尚德(JohnThunder), \nregisterAutumn, 詹濬鍵(Evans), \n陳建霖(HearSilent)</string>
Expand All @@ -135,7 +135,7 @@
<string name="about_itc_content">In year 2014,\nwe founded KUAS Information Technology
Club!\n\nIf you\'re enthusiastic or drawn to our projects, join our classes and talks or
come by to chat!</string>
<string name="about_itc_title">KUAS IT Club</string>
<string name="about_itc_title">NKUST IT Club</string>
<string name="about_contact_us">Contact Us</string>
<string name="about_open_source_title">Open Source License</string>
<string name="about_open_source_content">https://github.com/hearsilent/KUAS-AP-Material\n\nThis project is licensed under the terms of the MIT license:\nThe MIT License (MIT)\n\nCopyright &#169; 2015 HearSilent\n\nPermission is
Expand Down Expand Up @@ -302,10 +302,10 @@
<item>Are you a master of Obj-C ?</item>
<item>Or are you good at Swift ?</item>
<item>Maybe you\'re a skillful Java programmer?</item>
<item>Stop trying to penetrate me, come to KUAS IT Club!</item>
<item>Stop trying to penetrate me, come to NKUST IT Club!</item>
<item>What are you waiting for?</item>
<item>John is a white hac&#8230; uhm&#8230;</item>
<item>Heard of Lu\? He\'s Tyr of KUAS\!</item>
<item>Heard of Lu\? He\'s Tyr of NKUST\!</item>
</array>

<array name="score_sections">
Expand Down Expand Up @@ -368,4 +368,5 @@

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="can_not_use_bus">This account can\\\'t use this feature</string>
</resources>

0 comments on commit 5da684f

Please sign in to comment.