|
| 1 | +/* |
| 2 | + * SiYuan - 源于思考,饮水思源 |
| 3 | + * Copyright (c) 2020-present, b3log.org |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | +package org.b3log.siyuan; |
| 19 | + |
| 20 | +import android.content.Intent; |
| 21 | +import android.os.Bundle; |
| 22 | +import android.util.Log; |
| 23 | +import android.widget.Button; |
| 24 | +import android.widget.EditText; |
| 25 | + |
| 26 | +import androidx.annotation.Nullable; |
| 27 | +import androidx.appcompat.app.AppCompatActivity; |
| 28 | + |
| 29 | +import com.blankj.utilcode.util.StringUtils; |
| 30 | + |
| 31 | +/** |
| 32 | + * 追加到日记的快捷方式. |
| 33 | + * |
| 34 | + * @author <a href="https://88250.b3log.org">Liang Ding</a> |
| 35 | + * @version 1.0.0.0, Mar 21, 2025 |
| 36 | + * @since 3.1.26 |
| 37 | + */ |
| 38 | +public class ShortcutActivity extends AppCompatActivity { |
| 39 | + |
| 40 | + @Override |
| 41 | + protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 42 | + super.onCreate(savedInstanceState); |
| 43 | + setContentView(R.layout.activity_shortcut); |
| 44 | + handleIntent(getIntent()); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void onNewIntent(final Intent intent) { |
| 49 | + super.onNewIntent(intent); |
| 50 | + handleIntent(intent); |
| 51 | + } |
| 52 | + |
| 53 | + private void handleIntent(final Intent intent) { |
| 54 | + final String data = intent.getDataString(); |
| 55 | + if (StringUtils.equals(data, "appendDailynote")) { |
| 56 | + Log.i("shortcut", "Append to daily note"); |
| 57 | + setupFullScreenInput(); |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + Log.i("shortcut", "Unknown data [" + data + "]"); |
| 62 | + } |
| 63 | + |
| 64 | + private void setupFullScreenInput() { |
| 65 | + final EditText input = findViewById(R.id.full_screen_input); |
| 66 | + input.requestFocus(); |
| 67 | + |
| 68 | + |
| 69 | + final Button submitButton = findViewById(R.id.submit_button); |
| 70 | + submitButton.setOnClickListener(v -> { |
| 71 | + String userInput = input.getText().toString(); |
| 72 | + Log.i("shortcut", "User input: " + userInput); |
| 73 | + // Handle the user input here |
| 74 | + |
| 75 | + finish(); |
| 76 | + }); |
| 77 | + } |
| 78 | +} |
0 commit comments