Skip to content

Commit

Permalink
checks for presence of Muzei, and opens app store to it if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbluesky committed Sep 5, 2019
1 parent a7a0ab1 commit 12cbb6d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/src/main/java/com/antony/muzei/pixiv/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package com.antony.muzei.pixiv;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

Expand Down Expand Up @@ -54,6 +57,20 @@ protected void onCreate(Bundle savedInstanceState)
.add(R.id.FeedPreferencesFragment, new SettingsFragment())
.commit();

if (!isMuzeiInstalled())
{
// You must have Muzei installed for this app to work
// Click here to install Muzei
final String appPackageName = "net.nurik.roman.muzei"; // getPackageName() from Context or Activity object
try
{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe)
{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}

SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

// Stores user toggleable variables into a temporary store for later comparison in onDestroy()
Expand Down Expand Up @@ -163,6 +180,22 @@ public void onStop()
Toast.makeText(getApplicationContext(), getString(R.string.toast_newFilterMode), Toast.LENGTH_SHORT).show();
}
}


}

public boolean isMuzeiInstalled()
{
boolean found = true;
try
{
PackageManager packageManager = getApplicationContext().getPackageManager();
packageManager.getPackageInfo("net.nurik.roman.muzei", 0);
} catch (PackageManager.NameNotFoundException ex)
{
found = false;
}
return found;
}

// Functions in here action immediately on user interaction
Expand Down Expand Up @@ -208,6 +241,8 @@ public boolean onPreferenceClick(Preference preference)
// Uri profileImageUri = Uri.parse(sharedPrefs.getString("profileImageUri", ""));
// loginId.setIcon();
}


}
}
}

0 comments on commit 12cbb6d

Please sign in to comment.