-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d0679a
commit 1d55200
Showing
99 changed files
with
5,698 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
id 'com.google.gms.google-services' | ||
} | ||
|
||
android { | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.cumulocity.alarmapp" | ||
minSdk 24 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
buildFeatures { | ||
dataBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.8.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation "androidx.navigation:navigation-fragment:$nav_version" | ||
implementation "androidx.navigation:navigation-ui:$nav_version" | ||
implementation "com.cumulocity.client:cumulocity-kotlin-client:$cumulocityKotlinVersion@aar" | ||
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" | ||
implementation "com.squareup.retrofit2:converter-scalars:$retrofitScalarsVersion" | ||
implementation "com.squareup.retrofit2:converter-gson:$retrofitGsonVersion" | ||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' | ||
implementation platform('com.google.firebase:firebase-bom:32.1.0') | ||
implementation 'com.google.firebase:firebase-analytics' | ||
implementation 'com.google.firebase:firebase-messaging:23.0.2' | ||
testImplementation 'junit:junit:4.13.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "437874919529", | ||
"project_id": "alarmingapp-fb8dc", | ||
"storage_bucket": "alarmingapp-fb8dc.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:437874919529:android:c0bbc86eb85b5bde17baf8", | ||
"android_client_info": { | ||
"package_name": "com.cumulocity.alarmapp" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "437874919529-b38j70qk6rb81ev4tqgrkntjhmbt0gd1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyAd5KAYDuxrMcP2QCm4sp4gdxUZ0BdJSZ0" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "437874919529-b38j70qk6rb81ev4tqgrkntjhmbt0gd1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.cumulocity.alarmapp"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | ||
|
||
<application | ||
android:name=".MyApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AlarmingApp" | ||
tools:targetApi="31"> | ||
<meta-data | ||
android:name="com.google.firebase.messaging.default_notification_channel_id" | ||
android:value="12345" /> | ||
|
||
<activity | ||
android:name=".SplashScreenActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".LoginActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".WelcomeActivity" | ||
android:exported="true" | ||
android:launchMode="singleTask" | ||
android:excludeFromRecents="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<service | ||
android:name=".service.AppPushNotificationService" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions
106
android/app/src/main/java/com/cumulocity/alarmapp/AddCommentFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.cumulocity.alarmapp; | ||
|
||
import android.os.Bundle; | ||
import android.text.Editable; | ||
import android.text.TextWatcher; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.databinding.DataBindingUtil; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.navigation.Navigation; | ||
|
||
import com.cumulocity.alarmapp.databinding.FragmentAddCommentBinding; | ||
import com.cumulocity.alarmapp.fragments.C8yComment; | ||
import com.cumulocity.alarmapp.util.AlarmDetailsFilter; | ||
import com.cumulocity.alarmapp.util.CumulocityAPI; | ||
import com.cumulocity.alarmapp.util.LoginHolder; | ||
import com.cumulocity.client.model.Alarm; | ||
import com.google.android.material.color.MaterialColors; | ||
import com.google.android.material.transition.MaterialContainerTransform; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
|
||
public class AddCommentFragment extends Fragment { | ||
|
||
private FragmentAddCommentBinding fragmentAddCommentBinding; | ||
private Alarm alarm; | ||
|
||
private final String TAG = AddCommentFragment.class.getCanonicalName(); | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
fragmentAddCommentBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_add_comment, container, false); | ||
return fragmentAddCommentBinding.getRoot(); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
ArrayList<Alarm> list = (ArrayList<Alarm>) getArguments().getSerializable("AlarmSelected"); | ||
alarm = list.get(0); | ||
fragmentAddCommentBinding.submitButton.setEnabled(false); | ||
fragmentAddCommentBinding.submitButton.setOnClickListener(v -> navigateToAlarmDetails()); | ||
fragmentAddCommentBinding.inputField.addTextChangedListener(new TextWatcher() { | ||
@Override | ||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTextChanged(CharSequence s, int start, int before, int count) { | ||
|
||
} | ||
|
||
@Override | ||
public void afterTextChanged(Editable s) { | ||
fragmentAddCommentBinding.submitButton.setEnabled(s.toString().isEmpty() ? false : true); | ||
} | ||
}); | ||
MaterialContainerTransform enterContainerTransform = new MaterialContainerTransform(requireContext(), true); | ||
int colorSurface = MaterialColors.getColor(requireView(), com.google.android.material.R.attr.colorSurface); | ||
enterContainerTransform.setAllContainerColors(colorSurface); | ||
setSharedElementEnterTransition(enterContainerTransform); | ||
AlarmDetailsFilter.getInstance().selectComments(true); | ||
} | ||
|
||
private void navigateToAlarmDetails() { | ||
updateComment(); | ||
Navigation.findNavController(getView()).popBackStack(); | ||
} | ||
|
||
private void updateComment() { | ||
List<C8yComment> list = new ArrayList<>(); | ||
C8yComment[] comments = (C8yComment[]) alarm.get(C8yComment.IDENTIFIER); | ||
C8yComment c8yComment = new C8yComment(); | ||
c8yComment.setText(fragmentAddCommentBinding.inputField.getText().toString()); | ||
c8yComment.setUser(LoginHolder.getInstance(MyApplication.getAppContext()).getCurrentUserName()); | ||
list.add(c8yComment); | ||
if (comments != null) { | ||
list.addAll(Arrays.asList(comments)); | ||
} | ||
alarm.set(C8yComment.IDENTIFIER, Arrays.copyOf(list.toArray(), list.size(), C8yComment[].class)); | ||
CumulocityAPI.Companion.getInstance().updateAlarm(alarm, alarm.getId(), new Callback<Alarm>() { | ||
@Override | ||
public void onResponse(Call<Alarm> call, Response<Alarm> response) { | ||
Log.i(TAG, "Alarm updated: " + alarm.getId()); | ||
} | ||
|
||
@Override | ||
public void onFailure(Call<Alarm> call, Throwable t) { | ||
Log.e(TAG, "Failed to update Alarm: " + alarm.getId()); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.