yashsingh1/xdaforums huggingface dataset:
[Java for Android App Development] DHD22800:
Htc File Picker

Hi :D

Here I would show you how to use Htc File Picker to pick a file.

First, add a permission to your manifest (here's complete line):

<uses-permission android:name="com.htc.FilePicker.permission.INTENT_TOKEN"/>

Next, in your activity declare two variables:

private static final int READ_REQUEST_CODE = 42;
String file;

Here is the method for opening file picker:

public void performFileSearch(int selectionType, boolean dropBoxShareLinkEnable, boolean cloudFunctionEnabled,
boolean showPath, String...filter) {
final Intent intent = new Intent();
intent.setClassName("com.htc.FilePicker", "com.htc.FilePicker.FilePicker");
final Bundle bundle = new Bundle();
bundle.putString("application_name", "HTCFileManager");
bundle.putInt("viewType", 0);
bundle.putInt("selectionType", selectionType);
bundle.putBoolean("returnDropBoxShareLinkEnable", dropBoxShareLinkEnable);
bundle.putBoolean("CloudFunctionEnabled", cloudFunctionEnabled);
bundle.putBoolean("showPath", showPath);
bundle.putStringArray("filter", filter);
bundle.putInt("UsbConnectionMode", -1);
intent.putExtras(bundle);
intent.putExtra("sort_type", 0);
intent.putExtra("sort_order", 0);
this.startActivityForResult(intent, READ_REQUEST_CODE);
}

And here is the Activity Result method:

for single choice:

@Override
public void onActivityResult(int requestCode, int resultCode,
Intent resultData) {
if (resultCode == -1) {
if (requestCode == READ_REQUEST_CODE) {
if (resultData != null) {
while (true) {
try {
if (resultData.getStringArrayExtra("output")[0]!=null || resultData.getStringArrayExtra("output")[0]!="") {
file = resultData.getStringArrayExtra("output")[0];
//do whatever with your file
}
}
} catch (Exception ex2) {
ex2.printStackTrace();
break;
}
break;
}
}
}
}
super.onActivityResult(requestCode, resultCode, resultData);
}

Here's the sample apk and here the project (for eclipse).

I know that you probably think that this isn't the best way to do this, but for me this methods works fine :D
[Java for Android App Development] Nx Biotic:
Everyone here still using kitkat OpenSense sdk as a base for development on L or is it recommended to push the OpenSense libs in the libs folder and compile on Android 5 for Sense6+

---------- Post added at 10:42 PM ---------- Previous post was at 10:40 PM ----------

Im still trying to figure out how to recreate a masthead from Blinkfeed... If anyone has figured it out, lemme know =3
[Java for Android App Development] DHD22800:
Opensense libs in libs folder crash...I develop with OpenSense SDK.

What do you mean for "masthead from Blinkfeed" ?
[Java for Android App Development] Nx Biotic:
If you Decompile prism and take a look at some of the layouts, youll see something referencing to com.htc.lib1.view.masthead as a view, I believe thats the import anyway...

This is the Clockmasthead

View attachment 3184840

Im guess all of these panels are referred to as mastheads in Blinkfeed. Id like to incorporate these views in my launcher's custom panel view im developing for Sense6.

I have tried dexing the jar from Blinkfeed and incorporating it in my sdk for Sense and than decompiling to smali than back to java to understand the mastead code but im lost. Id like to know if its possible to recreate them or if im wasting my time trying to figure this out
[Java for Android App Development] Nx Biotic:
Quick Tip: Translucent is triggered in Lollipop Sense Actionbar by removing the theme to your activity, as it states above for development in kitkat to set a HoloLight theme. Only works if u set a prior no actionbar layout with translucent theme

You could either use the Sense actionbar or get fancy and use the Android 5 Toolbar
[Java for Android App Development] Nx Biotic:
Ive started working on OpenSense 7 sdk if anyones interested. Any help would be appreciated.
[Java for Android App Development] Jonny:
I haven't - no one's bothered to PM me the leaked system dump and I'm not working on pre-ported material as it contains files from an old sdk version and not 100% original files.

If anyone has the M9 system dump I'd appreciate a PM with a link so I can start work - I have a couple of ideas planned ;)
[Java for Android App Development] Nx Biotic:
Il PM u if i get the source of the clean dump, im using source from our full port our team is working on.

