三种功能的Release版本

pull/5/head
Dingzijian 3 years ago
parent 338ed8affc
commit 92579b6b2c

@ -161,7 +161,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private final static int REQUEST_CODE_OPEN_NODE = 102; private final static int REQUEST_CODE_OPEN_NODE = 102;
private final static int REQUEST_CODE_NEW_NODE = 103; private final static int REQUEST_CODE_NEW_NODE = 103;
//维护 //维护_丁梓坚_个性化背景_刷新界面
@Override @Override
public Window getWindow() { public Window getWindow() {
return super.getWindow(); return super.getWindow();
@ -172,7 +172,9 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(layout.note_list); setContentView(layout.note_list);
//维护_丁梓坚_个性化背景_初始化操作
SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_READABLE); SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_READABLE);
//需要先创建图片资源文件SampleCropImage.jpeg用于存放个性背景图片
if(!sharedPreferences.contains("DEFAULT")) if(!sharedPreferences.contains("DEFAULT"))
{ {
Drawable drawable= getResources().getDrawable(list_background); Drawable drawable= getResources().getDrawable(list_background);
@ -198,19 +200,21 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
//维护 //维护_丁梓坚_个性化背景_刷新界面
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_READABLE);//xml SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_READABLE);
//根据DEFAULT的值来判断是否加载个性背景
if(sharedPreferences.contains("DEFAULT")){ if(sharedPreferences.contains("DEFAULT")){
//默认背景
if(sharedPreferences.getInt("DEFAULT",0)==1) if(sharedPreferences.getInt("DEFAULT",0)==1)
getWindow().setBackgroundDrawableResource(R.drawable.list_background); getWindow().setBackgroundDrawableResource(R.drawable.list_background);
//个性背景
else{ else{
Bitmap bitmap = BitmapFactory.decodeFile(getCacheDir() + "/SampleCropImage.jpeg"); Bitmap bitmap = BitmapFactory.decodeFile(getCacheDir() + "/SampleCropImage.jpeg");
Drawable drawable =new BitmapDrawable(bitmap); Drawable drawable =new BitmapDrawable(bitmap);
getWindow().setBackgroundDrawable(drawable); getWindow().setBackgroundDrawable(drawable);
//Toast.makeText(this, "failed to get image", Toast.LENGTH_SHORT).show(); //Toast.makeText(this, "failed to get image", Toast.LENGTH_SHORT).show();
} }
} }

@ -82,7 +82,8 @@ public class NotesPreferenceActivity extends PreferenceActivity {
private static final String PREFERENCE_SYNC_ACCOUNT_KEY = "pref_sync_account_key"; private static final String PREFERENCE_SYNC_ACCOUNT_KEY = "pref_sync_account_key";
private static final String AUTHORITIES_FILTER_KEY = "authorities"; private static final String AUTHORITIES_FILTER_KEY = "authorities";
//维护
//维护_丁梓坚_个性化背景
private static final int CHOOSE_PHOTO = 1; private static final int CHOOSE_PHOTO = 1;
private PreferenceCategory mAccountCategory; private PreferenceCategory mAccountCategory;
@ -98,12 +99,6 @@ public class NotesPreferenceActivity extends PreferenceActivity {
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
//维护
//getWindow().setBackgroundDrawableResource(R.drawable.list_background);
//preference_textview
//RelativeLayout layout = (RelativeLayout)findViewById(R.id.preference_textview);
//setContentView(R.layout.activity_welcome);
/* using the app icon for navigation */ /* using the app icon for navigation */
getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true);
@ -185,18 +180,16 @@ public class NotesPreferenceActivity extends PreferenceActivity {
mAccountCategory.addPreference(accountPref); mAccountCategory.addPreference(accountPref);
} }
//维护 4 //维护_丁梓坚_个性化背景_打开相册
private void openAlbum() { private void openAlbum() {
Intent intent = new Intent(Intent.ACTION_PICK); Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*"); intent.setType("image/*");
startActivityForResult(intent, CHOOSE_PHOTO); startActivityForResult(intent, CHOOSE_PHOTO);
} }
//维护 //维护_丁梓坚_个性化背景_存储Bitmap
private Uri bitmap2uri(Bitmap b) {//c.getCacheDir() private Uri bitmap2uri(Bitmap b) {//c.getCacheDir()
File path = new File(getCacheDir() + "/123.jpeg"); File path = new File(getCacheDir() + "/123.jpeg");
//L.e("getAbsolutePath==="+path.getAbsolutePath()+" ===getAbsolutePath==="+path.getParent());
//Toast.makeText(this, path.toString(), Toast.LENGTH_SHORT).show();
try { try {
OutputStream os = new FileOutputStream(path); OutputStream os = new FileOutputStream(path);
b.compress(Bitmap.CompressFormat.JPEG, 100, os); b.compress(Bitmap.CompressFormat.JPEG, 100, os);
@ -207,7 +200,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
return null; return null;
} }
//维护 ! //维护_丁梓坚_个性化背景_根据相册图片进入裁剪操作
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) protected void onActivityResult(int requestCode, int resultCode, Intent data)
{ {
@ -242,10 +235,10 @@ public class NotesPreferenceActivity extends PreferenceActivity {
//维护 //维护_丁梓坚_个性化背景_选择栏
private String[] items2={"本地图片","还原"}; private String[] items2={"本地图片","还原"};
//维护 2 //维护_丁梓坚_个性化背景_选择栏
public void chooseBackground() { public void chooseBackground() {
/* /*
AlertDialog dialog; AlertDialog dialog;
@ -267,7 +260,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
} }
//维护4.2 //维护_丁梓坚_个性化背景_选择默认背景
private void returnToMenu() { private void returnToMenu() {
SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_WRITEABLE);//xml SharedPreferences sharedPreferences=getSharedPreferences("data1", Context.MODE_WORLD_WRITEABLE);//xml
@ -279,7 +272,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
finish(); finish();
} }
//维护 3 //维护_丁梓坚_个性化背景_监听选择
class backgroundListener implements DialogInterface.OnClickListener{ class backgroundListener implements DialogInterface.OnClickListener{
@Override @Override
@ -301,13 +294,12 @@ public class NotesPreferenceActivity extends PreferenceActivity {
} }
//维护 1 //维护_丁梓坚_个性化背景_加载监听选择
private void loadBackgroundPreference() { private void loadBackgroundPreference() {
//mAccountCategory.removeAll();
Preference background = new Preference(this); Preference background = new Preference(this);
//final String defaultAccount = getSyncAccountName(this);
background.setTitle("Set Background"); background.setTitle("Set Background");
background.setSummary("Reset menu background you like"); background.setSummary("Reset menu background you like");
@ -315,17 +307,10 @@ public class NotesPreferenceActivity extends PreferenceActivity {
//@Override //@Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
//if (ContextCompat.checkSelfPermission(NotesPreferenceActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(NotesPreferenceActivity.this, new String[]{Manifest.permission.WRITE_APN_SETTINGS}, 1);
//} else {
// NotesPreferenceActivity.this.openAlbum();
//}
chooseBackground(); chooseBackground();
return true; return true;
} }
}); });
@ -374,7 +359,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
private void refreshUI() { private void refreshUI() {
loadAccountPreference(); loadAccountPreference();
loadSyncButton(); loadSyncButton();
//维护 //维护_丁梓坚_个性化背景
loadBackgroundPreference(); loadBackgroundPreference();
} }

Loading…
Cancel
Save