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