How to create Android Test Project programmatically? - android

I've tried something like this:
public boolean createTestProject(String projectName, IProject testedProject, int apiLevel){
NewProjectWizardState mValues = new NewProjectWizardState(Mode.TEST);
mValues.projectName = projectName;
if(testedProject != null){
mValues.testedProject = testedProject;
mValues.testingSelf = false;
mValues.useExisting = false;
}
else{
mValues.testingSelf = true;
mValues.useExisting = false;
}
mValues.minSdk = "1.5";
mValues.minSdkModifiedByUser = true;
mValues.useDefaultLocation = true;
mValues.projectLocationModifiedByUser = false;
mValues.createActivity = false;
mValues.activityName = "sf";
mValues.applicationName = "sf";
mValues.packageName = "sf";
NewProjectCreator creator = new NewProjectCreator(mValues, getContainer());
return creator.createAndroidProjects();
}
but it throws NullPointerException at com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectCreator.createEclipseProject(NewProjectCreator.java:561). I've checked that file (maybe older version) and this line is empty. Did i miss something?
EDIT:
ok, I resolved that. I missed few things. Now it's working, it can even create android project (not test):
public IProject createProject(String projectName, IProject testedProject,
boolean testMode, int apiLevel, IWizardContainer container,
Type type, String packName) throws Exception {
NewProjectWizardState mValues;
if (testMode) {
mValues = new NewProjectWizardState(Mode.TEST);
} else {
mValues = new NewProjectWizardState(Mode.ANY);
}
mValues.projectName = projectName;
mValues.projectNameModifiedByUser = true;
mValues.applicationName = capitalize(mValues.projectName);
mValues.testApplicationName = projectName;
mValues.createActivity = false;
mValues.testedProject = testedProject;
mValues.minSdk = apiLevel;
mValues.updateSdkTargetToMatchMinSdkVersion();
String value = Platform.getLocation().append(mValues.projectName)
.toString();
value = TextProcessor.process(value);
mValues.projectLocation = new File(value);
mValues.packageName = "com.example.android.apis.test";
if (testedProject != null) {
mValues.testProjectName = projectName;
mValues.packageName = String.format("%1$s.test",
Helper.getPackageName(testedProject));
mValues.createPairProject = false;
mValues.testTargetPackageName = Helper
.getPackageName(testedProject);
}
if (testedProject == null && testMode) {
mValues.createPairProject = false;
mValues.testProjectName = projectName;
mValues.testTargetPackageName = "com.example.android.apis";
}
if (packName != null && packName.length > 0) {
mValues.packageName = packName;
}
NewProjectCreator creator = new NewProjectCreator(mValues,
container);
creator.createAndroidProjects();
return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}

Related

how to get url browser by Acceesibility (Class Name)

