Allow to copy the URL of the updates
This commit is contained in:
@@ -7,4 +7,9 @@
|
|||||||
android:title="@string/menu_delete_update"
|
android:title="@string/menu_delete_update"
|
||||||
android:visible="false"
|
android:visible="false"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_copy_url"
|
||||||
|
android:title="@string/menu_copy_url"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
@@ -50,6 +50,7 @@
|
|||||||
<string name="menu_refresh">Refresh</string>
|
<string name="menu_refresh">Refresh</string>
|
||||||
<string name="menu_auto_updates_check">Auto updates check</string>
|
<string name="menu_auto_updates_check">Auto updates check</string>
|
||||||
<string name="menu_delete_update">Delete</string>
|
<string name="menu_delete_update">Delete</string>
|
||||||
|
<string name="menu_copy_url">Copy URL</string>
|
||||||
|
|
||||||
<string name="dialog_checking_for_updates">Checking for updates</string>
|
<string name="dialog_checking_for_updates">Checking for updates</string>
|
||||||
<string name="snack_updates_found">New updates found</string>
|
<string name="snack_updates_found">New updates found</string>
|
||||||
@@ -85,6 +86,9 @@
|
|||||||
<string name="apply_update_dialog_message">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually.</string>
|
<string name="apply_update_dialog_message">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually.</string>
|
||||||
<string name="apply_update_dialog_message_ab">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>
|
<string name="apply_update_dialog_message_ab">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>
|
||||||
|
|
||||||
|
<string name="label_download_url">Download URL</string>
|
||||||
|
<string name="toast_download_url_copied">URL Copied</string>
|
||||||
|
|
||||||
<plurals name="duration_seconds">
|
<plurals name="duration_seconds">
|
||||||
<item quantity="one">1 second</item>
|
<item quantity="one">1 second</item>
|
||||||
<item quantity="other"><xliff:g id="count">%d</xliff:g> seconds</item>
|
<item quantity="other"><xliff:g id="count">%d</xliff:g> seconds</item>
|
||||||
|
@@ -428,6 +428,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
MenuInflater inflater = mode.getMenuInflater();
|
MenuInflater inflater = mode.getMenuInflater();
|
||||||
inflater.inflate(R.menu.menu_action_mode, menu);
|
inflater.inflate(R.menu.menu_action_mode, menu);
|
||||||
menu.findItem(R.id.menu_delete_action).setVisible(canDelete);
|
menu.findItem(R.id.menu_delete_action).setVisible(canDelete);
|
||||||
|
menu.findItem(R.id.menu_copy_url).setVisible(update.getAvailableOnline());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,6 +450,13 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_copy_url:
|
||||||
|
Utils.addToClipboard(mActivity,
|
||||||
|
mActivity.getString(R.string.label_download_url),
|
||||||
|
update.getDownloadUrl(),
|
||||||
|
mActivity.getString(R.string.toast_download_url_copied));
|
||||||
|
mode.finish();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.lineageos.updater.misc;
|
package org.lineageos.updater.misc;
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -24,6 +26,7 @@ import android.net.NetworkInfo;
|
|||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -283,4 +286,12 @@ public class Utils {
|
|||||||
public static boolean hasTouchscreen(Context context) {
|
public static boolean hasTouchscreen(Context context) {
|
||||||
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
|
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addToClipboard(Context context, String label, String text, String toastMessage) {
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(
|
||||||
|
Context.CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText(label, text);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user