Thought i had a good start earlier today but android studio and Eclipse both were yelling at me for imports so i probably missed a few... Trying to just make one jar file and not a few independents
[Java for Android App Development] Jonny:
I've been out of the developing scene for a while so I guess I can't blame anyone for not keeping me up-to-date lol - been focusing on projects that the organisations behind actually pay me for - eg this + some other stuff I can't disclose due to those pesky NDA's.
[Java for Android App Development] Nx Biotic:
Im heading into game development soon so i know watcha mean but id like folks to be all on the same page with everything instead of it being hush hush and get it yourself
[Java for Android App Development] Nx Biotic:
Screenshot or demo?
[Java for Android App Development] DHD22800:
Something like this:

I will update code for icons
[Java for Android App Development] Nx Biotic:
Right on
[Java for Android App Development] Nx Biotic:
Brilliant. Definitely using this in Sapphire UI
[Java for Android App Development] Nx Biotic:
Anyone getting htc preferences force closes in sense7
[Java for Android App Development] DHD22800:
No, I'm using sdk from 3th or 4th post, m7 with Sense 7 mod on ViperOne

It's a preference fragment.

HtcPreferenceActiviry works too.

All works for me

-----------------

I've a tip for all: when creating adapter not use textviews, use HtcListItem2LineText for 2 lines or HtcListItemSingleText. Why ? Because if you have a dark theme, the texview will remain in black, List Items from HTC will color using system colors. Themer change black to white
[Java for Android App Development] Nx Biotic:
Thankyou for verification
[Java for Android App Development] Nx Biotic:
Definitely convinced htc preferences arnt working on M9 sense 7 framework. Class not found. Updated OpenSense SDK to my best ability and still FCs. Probably changed method on this. Still investigating
[Java for Android App Development] mikrosmile:
Well, as far i can see, htc move this part of the code inside the settings app. They removed it from .jar files of framework files.

For example, look at settings app. HtcPreference is reffering from inside the settings.apk (settings->com->htc->libs->preference).

I guess, 3rd party development with htc's libs is over.

Learn Material :)
[Java for Android App Development] Nx Biotic:
Oh im definitely game for material and i see what u mean just a little while ago but i had so many devs telling me that our port was wrong but your qoute definitely confirms it. Definitely dont argue with the master htc community dev. It just bothers me because i just integrated htc preferences in my Sapphire launcher so il have to take em out -. - for Sense7 users or just start over with full material.

But as always great guide. We will continue to update it for Sense 6 and small things for Sense 7.
[Java for Android App Development] Jonny:
Probably better that way tbh... I'm not overly impressed with the HTC implementation of Material Design in Sense 7 - they've done an extremely half-assed job of it with some apps using the new CheckBox styles and others sticking to the old Holo style ones, stuff like that.
[Java for Android App Development] Nx Biotic:
Agreed
[Java for Android App Development] Mikanoshi:
Decompile com.htc.libs, pack it to jar and use as a lib in your apps :) It will be a lot of work though. Shouldn't they provide that lib?)

3rd party development on HTC was over long long ago, they can't even provide an SDK, all OpenSense stuff is so outdated it's useless.

You'll have to dex2jar everything yourself, very dev-friendly... And now all their apps are in Play Store with all the classes inside, on Sense 6 it was completely redundant. At least now they cleaned HTC frameworks on M9.
[Java for Android App Development] mikrosmile:
Yeah I know, like htcpreference class - I didn't found that in any lib , but found in settings apk :)

Other classes are present , yes, but most moved out

Отправлено с моего iPad используя Tapatalk
[Java for Android App Development] Mikanoshi:
There is HTCCommonctrl.jar\classes\com\htc\widget\preference\HtcPreference.java which is 3Kb of code compared to 41Kb in Settings apk))

How am I supposed to create HTC UI now? My Sense Toolbox is integrated in Settings and it will look stupid with Material design...

Maybe someone can ask HTC to help developers? I have my HTC Elevate account suspended due to inactivity :D
[Java for Android App Development] mikrosmile:
htc isn't interested in creating by someone else HTC UI :)

Maybe it is possible to use some old framework files.. don't know.