I want to get browsers Url using AcceesibilityService. I use EditText className in chrome and TextView className in Firefox. It works in all devices but does't work in Redmi xiaomi devices. In Redmi xiaomi devices parentNodeInfo className does't return EditText or TextView. Someone can help?
Here is my code :
if (eventValue == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
CharSequence className = parentNodeInfo.getClassName();
if (className.equals("android.widget.EditText") || className.equals("android.widget.TextView")) {
synchronized (Utils.isWorkingUrl) {
CharSequence strUrl = parentNodeInfo.getText();
if (strUrl != null) {
boolean isActiveUrlLog = SharedPref.read_Bool(getApplicationContext(), SharedPref.PREFKEY, SharedPref.IS_ACTIVE_URL_LOG);
if (isActiveUrlLog) {
boolean isUrl = Patterns.WEB_URL.matcher(strUrl).matches();
if (isUrl) {
boolean isConnected = ConnectionInternet.checkConnection();
if (isConnected) {
if ( Utils.pskIsBrowser(packageNameCurrent,this,true)){
if (!strUrl.equals("www.")){
strUrl="https://www." + strUrl;
ImageView imageView = new ImageView(this);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
imageLoader.LoadImage(Utils.getUtilsString(getApplicationContext(), UtilsText.DOMAIN_LOAD_ICON_URl) + "?sz=64&domain_url=" + strUrl, imageView, R.drawable.globe, false, sqlpc);
lastTime = currentTime;
}
else if (!strUrl.equals("https://")){
strUrl="https://" +strUrl;
ImageView imageView = new ImageView(this);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
imageLoader.LoadImage(Utils.getUtilsString(getApplicationContext(), UtilsText.DOMAIN_LOAD_ICON_URl) + "?sz=64&domain_url=" + strUrl, imageView, R.drawable.globe, false, sqlpc);
lastTime = currentTime;
}else {
ImageView imageView = new ImageView(this);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
imageLoader.LoadImage(Utils.getUtilsString(getApplicationContext(), UtilsText.DOMAIN_LOAD_ICON_URl) + "?sz=64&domain_url=" + strUrl, imageView, R.drawable.globe, false, sqlpc);
lastTime = currentTime;
}
}
}
}
}
}
}
}
}
Instead , U can use browser view id , here is my code .
String packageName = event.getPackageName().toString();
SupportedBrowserConfig browserConfig = null;
for (SupportedBrowserConfig supportedConfig : getSupportedBrowsers()) {
if (supportedConfig.packageName.equals(packageName)) {
browserConfig = supportedConfig;
}
}
//this is not supported browser, so exit
if (browserConfig == null) {
return;
}
String requiredText = "";
if (parentNodeInfo.getText() != null) {
requiredText = parentNodeInfo.getText().toString();
}
String capturedUrl = captureUrl(parentNodeInfo, browserConfig);
parentNodeInfo.recycle();
#NonNull
private static String[] packageNames() {
List<String> packageNames = new ArrayList<>();
for (SupportedBrowserConfig config : getSupportedBrowsers()) {
packageNames.add(config.packageName);
}
return packageNames.toArray(new String[0]);
}
private static class SupportedBrowserConfig {
public String packageName, addressBarId;
public SupportedBrowserConfig(String packageName, String addressBarId) {
this.packageName = packageName;
this.addressBarId = addressBarId;
}
}
#NonNull
private static List<SupportedBrowserConfig> getSupportedBrowsers() {
List<SupportedBrowserConfig> browsers = new ArrayList<>();
browsers.add(new SupportedBrowserConfig("com.android.chrome", "com.android.chrome:id/url_bar"));
browsers.add(new SupportedBrowserConfig("org.mozilla.firefox", "org.mozilla.firefox:id/url_bar_title"));
return browsers;
}
enter code here

Recyclerview item height changing when I do scroll up and down continuously

