|
| 1 | +package com.wolfaonliu.cardreader; |
| 2 | + |
| 3 | +import android.app.AlertDialog; |
| 4 | +import android.content.DialogInterface; |
| 5 | +import android.content.Intent; |
| 6 | +import android.net.Uri; |
| 7 | +import android.os.Bundle; |
| 8 | +import android.support.v7.app.AppCompatActivity; |
| 9 | +import android.support.v7.widget.RecyclerView; |
| 10 | +import android.support.v7.widget.Toolbar; |
| 11 | +import android.view.View; |
| 12 | +import android.widget.AdapterView; |
| 13 | +import android.widget.ListView; |
| 14 | + |
| 15 | +import java.util.ArrayList; |
| 16 | +import java.util.Arrays; |
| 17 | + |
| 18 | +public class AboutActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { |
| 19 | + |
| 20 | + Toolbar toolbar; |
| 21 | + |
| 22 | + |
| 23 | + private ListView mView; |
| 24 | + |
| 25 | + private AboutAdapter mAdapter; |
| 26 | + |
| 27 | + private RecyclerView.LayoutManager mLayoutManager; |
| 28 | + |
| 29 | + @Override |
| 30 | + protected void onCreate(Bundle savedInstanceState) { |
| 31 | + super.onCreate(savedInstanceState); |
| 32 | + setContentView(R.layout.activity_about); |
| 33 | + |
| 34 | + toolbar = findViewById(R.id.about_toolbar); |
| 35 | + setSupportActionBar(toolbar); |
| 36 | + getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
| 37 | + toolbar.setNavigationOnClickListener(new View.OnClickListener() { |
| 38 | + @Override |
| 39 | + public void onClick(View v) { |
| 40 | + finish(); |
| 41 | + } |
| 42 | + }); |
| 43 | + initData(); |
| 44 | + initView(); |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | + private void initData() { |
| 49 | + mAdapter = new AboutAdapter(getSet(), this); |
| 50 | + } |
| 51 | + |
| 52 | + private ArrayList<String[]> getSet() { |
| 53 | + ArrayList<String[]> settings = new ArrayList<>(); |
| 54 | + String[][] s = new String[4][2]; |
| 55 | + s[0][0] = getString(R.string.version); |
| 56 | + s[0][1] = Util.getVersion(this.getApplicationContext()); |
| 57 | + s[1][0] = getString(R.string.developer); |
| 58 | + s[1][1] = "wolfaonliu"; |
| 59 | + s[2][0] = getString(R.string.contact); |
| 60 | + s[2][1] = "wolfaonliu@gmail.com"; |
| 61 | + s[3][0] = getString(R.string.github); |
| 62 | + s[3][1] = "https://github.com/liuyanyi/NewcapecCardReader"; |
| 63 | + settings.addAll(Arrays.asList(s)); |
| 64 | + return settings; |
| 65 | + } |
| 66 | + |
| 67 | + private void initView() { |
| 68 | + mView = findViewById(R.id.set_list); |
| 69 | + // 设置adapter |
| 70 | + mView.setAdapter(mAdapter); |
| 71 | + mView.setOnItemClickListener(this); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 76 | + Uri uri; |
| 77 | + Intent intent; |
| 78 | + switch (position) { |
| 79 | + case 2: |
| 80 | +// uri = Uri.parse("wolfaonliu@gmail.com"); |
| 81 | +// intent = new Intent(Intent.ACTION_SENDTO, uri); |
| 82 | +//// intent.putExtra(Intent.EXTRA_SUBJECT, "Newcapec Card Reader Report"); |
| 83 | +// startActivity(intent); |
| 84 | + showEmailDialog(); |
| 85 | + break; |
| 86 | + case 3: |
| 87 | + uri = Uri.parse("https://github.com/liuyanyi/NewcapecCardReader"); |
| 88 | + intent = new Intent(Intent.ACTION_VIEW, uri); |
| 89 | + startActivity(intent); |
| 90 | + break; |
| 91 | + default: |
| 92 | + break; |
| 93 | + } |
| 94 | +// Toast.makeText(this, "你点击了第" + position + "项", Toast.LENGTH_SHORT).show(); |
| 95 | + } |
| 96 | + |
| 97 | + |
| 98 | + private void showEmailDialog() { |
| 99 | + AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| 100 | + builder.setTitle(R.string.Report) |
| 101 | + .setMessage(R.string.report_atten); |
| 102 | + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { |
| 103 | + @Override |
| 104 | + public void onClick(DialogInterface dialog, int which) { |
| 105 | + Intent email = new Intent(Intent.ACTION_SEND); |
| 106 | + email.setType("message/rfc822"); |
| 107 | + email.putExtra(Intent.EXTRA_EMAIL, new String[]{"wolfaonliu@gmail.com"}); |
| 108 | + email.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + getString(R.string.report)); |
| 109 | + startActivity(Intent.createChooser(email, getString(R.string.email_clint))); |
| 110 | + } |
| 111 | + }); |
| 112 | + builder.setNegativeButton(R.string.no, null); |
| 113 | + |
| 114 | + builder.show(); |
| 115 | + } |
| 116 | +} |
0 commit comments