And i guess it's possible to recreate classes in your apps from settings for example (as of now it doesnt require any special htc's libs), but yes, it will require tons of work, and maybe will not work at all..

p.s. you can make any app looks like HTC's, without using any reference class from htc's libs. All image sources (like their checkboxes and etc), animation xmls, layout stuff are present in htc-resources.apk.
[Java for Android App Development] Mikanoshi:
Which will require even more work :) New Sense 7 apps have tons of internal classes and are proguarded, what a nice surprise for modders.

Sense 7 sucks anyway, and it won't be released on M8 until the end of summer, on M7 it may never be released...
[Java for Android App Development] Nx Biotic:
How hard would it be to create our own sense7 lib with a custom htc preferences? Like for say mikroPreferences ;)

Yeah i did alot of digging and Ultimately found aosp is the way.
[Java for Android App Development] Mikanoshi:
Not very hard, just troublesome) Decompile Settings app and get com.htc.libs.*, review all the code, fix errors and dependencies.

Why insiders leak useless developer ROMs, but not the useful HTC java libs?)
[Java for Android App Development] Nx Biotic:
Very good question
[Java for Android App Development] Mikanoshi:
How about including the whole HTCCommonctrl.jar and HTCExtension.jar from Sense 6 inside apk? :) I'll test it.

Just need to delete unused classes or apk will be 5MB, it can be tricky to keep all required ones.
[Java for Android App Development] Nx Biotic:
Oh it works. Ive just ypgraded the android sdk to 5 and still use carasoul
[Java for Android App Development] Mikanoshi:
APK gains ~500Kb after ProGuard removes unused classes. It's better than +2.1Mb with full frameworks :)
[Java for Android App Development] Nx Biotic:
Right
[Java for Android App Development] mikrosmile:
as i said its not simple without proper libs..

by the way we with Jonny found the way to do so.. great fantastic.. will write the guide about it later :silly:

that is my app..

View attachment 1883581

amazing...

View attachment 1883592 View attachment 1883593 View attachment 1883594
[Java for Android App Development] MaartenXDA:
O.o Wow, that's great! Nice work to both of you!
[Java for Android App Development] Jonny:
Edit: Didn't see mikrosmile's post ;)

Ok, me and mikrosmile managed to get it working. Assuming you have OpenSense SDK at API level 16, Download the attached file (HTCExtension.jar) and put it into the htc addons folder in android sdk - for me its C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_apis-htc-16\libs

Then edit the manifest file found in C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_apis-htc-16\ to this:

# SDK Add-on Manifest

name=HTC OpenSense APIs
name-id=HTC OpenSense SDK
vendor=HTC
vendor-id=htc
description=HTC OpenSense APIs - Android SDK Add-on

# version of the Android platform on which this add-on is built.
api=16

# revision of the add-on
revision=1

# list of libraries, separated by a semi-colon.
libraries=htc-apis;HTCExtension

# details for each library
htc-apis=HTCSDK.jar; HTC OpenSense APIs Library
HTCExtension=HTCExtension.jar; HTC OpenSense API's Extension

Reload eclipse or whatever IDE you're using and it should appear in the HTC OpenSense API's dropdown :)

For OpenSense SDK API level 15 put HTCExtension.jar attachment into C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_sdk-htc-15\libs folder and change the manifest file found in C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_sdk-htc-15 to:

# SDK Add-on Manifest

name=HTC OpenSense SDK
name-id=HTC OpenSense SDK
vendor=HTC
vendor-id=htc
description=HTC OpenSense APIs - Android SDK Add-on

# version of the Android platform on which this add-on is built.
api=15

# revision of the add-on
revision=3

# list of libraries, separated by a semi-colon.
libraries=htc-apis;HTCExtension

# details for each library
htc-apis=HTCSDK.jar; HTC OpenSense APIs Library
HTCExtension=HTCExtension.jar; HTC OpenSense API's Extension

Then as above, reload the IDE
[Java for Android App Development] mikrosmile:
Yeah and later I will explain in details how to use preference . and also this lib allows to use as many features as you need ..

Will also look into new opportunities in the lib itself
[Java for Android App Development] MaartenXDA:
When trying, I get these errors:

"Description	Resource	Path	Location	Type

