コード例 #1
0
    def _current_level(self):

        System.putInt(mActivity.getContentResolver(),
                      System.SCREEN_BRIGHTNESS_MODE,
                      System.SCREEN_BRIGHTNESS_MODE_MANUAL)
        cr_level = System.getInt(mActivity.getContentResolver(),
                                 System.SCREEN_BRIGHTNESS)
        return (cr_level / 255.) * 100
コード例 #2
0
ファイル: brightness.py プロジェクト: autosportlabs/plyer
    def _current_level(self):

        System.putInt(
            mActivity.getContentResolver(),
            System.SCREEN_BRIGHTNESS_MODE,
            System.SCREEN_BRIGHTNESS_MODE_MANUAL)
        cr_level = System.getInt(
            mActivity.getContentResolver(),
            System.SCREEN_BRIGHTNESS)
        return (cr_level / 255.) * 100
コード例 #3
0
ファイル: filechooser.py プロジェクト: kivy/plyer
    def _parse_content(  # pylint: disable=too-many-arguments
            uri, projection, selection, selection_args, sort_order,
            index_all=False
    ):
        '''
        Parser for ``content://`` URI returned by some Android resources.

        .. versionadded:: 1.4.0
        '''

        result = None
        resolver = mActivity.getContentResolver()
        read = Intent.FLAG_GRANT_READ_URI_PERMISSION
        write = Intent.FLAG_GRANT_READ_URI_PERMISSION
        persist = Intent.FLAG_GRANT_READ_URI_PERMISSION

        # grant permission for our activity
        mActivity.grantUriPermission(
            mActivity.getPackageName(),
            uri,
            read | write | persist
        )

        if not index_all:
            cursor = resolver.query(
                uri, projection, selection,
                selection_args, sort_order
            )

            idx = cursor.getColumnIndex(projection[0])
            if idx != -1 and cursor.moveToFirst():
                result = cursor.getString(idx)
        else:
            result = []
            cursor = resolver.query(
                uri, projection, selection,
                selection_args, sort_order
            )
            while cursor.moveToNext():
                for idx in range(cursor.getColumnCount()):
                    result.append(cursor.getString(idx))
            result = '/'.join(result)
        return result
コード例 #4
0
ファイル: filechooser.py プロジェクト: Dmac500/Instabot
    def _parse_content(  # pylint: disable=too-many-arguments
            uri, projection, selection, selection_args, sort_order,
            index_all=False
    ):
        '''
        Parser for ``content://`` URI returned by some Android resources.

        .. versionadded:: 1.4.0
        '''

        result = None
        resolver = mActivity.getContentResolver()
        read = Intent.FLAG_GRANT_READ_URI_PERMISSION
        write = Intent.FLAG_GRANT_READ_URI_PERMISSION
        persist = Intent.FLAG_GRANT_READ_URI_PERMISSION

        # grant permission for our activity
        mActivity.grantUriPermission(
            mActivity.getPackageName(),
            uri,
            read | write | persist
        )

        if not index_all:
            cursor = resolver.query(
                uri, projection, selection,
                selection_args, sort_order
            )

            idx = cursor.getColumnIndex(projection[0])
            if idx != -1 and cursor.moveToFirst():
                result = cursor.getString(idx)
        else:
            result = []
            cursor = resolver.query(
                uri, projection, selection,
                selection_args, sort_order
            )
            while cursor.moveToNext():
                for idx in range(cursor.getColumnCount()):
                    result.append(cursor.getString(idx))
            result = '/'.join(result)
        return result
コード例 #5
0
 def share_uri(self, uri, app=None):
     try:
         cr = mActivity.getContentResolver()
         self.MIME = cr.getType(uri)
         self.uri = uri
         self.parcelable = cast('android.os.Parcelable', self.uri)
         self.send = Intent()
         self.send.setAction(Intent.ACTION_SEND)
         self.send.setType(self.MIME)
         self.send.putExtra(Intent.EXTRA_STREAM, self.parcelable)
         self.send.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
         if app:
             self.send.setPackage(app)
             mActivity.startActivity(self.send)
         else:
             self.send1 = Intent.createChooser(self.send, None)
             mActivity.startActivity(self.send1)
         Clock.schedule_once(self.begone_you_black_screen)
     except Exception as e:
         print('ERROR: ShareSnd().share_uri()' + str(e))
コード例 #6
0
 def retrieveUri(self, someUri):
     new_file_path = ''
     try:
         if someUri:
             someUri = cast('android.net.Uri', someUri)
             scheme = someUri.getScheme().lower()
             if scheme == 'content':
                 context = mActivity.getApplicationContext()
                 cursor = context.getContentResolver().query(
                     someUri, None, None, None, None)
                 dn = MediaStoreMediaColumns.DISPLAY_NAME
                 nameIndex = cursor.getColumnIndex(dn)
                 cursor.moveToFirst()
                 file_name = cursor.getString(nameIndex)
                 cursor.close()
             elif scheme == 'file':
                 file_name = basename(someUri.getPath())
             else:
                 #https://en.wikipedia.org/wiki/List_of_URI_schemes
                 return someUri.toString()
             # Save to
             new_file_path = PrivateStorage().getCacheDir()
             if not new_file_path:
                 new_file_path = PrivateStorage().getCacheDir('internal')
             new_file_path = join(new_file_path, "MediaStore")
             if not exists(new_file_path):
                 mkdir(new_file_path)
             new_file_path = join(new_file_path, file_name)
             # Copy
             rs = mActivity.getContentResolver().openInputStream(someUri)
             ws = FileOutputStream(new_file_path)
             FileUtils.copy(rs, ws)
             ws.flush()
             ws.close()
             rs.close()
     except Exception as e:
         print('ERROR SharedStorage.retrieveUri():\n' + str(e))
     return new_file_path
コード例 #7
0
 def _set_level(self, level):
     System.putInt(mActivity.getContentResolver(), System.SCREEN_BRIGHTNESS,
                   (level / 100.) * 255)
コード例 #8
0
 def view_photo(path):
     uri = Media.insertImage(mActivity.getContentResolver(), path, None,
                             None)
     droid.view(str(uri))
コード例 #9
0
ファイル: brightness.py プロジェクト: autosportlabs/plyer
 def _set_level(self, level):
     System.putInt(
         mActivity.getContentResolver(),
         System.SCREEN_BRIGHTNESS,
         (level / 100.) * 255)
コード例 #10
0
 def view_photo(path):
     uri = Media.insertImage(mActivity.getContentResolver(), path, None, None)
     droid.view(str(uri))