-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AboutView Change package Name Optimize Codes
- Loading branch information
Showing
27 changed files
with
572 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
app/src/main/java/com/wolfaonliu/cardreader/AboutActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String[]> getSet() { | ||
ArrayList<String[]> 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] = "[email protected]"; | ||
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("[email protected]"); | ||
// 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[]{"[email protected]"}); | ||
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(); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/wolfaonliu/cardreader/AboutAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String[]> mData; | ||
private Activity activity; | ||
|
||
private TextView setting; | ||
private TextView settingsub; | ||
|
||
|
||
public AboutAdapter(ArrayList<String[]> 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; | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.