The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project	SkyDragonStoreFree	Unknown	Java Problem

"

"Description	Resource	Path	Location	Type

Unable to resolve target 'HTC:HTC OpenSense SDK:15'	SkyDragonStoreFree	Unknown	Android Target Problem

"

"Description	Resource	Path	Location	Type

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files	NewsActivity.java	/SkyDragonStoreFree/src/com/maartenxda/skydragon	line 1	Java Problem

"

Do note that I'm using API level 15

EDIT: Nevermind, works now, great work both! :D But I still get this error: "[2013-04-14 19:33:36 - SkyDragonStore] Unable to resolve target 'HTC:HTC OpenSense APIs:15'"

Could you guys please help me? :)
[Java for Android App Development] mikrosmile:
What if you change to opensense 16? Just in eclipse - project - properties - android - choose v16
[Java for Android App Development] MaartenXDA:
Didn't work. But it seemed I had lost my permissions in my developers environment, rebooted my laptop and now everything's okay :)

Thanks both :D
[Java for Android App Development] Jonny:
I've edited the post to add instructions for API 15 :)
[Java for Android App Development] MaartenXDA:
Great, thanks ^.^

Oh and mikrosmile, how the hell do you get the preferences to work? Using com.htc.preference.HtcPreferenceCategory/Screen or anything else doesn't work, neither does HtcPreferencesCategory
[Java for Android App Development] mikrosmile:
Where you have Prefrence activity change it to HtcPreferenceActivity, import com.htc.preference.*;

In prefs.xml use this way <com.htc.preference.HtcPreferenceScreen

com.htc.preference.HtcCheckBoxPreference and etc..

later will write about it in details with example
[Java for Android App Development] xcesco89:
Can you also add a little example for HtcSpinner ??

I'm trying to use this with the usual ArrayAdapter it displays a black dialog without "sense style" :)

Thanks a lot for this guide :)

Inviato dal mio HTC One X con Tapatalk 2
[Java for Android App Development] mikrosmile:
you mean this horizonatal progress bar ?

View attachment 1885363

Or this Spinner?

View attachment 1885364

Ah or you mean progress bar but not for downloading?
[Java for Android App Development] mikrosmile:
Or something like that?

View attachment 1885367
[Java for Android App Development] xcesco89:
I mean the spinners you see in the screenshot, but when you click it, instead of a dropdown list, you will see a dialog .

The problem is, with the android ArrayAdapter, you will se only a black dialog and nothing more!(see the other screenshot)

(don't look at the messed layout, I'm converting it from my AOSP version :)

And another thing, how can I add different row layouts in htclistview?

I've tried with a custom adapter and two row layouts but I can't get these working :P

Inviato dal mio HTC One X con Tapatalk 2
[Java for Android App Development] mikrosmile:
but its simple..

you need to use arrays.

This is Dialog when you click on button

HtcAlertDialog.Builder builder2 = new HtcAlertDialog.Builder(AboutActivity.this);
builder2.setIcon(R.drawable.ic_about)
.setTitle(obj_itemDetails.getName())
.setItems([COLOR="Red"]R.array.select_dialog_items[/COLOR],
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
@SuppressWarnings("unused")
[COLOR="red"]String[] items = getResources().getStringArray(R.array.select_dialog_items);[/COLOR]

if (id == 0){
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(obj_itemDetails.getUrl())));
}else if(id == 1){
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(obj_itemDetails.getPayPal())));
}else if(id == 2){
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(obj_itemDetails.getTwitter())));
}
}
}).create();
builder2.show();
}
});

This is arrays.xml

<string-array name="[COLOR="red"]select_dialog_items[/COLOR]">
<item>Open XDA Profile</item>
<item>Donate via PayPal</item>
<item>Follow on Twitter</item>
</string-array>

Output of this code..

View attachment 1885506
[Java for Android App Development] xcesco89:
My app imports values from a file in an array, I don't have a static array in strings xml :)

I will try to make a custom dialog with a custom layout (radio buttons or something like that) and for the spinner I will try to set a simple OnClickListener instead of OnItemSelectedListener and see what happens :p