In one of my applications I am trying to use recyclerview to display content. My content would be like chat history(it may be a single line text or multiple lines text).To implement this I have used recyclerview with Textview height as wrap_content to adjust the height based on the content. For the first time it is loading fine. But when I do scroll up and down I am getting some extra white space for some of the items. (I strongly suspect this extra space is for earlier item height).
Ex: I have a recyclerview list having 1,2,3,4,5.. lines text in each row. When I do scroll up down continuously I am getting row/item height is changing like 1 line text item got 5 lines text space and 5 lines text item got 1 line text.
Please find my adapter code below.
public class ConversationMessagesAdapterNew extends RecyclerView.Adapter {
private ConversationDetailActivityNew context;
private LayoutInflater layoutInflater;
private Utils utils;
private List<Message> messages = null;
private SessionManagement mSessionManage;
private int loginId = 0, attachmentsCount = 0, gifCount = 0;
private String mProfilePicId, mFname, mLname, fname = "", lname = "";
private ComposeDetails composeDetails;
private JSONArray attachmentArrayObj = new JSONArray();
public ConversationMessagesAdapterNew(ConversationDetailActivityNew context) {
this.context = context;
this.layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.utils = new Utils(context);
setHasStableIds(true);
this.mSessionManage = new SessionManagement(context, Utils.SHARED_PREF);
loginId = Integer.parseInt(mSessionManage.getString("userId"));
this.mProfilePicId = mSessionManage.getString("profilePicId");
this.mFname = mSessionManage.getString("firstName");
this.mLname = mSessionManage.getString("lastName");
}
public void setMessages(List<Message> messagesList) {
this.messages = messagesList;
/*if (messagesList == null) {
if (this.messages != null) {
this.messages.clear();
this.messages = null;
}
} else {
if (this.messages != null && this.messages.size() > 0)
this.messages.addAll(messagesList);
else
this.messages = messagesList;
}*/
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.conversation_messages_list_row_item_longpress, parent, false);
return new ViewHolder(itemView);
}
#Override
public void onBindViewHolder(#NonNull RecyclerView.ViewHolder holder, int position) {
final ViewHolder messagesListViewHolder = (ViewHolder) holder;
Message message = messages.get(position);
messagesListViewHolder.mMainLayout.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
(context).loadMoreButtonlayout(message);
return true;
}
});
try {
String picId = "";
composeDetails = (context).getProfilePicId(String.valueOf(message.getSenderId()));
if (composeDetails != null) {
fname = composeDetails.getFristName();
lname = composeDetails.getLastName();
}
if (message.getSenderId() == loginId) {
picId = mProfilePicId;
} else {
//picId = ((ConversationDetailActivity)context).getProfilePicId(String.valueOf(message.getSenderId()));
if (composeDetails != null) {
picId = composeDetails.getProfilePicture();
fname = composeDetails.getFristName();
lname = composeDetails.getLastName();
}
mFname = fname;
mLname = lname;
}
if (!picId.equals("null")) {
messagesListViewHolder.iv_user_profile.setVisibility(View.VISIBLE);
messagesListViewHolder.tv_lettersText.setVisibility(View.GONE);
messagesListViewHolder.mCardView.setCardBackgroundColor(Color.parseColor("#EFEFEF"));
String url = String.format("%s%s", Constants.mDisplayProfilePicUrl, picId);
Picasso.with(context).load(url).placeholder(R.drawable.user_default).into(messagesListViewHolder.iv_user_profile);
} else {
messagesListViewHolder.iv_user_profile.setVisibility(View.GONE);
messagesListViewHolder.tv_lettersText.setVisibility(View.VISIBLE);
messagesListViewHolder.mCardView.setCardBackgroundColor(Color.parseColor("#77B633"));
String name = getName(mFname, mLname);
messagesListViewHolder.tv_lettersText.setText(name);
}
if (message.getMessageType().equals("OFFNETEMAIL")) {
messagesListViewHolder.tv_sender_name.setTextColor(Color.parseColor("#2C303E"));
} else {
messagesListViewHolder.tv_sender_name.setTextColor(Color.parseColor("#276eb6"));
}
String sendName = message.getSenderName();
if (message.getMetric().getFlags().getCount() > 0 ||
message.getMetric().getLikes().getCount() > 0) {
if (sendName.length() > 15) {
sendName = sendName.substring(0, 15) + "..";
}
} else {
if (sendName.length() > 18) {
sendName = sendName.substring(0, 18) + "..";
}
}
messagesListViewHolder.tv_sender_name.setText(sendName);
messagesListViewHolder.tv_created_time.setText(utils.getTimeStampByString(message.getCreatedOn()));
String content = message.getContent();
// Attachment parsing
String prtnAttachment = "\\<attachment:(.*?)\\>";
Pattern ptr = Pattern.compile(prtnAttachment);
Matcher m = ptr.matcher(content);
while (m.find()) {
String[] fileStr = m.group(0).toString().split(":");
if (fileStr.length > 0) {
JSONObject file = new JSONObject();
file.put("fileId", fileStr[1].toString());
file.put("fileName", fileStr[2].toString());
file.put("fileType", fileStr[3].toString());
file.put("randomFileName", fileStr[4].toString());
file.put("fileSize", fileStr[5].toString());
attachmentArrayObj.put(file);
attachmentsCount++;
} else {
//attachmentsFlag = false;
// imageFlag = false;
attachmentsCount = 0;
}
}
// Emoji / Mentions parsing
String ptrsEmoji = "\\<:(.*?)\\>";
Pattern ptrEmoji = Pattern.compile(ptrsEmoji);
Matcher em = ptrEmoji.matcher(content);
while (em.find()) {
String[] emojiStr = em.group(0).split(":");
if (emojiStr.length > 0) {
if (emojiStr[1].contains("mention-everyone")) {
String parsedStr = "<font color='#1F6EB7'>" + "#everyone" + "</font>";
content = content.replaceAll(em.group(0), parsedStr);
} else if (emojiStr[1].contains("mention-")) {
String[] ms = emojiStr[1].split("-");
String parsedStr = "<font color='#1F6EB7'>" + "#" + ms[1] + "</font>";
content = content.replaceAll(em.group(0), parsedStr);
} else {
String parsedStr = "&#x" + emojiStr[1];
content = content.replaceAll(em.group(0), parsedStr);
}
}
}
if (content.length() > 0) {
messagesListViewHolder.tv_message.setVisibility(View.VISIBLE);
messagesListViewHolder.tv_message.setText(Html.fromHtml(content));
} else {
messagesListViewHolder.tv_message.setVisibility(View.GONE);
}
if (attachmentsCount > 0) {
messagesListViewHolder.tv_message.setVisibility(View.GONE);
messagesListViewHolder.mAttachLayout.setVisibility(View.VISIBLE);
messagesListViewHolder.tv_attachments.setText(String.valueOf(attachmentsCount + gifCount) + " Attachments.");
attachmentsCount = 0;
} else {
attachmentsCount = 0;
messagesListViewHolder.tv_message.setVisibility(View.VISIBLE);
messagesListViewHolder.mAttachLayout.setVisibility(View.GONE);
}
// Likes and Flag sectin
if (message.getMetric().getLikes().getCount() > 0) {
messagesListViewHolder.iv_likes_icon.setVisibility(View.VISIBLE);
messagesListViewHolder.tv_likes_count.setVisibility(View.VISIBLE);
messagesListViewHolder.tv_likes_count.setText(String.valueOf(message.getMetric().getLikes().getCount()));
} else {
messagesListViewHolder.iv_likes_icon.setVisibility(View.GONE);
messagesListViewHolder.tv_likes_count.setVisibility(View.GONE);
}
if (message.getMetric().getFlags().getCount() > 0) {
messagesListViewHolder.iv_flag_icon.setVisibility(View.VISIBLE);
} else {
messagesListViewHolder.iv_flag_icon.setVisibility(View.GONE);
}
messagesListViewHolder.mAttachLayout.setOnClickListener(v -> {
Intent attachmentIntent = new Intent(context, AttachmentsView.class);
attachmentIntent.putExtra("contentAttachment", message.getContent());
context.startActivity(attachmentIntent);
});
messagesListViewHolder.mAttachLayout.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
(context).loadMoreButtonlayout(message);
return true;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public int getItemCount() {
if (messages != null && messages.size() > 0)
return messages.size();
else
return 0;
}
#Override
public long getItemId(int position) {
Message message = messages.get(position);
return message.getId();
}
#Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
public class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout mMainLayout;
ImageView iv_user_profile, iv_likes_icon, iv_flag_icon;
TextView tv_sender_name, tv_created_time, tv_message, tv_lettersText, tv_attachments, tv_likes_count;
CardView mCardView;
FrameLayout mMoreLayout;
RelativeLayout mAttachLayout;
View mDummyLongPressLayout;
public ViewHolder(#NonNull View itemView) {
super(itemView);
mMainLayout = itemView.findViewById(R.id.longpress_layout_detailpage);
mDummyLongPressLayout = itemView.findViewById(R.id.DummyLongPressLayout);
mMoreLayout = itemView.findViewById(R.id.delete_layout);
iv_user_profile = itemView.findViewById(R.id.iv_user_profile);
tv_sender_name = itemView.findViewById(R.id.tv_sender_name);
tv_sender_name.setTypeface(utils.mRobotoBold);
tv_created_time = itemView.findViewById(R.id.tv_created_time);
tv_created_time.setTypeface(utils.mRobotoRegular);
tv_message = itemView.findViewById(R.id.tv_message);
tv_message.setTypeface(utils.mRobotoRegular);
tv_lettersText = itemView.findViewById(R.id.tv_lettersText);
tv_lettersText.setTypeface(utils.mRobotoRegular);
mCardView = itemView.findViewById(R.id.card_view);
mAttachLayout = itemView.findViewById(R.id.AttachmentsLayout);
mAttachLayout.setVisibility(View.GONE);
tv_attachments = itemView.findViewById(R.id.tv_attachments);
tv_likes_count = itemView.findViewById(R.id.tv_likes_count);
iv_likes_icon = itemView.findViewById(R.id.iv_like_icon);
iv_flag_icon = itemView.findViewById(R.id.iv_flag_icon);
}
}
private String getName(String fname, String lname) {
if (fname.length() > 0) {
if (!fname.equals("null")) {
fname = fname.substring(0, 1).toUpperCase();
} else {
fname = "";
}
} else {
fname = "";
}
if (lname.length() > 0) {
if (!lname.equals("null")) {
lname = lname.substring(0, 1).toUpperCase();
} else {
lname = "";
}
} else {
lname = "";
}
return fname + lname;
}
}

