Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.app.Activity;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.BaseAdapter;
- import android.widget.EditText;
- import android.widget.Button;
- import android.widget.ImageButton;
- import android.widget.TextView;
- import android.graphics.Color;
- import android.text.InputType;
- import android.text.TextWatcher;
- import android.text.Editable;
- import android.content.ClipboardManager;
- import android.content.ClipData;
- import android.database.sqlite.SQLiteDatabase;
- import android.database.Cursor;
- import android.util.Patterns;
- import android.content.Intent;
- import android.net.Uri;
- import android.view.ViewTreeObserver;
- import android.view.KeyEvent;
- import android.widget.GridLayout;
- import android.view.Gravity;
- import android.widget.FrameLayout;
- import android.graphics.drawable.GradientDrawable;
- import android.util.DisplayMetrics;
- import android.view.WindowManager;
- import android.content.res.Configuration;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.function.Consumer;
- import java.util.concurrent.Callable;
- import com.joaomgcd.taskerm.action.java.JavaCodeException;
- import com.joaomgcd.taskerm.action.java.ClassImplementation;
- import android.view.MotionEvent;
- import android.widget.RadioButton;
- import android.widget.RadioGroup;
- import android.view.inputmethod.InputMethodManager;
- import android.widget.AbsListView;
- /* === for unix timestrings === */
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Locale;
- /* === Get DB path === */
- dbPath = tasker.getVariable("CBM_dbpath");
- if (dbPath == null) {
- throw new JavaCodeException("CBM_dbpath variable is not set");
- }
- debugEnabled = "true".equals(tasker.getVariable("debug_enabled"));
- void logToFile(String message) {
- if (!debugEnabled) return;
- try {
- logFile = "/storage/emulated/0/Tasker/log/clipboard_ui_debug.log";
- tasker.log(message, logFile);
- } catch(Exception e) {
- tasker.log("File log error: " + e.getMessage());
- }
- }
- /* === Global state === */
- Activity activity;
- FrameLayout rootOverlay;
- LinearLayout mainLayout;
- ListView listView;
- EditText searchEdit;
- ImageButton filterBtn, settingsBtn, deleteAllBtn;
- LinearLayout buttonBar;
- TextView loadingText;
- ArrayList allClips = new ArrayList();
- ArrayList filteredClips = new ArrayList();
- Object adapter;
- Runnable applyTheme, updateDataList;
- boolean isStarFilterActive = false;
- String searchQuery = "";
- String currentTheme;
- HashMap colorPalette;
- View currentOverlay = null;
- int screenWidth, screenHeight, desiredWidth, desiredHeight;
- /* === Get color palette based on theme === */
- getColorPalette(themeName) {
- palette = new HashMap();
- if (themeName.equals("light")) {
- palette.put("background", Color.parseColor("#F5F5F5"));
- palette.put("card", Color.parseColor("#E0E0E0"));
- palette.put("cardStarred", Color.parseColor("#FFF9C4"));
- palette.put("overlay", Color.parseColor("#FAFAFA"));
- palette.put("overlayDim", Color.parseColor("#CC000000"));
- palette.put("textPrimary", Color.parseColor("#212121"));
- palette.put("textSecondary", Color.parseColor("#757575"));
- palette.put("hint", Color.parseColor("#9E9E9E"));
- palette.put("input", Color.parseColor("#E0E0E0"));
- palette.put("inputText", Color.parseColor("#424242"));
- palette.put("star", Color.parseColor("#FFC107"));
- palette.put("icon", Color.parseColor("#000000"));
- palette.put("button", Color.parseColor("#E0E0E0"));
- palette.put("buttonActive", Color.parseColor("#FFC107"));
- palette.put("header", Color.parseColor("#E0E0E0"));
- } else {
- palette.put("background", Color.parseColor("#1E1E1E"));
- palette.put("card", Color.parseColor("#2D2D2D"));
- palette.put("cardStarred", Color.parseColor("#3D2D00"));
- palette.put("overlay", Color.parseColor("#1E1E1E"));
- palette.put("overlayDim", Color.parseColor("#CC000000"));
- palette.put("textPrimary", Color.WHITE);
- palette.put("textSecondary", Color.GRAY);
- palette.put("hint", Color.GRAY);
- palette.put("input", Color.parseColor("#2D2D2D"));
- palette.put("inputText", Color.WHITE);
- palette.put("star", Color.parseColor("#FFC107"));
- palette.put("icon", Color.parseColor("#FFFFFF"));
- palette.put("button", Color.parseColor("#2D2D2D"));
- palette.put("buttonActive", Color.parseColor("#FFC107"));
- palette.put("header", Color.parseColor("#2D2D2D"));
- }
- return palette;
- }
- /* === Detect system theme === */
- isSystemDarkMode() {
- config = context.getResources().getConfiguration();
- nightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
- return nightMode == Configuration.UI_MODE_NIGHT_YES;
- }
- /* === Resolve theme (handles auto mode) === */
- resolveTheme(theme) {
- if (theme == null || theme.isEmpty()) {
- return "dark";
- }
- if (theme.equals("auto")) {
- return isSystemDarkMode() ? "dark" : "light";
- }
- return theme;
- }
- /* === Load clips from DB (Safe DB handling) === */
- loadClips = new Runnable() {
- run() {
- db = null;
- cursor = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY);
- cursor = db.rawQuery("SELECT rowid, text, star, timestamp FROM clip ORDER BY timestamp DESC", null);
- temp = new ArrayList();
- // human readable time
- sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.getDefault());
- while (cursor.moveToNext()) {
- clip = new Object[4];
- clip[0] = new Integer(cursor.getInt(0));
- clip[1] = cursor.getString(1);
- clip[2] = new Boolean(cursor.getInt(2) == 1);
- // Unix-timestamp to human readable format
- rawTimestamp = cursor.getString(3);
- try {
- // SQLite Unix-Timestamps are often in seconds, Java needs msec (* 1000)
- long unixTime = Long.parseLong(rawTimestamp);
- // Falls der Wert kleiner als 10000000000L ist, sind es Sekunden
- if (unixTime < 10000000000L) unixTime *= 1000;
- clip[3] = sdf.format(new Date(unixTime));
- } catch (Exception e) {
- clip[3] = rawTimestamp; // Fallback, if not Unix-format
- }
- temp.add(clip);
- }
- allClips = temp;
- } catch (Exception e) {
- logToFile("Load DB Error: " + e.getMessage());
- } finally {
- if (cursor != null) cursor.close();
- if (db != null) db.close();
- }
- updateDataList.run();
- }
- };
- /* === Filter Data List Logic === */
- updateDataList = new Runnable() {
- run() {
- filteredClips.clear();
- for (int i=0; i<allClips.size(); i++) {
- Object[] data = (Object[]) allClips.get(i);
- String clipText = (String)data[1];
- boolean clipStar = ((Boolean)data[2]).booleanValue();
- if (isStarFilterActive && !clipStar) continue;
- if (searchQuery.length() > 0 && clipText.toLowerCase().indexOf(searchQuery.toLowerCase()) == -1) continue;
- Object[] viewData = new Object[5]; // Size increased to 5
- viewData[0] = data[0];
- viewData[1] = data[1];
- viewData[2] = data[2];
- viewData[3] = new Integer(i);
- viewData[4] = data[3]; // Pass timestamp forward
- filteredClips.add(viewData);
- }
- if (adapter != null) {
- adapter.notifyDataSetChanged();
- }
- }
- };
- /* === Create rounded background === */
- createRoundedBackground(color, radius) {
- shape = new GradientDrawable();
- shape.setShape(GradientDrawable.RECTANGLE);
- shape.setCornerRadius(radius);
- shape.setColor(color);
- return shape;
- }
- /* === Create icon-only button === */
- createIconOnlyButton(ctx, iconName, bgColor, iconColor) {
- btn = new ImageButton(ctx);
- btn.setBackgroundColor(bgColor);
- btn.setPadding(20, 20, 20, 20);
- btn.setScaleType(android.widget.ImageView.ScaleType.CENTER);
- try {
- resId = ctx.getResources().getIdentifier(iconName, "drawable", "net.dinglisch.android.taskerm");
- if (resId != 0) {
- drawable = ctx.getResources().getDrawable(resId);
- if (drawable != null) {
- drawable.setTint(iconColor);
- btn.setImageDrawable(drawable);
- }
- }
- } catch (Exception e) {
- logToFile("Failed to load icon: " + e.getMessage());
- }
- return btn;
- }
- /* === Remove overlay === */
- removeOverlay(overlayView) {
- ((ViewGroup) overlayView.getParent()).removeView(overlayView);
- currentOverlay = null;
- }
- /* === Get current DB trigger (Safe DB handling) === */
- getCurrentTrigger() {
- result = new Object[2];
- result[0] = "none";
- result[1] = "";
- db = null;
- cursor = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY);
- cursor = db.rawQuery("SELECT sql FROM sqlite_master WHERE type='trigger' AND name='clip_limit'", null);
- if (cursor.moveToFirst()) {
- sql = cursor.getString(0);
- if (sql.indexOf("datetime('now'") != -1) {
- startIdx = sql.indexOf("'-") + 2;
- endIdx = sql.indexOf(" days", startIdx);
- if (startIdx != -1 && endIdx != -1) {
- result[0] = "days";
- result[1] = sql.substring(startIdx, endIdx);
- }
- } else if (sql.indexOf("LIMIT") != -1) {
- startIdx = sql.indexOf("LIMIT ") + 6;
- endIdx = sql.indexOf(")", startIdx);
- if (endIdx == -1) endIdx = sql.indexOf(";", startIdx);
- if (endIdx == -1) endIdx = sql.length();
- if (startIdx != -1) {
- valueStr = sql.substring(startIdx, endIdx).trim();
- if (!valueStr.isEmpty()) {
- result[0] = "count";
- result[1] = valueStr;
- }
- }
- }
- }
- } catch (Exception e) {
- logToFile("Get trigger error: " + e.getMessage());
- } finally {
- if (cursor != null) cursor.close();
- if (db != null) db.close();
- }
- return result;
- }
- /* === Create clip detail overlay === */
- createClipDetailOverlay(clipId, clipText, clipStar, data, index) {
- overlay = new FrameLayout(activity);
- overlay.setBackgroundColor(((Integer)colorPalette.get("overlayDim")).intValue());
- overlay.setClickable(true);
- overlay.setFocusable(true);
- overlay.setFocusableInTouchMode(true);
- currentOverlay = overlay;
- panel = new LinearLayout(activity);
- panel.setOrientation(LinearLayout.VERTICAL);
- panel.setPadding(20, 20, 20, 20);
- panelParams = new FrameLayout.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
- panelParams.gravity = Gravity.CENTER;
- panel.setLayoutParams(panelParams);
- panelBg = ((Integer)colorPalette.get("overlay")).intValue();
- panel.setBackground(createRoundedBackground(panelBg, 20));
- panelObserver = new ViewTreeObserver.OnGlobalLayoutListener() {
- onGlobalLayout() {
- if (panel.getHeight() > desiredHeight) {
- params = (FrameLayout.LayoutParams) panel.getLayoutParams();
- if (params.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
- params.height = desiredHeight;
- panel.setLayoutParams(params);
- }
- }
- panel.getViewTreeObserver().removeOnGlobalLayoutListener(panelObserver);
- }
- };
- panel.getViewTreeObserver().addOnGlobalLayoutListener(panelObserver);
- header = new LinearLayout(activity);
- header.setOrientation(LinearLayout.HORIZONTAL);
- header.setBackgroundColor(((Integer)colorPalette.get("header")).intValue());
- header.setGravity(Gravity.CENTER_VERTICAL);
- // Title and Timestamp container
- titleContainer = new LinearLayout(activity);
- titleContainer.setOrientation(LinearLayout.VERTICAL);
- titleContainer.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
- titleContainer.setPadding(20, 10, 20, 10);
- title = new TextView(activity);
- title.setText("Clip Details");
- title.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- title.setTextSize(18);
- timestampView = new TextView(activity);
- String ts = (String) data[4];
- timestampView.setText(ts != null ? ts : "");
- timestampView.setTextColor(((Integer)colorPalette.get("textSecondary")).intValue());
- timestampView.setTextSize(12);
- titleContainer.addView(title);
- titleContainer.addView(timestampView);
- closeBtn = createIconOnlyButton(activity, "mw_navigation_close", ((Integer)colorPalette.get("header")).intValue(), ((Integer)colorPalette.get("icon")).intValue());
- header.addView(titleContainer);
- header.addView(closeBtn);
- panel.addView(header);
- buttonGrid = new GridLayout(activity);
- buttonGrid.setOrientation(GridLayout.HORIZONTAL);
- buttonGrid.setPadding(0, 10, 0, 10);
- buttonGrid.setUseDefaultMargins(true);
- btnIcons = new String[]{ "mw_content_content_copy", "mw_content_content_paste", "mw_social_share", "mw_editor_mode_edit", clipStar ? "mw_action_grade" : "mw_toggle_star_border", "mw_action_delete", "mw_content_save", "mw_navigation_cancel" };
- btnColors = new int[]{ Color.parseColor("#4CAF50"), Color.parseColor("#FF9800"), Color.parseColor("#03A9F4"), Color.parseColor("#2196F3"), Color.parseColor("#FFC107"), Color.parseColor("#F44336"), Color.parseColor("#2196F3"), Color.parseColor("#757575") };
- btnRefs = new ImageButton[btnIcons.length];
- for (int i = 0; i < btnIcons.length; i++) {
- b = createIconOnlyButton(activity, btnIcons[i], btnColors[i], Color.WHITE);
- glp = new GridLayout.LayoutParams();
- glp.width = 0;
- glp.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
- glp.setMargins(5, 5, 5, 5);
- b.setLayoutParams(glp);
- buttonGrid.addView(b);
- btnRefs[i] = b;
- }
- copyBtn = btnRefs[0];
- pasteBtn = btnRefs[1];
- shareBtn = btnRefs[2];
- editBtn = btnRefs[3];
- starBtn = btnRefs[4];
- deleteBtn = btnRefs[5];
- saveBtn = btnRefs[6];
- cancelBtn = btnRefs[7];
- saveBtn.setVisibility(View.GONE);
- cancelBtn.setVisibility(View.GONE);
- panel.addView(buttonGrid);
- textScroll = new android.widget.ScrollView(activity);
- textScrollParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- textScroll.setLayoutParams(textScrollParams);
- fullText = new EditText(activity);
- fullText.setText(clipText);
- fullText.setBackgroundColor(((Integer)colorPalette.get("input")).intValue());
- fullText.setTextColor(((Integer)colorPalette.get("inputText")).intValue());
- fullText.setTextSize(16);
- fullText.setPadding(20, 20, 20, 30);
- fullText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
- fullText.setFocusable(true);
- fullText.setFocusableInTouchMode(false);
- fullText.setClickable(false);
- fullText.setCursorVisible(false);
- fullText.setTextIsSelectable(true);
- textScroll.addView(fullText);
- panel.addView(textScroll);
- overlay.addView(panel);
- rootOverlay.addView(overlay);
- final FrameLayout finalOverlay = overlay;
- final LinearLayout finalPanel = panel;
- final EditText finalFullText = fullText;
- overlay.post(new Runnable() {
- run() { finalOverlay.requestFocus(); }
- });
- overlay.setOnKeyListener(new View.OnKeyListener() {
- onKey(View v, int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
- removeOverlay(finalOverlay);
- return true;
- }
- return false;
- }
- });
- finalOverlay.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalOverlay); }
- });
- finalPanel.setClickable(true);
- finalPanel.setOnClickListener(new View.OnClickListener() { onClick(View v) {} });
- closeBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalOverlay); }
- });
- pasteBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- tasker.setVariable("clipboard_paste_text", finalFullText.getText().toString());
- activity.finish();
- variables = new HashMap();
- variables.put("par1", "paste");
- variables.put("clipboard_paste_text", finalFullText.getText().toString());
- tasker.callTask("CBM - Helper", variables);
- }
- });
- copyBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- cm = (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
- cm.setPrimaryClip(ClipData.newPlainText("clip", finalFullText.getText().toString()));
- removeOverlay(finalOverlay);
- }
- });
- shareBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- shareIntent = new Intent(Intent.ACTION_SEND);
- shareIntent.setType("text/plain");
- shareIntent.putExtra(Intent.EXTRA_TEXT, finalFullText.getText().toString());
- activity.startActivity(Intent.createChooser(shareIntent, "Share clip via"));
- activity.finish();
- }
- });
- editBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- panelParams = (FrameLayout.LayoutParams) finalPanel.getLayoutParams();
- panelParams.height = (int)(screenHeight * 0.55);
- panelParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
- finalPanel.setLayoutParams(panelParams);
- pasteBtn.setVisibility(View.GONE);
- shareBtn.setVisibility(View.GONE);
- editBtn.setVisibility(View.GONE);
- starBtn.setVisibility(View.GONE);
- deleteBtn.setVisibility(View.GONE);
- saveBtn.setVisibility(View.VISIBLE);
- cancelBtn.setVisibility(View.VISIBLE);
- finalFullText.setFocusable(true);
- finalFullText.setFocusableInTouchMode(true);
- finalFullText.setClickable(true);
- finalFullText.setCursorVisible(true);
- finalFullText.setOnKeyListener(new View.OnKeyListener() {
- onKey(View v, int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
- imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(finalFullText.getWindowToken(), 0);
- removeOverlay(finalOverlay);
- return true;
- }
- return false;
- }
- });
- finalFullText.requestFocus();
- finalFullText.setSelection(0);
- finalFullText.post(new Runnable() {
- run() {
- imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
- imm.showSoftInput(finalFullText, InputMethodManager.SHOW_IMPLICIT);
- }
- });
- }
- });
- saveBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- newText = finalFullText.getText().toString();
- db = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.execSQL("UPDATE clip SET text=? WHERE rowid=?", new Object[]{newText, clipId});
- Object[] originalData = (Object[]) allClips.get(index);
- originalData[1] = newText;
- } catch (Exception e) {
- logToFile("Save error: " + e.getMessage());
- } finally {
- if (db != null) db.close();
- }
- removeOverlay(finalOverlay);
- updateDataList.run();
- }
- });
- cancelBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalOverlay); }
- });
- starBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- newStar = clipStar ? 0 : 1;
- db = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.execSQL("UPDATE clip SET star=? WHERE rowid=?", new Object[]{newStar, clipId});
- Object[] originalData = (Object[]) allClips.get(index);
- originalData[2] = new Boolean(newStar == 1);
- } catch (Exception e) {
- logToFile("Star error: " + e.getMessage());
- } finally {
- if (db != null) db.close();
- }
- removeOverlay(finalOverlay);
- updateDataList.run();
- }
- });
- deleteBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- db = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.execSQL("DELETE FROM clip WHERE rowid=?", new Object[]{clipId});
- allClips.remove(index);
- } catch (Exception e) {
- logToFile("Delete error: " + e.getMessage());
- } finally {
- if (db != null) db.close();
- }
- removeOverlay(finalOverlay);
- updateDataList.run();
- }
- });
- }
- /* === Create confirmation dialog === */
- createConfirmationDialog(title, message, onConfirm) {
- confirmOverlay = new FrameLayout(activity);
- confirmOverlay.setBackgroundColor(((Integer)colorPalette.get("overlayDim")).intValue());
- confirmOverlay.setClickable(true);
- confirmOverlay.setFocusableInTouchMode(true);
- currentOverlay = confirmOverlay;
- confirmPanel = new LinearLayout(activity);
- confirmPanel.setOrientation(LinearLayout.VERTICAL);
- panelBg = ((Integer)colorPalette.get("overlay")).intValue();
- confirmPanel.setBackgroundColor(panelBg);
- confirmPanel.setPadding(30, 30, 30, 30);
- confirmPanel.setLayoutParams(new FrameLayout.LayoutParams((int)(desiredWidth * 0.9), ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
- confirmPanel.setBackground(createRoundedBackground(panelBg, 20));
- confirmTitle = new TextView(activity);
- confirmTitle.setText(title);
- confirmTitle.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- confirmTitle.setTextSize(18);
- confirmTitle.setPadding(0, 0, 0, 20);
- confirmPanel.addView(confirmTitle);
- confirmMessage = new TextView(activity);
- confirmMessage.setText(message);
- confirmMessage.setTextColor(((Integer)colorPalette.get("textSecondary")).intValue());
- confirmMessage.setTextSize(14);
- confirmMessage.setPadding(0, 0, 0, 30);
- confirmPanel.addView(confirmMessage);
- confirmButtonLayout = new LinearLayout(activity);
- confirmButtonLayout.setOrientation(LinearLayout.HORIZONTAL);
- confirmDeleteBtn = new Button(activity);
- confirmDeleteBtn.setText("Delete All");
- confirmDeleteBtn.setTextColor(Color.WHITE);
- confirmDeleteBtn.setBackgroundColor(Color.parseColor("#F44336"));
- deleteParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
- deleteParams.setMargins(0, 0, 10, 0);
- confirmDeleteBtn.setLayoutParams(deleteParams);
- confirmCancelBtn = new Button(activity);
- confirmCancelBtn.setText("Cancel");
- confirmCancelBtn.setTextColor(Color.WHITE);
- confirmCancelBtn.setBackgroundColor(Color.parseColor("#757575"));
- confirmCancelBtn.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
- confirmButtonLayout.addView(confirmDeleteBtn);
- confirmButtonLayout.addView(confirmCancelBtn);
- confirmPanel.addView(confirmButtonLayout);
- confirmOverlay.addView(confirmPanel);
- rootOverlay.addView(confirmOverlay);
- final FrameLayout finalConfirmOverlay = confirmOverlay;
- final Runnable finalOnConfirm = onConfirm;
- confirmCancelBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalConfirmOverlay); }
- });
- confirmDeleteBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- finalOnConfirm.run();
- removeOverlay(finalConfirmOverlay);
- }
- });
- }
- /* === Rebuild button bar with current theme === */
- rebuildButtonBar() {
- buttonBar.removeAllViews();
- buttonColor = ((Integer)colorPalette.get("button")).intValue();
- iconColor = ((Integer)colorPalette.get("icon")).intValue();
- filterBtn = createIconOnlyButton(activity, "mw_action_grade", buttonColor, iconColor);
- filterParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
- filterParams.setMargins(0, 0, 5, 0);
- filterBtn.setLayoutParams(filterParams);
- settingsBtn = createIconOnlyButton(activity, "mw_action_settings", buttonColor, iconColor);
- settingsParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
- settingsParams.setMargins(5, 0, 5, 0);
- settingsBtn.setLayoutParams(settingsParams);
- deleteAllBtn = createIconOnlyButton(activity, "mw_content_delete_sweep", buttonColor, iconColor);
- deleteAllParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
- deleteAllParams.setMargins(5, 0, 0, 0);
- deleteAllBtn.setLayoutParams(deleteAllParams);
- buttonBar.addView(filterBtn);
- buttonBar.addView(settingsBtn);
- buttonBar.addView(deleteAllBtn);
- filterBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- isStarFilterActive = !isStarFilterActive;
- filterBtn.setBackgroundColor(isStarFilterActive ? ((Integer)colorPalette.get("buttonActive")).intValue() : ((Integer)colorPalette.get("button")).intValue());
- updateDataList.run();
- }
- });
- deleteAllBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- createConfirmationDialog(
- "Delete All Unstarred Clips?",
- "This will permanently delete all clips that are not starred.",
- new Runnable() {
- run() {
- db = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.execSQL("DELETE FROM clip WHERE star = 0");
- } catch (Exception e) {
- logToFile("Delete all error: " + e.getMessage());
- } finally {
- if (db != null) db.close();
- }
- loadClips.run();
- logToFile("Deleted all unstarred clips");
- }
- }
- );
- }
- });
- /* === Settings button === */
- settingsBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- currentTrigger = getCurrentTrigger();
- currentType = (String) currentTrigger[0];
- currentValue = (String) currentTrigger[1];
- settingsOverlay = new FrameLayout(activity);
- settingsOverlay.setBackgroundColor(((Integer)colorPalette.get("overlayDim")).intValue());
- settingsOverlay.setClickable(true);
- settingsOverlay.setFocusableInTouchMode(true);
- currentOverlay = settingsOverlay;
- settingsPanel = new LinearLayout(activity);
- settingsPanel.setOrientation(LinearLayout.VERTICAL);
- panelBg = ((Integer)colorPalette.get("overlay")).intValue();
- settingsPanel.setBackgroundColor(panelBg);
- settingsPanel.setPadding(30, 30, 30, 30);
- settingsPanel.setLayoutParams(new FrameLayout.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
- settingsPanel.setBackground(createRoundedBackground(panelBg, 20));
- settingsHeader = new LinearLayout(activity);
- settingsHeader.setOrientation(LinearLayout.HORIZONTAL);
- settingsHeader.setBackgroundColor(((Integer)colorPalette.get("header")).intValue());
- settingsTitle = new TextView(activity);
- settingsTitle.setText("Settings");
- settingsTitle.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- settingsTitle.setTextSize(18);
- settingsTitle.setPadding(20, 20, 20, 20);
- settingsTitle.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
- settingsCloseBtn = createIconOnlyButton(activity, "mw_navigation_close", ((Integer)colorPalette.get("header")).intValue(), ((Integer)colorPalette.get("icon")).intValue());
- settingsHeader.addView(settingsTitle);
- settingsHeader.addView(settingsCloseBtn);
- settingsPanel.addView(settingsHeader);
- themeLabel = new TextView(activity);
- themeLabel.setText("Theme:");
- themeLabel.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- themeLabel.setTextSize(16);
- themeLabel.setPadding(0, 20, 0, 10);
- settingsPanel.addView(themeLabel);
- themeGroup = new RadioGroup(activity);
- themeGroup.setOrientation(RadioGroup.VERTICAL);
- darkRadio = new RadioButton(activity);
- darkRadio.setText("Dark");
- darkRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- darkRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- darkRadio.setId(11);
- lightRadio = new RadioButton(activity);
- lightRadio.setText("Light");
- lightRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- lightRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- lightRadio.setId(12);
- autoRadio = new RadioButton(activity);
- autoRadio.setText("Auto (System)");
- autoRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- autoRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- autoRadio.setId(13);
- themeGroup.addView(darkRadio);
- themeGroup.addView(lightRadio);
- themeGroup.addView(autoRadio);
- settingsPanel.addView(themeGroup);
- if (currentTheme.equals("light")) {
- themeGroup.check(12);
- } else if (currentTheme.equals("auto")) {
- themeGroup.check(13);
- } else {
- themeGroup.check(11);
- }
- divider = new View(activity);
- divider.setBackgroundColor(((Integer)colorPalette.get("textSecondary")).intValue());
- dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2);
- dividerParams.setMargins(0, 20, 0, 20);
- divider.setLayoutParams(dividerParams);
- settingsPanel.addView(divider);
- limitTypeLabel = new TextView(activity);
- limitTypeLabel.setText("Database Limit Type:");
- limitTypeLabel.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- limitTypeLabel.setTextSize(16);
- limitTypeLabel.setPadding(0, 0, 0, 10);
- settingsPanel.addView(limitTypeLabel);
- limitTypeGroup = new RadioGroup(activity);
- limitTypeGroup.setOrientation(RadioGroup.VERTICAL);
- noneRadio = new RadioButton(activity);
- noneRadio.setText("No Limit");
- noneRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- noneRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- noneRadio.setId(1);
- daysRadio = new RadioButton(activity);
- daysRadio.setText("By Days");
- daysRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- daysRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- daysRadio.setId(2);
- countRadio = new RadioButton(activity);
- countRadio.setText("By Count");
- countRadio.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- countRadio.setButtonTintList(android.content.res.ColorStateList.valueOf(((Integer)colorPalette.get("textPrimary")).intValue()));
- countRadio.setId(3);
- limitTypeGroup.addView(noneRadio);
- limitTypeGroup.addView(daysRadio);
- limitTypeGroup.addView(countRadio);
- settingsPanel.addView(limitTypeGroup);
- if (currentType.equals("days")) {
- limitTypeGroup.check(2);
- } else if (currentType.equals("count")) {
- limitTypeGroup.check(3);
- } else {
- limitTypeGroup.check(1);
- }
- valueLabel = new TextView(activity);
- valueLabel.setText("Limit Value:");
- valueLabel.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- valueLabel.setTextSize(16);
- valueLabel.setPadding(0, 20, 0, 10);
- settingsPanel.addView(valueLabel);
- valueInput = new EditText(activity);
- valueInput.setHint("Enter value...");
- valueInput.setTextColor(((Integer)colorPalette.get("inputText")).intValue());
- valueInput.setHintTextColor(((Integer)colorPalette.get("hint")).intValue());
- valueInput.setBackgroundColor(((Integer)colorPalette.get("input")).intValue());
- valueInput.setPadding(20, 20, 20, 20);
- valueInput.setInputType(InputType.TYPE_CLASS_NUMBER);
- if (!currentValue.isEmpty()) {
- valueInput.setText(currentValue);
- }
- settingsPanel.addView(valueInput);
- statusLabel = new TextView(activity);
- statusLabel.setTextColor(((Integer)colorPalette.get("star")).intValue());
- statusLabel.setTextSize(14);
- statusLabel.setPadding(0, 20, 0, 0);
- if (currentType.equals("none")) {
- statusLabel.setText("Current: No limit active");
- } else if (currentType.equals("days")) {
- statusLabel.setText("Current: Delete clips older than " + currentValue + " days (starred excluded)");
- } else if (currentType.equals("count")) {
- statusLabel.setText("Current: Keep only latest " + currentValue + " clips (starred excluded)");
- }
- settingsPanel.addView(statusLabel);
- settingsButtonLayout = new LinearLayout(activity);
- settingsButtonLayout.setOrientation(LinearLayout.HORIZONTAL);
- settingsButtonLayout.setPadding(0, 30, 0, 0);
- saveSettingsBtn = createIconOnlyButton(activity, "mw_content_save", Color.parseColor("#2196F3"), Color.WHITE);
- saveSettingsParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
- saveSettingsParams.setMargins(0, 0, 10, 0);
- saveSettingsBtn.setLayoutParams(saveSettingsParams);
- cancelSettingsBtn = createIconOnlyButton(activity, "mw_navigation_cancel", Color.parseColor("#757575"), Color.WHITE);
- cancelSettingsBtn.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
- settingsButtonLayout.addView(saveSettingsBtn);
- settingsButtonLayout.addView(cancelSettingsBtn);
- settingsPanel.addView(settingsButtonLayout);
- settingsOverlay.addView(settingsPanel);
- rootOverlay.addView(settingsOverlay);
- final FrameLayout finalSettingsOverlay = settingsOverlay;
- final RadioGroup finalThemeGroup = themeGroup;
- final RadioGroup finalLimitTypeGroup = limitTypeGroup;
- final EditText finalValueInput = valueInput;
- settingsOverlay.setOnKeyListener(new View.OnKeyListener() {
- onKey(View v, int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
- removeOverlay(finalSettingsOverlay);
- return true;
- }
- return false;
- }
- });
- settingsOverlay.requestFocus();
- settingsCloseBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalSettingsOverlay); }
- });
- cancelSettingsBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { removeOverlay(finalSettingsOverlay); }
- });
- saveSettingsBtn.setOnClickListener(new View.OnClickListener() {
- onClick(View v) {
- themeId = finalThemeGroup.getCheckedRadioButtonId();
- newTheme = "dark";
- if (themeId == 12) {
- newTheme = "light";
- } else if (themeId == 13) {
- newTheme = "auto";
- }
- themeChanged = !newTheme.equals(currentTheme);
- if (themeChanged) {
- tasker.setVariable("theme", newTheme);
- currentTheme = newTheme;
- }
- selectedId = finalLimitTypeGroup.getCheckedRadioButtonId();
- value = finalValueInput.getText().toString().trim();
- db = null;
- try {
- db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.execSQL("DROP TRIGGER IF EXISTS clip_limit");
- if (selectedId == 1) {
- removeOverlay(finalSettingsOverlay);
- if (themeChanged) applyTheme.run();
- logToFile("Database limit removed");
- return;
- }
- if (value.isEmpty()) {
- logToFile("Please enter a value for the limit");
- return;
- }
- if (selectedId == 2) {
- triggerSql = "CREATE TRIGGER IF NOT EXISTS clip_limit AFTER INSERT ON clip " +
- "BEGIN " +
- "DELETE FROM clip WHERE star = 0 AND timestamp < strftime('%s', datetime('now', '-" + value + " days')); " +
- "END;";
- db.execSQL(triggerSql);
- logToFile("Set limit to " + value + " days");
- } else if (selectedId == 3) {
- triggerSql = "CREATE TRIGGER IF NOT EXISTS clip_limit AFTER INSERT ON clip " +
- "BEGIN " +
- "DELETE FROM clip WHERE star = 0 AND rowid NOT IN (" +
- "SELECT rowid FROM clip WHERE star = 0 ORDER BY timestamp DESC LIMIT " + value + "); " +
- "END;";
- db.execSQL(triggerSql);
- logToFile("Set limit to " + value + " clips");
- }
- } catch (Exception e) {
- logToFile("Save settings error: " + e.getMessage());
- } finally {
- if (db != null) db.close();
- }
- removeOverlay(finalSettingsOverlay);
- if (themeChanged) applyTheme.run();
- }
- });
- }
- });
- if (isStarFilterActive) {
- filterBtn.setBackgroundColor(((Integer)colorPalette.get("buttonActive")).intValue());
- }
- }
- /* === Helper for Adapter: Create View (Fixed Memory Leak) === */
- View createListItemView(ViewGroup parent) {
- card = new LinearLayout(activity);
- card.setOrientation(LinearLayout.VERTICAL);
- card.setPadding(20, 20, 20, 20);
- lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- card.setLayoutParams(lp);
- txt = new TextView(activity);
- txt.setTextSize(16);
- txt.setMaxLines(10);
- txt.setEllipsize(android.text.TextUtils.TruncateAt.END);
- card.addView(txt);
- indicator = new TextView(activity);
- indicator.setText("...MORE");
- indicator.setTextSize(12);
- indicator.setPadding(0, 5, 0, 0);
- indicator.setVisibility(View.GONE);
- indicatorParams = new LinearLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT
- );
- indicatorParams.gravity = Gravity.CENTER_HORIZONTAL;
- indicator.setLayoutParams(indicatorParams);
- card.addView(indicator);
- Object[] holder = new Object[4];
- holder[0] = txt;
- holder[1] = indicator;
- holder[2] = card;
- holder[3] = null;
- card.setTag(holder);
- card.setOnTouchListener(new View.OnTouchListener() {
- float startX, startY;
- boolean isLongPress = false;
- boolean hasMoved = false;
- Runnable longPressRunnable;
- onTouch(View v, MotionEvent event) {
- Object[] tagHolder = (Object[]) v.getTag();
- if (tagHolder == null || tagHolder[3] == null) return false;
- Object[] data = (Object[]) tagHolder[3];
- int clipId = ((Integer)data[0]).intValue();
- String clipText = (String)data[1];
- boolean clipStar = ((Boolean)data[2]).booleanValue();
- int originalIndex = ((Integer)data[3]).intValue();
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- startX = event.getX();
- startY = event.getY();
- isLongPress = false;
- hasMoved = false;
- longPressRunnable = new Runnable() {
- run() {
- if (!hasMoved) {
- isLongPress = true;
- v.performHapticFeedback(android.view.HapticFeedbackConstants.LONG_PRESS);
- cm = (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
- cm.setPrimaryClip(ClipData.newPlainText("clip", clipText));
- activity.finish();
- }
- }
- };
- v.postDelayed(longPressRunnable, 500);
- return true;
- case MotionEvent.ACTION_MOVE:
- if (Math.abs(event.getX() - startX) > 10 || Math.abs(event.getY() - startY) > 10) {
- hasMoved = true;
- if (longPressRunnable != null) v.removeCallbacks(longPressRunnable);
- }
- return true;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
- if (longPressRunnable != null) v.removeCallbacks(longPressRunnable);
- if (event.getAction() == MotionEvent.ACTION_UP && !isLongPress && !hasMoved) {
- createClipDetailOverlay(clipId, clipText, clipStar, data, originalIndex);
- }
- return true;
- }
- return false;
- }
- });
- return card;
- }
- /* === Helper for Adapter: Bind View === */
- void bindListItemView(View view, int position) {
- Object[] holder = (Object[]) view.getTag();
- TextView txt = (TextView) holder[0];
- TextView indicator = (TextView) holder[1];
- LinearLayout card = (LinearLayout) holder[2];
- Object[] data = (Object[]) filteredClips.get(position);
- holder[3] = data;
- String clipText = (String)data[1];
- boolean clipStar = ((Boolean)data[2]).booleanValue();
- cardColor = clipStar ? ((Integer)colorPalette.get("cardStarred")).intValue() : ((Integer)colorPalette.get("card")).intValue();
- card.setBackground(createRoundedBackground(cardColor, 15));
- txt.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- indicator.setTextColor(((Integer)colorPalette.get("textSecondary")).intValue());
- txt.setText(clipText);
- if (clipText.length() > 300 || clipText.split("\n").length > 8) {
- indicator.setVisibility(View.VISIBLE);
- } else {
- indicator.setVisibility(View.GONE);
- }
- }
- /* === Main activity UI === */
- activityConsumer = new Consumer() {
- accept(Object actObj) {
- activity = (Activity) actObj;
- metrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
- screenWidth = metrics.widthPixels;
- screenHeight = metrics.heightPixels;
- desiredWidth = (int)(screenWidth * 0.9);
- desiredHeight = (int)(screenHeight * 0.8);
- savedTheme = tasker.getVariable("theme");
- if (savedTheme == null || savedTheme.isEmpty()) savedTheme = "dark";
- currentTheme = savedTheme;
- resolvedTheme = resolveTheme(savedTheme);
- colorPalette = getColorPalette(resolvedTheme);
- window = activity.getWindow();
- window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
- layoutParams = window.getAttributes();
- layoutParams.dimAmount = 0.7f;
- window.setAttributes(layoutParams);
- window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
- rootOverlay = new FrameLayout(activity);
- rootOverlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- rootOverlay.setClickable(true);
- rootOverlay.setFocusableInTouchMode(true);
- rootOverlay.setOnKeyListener(new View.OnKeyListener() {
- onKey(View v, int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
- if (currentOverlay != null) {
- removeOverlay(currentOverlay);
- } else {
- activity.finish();
- }
- return true;
- }
- return false;
- }
- });
- rootOverlay.setOnClickListener(new View.OnClickListener() {
- onClick(View v) { activity.finish(); }
- });
- mainLayout = new LinearLayout(activity);
- mainLayout.setOrientation(LinearLayout.VERTICAL);
- bgColor = ((Integer)colorPalette.get("background")).intValue();
- mainLayout.setBackgroundColor(bgColor);
- mainLayout.setPadding(20, 20, 20, 20);
- mainLayout.setBackground(createRoundedBackground(bgColor, 20));
- mainLayoutParams = new FrameLayout.LayoutParams(desiredWidth, desiredHeight);
- mainLayoutParams.gravity = Gravity.CENTER;
- mainLayout.setLayoutParams(mainLayoutParams);
- mainLayout.setClickable(true);
- buttonBar = new LinearLayout(activity);
- buttonBar.setOrientation(LinearLayout.HORIZONTAL);
- buttonBar.setPadding(0, 0,0, 15);
- rebuildButtonBar();
- mainLayout.addView(buttonBar);
- searchEdit = new EditText(activity);
- searchEdit.setHint("Search clips...");
- searchEdit.setTextColor(((Integer)colorPalette.get("inputText")).intValue());
- searchEdit.setHintTextColor(((Integer)colorPalette.get("hint")).intValue());
- searchEdit.setBackgroundColor(((Integer)colorPalette.get("input")).intValue());
- searchEdit.setPadding(20, 20, 20, 20);
- searchParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- searchParams.setMargins(0, 0, 0, 20);
- searchEdit.setLayoutParams(searchParams);
- mainLayout.addView(searchEdit);
- loadingText = new TextView(activity);
- loadingText.setText("Loading clips...");
- loadingText.setTextColor(((Integer)colorPalette.get("textPrimary")).intValue());
- loadingText.setPadding(10, 40, 10, 20);
- mainLayout.addView(loadingText);
- listView = new ListView(activity);
- listView.setDivider(null);
- listView.setDividerHeight(20);
- listView.setClipToPadding(false);
- listView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
- adapter = tasker.implementClass(BaseAdapter.class, new ClassImplementation() {
- run(Callable superCaller, String methodName, Object[] args) {
- if (methodName.equals("getCount")) return filteredClips.size();
- if (methodName.equals("getItem")) return filteredClips.get(((Integer)args[0]).intValue());
- if (methodName.equals("getItemId")) return (long)((Integer)args[0]).intValue();
- if (methodName.equals("getView")) {
- int position = ((Integer)args[0]).intValue();
- View convertView = (View)args[1];
- ViewGroup parent = (ViewGroup)args[2];
- if (convertView == null) convertView = createListItemView(parent);
- bindListItemView(convertView, position);
- return convertView;
- }
- return superCaller.call();
- }
- });
- listView.setAdapter(adapter);
- listView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
- mainLayout.addView(listView);
- rootOverlay.addView(mainLayout);
- activity.setContentView(rootOverlay);
- rootOverlay.requestFocus();
- loadClips.run();
- loadingText.setVisibility(View.GONE);
- applyTheme = new Runnable() {
- run() {
- resolvedTheme = resolveTheme(currentTheme);
- colorPalette = getColorPalette(resolvedTheme);
- bgColor = ((Integer)colorPalette.get("background")).intValue();
- mainLayout.setBackgroundColor(bgColor);
- mainLayout.setBackground(createRoundedBackground(bgColor, 20));
- rebuildButtonBar();
- searchEdit.setBackgroundColor(((Integer)colorPalette.get("input")).intValue());
- searchEdit.setTextColor(((Integer)colorPalette.get("inputText")).intValue());
- searchEdit.setHintTextColor(((Integer)colorPalette.get("hint")).intValue());
- listView.invalidateViews();
- }
- };
- searchEdit.addTextChangedListener(new TextWatcher() {
- beforeTextChanged(CharSequence s, int st, int c, int a) {}
- onTextChanged(CharSequence s, int st, int b, int c) {}
- afterTextChanged(final Editable s) {
- searchQuery = s.toString();
- updateDataList.run();
- }
- });
- }
- };
- tasker.doWithActivity(activityConsumer);
Advertisement
Add Comment
Please, Sign In to add comment