diff --git a/app/src/main/java/com/google/code/appsorganizer/ApplicationContextMenuManager.java b/app/src/main/java/com/google/code/appsorganizer/ApplicationContextMenuManager.java index 7e4f6a6..dc231dd 100644 --- a/app/src/main/java/com/google/code/appsorganizer/ApplicationContextMenuManager.java +++ b/app/src/main/java/com/google/code/appsorganizer/ApplicationContextMenuManager.java @@ -18,66 +18,117 @@ */ package com.google.code.appsorganizer; +import static android.view.Menu.NONE; + import android.app.Activity; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.view.ContextMenu; import android.view.MenuItem; +import android.view.SubMenu; import android.widget.Toast; import com.google.code.appsorganizer.db.DatabaseHelper; +import com.google.code.appsorganizer.dialogs.GenericDialogManager; import com.google.code.appsorganizer.dialogs.GenericDialogManagerActivity; +import com.google.code.appsorganizer.dialogs.OnOkClickListener; import com.google.code.appsorganizer.model.AppCache; +import com.google.code.appsorganizer.preferences.PreferencesFromXml; + +//import java.nio.DoubleBuffer; /** * @author fabio - * + * */ public class ApplicationContextMenuManager { - private static final int UNINSTALL = 2; - private static final int LAUNCH = 1; - private static final int CHOOSE_LABELS = 0; - private static final int SET_STAR = 3; - private static final int UNSET_STAR = 4; - private static final int APPINFO = 5; + private static final int UNINSTALL = 3; + private static final int LAUNCH = 2; + private static final int CHOOSE_LABELS = 1; + private static final int SET_STAR = 4; + private static final int UNSET_STAR = 5; + private static final int APPINFO = 6; + + // Option menu items + private static final int NEW_LABEL = 7; + private static final int RELOAD = 8; + private static final int IMPORT_MENU = 9; + private static final int EXPORT_MENU = 10; + private static final int PREFERENCES = 11; public static void createMenu(Context context, ContextMenu menu, String label, int id) { menu.setHeaderTitle(label); - menu.add(0, CHOOSE_LABELS, 0, R.string.choose_labels_header); + menu.add(NONE, CHOOSE_LABELS, 0, R.string.choose_labels_header); if (id >= 0) { AppCache app = DatabaseHelper.initOrSingleton(context).appCacheDao.queryById(Long.valueOf(id)); - menu.add(0, app.starred ? UNSET_STAR : SET_STAR, + menu.add(NONE, app.starred ? UNSET_STAR : SET_STAR, 1, app.starred ? R.string.unstar_app : R.string.star_app); } - menu.add(0, LAUNCH, 2, R.string.launch); - menu.add(0, APPINFO, 3, R.string.appinfo); - menu.add(0, UNINSTALL, 4, R.string.uninstall); + menu.add(NONE, LAUNCH, 2, R.string.launch); + menu.add(NONE, APPINFO, 3, R.string.appinfo); + menu.add(NONE, UNINSTALL, 4, R.string.uninstall); + + // Option menu items + // //menu.addSubMenu(); + menu.add(0, NONE, 5, null); + menu.add(0, NEW_LABEL, 6, R.string.New_label); + menu.add(0, RELOAD, 7, R.string.reload_apps); + menu.add(0, IMPORT_MENU, 8, R.string.import_menu); + menu.add(0, EXPORT_MENU, 9, R.string.export_menu); + menu.add(0, PREFERENCES, 10, R.string.Preferences); } public static void onContextItemSelected(MenuItem item, String packageName, String name, Activity activity, - ChooseLabelDialogCreator chooseLabelDialog) { + ChooseLabelDialogCreator chooseLabelDialog) { switch (item.getItemId()) { - case CHOOSE_LABELS: - chooseLabelDialog.setCurrentApp(packageName, name); - ((GenericDialogManagerActivity) activity).showDialog(chooseLabelDialog); - break; - case SET_STAR: - DatabaseHelper.initOrSingleton(activity).appCacheDao.updateStarred(packageName, name, true); - break; - case UNSET_STAR: - DatabaseHelper.initOrSingleton(activity).appCacheDao.updateStarred(packageName, name, false); - break; - case LAUNCH: - startApplication(activity, packageName, name); - break; - case APPINFO: - viewApplicationInfo(activity, packageName); - break; - case UNINSTALL: - uninstallApplication(activity, packageName); - break; + case CHOOSE_LABELS: + chooseLabelDialog.setCurrentApp(packageName, name); + ((GenericDialogManagerActivity) activity).showDialog(chooseLabelDialog); + break; + case SET_STAR: + DatabaseHelper.initOrSingleton(activity).appCacheDao.updateStarred(packageName, name, true); + break; + case UNSET_STAR: + DatabaseHelper.initOrSingleton(activity).appCacheDao.updateStarred(packageName, name, false); + break; + case LAUNCH: + startApplication(activity, packageName, name); + break; + case APPINFO: + viewApplicationInfo(activity, packageName); + break; + case UNINSTALL: + uninstallApplication(activity, packageName); + break; + + // Option menu items + case NEW_LABEL: + GenericDialogManager genericDialogManager = ((GenericDialogManagerActivity) activity).getGenericDialogManager(); + NewLabelDialog newLabelDialog = new NewLabelDialog(genericDialogManager, new OnOkClickListener() { + + private static final long serialVersionUID = 1036198138637107577L; + + public void onClick(CharSequence l, DialogInterface dialog, int which) { + DatabaseHelper.initOrSingleton(activity).labelDao.insert(l.toString()); + } + }); + newLabelDialog.showDialog(); + break; + case RELOAD: + new AppsReloader(activity, true).reload(); + break; + case IMPORT_MENU: + activity.startActivity(new Intent(activity, FileImporter.class)); + break; + case EXPORT_MENU: + activity.startActivity(new Intent(activity, FileExporter.class)); + break; + case PREFERENCES: + activity.startActivity(new Intent(activity, PreferencesFromXml.class)); + break; } } diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 55dbbd2..95f1328 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -41,7 +41,7 @@ 如何使用 Apps Organizer 星號標記 你可以藉由在桌面上長按來建立標籤的捷徑 - An how to is available online (see about dialog for details) + A how to is available online (see about dialog for details) 偏好設定 捷徑夾 顯示關閉按鈕 @@ -74,4 +74,4 @@ 選擇程式 Android Image Gallery 更新紀錄 - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 661825b..8887502 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,7 +48,7 @@ How to use Apps Organizer Starred apps You can create labels home shortcuts with a long click on your Android home - An how to is available online (see about dialog for details) + A how to is available online (see about dialog for details) Preferences Shortcut folder Show close button @@ -168,9 +168,9 @@ Android 2.0 support Label already exists Looking for icons... - Loading icons... - Error while launching application - New label + Loading icons... + Error while launching application + New label Apps list Internet Android diff --git a/build.gradle.kts b/build.gradle.kts index 3a2b3a6..3d6c84e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.2.2" apply false + id("com.android.application") version "8.3.0" apply false //CHECK //id("com.android.library") version "8.2.2" apply false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0a0a766..a32634c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed Feb 07 21:25:08 CET 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists