Skip to content

Commit

Permalink
Several changes
Browse files Browse the repository at this point in the history
1. Add widgets
2. Add wallpaper functionality using muzei
3. Integrate places API
  • Loading branch information
Protino committed Nov 27, 2016
1 parent 31114c8 commit dac6e8a
Show file tree
Hide file tree
Showing 49 changed files with 1,331 additions and 193 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.DS_Store
/build
/captures
/.log
/projectFilesBackup
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ android {

defaultConfig {
applicationId "com.calgen.prodek.sunshine_v2"
minSdkVersion 10
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true

}
buildTypes {
release {
Expand All @@ -24,21 +26,22 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:support-annotations:23.2.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.android.support:gridlayout-v7:23.2.0'

//cardview and recycler view
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile files('libs/muzei-api-2.0.jar')
compile 'com.google.android.gms:play-services-places:9.8.0'
compile 'com.google.android.gms:play-services-gcm:9.8.0'
}


Expand Down
Binary file added app/libs/muzei-api-2.0.jar
Binary file not shown.
50 changes: 50 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API-KEY"/>
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
Expand Down Expand Up @@ -108,5 +111,52 @@
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent"/>

<!--Today Widget receiver and service-->
<receiver
android:name=".widget.TodayWidgetProvider"
android:label="@string/title_today_widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="com.calgen.prodek.sunshine_v2.ACTION_DATA_UPDATED"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info_today"/>
</receiver>
<service android:name=".widget.TodayWidgetIntentService"/>

<!-- Detail Widget receiver and service-->
<receiver
android:name=".widget.DetailWidgetProvider"
android:enabled="@bool/widget_detail_enabled"
android:label="@string/title_detail_widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="com.calgen.prodek.sunshine_v2.ACTION_DATA_UPDATED"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info_detail"/>
</receiver>
<service
android:name=".widget.DetailWidgetRemoteViewsService"
android:enabled="@bool/widget_detail_enabled"
android:exported="false"
android:permission="android.permission.BIND_REMOTEVIEWS"/>

<!-- Muzei Extension -->
<service
android:name=".muzei.WeatherMuzeiSource"
android:description="@string/muzei_description"
android:icon="@mipmap/ic_muzei"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.google.android.apps.muzei.api.MuzeiArtSource"/>
</intent-filter>
<meta-data
android:name="color"
android:value="@color/colorPrimary"/>
</service>

</application>
</manifest>
Binary file removed app/src/main/ic_launcher-web.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
import com.calgen.prodek.sunshine_v2.R;
import com.calgen.prodek.sunshine_v2.Utility;
import com.calgen.prodek.sunshine_v2.adapter.ForecastAdapter;
import com.calgen.prodek.sunshine_v2.data.WeatherContract;
import com.calgen.prodek.sunshine_v2.fragment.DetailFragment;
import com.calgen.prodek.sunshine_v2.fragment.ForecastFragment;
import com.calgen.prodek.sunshine_v2.sync.SunshineSyncAdapter;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;

public class MainActivity extends AppCompatActivity implements ForecastFragment.Callback {

private static final String TAG = MainActivity.class.getSimpleName();
private static final String DETAIL_FRAGMENT_TAG = "DFTAG";
private static final String PANE_TYPE = "pane_type";
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private static boolean mTwoPane;
private String mLocation;

Expand All @@ -41,12 +39,21 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
mLocation = Utility.getPreferredLocation(this);

Uri contentUri = getIntent() != null ? getIntent().getData() : null;

if (findViewById(R.id.weather_detail_container) != null) {
mTwoPane = true;

if (savedInstanceState == null) {
DetailFragment detailFragment = new DetailFragment();
if (contentUri != null) {
Bundle bundle = new Bundle();
bundle.putParcelable(DetailFragment.DETAIL_URI, contentUri);
detailFragment.setArguments(bundle);
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.weather_detail_container, new DetailFragment(), DETAIL_FRAGMENT_TAG)
.replace(R.id.weather_detail_container, detailFragment, DETAIL_FRAGMENT_TAG)
.commit();
}
} else {
Expand All @@ -55,7 +62,11 @@ protected void onCreate(Bundle savedInstanceState) {

ForecastFragment forecastFragment = (ForecastFragment) (getSupportFragmentManager().findFragmentById(R.id.fragment_forecast));
forecastFragment.setUseTodayLayout(!mTwoPane);

if (contentUri != null) {
forecastFragment.setInitialSelectedDate(
WeatherContract.WeatherEntry.getDateFromUri(contentUri)
);
}
SunshineSyncAdapter.initializeSyncAdapter(this);
}

Expand Down Expand Up @@ -150,27 +161,4 @@ public void onItemSelected(Uri dateUri, ForecastAdapter.ViewHolder viewHolder) {
ActivityCompat.startActivity(this, intent, activityOptionsCompat.toBundle());
}
}

/**
* Check the device to make sure it has the Google Play Services APK.
* If it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*
* @return true if PlayServices is available else false
*/
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported");
finish();
}
return false;
}
return true;
}
}
Loading

0 comments on commit dac6e8a

Please sign in to comment.