|
|
@ -171,40 +171,40 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, O
|
|
|
|
add_tag = customView.findViewById(R.id.add_tag);
|
|
|
|
add_tag = customView.findViewById(R.id.add_tag);
|
|
|
|
|
|
|
|
|
|
|
|
add_tag.setOnClickListener(new OnClickListener() {
|
|
|
|
add_tag.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (sharedPreferences.getString("tagListString", "").split("_").length < 8) {
|
|
|
|
if (sharedPreferences.getString("tagListString", "").split("_").length < 8) {
|
|
|
|
final EditText et = new EditText(context);
|
|
|
|
final EditText et = new EditText(context);
|
|
|
|
new AlertDialog.Builder(MainActivity.this)
|
|
|
|
new AlertDialog.Builder(MainActivity.this)
|
|
|
|
.setMessage("输入标签名")
|
|
|
|
.setMessage("输入标签名")
|
|
|
|
.setView(et)
|
|
|
|
.setView(et)
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
List<String> tagList = Arrays.asList(sharedPreferences.getString("tagListString", null).split("_")); //获取tags
|
|
|
|
List<String> tagList = Arrays.asList(sharedPreferences.getString("tagListString", null).split("_")); //获取tags
|
|
|
|
|
|
|
|
|
|
|
|
String name = et.getText().toString();
|
|
|
|
String name = et.getText().toString();
|
|
|
|
if (!tagList.contains(name)) {
|
|
|
|
if (!tagList.contains(name)) {
|
|
|
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
String oldTagListString = sharedPreferences.getString("tagListString", null);
|
|
|
|
String oldTagListString = sharedPreferences.getString("tagListString", null);
|
|
|
|
String newTagListString = oldTagListString + "_" + name;
|
|
|
|
String newTagListString = oldTagListString + "_" + name;
|
|
|
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
|
|
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
|
|
|
editor.putString("tagListString", newTagListString);
|
|
|
|
editor.putString("tagListString", newTagListString);
|
|
|
|
editor.apply();
|
|
|
|
editor.apply();
|
|
|
|
refreshTagList();
|
|
|
|
refreshTagList();
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
Toast.makeText(context, "Repeated tag!", Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(context, "Repeated tag!", Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
dialog.dismiss();
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).create().show();
|
|
|
|
}).create().show();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Toast.makeText(context, "自定义的标签够多了!", Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(context, "自定义的标签够多了!", Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
//final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
@ -481,8 +481,8 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, O
|
|
|
|
else myToolbar.setTitle("所有笔记");
|
|
|
|
else myToolbar.setTitle("所有笔记");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams")
|
|
|
|
public void initPopupView() {
|
|
|
|
public void initPopupView() {
|
|
|
|
//instantiate the popup.xml layout file
|
|
|
|
|
|
|
|
layoutInflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
layoutInflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
customView = (ViewGroup) layoutInflater.inflate(R.layout.setting_layout, null);
|
|
|
|
customView = (ViewGroup) layoutInflater.inflate(R.layout.setting_layout, null);
|
|
|
|
coverView = (ViewGroup) layoutInflater.inflate(R.layout.setting_cover, null);
|
|
|
|
coverView = (ViewGroup) layoutInflater.inflate(R.layout.setting_cover, null);
|
|
|
@ -496,8 +496,6 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, O
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initPrefs() {
|
|
|
|
private void initPrefs() {
|
|
|
|
//initialize all useful SharedPreferences for the first time the app runs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
|
|
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
|
|
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
|
|
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
|
|
|
if (!sharedPreferences.contains("nightMode")) {
|
|
|
|
if (!sharedPreferences.contains("nightMode")) {
|
|
|
|