Inviato dal mio HTC One X con Tapatalk 2
[Java for Android App Development] MaartenXDA:
Hm, weird, doesn't seem to work even after trying several things. Will wait for the detailed version then :)
[Java for Android App Development] mikrosmile:
HtcPreferenceActivity guide is added with examples
[Java for Android App Development] mikrosmile:
xcesco89 thanks, yeah)

but i dont think that i forgot it.. its just different from normal prefs.. :silly:
[Java for Android App Development] xcesco89:
Everyone have is own type of workflow eheheh! :)

There is one thing I've not understand, how can I add the "three dots menu" in the actionbar!

I know how to do this for Aosp apps, but with sense sdk I can't get this working D:

Inviato dal mio HTC One X con Tapatalk 2
[Java for Android App Development] mikrosmile:
yeah. i make the guide on basic htc code..on tabs, actionbar, prefs, dialogs soon complete the htc listview.

other things is already depends on the app and i cannot write about everything ))

by the way try use this in your main activity, add it before Setupactionbar method

public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add("ContextMenu");
}

@Override
public boolean onCreateOptionsMenu (Menu menu) {
menu.add(1, 1, 1, R.string.settings);
return true;
}

public boolean onOptionsItemSelected(MenuItem menuitem)
{
boolean flag = true;
switch (menuitem.getItemId())
{
case 1:
//Do your things
break;
}
return flag;

}

Menu name will appear automatically on all available languages.. dont need to create Menu string
[Java for Android App Development] mikrosmile:
Added to OP how to add Menu with example
[Java for Android App Development] xcesco89:
just a little add for the HtcPreferenceActivity :D

in your XML you can also add an icon with:

android:icon="@drawable/youricon"

i know that all off you know about this thing, but it's better to avoid some questions :D
[Java for Android App Development] MaartenXDA:
Hey mikrosmile,

I have a news section in my app, which uses SAXParser. Somehow it only works when I set the targetSdkVersion to 9, when I set it to 10 or higher the app FC's.

But, the HTCPreferences only work when I set it to 14 or higher. What should I do?
[Java for Android App Development] mikrosmile:
yeah opensense works only since 15 or as you said 14 (never tried)

hmm i suggest to use another saxparser method
[Java for Android App Development] MaartenXDA:
Hey mikrosmile, how do you show only the selected item when clicking something? Like in the skins section?

Sent from my awesome fridge
[Java for Android App Development] mikrosmile:
hmm.. OnClickLisener for example..

listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// Do things here when user click on item
}
});
[Java for Android App Development] MaartenXDA:
Yeah but I mean, when you click a skin in the skins section, a popup shows in which you can download that specific skin, even though you're parsing it from the web (right?). I want to know how I could for example launch a dialog in which I set the text I parse from the selected item. Can you help me with that?
[Java for Android App Development] mikrosmile:
ok here is example.. its simple.. in your OnItemClick method you create your dialog and paste whatever you want

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

[MENTION=439709]override[/MENTION]
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
vibrator.vibrate(50);
Object o = listView.getItemAtPosition(position);
final News obj_itemDetails = (News)o;

HtcAlertDialog.Builder alertDialog = new HtcAlertDialog.Builder(SkinsActivity.this);

alertDialog.setTitle(R.string.install_skins);

alertDialog.setMessage(obj_itemDetails.getHeadline());

alertDialog.setIcon(R.drawable.icon_info);

alertDialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
DownloadMapAsync mew = new DownloadMapAsync();
mew.execute(obj_itemDetails.getDescription());
}
});
alertDialog.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {

dialog.cancel();
}
});
alertDialog.show();
}

});

DownloadMapAsync(); - AsyncTask method to download file from web

obj_itemDetails - data the app stores from external links (i.e xml on the server - see myStore for example)

so for title im using Header which is name of item in the skins.xml file

Description im using to store url for the file

So you create your dialog and paste anything you want inside.
[Java for Android App Development] MaartenXDA:
Thanks :)

And do you know what HtcWrapScrollView is? If I set it it shows the exact same as a normal ScrollView.
[Java for Android App Development] mikrosmile:
hmm no) i dont get so far with htc stuff yet..
[Java for Android App Development] mikrosmile:
Coming soon to the guide.. carousel with fragments guide

View attachment 1908719
[Java for Android App Development] mikrosmile:
Added how to build Caorusel with Fragments instead of Activities. (Support Sense 5).