Issue #227 device definition is now opened on long press on the device list item

This commit is contained in:
Sergey Eremin
2017-08-25 03:37:10 +03:00
parent bc0a540f5c
commit c0f69246cc
4 changed files with 68 additions and 0 deletions

View File

@@ -116,6 +116,8 @@
<meta-data android:name="android.app.default_searchable" android:value=".SearchActivity" />
</activity>
<activity android:name=".BugReportActivity" android:launchMode="singleInstance" android:noHistory="true" android:process=":report_process" />
<activity android:name=".DeviceInfoActivity" android:launchMode="singleInstance" android:configChanges="keyboardHidden|orientation|screenSize" />
<service android:enabled="true" android:name=".notification.CancelDownloadService" />
<service android:enabled="true" android:name=".notification.IgnoreUpdatesService" />
<service android:enabled="true" android:name=".bugreport.BugReportService" />

View File

@@ -0,0 +1,37 @@
package com.github.yeriomin.yalpstore;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
public class DeviceInfoActivity extends YalpStoreActivity {
public static final String INTENT_DEVICE_NAME = "INTENT_DEVICE_NAME";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.deviceinfo_activity_layout);
onNewIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String deviceName = intent.getStringExtra(INTENT_DEVICE_NAME);
if (TextUtils.isEmpty(deviceName)) {
Log.e(getClass().getName(), "No device name given");
finish();
return;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(byteArrayOutputStream);
new SpoofDeviceManager(this).getProperties(deviceName).list(printStream);
((TextView) findViewById(R.id.device_info)).setText(new String(byteArrayOutputStream.toByteArray()));
}
}

View File

@@ -7,9 +7,12 @@ import android.content.Intent;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import com.github.yeriomin.playstoreapi.PropertiesDeviceInfoProvider;
import com.github.yeriomin.yalpstore.ContextUtil;
import com.github.yeriomin.yalpstore.DeviceInfoActivity;
import com.github.yeriomin.yalpstore.OnListPreferenceChangeListener;
import com.github.yeriomin.yalpstore.Paths;
import com.github.yeriomin.yalpstore.PlayStoreApiAuthenticator;
@@ -37,6 +40,15 @@ public class Device extends List {
@Override
public boolean onPreferenceClick(Preference preference) {
ContextUtil.toast(activity.getApplicationContext(), R.string.pref_device_to_pretend_to_be_notice, Paths.getYalpPath().getName());
((AlertDialog) listPreference.getDialog()).getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
Intent i = new Intent(activity, DeviceInfoActivity.class);
i.putExtra(DeviceInfoActivity.INTENT_DEVICE_NAME, (String) keyValueMap.keySet().toArray()[position]);
activity.startActivity(i);
return false;
}
});
return false;
}
});

View File

@@ -0,0 +1,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/device_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:typeface="monospace" />
</ScrollView>
</LinearLayout>