mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-24 04:05:13 +00:00
Fixup 33a6137
This commit is contained in:
parent
33a6137aec
commit
db93985e28
6 changed files with 72 additions and 50 deletions
|
@ -119,7 +119,7 @@ public class PackageUtils {
|
|||
try {
|
||||
return context.getPackageManager().getPackageInfo(packageName, 0).versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,19 +78,19 @@ public class GcmData {
|
|||
}
|
||||
}
|
||||
|
||||
public void app_registered(String app, String signature, String regId) {
|
||||
public void noteAppRegistered(String app, String signature, String regId) {
|
||||
getInfoSharedPreferences().edit().putString(app + ":" + signature, regId).apply();
|
||||
}
|
||||
|
||||
public void app_registration_error(String app, String signature) {
|
||||
public void noteAppRegistrationError(String app, String signature) {
|
||||
getInfoSharedPreferences().edit().putString(app + ":" + signature, "-").apply();
|
||||
}
|
||||
|
||||
public void app_unregistered(String app, String signature) {
|
||||
public void noteAppUnregistered(String app, String signature) {
|
||||
getInfoSharedPreferences().edit().putString(app + ":" + signature, REMOVED).apply();
|
||||
}
|
||||
|
||||
public void app_unregistration_error(String app, String signature) {
|
||||
public void noteAppUnregistrationError(String app, String signature) {
|
||||
getInfoSharedPreferences().edit().putString(app + ":" + signature, ERROR).apply();
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class GcmData {
|
|||
}
|
||||
|
||||
public AppInfo getAppInfo(String app, String signature) {
|
||||
return getAppInfo(app + signature);
|
||||
return getAppInfo(app + ":" + signature);
|
||||
}
|
||||
|
||||
public List<AppInfo> getAppsInfo() {
|
||||
|
|
|
@ -60,9 +60,9 @@ public class PushRegisterService extends IntentService {
|
|||
RegisterResponse response = register(context, app, appSignature, sender, info, false);
|
||||
String regId = response.token;
|
||||
if (regId != null) {
|
||||
(new GcmData(context)).app_registered(app, appSignature, regId);
|
||||
(new GcmData(context)).noteAppRegistered(app, appSignature, regId);
|
||||
} else {
|
||||
(new GcmData(context)).app_registration_error(app, appSignature);
|
||||
(new GcmData(context)).noteAppRegistrationError(app, appSignature);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ public class PushRegisterService extends IntentService {
|
|||
public static RegisterResponse unregister(Context context, String app, String appSignature, String sender, String info) {
|
||||
RegisterResponse response = register(context, app, appSignature, sender, info, true);
|
||||
if (!app.equals(response.deleted)) {
|
||||
(new GcmData(context)).app_unregistration_error(app, appSignature);
|
||||
(new GcmData(context)).noteAppUnregistrationError(app, appSignature);
|
||||
} else {
|
||||
(new GcmData(context)).app_unregistered(app, appSignature);
|
||||
(new GcmData(context)).noteAppUnregistered(app, appSignature);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -55,14 +55,15 @@ public class GcmRegisteredAppsFragment extends Fragment {
|
|||
View view = inflater.inflate(R.layout.gcm_apps_list, container, false);
|
||||
ListView listView = (ListView) view.findViewById(R.id.list_view);
|
||||
registerForContextMenu(listView);
|
||||
listView.setAdapter(updateListView());
|
||||
updateListView();
|
||||
listView.setAdapter(appsAdapter);
|
||||
return listView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
((ListView) getView().findViewById(R.id.list_view)).setAdapter(updateListView());
|
||||
updateListView();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,27 +95,31 @@ public class GcmRegisteredAppsFragment extends Fragment {
|
|||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
((ListView) getView().findViewById(R.id.list_view)).setAdapter(updateListView());
|
||||
updateListView();
|
||||
}
|
||||
}.execute();
|
||||
return true;
|
||||
}
|
||||
|
||||
synchronized public AppsAdapter updateListView() {
|
||||
public synchronized void updateListView() {
|
||||
ArrayList<GcmData.AppInfo> registeredApps = new ArrayList<GcmData.AppInfo>();
|
||||
for (GcmData.AppInfo appInfo : gcmStorage.getAppsInfo()) {
|
||||
if (appInfo.isRegistered()) {
|
||||
registeredApps.add(appInfo);
|
||||
}
|
||||
}
|
||||
appsAdapter = new AppsAdapter(getContext(), registeredApps.toArray(new GcmData.AppInfo[registeredApps.size()]));
|
||||
return appsAdapter;
|
||||
if (appsAdapter != null) {
|
||||
appsAdapter.update(registeredApps.toArray(new GcmData.AppInfo[registeredApps.size()]));
|
||||
} else {
|
||||
appsAdapter = new AppsAdapter(getContext(), registeredApps.toArray(new GcmData.AppInfo[registeredApps.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
private class AppsAdapter extends ArrayAdapter<GcmData.AppInfo> {
|
||||
|
||||
public AppsAdapter(Context context, GcmData.AppInfo[] libraries) {
|
||||
super(context, R.layout.gcm_app, R.id.title, libraries);
|
||||
super(context, R.layout.gcm_app, R.id.title);
|
||||
addAll(libraries);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,9 +139,12 @@ public class GcmRegisteredAppsFragment extends Fragment {
|
|||
if (appInfo.hasUnregistrationError()) {
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
warning.setText(getString(R.string.gcm_app_error_unregistering));
|
||||
} else {
|
||||
warning.setVisibility(View.GONE);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
title.setText(appInfo.app);
|
||||
image.setImageDrawable(null);
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
warning.setText(getString(R.string.gcm_app_not_installed_anymore));
|
||||
}
|
||||
|
@ -144,5 +152,12 @@ public class GcmRegisteredAppsFragment extends Fragment {
|
|||
|
||||
return v;
|
||||
}
|
||||
|
||||
public void update(GcmData.AppInfo[] appInfos) {
|
||||
setNotifyOnChange(false);
|
||||
clear();
|
||||
addAll(appInfos);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,56 +14,62 @@
|
|||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/listPreferredItemHeight"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft" >
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/listPreferredItemHeight"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight">
|
||||
|
||||
<ImageView android:id="@+id/image"
|
||||
android:layout_height="wrap_content"
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:minHeight="40dp"
|
||||
android:maxHeight="40dp"
|
||||
android:minWidth="40dp"
|
||||
android:maxWidth="40dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:maxHeight="40dp"
|
||||
android:maxWidth="40dp"
|
||||
android:minHeight="40dp"
|
||||
android:minWidth="40dp"
|
||||
android:scaleType="fitCenter"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center"
|
||||
android:minHeight="?attr/listPreferredItemHeight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent">
|
||||
android:layout_marginLeft="10dp"
|
||||
android:minHeight="?attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_height="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/sub"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textColor="@android:color/darker_gray"/>
|
||||
|
||||
<TextView android:id="@+id/warning"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:textColor="@android:color/holo_red_dark"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
tools:targetApi="lollipop" />
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="@color/material_error"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/sub"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
tools:targetApi="lollipop" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,4 +20,5 @@
|
|||
<color name="login_blue_theme_accent">#ffFFAB40</color>
|
||||
|
||||
<color name="dialog_border_color">#88CCCCCC</color>
|
||||
<color name="material_error">#fff44336</color>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue