Merge pull request #30 from cis-navjot-g/newwork

fix identicon issue for android devices
This commit is contained in:
cis-navjot-g 2019-09-18 14:42:29 +05:30 committed by GitHub
commit 3f90ec2d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 50 deletions

View File

@ -650,7 +650,7 @@ NavigationLayout:
do_scroll_x: False
BoxLayout:
orientation: 'vertical'
padding: [dp(app.window_size[0]/4*1.1), dp(10)]
padding: [dp(app.window_size[0]/16 if app.window_size[0] <= 720 else app.window_size[0]/4*1.1), dp(10)]
spacing: 12
size_hint_y: None
height: self.minimum_height + dp(app.window_size[1]) if app.window_size[1] > app.window_size[0] else dp(app.window_size[0])

View File

@ -57,9 +57,10 @@ import state
from uikivysignaler import UIkivySignaler
# pylint: disable=unused-argument, too-few-public-methods, import-error
if platform == 'linux':
import identiconGeneration
import identiconGeneration
import os
from kivy.core.clipboard import Clipboard
# pylint: disable=unused-argument, too-few-public-methods
def toast(text):
@ -1028,8 +1029,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
def getCurrentAccountData(self, text):
"""Get Current Address Account Data."""
if platform == 'linux':
self.set_identicon(text)
self.set_identicon(text)
address_label = self.current_address_label(
BMConfigParser().get(text, 'label'), text)
self.root_window.children[1].ids.toolbar.title = address_label
@ -1089,10 +1089,9 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
def getDefaultAccData(self):
"""Getting Default Account Data."""
if BMConfigParser().addresses():
if platform == 'linux':
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
self.createFolder('./images/default_identicon/')
img.texture.save('./images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]))
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
self.createFolder('./images/default_identicon/')
img.texture.save('./images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]))
return BMConfigParser().addresses()[0]
return 'Select Address'
@ -1109,8 +1108,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
def get_default_image():
"""Getting default image on address"""
if BMConfigParser().addresses():
if platform == 'linux':
return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0])
return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0])
return ''
@staticmethod

View File

@ -78,7 +78,7 @@ void getnumthreads()
#ifdef _WIN32
DWORD_PTR dwProcessAffinity, dwSystemAffinity;
#elif __linux__
// cpu_set_t dwProcessAffinity;
cpu_set_t dwProcessAffinity;
#elif __OpenBSD__
int mib[2], core_count = 0;
int dwProcessAffinity = 0;
@ -87,13 +87,13 @@ void getnumthreads()
int dwProcessAffinity = 0;
int32_t core_count = 0;
#endif
// size_t len = sizeof(dwProcessAffinity);
// if (numthreads > 0)
// return;
size_t len = sizeof(dwProcessAffinity);
if (numthreads > 0)
return;
#ifdef _WIN32
GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinity, &dwSystemAffinity);
#elif __linux__
// sched_getaffinity(0, len, &dwProcessAffinity);
sched_getaffinity(0, len, &dwProcessAffinity);
#elif __OpenBSD__
len2 = sizeof(core_count);
mib[0] = CTL_HW;
@ -106,22 +106,22 @@ void getnumthreads()
else if (sysctlbyname("hw.ncpu", &core_count, &len, 0, 0) == 0)
numthreads = core_count;
#endif
// for (unsigned int i = 0; i < len * 8; i++)
// #if defined(_WIN32)
// #if defined(_MSC_VER)
// if (dwProcessAffinity & (1i64 << i))
// #else // CYGWIN/MINGW
// if (dwProcessAffinity & (1ULL << i))
// #endif
// #elif defined __linux__
// if (CPU_ISSET(i, &dwProcessAffinity))
// #else
// if (dwProcessAffinity & (1 << i))
// #endif
// numthreads++;
// if (numthreads == 0) // something failed
// numthreads = 1;
// printf("Number of threads: %i\n", (int)numthreads);
for (unsigned int i = 0; i < len * 8; i++)
#if defined(_WIN32)
#if defined(_MSC_VER)
if (dwProcessAffinity & (1i64 << i))
#else // CYGWIN/MINGW
if (dwProcessAffinity & (1ULL << i))
#endif
#elif defined __linux__
if (CPU_ISSET(i, &dwProcessAffinity))
#else
if (dwProcessAffinity & (1 << i))
#endif
numthreads++;
if (numthreads == 0) // something failed
numthreads = 1;
printf("Number of threads: %i\n", (int)numthreads);
}
extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, unsigned long long target)
@ -146,7 +146,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
# else
pthread_create(&threads[i], NULL, threadfunc, (void*)&threaddata[i]);
# ifdef __linux__
pthread_setschedparam(threads[i], 0, &schparam);
pthread_setschedparam(threads[i], SCHED_IDLE, &schparam);
# else
pthread_setschedparam(threads[i], SCHED_RR, &schparam);
# endif
@ -162,4 +162,4 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
free(threads);
free(threaddata);
return successval;
}
}

View File

@ -44,7 +44,9 @@ requirements =
bitmsghash,
kivymd,
kivy-garden,
qrcode
qrcode,
Pillow,
msgpack
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes

View File

@ -1213,6 +1213,7 @@ class singleWorker(StoppableThread):
powStartTime = time.time()
initialHash = hashlib.sha512(encryptedPayload).digest()
trialValue, nonce = proofofwork.run(target, initialHash)
print("nonce calculated value#############################", nonce)
logger.info(
'(For msg message) Found proof of work %s Nonce: %s',
trialValue, nonce

View File

@ -1,7 +1,10 @@
from importlib import import_module
from os import path, listdir
from string import lower
try:
from kivy.utils import platform
except:
platform = ''
from debug import logger
import messagetypes
import paths
@ -32,7 +35,7 @@ def constructObject(data):
else:
return returnObj
if paths.frozen is not None:
if paths.frozen is not None or platform == "android":
import messagetypes.message
import messagetypes.vote
else:

View File

@ -13,28 +13,24 @@ class translateClass:
else:
return self.text
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
# return translateText(context, text, n)
def _translate(context, text, disambiguation = None, encoding = None, n = None):
return text
return translateText(context, text, n)
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
# return translateClass(context, text.replace('%','',1))
def translateText(context, text, n = None):
try:
enableGUI = state.enableGUI
except AttributeError: # inside the plugin
enableGUI = True
if enableGUI:
if not state.kivy and enableGUI:
try:
from PyQt4 import QtCore, QtGui
except Exception as err:
try:
if state.kivy:
pass
except Exception as err:
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err
os._exit(0)
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err
os._exit(0)
if n is None:
return QtGui.QApplication.translate(context, text)
else: