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