Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
feat: add menu
Browse files Browse the repository at this point in the history
  • Loading branch information
itning committed Jul 9, 2020
1 parent 055b38c commit 3c7d82a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/src/main/java/top/itning/getupearly/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

Expand Down Expand Up @@ -56,6 +58,10 @@ public class MainActivity extends AppCompatActivity {
* 支付宝天天红包赛
*/
private static final String ALI_DD_SPORTS_SERVER_URL_SCHEME = "alipays://platformapi/startapp?appId=20000067&url=https%3a%2f%2fhuodong.taobao.com%2fwow%2ftyact%2fact%2fddsports-home-alipay%3fgame_type%3d1";
/**
* Project GitHub Url
*/
private static final String GITHUB_FOR_STAR = "https://github.com/itning/GetUpEarly";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -68,6 +74,22 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimary));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, getString(R.string.app_version_str, BuildConfig.VERSION_NAME));
getMenuInflater().inflate(R.menu.main_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.github_for_star) {
startUrlScheme(GITHUB_FOR_STAR);
return true;
}
return super.onOptionsItemSelected(item);
}

public void onBtnClick(View view) {
try {
switch (view.getId()) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/main_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/github_for_star"
android:title="@string/github_for_star_str" />
</menu>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<string name="ali_manor_str">蚂蚁庄园</string>
<string name="ali_sport_server_str">支付宝早起打卡挑战赛</string>
<string name="ali_dd_server_str">支付宝天天红包赛</string>
<string name="github_for_star_str">在GitHub上点个Star</string>
<string name="app_version_str">版本:%1$s</string>
</resources>

0 comments on commit 3c7d82a

Please sign in to comment.