summaryrefslogtreecommitdiff
path: root/mobile/app/gallery-view-model.ts
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-01-25 20:40:16 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-01-25 20:40:16 +0100
commit466d03a38cb01e9ff9a2d11be113a81c2bdce34a (patch)
treed584482d4ed5e9b8fe569af7ce25594c1bd51d63 /mobile/app/gallery-view-model.ts
initial commit
Diffstat (limited to 'mobile/app/gallery-view-model.ts')
-rw-r--r--mobile/app/gallery-view-model.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/mobile/app/gallery-view-model.ts b/mobile/app/gallery-view-model.ts
new file mode 100644
index 0000000..e15839a
--- /dev/null
+++ b/mobile/app/gallery-view-model.ts
@@ -0,0 +1,51 @@
+import { AndroidActivityRequestPermissionsEventData, Application, Observable, Utils } from '@nativescript/core';
+
+export class GalleryModel extends Observable {
+ constructor() {
+ super();
+ }
+
+ peng() {
+ const check = function () {
+ return new Promise((resolve, reject) => {
+ (Application.android.foregroundActivity || Application.android.startActivity).requestPermissions([
+ android.Manifest.permission.READ_EXTERNAL_STORAGE,
+ ], 1337);
+ function onActivityResult(args) {
+ if (args.requestCode === 1337) {
+ Application.android.off(Application.android.activityRequestPermissionsEvent, onActivityResult);
+ console.log(args);
+ console.log(args.grantResults);
+ resolve(args);
+ }
+ }
+ Application.android.on(Application.android.activityRequestPermissionsEvent, onActivityResult);
+ });
+ }
+
+
+ check().then(() => {
+ console.log('query');
+ const cursor = Utils.android.getApplicationContext().getContentResolver().query(
+ android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ [
+ android.provider.MediaStore.Images.ImageColumns._ID,
+ android.provider.MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
+ android.provider.MediaStore.Images.ImageColumns.DATE_TAKEN,
+ ],
+ '1) GROUP BY (' + android.provider.MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
+ null,
+ null
+ );
+
+ console.log(cursor, cursor.getCount());
+ if (cursor) {
+ console.log(cursor.moveToFirst());
+
+ const bucketColumn = cursor.getColumnIndex(android.provider.MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME);
+ console.log(bucketColumn);
+ // console.log(cursor.getString(bucketColumn));
+ }
+ });
+ }
+}