Black Screen with MSAA on Android with Vulkan

I have a problem with MSAA setup on Android. On any desktop machine tested (Intel, NVIDIA) I get a correct resolve framebuffer and renderpass (I currently have an empty renderpass where I only clear the back color) and the screen renders simply grey (desired) but on android the screen is black.
I do not get any validation errors. The code just "works" but it does not seem right to me.
Here is my Renderpass code:
VkSampleCountFlagBits sampleCount = GetMaxUsableSampleCount();
VkAttachmentDescription colorResolveAttachment = {};
colorResolveAttachment.format = mSwapchainImageFormat;
colorResolveAttachment.samples = sampleCount;
colorResolveAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
colorResolveAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorResolveAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorResolveAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorResolveAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorResolveAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentDescription colorAttachment = {};
colorAttachment.format = mSwapchainImageFormat;
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
colorAttachment.loadOp = (mSamples != 0) ? VK_ATTACHMENT_LOAD_OP_DONT_CARE : VK_ATTACHMENT_LOAD_OP_CLEAR;
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentDescription depthResolveAttachment = {};
depthResolveAttachment.format = mDepthImageFormat;
depthResolveAttachment.samples = sampleCount;
depthResolveAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
depthResolveAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthResolveAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthResolveAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthResolveAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
depthResolveAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentDescription depthAttachment = {};
depthAttachment.format = mDepthImageFormat;
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
depthAttachment.loadOp = (mSamples != 0) ? VK_ATTACHMENT_LOAD_OP_DONT_CARE : VK_ATTACHMENT_LOAD_OP_CLEAR;
depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentReference colorAttachmentRef = {};
colorAttachmentRef.attachment = 0;
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = (mSamples != 0) ? 2 : 1;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentReference colorAttachmentResolveRef = {};
colorAttachmentResolveRef.attachment = 1;
colorAttachmentResolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;
subpass.pDepthStencilAttachment = &depthAttachmentRef;
if(mSamples != 0)
{
subpass.pResolveAttachments = &colorAttachmentResolveRef;
}
std::vector<VkSubpassDependency> dependencies;
if(mSamples != 0)
{
std::array<VkSubpassDependency, 2> dependency;
dependency[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependency[0].dstSubpass = 0;
dependency[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependency[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependency[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependency[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
dependency[1].srcSubpass = 0;
dependency[1].dstSubpass = VK_SUBPASS_EXTERNAL;
dependency[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependency[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependency[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependency[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
dependencies.push_back(dependency[0]);
dependencies.push_back(dependency[1]);
}
else
{
VkSubpassDependency dependency = {};
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.srcAccessMask = 0;
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependencies.push_back(dependency);
}
std::vector<VkAttachmentDescription> attachments;
if(mSamples != 0)
{
attachments.push_back(colorResolveAttachment);
attachments.push_back(colorAttachment);
attachments.push_back(depthResolveAttachment);
attachments.push_back(depthAttachment);
}
else
{
attachments.push_back(colorAttachment);
attachments.push_back(depthAttachment);
}
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
renderPassInfo.pAttachments = attachments.data();
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = &subpass;
renderPassInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
renderPassInfo.pDependencies = dependencies.data();
if(vkCreateRenderPass(mDevice, &renderPassInfo, nullptr, &mRenderPass) != VK_SUCCESS)
{
Console::FatalError("Failed to create render pass!");
return false;
}
return true;
Here is my Freambuffer code:
if(!CreateMultiSampleTargets())
return false;
mSwapchainFramebuffers.resize(mSwapchainImageViews.size());
for(size_t i = 0u; i < mSwapchainImageViews.size(); i++)
{
std::vector<VkImageView> attachments;
if(mSamples != 0)
{
attachments.push_back(mMultiSampleColorImageView);
attachments.push_back(mSwapchainImageViews[i]);
attachments.push_back(mMultiSampleDepthImageView);
attachments.push_back(mDepthImageView);
}
else
{
attachments.push_back(mSwapchainImageViews[i]);
attachments.push_back(mDepthImageView);
}
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = mRenderPass;
framebufferInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
framebufferInfo.pAttachments = attachments.data();
framebufferInfo.width = mSwapchainExtent.width;
framebufferInfo.height = mSwapchainExtent.height;
framebufferInfo.layers = 1;
if(vkCreateFramebuffer(mDevice, &framebufferInfo, nullptr, &mSwapchainFramebuffers[i]) != VK_SUCCESS)
{
Console::FatalError("Failed to create framebuffer!");
return false;
}
}
I should mention that my code is heavily based on this: https://github.com/SaschaWillems/Vulkan/blob/master/multisampling/multisampling.cpp
The solution was to upgrade my Oneplus 3 to android 8 to get a newer driver version where this issue does not occur. I guess this was a driver bug.

Haxe, OpenFL android debug giving error in for cpp

I'm developing an app in FlashDevelop, using Haxe and OpenFl
When I test my app in flash target, it works fine. But when I compile for android, it comes up with this error during the compilation:
./src/ReaderView2.cpp: In member function 'virtual Void ReaderView2_obj::setZoom()':
./src/ReaderView2.cpp:653: error: base operand of '->' has non-pointer type 'String'
Build halted with errors (haxelib.exe).
...Which is obviously something to do with cpp, which I'm not really an expert.
Does any body know what the error means?
Here's the setZooom function: (the whole file is quite large)
public function setZoom()
{
hideOptions();
while (numChildren > 0)
{
Main.remove(getChildAt(0));
}
if (image != null) if (image.parent != null) image.parent.removeChild(image);
images = new Array();
field = new TextField();
var fieldFont = Assets.getFont("fonts/Kreon-Regular.ttf");
var format:TextFormat = new TextFormat(fieldFont.fontName, currentZoom, 0x4F4F4F);
format.align = TextFormatAlign.LEFT;
field.defaultTextFormat = format;
field.embedFonts = true;
field.text = fullText;
field.selectable = false;
field.wordWrap = true;
field.border = false;
field.autoSize = TextFieldAutoSize.LEFT;
field.width = displayWidth;
//field.x = 0;
//split string into words
var allParas:Array<String> = fullText.split("\r\n");
var words:Array<String>;
var fields:Array<TextField> = new Array();
var tempField:TextField = null;
var contentHeight:Float = displayHeight;
var wordI:Int;
var paraI:Int = 0;
var tempArr2:Array<String>;
while (paraI < allParas.length)
{
if (false) //check img tag
{
}
else //if para is words
{
wordI = 0;
words = allParas[paraI].split(" ");
while (wordI < words.length)
{
if (tempField == null || tempField.textHeight > contentHeight)
{
if (tempField != null) {
wordI--;
tempArr2 = tempField.text.toString().split(" ");
for (i in 0... tempArr2.length)
{
tempArr2.remove("");
}
tempArr2.pop();
tempField.text = tempArr2.join(" ");
}
tempField = new TextField();
tempField.defaultTextFormat = field.getTextFormat();
tempField.embedFonts = true;
tempField.text = "";
tempField.border = false;
tempField.selectable = false;
tempField.wordWrap = true;
tempField.autoSize = TextFieldAutoSize.LEFT;
tempField.width = displayWidth-2;
tempField.x = 0;
fields.push(tempField);
}
else
{
tempField.appendText(words[wordI] + (wordI == words.length - 1? "\n": " "));
wordI++;
}
}
}
paraI++;
}
var bd:BitmapData;
for (i in 0... fields.length)
{
bd = new BitmapData(Std.int(fields[i].width), Std.int(fields[i].height));
bd.draw(fields[i]);
images.push(new Bitmap(bd, PixelSnapping.AUTO, true));
}
//addChild(fields[0]);
images[0].x = 10;
addChild(images[0]);
currentPageInstance = images[0];
currentPage = 0;
drawScrollBar();
if (optionsBtn!=null)addChild(optionsBtn);
}
So apparently using the toString() funcion gives problems for a cpp target.

email extractor android program crashes aide

public class MainActivity extends Activity {
public static LinearLayout layout = null;
public static EditText urlstring = null;
public static Button submit = null;
public static ListView emailsfound = null;
public static ArrayList<String> emaillist = new ArrayList<String>();
public static ArrayList<String> urllist = new ArrayList<String>();
public static ArrayAdapter<String> adapter = null;
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout = new LinearLayout(this);
urlstring = new EditText(this);
submit = new Button(this);
submit.setText("Submit");
emailsfound = new ListView(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(urlstring);
layout.addView(submit);
layout.addView(emailsfound);
setContentView(layout);
adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, emaillist);
emailsfound.setAdapter(adapter);
submit.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
urllist.add(urlstring.getText().toString());
int i = 0;
while (true) {
String page = getPage(urlstring.getText().toString());
ArrayList<String> urls = new ArrayList<String>();
urls = getURLs(page);
ArrayList<String> addresses = new ArrayList<String>();
addresses = getAddresses(page);
for (int a = 0; i < urls.size(); i++) {
urllist.add(urls.get(a));
}
for (int a = 0; a < addresses.size(); i++) {
emaillist.add(addresses.get(a));
}
removeDuplicates(urllist);
removeDuplicates(emaillist);
adapter.notifyDataSetChanged();
i++;
urlstring.setText(urllist.get(i).toString());
}
}
;
});
}
public String getPage(String url) {
if (url.toLowerCase().startsWith("http") == false) {
url = "http://" + url;
}
URL fromstring = null;
URLConnection openConnection = null;
try {
fromstring = new URL(url);
openConnection = fromstring.openConnection();
BufferedReader in = null;
url = "";
in = new BufferedReader(new InputStreamReader(openConnection.getInputStream()));
String input = "";
if (in != null) {
while ((input = in.readLine()) != null) {
url = url + input + "\r\n";
}
in.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return url;
}
public ArrayList<String> getURLs(String page) {
ArrayList<String> s = new ArrayList<String>();
while (page.toLowerCase().contains("<a href=\"http")) {
int i = page.toLowerCase().indexOf("href=\"http") + "href=\"".length();
if (i > -1) {
String s1 = page.substring(i, page.toLowerCase().indexOf("\"", i));
s.add(s1);
page = page.substring(i + "http".length());
}
}
return s;
}
public boolean validate(String email) {
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*" + "#[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
public ArrayList<String> getAddresses(String page) {
ArrayList<String> s = new ArrayList<String>();
while (page.contains("#")) {
int i = page.indexOf("#");
if (i > -1) {
int beginning = page.lastIndexOf(" ", i);
if (beginning > -1) {
int ending = page.indexOf(" ", i);
if (ending > -1) {
String address = page.substring(beginning + 1, ending - 1);
address = address.toLowerCase();
if (address.startsWith("href=\"mailto:")) {
int b = address.indexOf(":") + 1;
address = address.substring(b);
int e = address.indexOf("\"");
if (e > -1) {
if (e > address.indexOf("#")) {
address = address.substring(0, address.indexOf("\""));
}
if (address.contains("?")) {
address = address.substring(0, address.indexOf("?"));
}
if (!address.contains("<") && !address.contains(">")) {
if (validate(address)) {
s.add(address);
}
}
} else {
int b2 = address.indexOf(">") + 1;
if (b2 > -1) {
if (b2 < address.indexOf("#")) {
address = address.substring(b2);
}
}
int e2 = address.indexOf("<");
if (e2 > -1) {
if (e2 > address.indexOf("#")) {
address = address.substring(0, e2);
}
}
if (!address.contains("<") && !address.contains(">")) {
if (validate(address)) {
s.add(address);
}
}
}
}
}
}
}
page = page.substring(i + 1);
}
return s;
}
public ArrayList<String> removeDuplicates(ArrayList<String> List) {
ArrayList<String> output = new ArrayList<String>();
for (int i = 0; i < List.size(); i++) {
boolean b = false;
for (int a = 0; a < List.size(); i++) {
if (List.get(i).toString().toLowerCase().equals(List.get(a).toString().toLowerCase())) {
b = true;
}
}
if (b == false) {
output.add(List.get(i));
}
}
return output;
}
}
This Program Was Made in AIDE on an android netbook.
It Crashes On Button Click. I was wondering what I Was doing wrong.
I tried before with runnables but it crashed then too. I'm new to
android development but I am fluent in Java. I noticed there are
alot of differences between android and Java.

Categories

Resources