setFirebaseId(@Path("uuid") String uuid,
178 | @Field("firebase_id") String firebaseId);
179 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/service/MyFirebaseMessagingService.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.service;
2 |
3 | import android.app.NotificationChannel;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.media.RingtoneManager;
9 | import android.net.Uri;
10 | import android.os.Build;
11 | import android.util.Log;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.core.app.NotificationCompat;
15 |
16 | import com.github.mahadel.demo.R;
17 | import com.github.mahadel.demo.model.AuthenticationInfo;
18 | import com.github.mahadel.demo.model.ResponseMessage;
19 | import com.github.mahadel.demo.ui.activity.MainActivity;
20 | import com.github.mahadel.demo.util.Constant;
21 | import com.github.mahadel.demo.util.RetrofitUtil;
22 | import com.github.pwittchen.prefser.library.rx2.Prefser;
23 | import com.google.firebase.messaging.FirebaseMessagingService;
24 | import com.google.firebase.messaging.RemoteMessage;
25 |
26 | import retrofit2.Call;
27 | import retrofit2.Callback;
28 | import retrofit2.Response;
29 |
30 | public class MyFirebaseMessagingService extends FirebaseMessagingService {
31 |
32 | /**
33 | * Called when message is received.
34 | *
35 | * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
36 | */
37 | @Override
38 | public void onMessageReceived(RemoteMessage remoteMessage) {
39 | if (remoteMessage.getNotification() != null) {
40 | sendNotification(remoteMessage.getNotification().getBody(), remoteMessage.getNotification().getTitle());
41 | }
42 | }
43 |
44 |
45 | /**
46 | * Called if InstanceID token is updated. This may occur if the security of
47 | * the previous token had been compromised. Note that this is called when the InstanceID token
48 | * is initially generated so this is where you would retrieve the token.
49 | */
50 | @Override
51 | public void onNewToken(String token) {
52 | // If you want to send messages to this application instance or
53 | // manage this apps subscriptions on the server side, send the
54 | // Instance ID token to your app server.
55 | sendRegistrationToServer(token);
56 | }
57 | // [END on_new_token]
58 |
59 | /**
60 | * Persist token to third-party servers.
61 | *
62 | * Modify this method to associate the user's FCM InstanceID token with any server-side account
63 | * maintained by your application.
64 | *
65 | * @param token The new token.
66 | */
67 | private void sendRegistrationToServer(String token) {
68 | Prefser prefser = new Prefser(this);
69 | AuthenticationInfo info = prefser.get(Constant.TOKEN, AuthenticationInfo.class, null);
70 | if (info != null) {
71 | APIService apiService = RetrofitUtil.getRetrofit(info.getToken()).create(APIService.class);
72 | Call call = apiService.setFirebaseId(info.getUuid(), token);
73 | call.enqueue(new Callback() {
74 | @Override
75 | public void onResponse(@NonNull Call call, @NonNull Response response) {
76 | if (response.isSuccessful()) {
77 | Log.d("submitToken", "success");
78 | }
79 | }
80 |
81 | @Override
82 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
83 | Log.d("submitToken", "failed");
84 | t.printStackTrace();
85 | }
86 | });
87 | }
88 | }
89 |
90 | /**
91 | * Create and show a simple notification containing the received FCM message.
92 | *
93 | * @param messageBody FCM message body received.
94 | * @param title FCM message title received.
95 | */
96 | private void sendNotification(String messageBody, String title) {
97 | Intent intent = new Intent(this, MainActivity.class);
98 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
99 | PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
100 | PendingIntent.FLAG_ONE_SHOT);
101 |
102 | String channelId = getString(R.string.default_notification_channel_id);
103 | Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
104 | NotificationCompat.Builder notificationBuilder =
105 | new NotificationCompat.Builder(this, channelId)
106 | .setSmallIcon(R.drawable.ic_persian)
107 | .setContentTitle(title)
108 | .setContentText(messageBody)
109 | .setAutoCancel(true)
110 | .setSound(defaultSoundUri)
111 | .setContentIntent(pendingIntent);
112 |
113 | NotificationManager notificationManager =
114 | (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
115 |
116 | // Since android Oreo notification channel is needed.
117 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
118 | NotificationChannel channel = new NotificationChannel(channelId,
119 | "Channel human readable title",
120 | NotificationManager.IMPORTANCE_DEFAULT);
121 | notificationManager.createNotificationChannel(channel);
122 | }
123 |
124 | notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | import com.github.mahadel.demo.R;
9 | import com.github.mahadel.demo.util.Constant;
10 | import com.github.mahadel.demo.util.MyApplication;
11 | import com.github.pwittchen.prefser.library.rx2.Prefser;
12 |
13 | import io.github.inflationx.viewpump.ViewPumpContextWrapper;
14 |
15 | /**
16 | * BaseActivity handle theme and custom font for all activity
17 | * Other activity should be extend it
18 | */
19 | public class BaseActivity extends AppCompatActivity {
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | //Get type of theme from shared preferences
23 | Prefser prefser = new Prefser(this);
24 | if (prefser.get(Constant.IS_DARK_THEME, Boolean.class, true)) {
25 | setTheme(R.style.BaseAppTheme_Dark);
26 | } else {
27 | setTheme(R.style.BaseAppTheme);
28 | }
29 | super.onCreate(savedInstanceState);
30 | }
31 |
32 | @Override
33 | protected void attachBaseContext(Context base) {
34 | Context newContext = MyApplication.localeManager.setLocale(base);
35 | super.attachBaseContext(ViewPumpContextWrapper.wrap(newContext));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/activity/SelectSkillActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.view.Window;
7 | import android.view.WindowManager;
8 | import android.widget.Toast;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.recyclerview.widget.GridLayoutManager;
12 | import androidx.recyclerview.widget.RecyclerView;
13 |
14 | import com.github.mahadel.demo.R;
15 | import com.github.mahadel.demo.model.Category;
16 | import com.github.mahadel.demo.model.SkillsItem;
17 | import com.github.mahadel.demo.model.UserSkill;
18 | import com.github.mahadel.demo.util.Constant;
19 | import com.github.mahadel.demo.util.DatabaseUtil;
20 | import com.github.mahadel.demo.util.GridSpacingItemDecoration;
21 | import com.github.mahadel.demo.util.MyApplication;
22 | import com.google.android.material.button.MaterialButton;
23 | import com.mikepenz.fastadapter.FastAdapter;
24 | import com.mikepenz.fastadapter.IAdapter;
25 | import com.mikepenz.fastadapter.adapters.ItemAdapter;
26 | import com.mikepenz.fastadapter.listeners.OnClickListener;
27 |
28 | import java.util.List;
29 |
30 | import javax.annotation.Nullable;
31 |
32 | import butterknife.BindView;
33 | import butterknife.ButterKnife;
34 | import butterknife.OnClick;
35 | import io.objectbox.Box;
36 | import io.objectbox.BoxStore;
37 |
38 | import static com.github.mahadel.demo.util.AppUtil.dpToPx;
39 |
40 | /**
41 | * SelectSkillActivity select skill from list and return to fragment of requester
42 | */
43 | public class SelectSkillActivity extends BaseActivity {
44 | @BindView(R.id.recycler_view)
45 | RecyclerView recyclerView;
46 | @BindView(R.id.category_button)
47 | MaterialButton categoryButton;
48 | private Box skillsItemBox;
49 | private Box categoryBox;
50 | private Box userSkillBox;
51 | private FastAdapter mFastAdapterSkill;
52 | private ItemAdapter mItemAdapterSkill;
53 | private FastAdapter mFastAdapterCategory;
54 | private ItemAdapter mItemAdapterCategory;
55 |
56 | @Override
57 | protected void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | requestWindowFeature(Window.FEATURE_NO_TITLE);
60 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
61 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
62 | setContentView(R.layout.activity_select_skill);
63 | ButterKnife.bind(this);
64 | initVariables();
65 | initRecyclerView();
66 | initAdapters();
67 | }
68 |
69 | /**
70 | * Setup init values of variables
71 | */
72 | private void initVariables() {
73 | BoxStore boxStore = MyApplication.getBoxStore();
74 | skillsItemBox = boxStore.boxFor(SkillsItem.class);
75 | categoryBox = boxStore.boxFor(Category.class);
76 | userSkillBox = boxStore.boxFor(UserSkill.class);
77 | }
78 |
79 | /**
80 | * Setup recycler view
81 | */
82 |
83 | private void initRecyclerView() {
84 | RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
85 | recyclerView.setLayoutManager(mLayoutManager);
86 | recyclerView.addItemDecoration(new GridSpacingItemDecoration(2, dpToPx(6, getResources()), true));
87 | }
88 |
89 | /**
90 | * Setup FastAdapter variables & handle event of them
91 | */
92 | private void initAdapters() {
93 | mItemAdapterCategory = new ItemAdapter<>();
94 | mFastAdapterCategory = FastAdapter.with(mItemAdapterCategory);
95 | recyclerView.setAdapter(mFastAdapterCategory);
96 | mItemAdapterSkill = new ItemAdapter<>();
97 | mFastAdapterSkill = FastAdapter.with(mItemAdapterSkill);
98 | mFastAdapterCategory.withOnClickListener(new OnClickListener() {
99 | @Override
100 | public boolean onClick(@Nullable View v, @NonNull IAdapter adapter, @NonNull Category item, int position) {
101 | getSkills(item);
102 | return true;
103 | }
104 | });
105 | mFastAdapterSkill.withOnClickListener(new OnClickListener() {
106 | @Override
107 | public boolean onClick(@Nullable View v, @NonNull IAdapter adapter, @NonNull SkillsItem item, int position) {
108 | returnResult(item);
109 | return true;
110 | }
111 | });
112 | getCategory();
113 | }
114 |
115 | /**
116 | * Get skills from local db that belong to selected category
117 | *
118 | * @param item {@link Category}
119 | */
120 | private void getSkills(Category item) {
121 | List skillsItems = DatabaseUtil.getSkillItemOfCategory(skillsItemBox, item.getUuid());
122 | recyclerView.setAdapter(mFastAdapterSkill);
123 | mItemAdapterSkill.clear();
124 | mItemAdapterSkill.add(skillsItems);
125 | categoryButton.setVisibility(View.VISIBLE);
126 |
127 | }
128 |
129 | /**
130 | * Get categories from local db
131 | */
132 | private void getCategory() {
133 | List categories = categoryBox.getAll();
134 | mItemAdapterCategory.clear();
135 | mItemAdapterCategory.add(categories);
136 | }
137 |
138 | /**
139 | * Return selected skill to the fragment that request it
140 | *
141 | * @param item {@link SkillsItem}
142 | */
143 | private void returnResult(@NonNull SkillsItem item) {
144 | if (!isUserSkillDuplicate(item)) {
145 | Intent resultIntent = new Intent();
146 | resultIntent.putExtra(Constant.SKILL_ITEM, item);
147 | setResult(RESULT_OK, resultIntent);
148 | finish();
149 | } else {
150 | Toast.makeText(SelectSkillActivity.this, getString(R.string.skill_exists_warning), Toast.LENGTH_SHORT).show();
151 | }
152 | }
153 |
154 | /**
155 | * Check for duplicate select items
156 | *
157 | * @param item {@link SkillsItem}
158 | * @return Boolean
159 | */
160 | private boolean isUserSkillDuplicate(SkillsItem item) {
161 | UserSkill userSkill = DatabaseUtil.getUserSkillWithSkillUUID(userSkillBox, item.getUuid());
162 | return userSkill != null;
163 | }
164 |
165 |
166 | @OnClick(R.id.close_image_view)
167 | void closeDialog() {
168 | finish();
169 | }
170 |
171 | @OnClick(R.id.category_button)
172 | public void handleCategoryButton(View view) {
173 | view.setVisibility(View.GONE);
174 | initAdapters();
175 | }
176 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/fragment/AboutFragment.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.ActivityNotFoundException;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 |
16 | import androidx.annotation.NonNull;
17 | import androidx.appcompat.widget.AppCompatTextView;
18 | import androidx.fragment.app.DialogFragment;
19 |
20 | import com.blankj.utilcode.util.SnackbarUtils;
21 | import com.github.mahadel.demo.R;
22 | import com.github.mahadel.demo.model.About;
23 | import com.github.mahadel.demo.model.AuthenticationInfo;
24 | import com.github.mahadel.demo.service.APIService;
25 | import com.github.mahadel.demo.util.AppUtil;
26 | import com.github.mahadel.demo.util.Constant;
27 | import com.github.mahadel.demo.util.FirebaseEventLog;
28 | import com.github.mahadel.demo.util.RetrofitUtil;
29 | import com.github.pwittchen.prefser.library.rx2.Prefser;
30 | import com.google.android.material.button.MaterialButton;
31 |
32 | import butterknife.BindView;
33 | import butterknife.ButterKnife;
34 | import butterknife.OnClick;
35 | import retrofit2.Call;
36 | import retrofit2.Callback;
37 | import retrofit2.Response;
38 |
39 | /**
40 | * AboutFragment showing {@link About} instance values in the fragment
41 | */
42 | public class AboutFragment extends DialogFragment {
43 | private static final String TAG = "AboutFragment";
44 | @BindView(R.id.version_app_text_view)
45 | AppCompatTextView versionAppTextView;
46 | @BindView(R.id.update_button)
47 | MaterialButton updateButton;
48 | @BindView(R.id.sponsor_name)
49 | AppCompatTextView sponsorName;
50 | @BindView(R.id.sponsor_description_text_view)
51 | AppCompatTextView sponsorDescriptionTextView;
52 | private Dialog loadingDialog;
53 | private Activity activity;
54 | private About about;
55 | private String versionName;
56 | private AuthenticationInfo info;
57 |
58 | @Override
59 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
60 | View rootView = inflater.inflate(R.layout.fragment_about, container, false);
61 | ButterKnife.bind(this, rootView);
62 | initVariables();
63 | setAppVersion();
64 | getAbout();
65 | return rootView;
66 | }
67 |
68 | /**
69 | * Setup init values of variables
70 | */
71 | private void initVariables() {
72 | activity = getActivity();
73 | Prefser prefser = new Prefser(activity);
74 | info = prefser.get(Constant.TOKEN, AuthenticationInfo.class, null);
75 | loadingDialog = AppUtil.getLoadingDialog(activity);
76 | }
77 |
78 | /**
79 | * Get app version
80 | */
81 | private void setAppVersion() {
82 | versionName = "";
83 | try {
84 | versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
85 | } catch (PackageManager.NameNotFoundException e) {
86 | e.printStackTrace();
87 | }
88 | versionAppTextView.setText(versionName);
89 | }
90 |
91 | /**
92 | * Get {@link About} instance from server
93 | */
94 | private void getAbout() {
95 | loadingDialog.show();
96 | APIService apiService = RetrofitUtil.getRetrofit(info.getToken()).create(APIService.class);
97 | Call call = apiService.getAbout();
98 | call.enqueue(new Callback() {
99 | @Override
100 | public void onResponse(@NonNull Call call, @NonNull Response response) {
101 | loadingDialog.dismiss();
102 | if (response.isSuccessful()) {
103 | about = response.body();
104 | handleAbout();
105 | }
106 | }
107 |
108 | @Override
109 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
110 | loadingDialog.dismiss();
111 | t.printStackTrace();
112 | FirebaseEventLog.log("server_failure", TAG, "getAbout", t.getMessage());
113 | }
114 | });
115 | }
116 |
117 | /**
118 | * Showing values of {@link About} in the UI
119 | */
120 | private void handleAbout() {
121 | if (!about.getAppVersion().equals(versionName)) {
122 | updateButton.setVisibility(View.VISIBLE);
123 | }
124 | sponsorName.setText(about.getSponsorName());
125 | sponsorDescriptionTextView.setText(about.getSponsorDescription());
126 |
127 | }
128 |
129 | @NonNull
130 | @Override
131 | public Dialog onCreateDialog(Bundle savedInstanceState) {
132 | Dialog dialog = super.onCreateDialog(savedInstanceState);
133 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
134 | dialog.setCancelable(true);
135 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
136 | lp.copyFrom(dialog.getWindow().getAttributes());
137 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
138 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
139 | dialog.getWindow().setAttributes(lp);
140 | return dialog;
141 | }
142 |
143 | @OnClick(R.id.close_image_view)
144 | void close() {
145 | dismiss();
146 | if (getFragmentManager() != null) {
147 | getFragmentManager().popBackStackImmediate();
148 | }
149 | }
150 |
151 | /**
152 | * Handle view click and opening Website in the default browser app
153 | *
154 | * @param view {@link View}
155 | */
156 | @OnClick({R.id.update_button, R.id.changelog_layout, R.id.license_layout, R.id.sponsor_website, R.id.developer_layout})
157 | void handleLayoutClicks(View view) {
158 | if (about != null) {
159 | switch (view.getId()) {
160 | case R.id.update_button:
161 | startBrowser(about.getAppUrl(), view);
162 | break;
163 | case R.id.changelog_layout:
164 | startBrowser(about.getChangelogUrl(), view);
165 | break;
166 | case R.id.license_layout:
167 | startBrowser(about.getLicenseUrl(), view);
168 | break;
169 | case R.id.sponsor_website:
170 | startBrowser(about.getSponsorUrl(), view);
171 | break;
172 | case R.id.developer_layout:
173 | startBrowser(getString(R.string.bkhezry_twitter_url), view);
174 | break;
175 | }
176 | } else {
177 | AppUtil.showSnackbar(view, getString(R.string.error_request_message), activity, SnackbarUtils.LENGTH_LONG);
178 | getAbout();
179 | }
180 | }
181 |
182 | /**
183 | * Showing url in the browser
184 | *
185 | * @param url String
186 | * @param view {@link View}
187 | */
188 | private void startBrowser(String url, View view) {
189 | try {
190 | Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
191 | startActivity(browserIntent);
192 | } catch (ActivityNotFoundException e) {
193 | AppUtil.showSnackbar(view, getString(R.string.browser_not_found_label), activity, SnackbarUtils.LENGTH_INDEFINITE);
194 | e.printStackTrace();
195 | }
196 |
197 | }
198 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/fragment/AddSkillFragment.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Toast;
11 |
12 | import androidx.annotation.NonNull;
13 | import androidx.appcompat.widget.AppCompatEditText;
14 | import androidx.appcompat.widget.AppCompatTextView;
15 | import androidx.fragment.app.Fragment;
16 |
17 | import com.blankj.utilcode.util.NetworkUtils;
18 | import com.blankj.utilcode.util.SnackbarUtils;
19 | import com.github.mahadel.demo.R;
20 | import com.github.mahadel.demo.listener.CallbackResult;
21 | import com.github.mahadel.demo.model.AuthenticationInfo;
22 | import com.github.mahadel.demo.model.SkillsItem;
23 | import com.github.mahadel.demo.model.UserSkill;
24 | import com.github.mahadel.demo.service.APIService;
25 | import com.github.mahadel.demo.ui.activity.SelectSkillActivity;
26 | import com.github.mahadel.demo.util.AppUtil;
27 | import com.github.mahadel.demo.util.Constant;
28 | import com.github.mahadel.demo.util.FirebaseEventLog;
29 | import com.github.mahadel.demo.util.RetrofitUtil;
30 | import com.github.pwittchen.prefser.library.rx2.Prefser;
31 | import com.google.android.material.button.MaterialButton;
32 |
33 | import butterknife.BindView;
34 | import butterknife.ButterKnife;
35 | import butterknife.OnClick;
36 | import retrofit2.Call;
37 | import retrofit2.Callback;
38 | import retrofit2.Response;
39 |
40 | import static android.app.Activity.RESULT_OK;
41 |
42 | /**
43 | * AddSkillFragment Showing Ui for select skill and submit userSkill to the server
44 | */
45 | public class AddSkillFragment extends Fragment {
46 |
47 | private static final int REQUEST_SELECT_SKILL = 10001;
48 | private static final String TAG = "AddSkillFragment";
49 | @BindView(R.id.skill_type_text_view)
50 | AppCompatTextView skillTypeTextView;
51 | @BindView(R.id.skill_description_edit_text)
52 | AppCompatEditText skillDescriptionEditText;
53 | @BindView(R.id.select_skill_button)
54 | MaterialButton selectSkillButton;
55 | private CallbackResult callbackResult;
56 | private AppUtil.SkillType skillType;
57 | private Activity activity;
58 | private SkillsItem skillsItem;
59 | private Prefser prefser;
60 | private Dialog loadingDialog;
61 | private AuthenticationInfo info;
62 |
63 |
64 | /**
65 | * Set callback listener for handle added userSkill to the MainActivity
66 | *
67 | * @param callbackResult CallbackResult
68 | */
69 | public void setOnCallbackResult(final CallbackResult callbackResult) {
70 | this.callbackResult = callbackResult;
71 | }
72 |
73 | /**
74 | * Set SkillType
75 | *
76 | * @param skillType {@link com.github.mahadel.demo.util.AppUtil.SkillType}
77 | */
78 | public void setSkillType(AppUtil.SkillType skillType) {
79 | this.skillType = skillType;
80 | }
81 |
82 |
83 | @Override
84 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
85 | View rootView = inflater.inflate(R.layout.fragment_add_skill, container, false);
86 | ButterKnife.bind(this, rootView);
87 | initVariables();
88 | return rootView;
89 | }
90 |
91 | /**
92 | * Setup init values of variables
93 | */
94 | private void initVariables() {
95 | activity = getActivity();
96 | if (activity != null) {
97 | prefser = new Prefser(activity);
98 | loadingDialog = AppUtil.getLoadingDialog(activity);
99 | }
100 | info = prefser.get(Constant.TOKEN, AuthenticationInfo.class, null);
101 | if (skillType == AppUtil.SkillType.WANT_LEARN) {
102 | skillTypeTextView.setText(R.string.add_skill_learn_label);
103 | } else {
104 | skillTypeTextView.setText(R.string.add_skill_teach_label);
105 | }
106 | }
107 |
108 | /**
109 | * Submit click handler. Check internet connection before submit data to the server
110 | *
111 | * @param view {@link View}
112 | */
113 | @OnClick(R.id.submit_btn)
114 | void submit(View view) {
115 | if (NetworkUtils.isConnected()) {
116 | submitUserSkill();
117 | } else {
118 | AppUtil.showSnackbar(view, getString(R.string.no_internet_label), activity, SnackbarUtils.LENGTH_LONG);
119 | }
120 | }
121 |
122 | /**
123 | * Submit userSkill to the server
124 | */
125 | private void submitUserSkill() {
126 | String description = skillDescriptionEditText.getText().toString();
127 | int skillTypeInt;
128 | if (skillType == AppUtil.SkillType.WANT_TEACH) {
129 | skillTypeInt = 1;
130 | } else {
131 | skillTypeInt = 2;
132 | }
133 | if (skillsItem != null) {
134 | loadingDialog.show();
135 | APIService apiService = RetrofitUtil.getRetrofit(info.getToken()).create(APIService.class);
136 | Call call = apiService.addUserSkill(info.getUuid(), skillsItem.getUuid(), description, skillTypeInt);
137 | call.enqueue(new Callback() {
138 | @Override
139 | public void onResponse(@NonNull Call call, @NonNull Response response) {
140 | loadingDialog.dismiss();
141 | if (response.isSuccessful()) {
142 | UserSkill userSkill = response.body();
143 | handleUserSkill(userSkill);
144 | }
145 | }
146 |
147 | @Override
148 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
149 | loadingDialog.dismiss();
150 | t.printStackTrace();
151 | AppUtil.showSnackbar(skillTypeTextView, getString(R.string.error_request_message), activity, SnackbarUtils.LENGTH_LONG);
152 | FirebaseEventLog.log("server_failure", TAG, "submitUserSkill", t.getMessage());
153 | }
154 | });
155 | } else {
156 | Toast.makeText(activity, getString(R.string.select_skill_message_label), Toast.LENGTH_LONG).show();
157 | }
158 | }
159 |
160 | /**
161 | * Send back userSkill that added to the server to MainActivity
162 | *
163 | * @param userSkill {@link UserSkill}
164 | */
165 | private void handleUserSkill(UserSkill userSkill) {
166 | if (callbackResult != null) {
167 | callbackResult.sendResult(userSkill, skillType);
168 | AppUtil.hideSoftInput(activity);
169 | }
170 |
171 | }
172 |
173 | @OnClick(R.id.select_skill_button)
174 | void selectSkill() {
175 | showSelectSkillDialog();
176 | }
177 |
178 | /**
179 | * Start {@link SelectSkillActivity} for getting skill
180 | */
181 |
182 | private void showSelectSkillDialog() {
183 | Intent intent = new Intent(activity, SelectSkillActivity.class);
184 | startActivityForResult(intent, REQUEST_SELECT_SKILL);
185 | }
186 |
187 | @Override
188 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
189 | super.onActivityResult(requestCode, resultCode, data);
190 | if (requestCode == REQUEST_SELECT_SKILL && resultCode == RESULT_OK) {
191 | skillsItem = data.getParcelableExtra(Constant.SKILL_ITEM);
192 | if (AppUtil.isRTL(activity)) {
193 | selectSkillButton.setText(skillsItem.getFaName());
194 | } else {
195 | selectSkillButton.setText(skillsItem.getEnName());
196 | }
197 |
198 | }
199 | }
200 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/fragment/EditProfileFragment.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.Window;
10 | import android.view.WindowManager;
11 | import android.widget.RadioGroup;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.appcompat.widget.AppCompatRadioButton;
15 | import androidx.fragment.app.DialogFragment;
16 |
17 | import com.blankj.utilcode.util.NetworkUtils;
18 | import com.blankj.utilcode.util.SnackbarUtils;
19 | import com.github.mahadel.demo.R;
20 | import com.github.mahadel.demo.model.AuthenticationInfo;
21 | import com.github.mahadel.demo.model.ResponseMessage;
22 | import com.github.mahadel.demo.model.UserInfo;
23 | import com.github.mahadel.demo.service.APIService;
24 | import com.github.mahadel.demo.util.AppUtil;
25 | import com.github.mahadel.demo.util.Constant;
26 | import com.github.mahadel.demo.util.FirebaseEventLog;
27 | import com.github.mahadel.demo.util.RetrofitUtil;
28 | import com.github.pwittchen.prefser.library.rx2.Prefser;
29 | import com.google.android.material.textfield.TextInputEditText;
30 | import com.google.android.material.textfield.TextInputLayout;
31 |
32 | import butterknife.BindView;
33 | import butterknife.ButterKnife;
34 | import butterknife.OnClick;
35 | import retrofit2.Call;
36 | import retrofit2.Callback;
37 | import retrofit2.Response;
38 |
39 | /**
40 | * EditProfileFragment Edit information of user
41 | */
42 | public class EditProfileFragment extends DialogFragment {
43 |
44 | private static final String TAG = "EditProfileFragment";
45 | @BindView(R.id.first_name_edit_text)
46 | TextInputEditText firstNameEditText;
47 | @BindView(R.id.til_first_name)
48 | TextInputLayout tilFirstName;
49 | @BindView(R.id.last_name_edit_text)
50 | TextInputEditText lastNameEditText;
51 | @BindView(R.id.til_last_name)
52 | TextInputLayout tilLastName;
53 | @BindView(R.id.radioMale)
54 | AppCompatRadioButton radioMale;
55 | @BindView(R.id.radioFemale)
56 | AppCompatRadioButton radioFemale;
57 | @BindView(R.id.radioGender)
58 | RadioGroup radioGender;
59 | private Activity activity;
60 | private UserInfo userInfo;
61 | private CallbackListener listener;
62 | private Dialog loadingDialog;
63 | private AuthenticationInfo info;
64 |
65 | /**
66 | * Set callback listener for handle edit event
67 | *
68 | * @param listener {@link CallbackListener}
69 | */
70 | void setOnCallbackResult(CallbackListener listener) {
71 | this.listener = listener;
72 | }
73 |
74 | @Override
75 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
76 | View rootView = inflater.inflate(R.layout.dialog_edit_profile, container, false);
77 | ButterKnife.bind(this, rootView);
78 | initVariables();
79 | return rootView;
80 | }
81 |
82 | /**
83 | * Setup init values of variables
84 | */
85 | private void initVariables() {
86 | activity = getActivity();
87 | Prefser prefser = new Prefser(activity);
88 | info = prefser.get(Constant.TOKEN, AuthenticationInfo.class, null);
89 | loadingDialog = AppUtil.getLoadingDialog(activity);
90 | firstNameEditText.setText(userInfo.getFirstName());
91 | lastNameEditText.setText(userInfo.getLastName());
92 | if (userInfo.getGender() == 1) {
93 | radioMale.setChecked(true);
94 | } else {
95 | radioFemale.setChecked(true);
96 | }
97 | }
98 |
99 |
100 | @NonNull
101 | @Override
102 | public Dialog onCreateDialog(Bundle savedInstanceState) {
103 | Dialog dialog = super.onCreateDialog(savedInstanceState);
104 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
105 | dialog.setCancelable(true);
106 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
107 | lp.copyFrom(dialog.getWindow().getAttributes());
108 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
109 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
110 | dialog.getWindow().setAttributes(lp);
111 | return dialog;
112 | }
113 |
114 | /**
115 | * Set user information to the fragment
116 | *
117 | * @param userInfo {@link UserInfo}
118 | */
119 | void setUserInfo(UserInfo userInfo) {
120 | this.userInfo = userInfo;
121 | }
122 |
123 | /**
124 | * Handle edit profile click event
125 | *
126 | * @param view {@link View}
127 | */
128 | @OnClick(R.id.submit_info_button)
129 | void editProfileInfo(View view) {
130 | int gender;
131 | String firstName = firstNameEditText.getText().toString();
132 | String lastName = lastNameEditText.getText().toString();
133 | if (!firstName.equals("") && !lastName.equals("")) {
134 | if (radioGender.getCheckedRadioButtonId() == R.id.radioFemale) {
135 | gender = 2;
136 | } else {
137 | gender = 1;
138 | }
139 | if (NetworkUtils.isConnected()) {
140 | updateUser(view, firstName, lastName, gender);
141 | } else {
142 | AppUtil.showSnackbar(view, getString(R.string.no_internet_label), activity, SnackbarUtils.LENGTH_LONG);
143 | }
144 | } else {
145 | AppUtil.showSnackbar(view, getString(R.string.field_require_label), activity, SnackbarUtils.LENGTH_LONG);
146 | }
147 | }
148 |
149 | /**
150 | * Update user information in the server
151 | *
152 | * @param view
153 | * @param firstName String first name
154 | * @param lastName String last name
155 | * @param gender Int gender
156 | */
157 | private void updateUser(View view, final String firstName, final String lastName, final int gender) {
158 | loadingDialog.show();
159 | APIService apiService = RetrofitUtil.getRetrofit(info.getToken()).create(APIService.class);
160 | Call call = apiService.updateUser(info.getUuid(), firstName, lastName, gender);
161 | call.enqueue(new Callback() {
162 | @Override
163 | public void onResponse(@NonNull Call call, @NonNull Response response) {
164 | loadingDialog.dismiss();
165 | if (response.isSuccessful()) {
166 | userInfo.setFirstName(firstName);
167 | userInfo.setGender(gender);
168 | userInfo.setLastName(lastName);
169 | if (listener != null) {
170 | listener.sendResult(userInfo);
171 | close();
172 | }
173 | }
174 | }
175 |
176 | @Override
177 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
178 | loadingDialog.dismiss();
179 | t.printStackTrace();
180 | AppUtil.showSnackbar(view, getString(R.string.error_request_message), activity, SnackbarUtils.LENGTH_LONG);
181 | FirebaseEventLog.log("server_failure", TAG, "updateUser", t.getMessage());
182 | }
183 | });
184 |
185 | }
186 |
187 | @OnClick(R.id.close_image_view)
188 | void close() {
189 | dismiss();
190 | if (getFragmentManager() != null) {
191 | getFragmentManager().popBackStackImmediate();
192 | }
193 | }
194 |
195 | public interface CallbackListener {
196 | void sendResult(UserInfo userInfo);
197 | }
198 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/ui/fragment/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.Window;
11 | import android.view.WindowManager;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.appcompat.widget.AppCompatImageView;
15 | import androidx.fragment.app.DialogFragment;
16 |
17 | import com.github.mahadel.demo.R;
18 | import com.github.mahadel.demo.ui.activity.MainActivity;
19 | import com.github.mahadel.demo.util.Constant;
20 | import com.github.mahadel.demo.util.LocaleManager;
21 | import com.github.mahadel.demo.util.MyApplication;
22 | import com.github.pwittchen.prefser.library.rx2.Prefser;
23 |
24 | import butterknife.BindView;
25 | import butterknife.ButterKnife;
26 | import butterknife.OnClick;
27 |
28 | /**
29 | * SettingsFragment change language & theme of application
30 | */
31 | public class SettingsFragment extends DialogFragment {
32 | @BindView(R.id.persian_image_view)
33 | AppCompatImageView persianImageView;
34 | @BindView(R.id.english_image_view)
35 | AppCompatImageView englishImageView;
36 | private Activity activity;
37 | private Prefser prefser;
38 |
39 | @Override
40 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
41 | View rootView = inflater.inflate(R.layout.fragment_settings, container, false);
42 | ButterKnife.bind(this, rootView);
43 | initVariables();
44 | setUpLocale();
45 | return rootView;
46 | }
47 |
48 | /**
49 | * Setup init values of variables
50 | */
51 | private void initVariables() {
52 | activity = getActivity();
53 | prefser = new Prefser(activity);
54 | }
55 |
56 | @NonNull
57 | @Override
58 | public Dialog onCreateDialog(Bundle savedInstanceState) {
59 | Dialog dialog = super.onCreateDialog(savedInstanceState);
60 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
61 | dialog.setCancelable(true);
62 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
63 | lp.copyFrom(dialog.getWindow().getAttributes());
64 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
65 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
66 | dialog.getWindow().setAttributes(lp);
67 | return dialog;
68 | }
69 |
70 | @OnClick(R.id.close_image_view)
71 | void close() {
72 | dismiss();
73 | if (getFragmentManager() != null) {
74 | getFragmentManager().popBackStackImmediate();
75 | }
76 | }
77 |
78 | /**
79 | * Handle change language click event
80 | *
81 | * @param view {@link View}
82 | */
83 |
84 | @OnClick({R.id.persian_image_view, R.id.english_image_view})
85 | void handleLanguage(View view) {
86 | switch (view.getId()) {
87 | case R.id.persian_image_view:
88 | restartApp(LocaleManager.LANGUAGE_PERSIAN);
89 | break;
90 | case R.id.english_image_view:
91 | restartApp(LocaleManager.LANGUAGE_ENGLISH);
92 | break;
93 | }
94 | }
95 |
96 | /**
97 | * Setup locale layout
98 | */
99 | private void setUpLocale() {
100 | if (MyApplication.localeManager.getLanguage().equals(LocaleManager.LANGUAGE_PERSIAN)) {
101 | changeLanguagePersian();
102 | } else {
103 | changeLanguageEnglish();
104 | }
105 | }
106 |
107 | /**
108 | * Set new locale & restart app
109 | *
110 | * @param language String selected language
111 | */
112 | private void restartApp(String language) {
113 | MyApplication.localeManager.setNewLocale(activity, language);
114 | Intent i = new Intent(activity, MainActivity.class);
115 | startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK));
116 | System.exit(0);
117 | }
118 |
119 | private void changeLanguagePersian() {
120 | persianImageView.setBackgroundResource(R.drawable.image_border);
121 | englishImageView.setBackgroundResource(android.R.color.transparent);
122 | }
123 |
124 | private void changeLanguageEnglish() {
125 | englishImageView.setBackgroundResource(R.drawable.image_border);
126 | persianImageView.setBackgroundResource(android.R.color.transparent);
127 | }
128 |
129 | /**
130 | * Handle change theme click event
131 | *
132 | * @param view View {@link View}
133 | */
134 | @OnClick({R.id.dark_theme_button, R.id.light_theme_button})
135 | void handleThemeClick(View view) {
136 | switch (view.getId()) {
137 | case R.id.dark_theme_button:
138 | prefser.put(Constant.IS_DARK_THEME, true);
139 | restartActivity();
140 | break;
141 | case R.id.light_theme_button:
142 | prefser.put(Constant.IS_DARK_THEME, false);
143 | restartActivity();
144 | break;
145 | }
146 | }
147 |
148 | /**
149 | * Restart app after change theme of it
150 | */
151 |
152 | private void restartActivity() {
153 | activity.finish();
154 | final Intent intent = activity.getIntent();
155 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
156 | activity.startActivity(intent);
157 | }
158 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/Constant.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | public class Constant {
4 | public static final String LANGUAGE = "language";
5 | public static final String BASE_URL = "https://demo.mahadel.ir/api/v1/";
6 | public static final String TOKEN = "token";
7 | public static final String GRAVATAR_URL = "https://www.gravatar.com/avatar/";
8 | public static final String IS_DARK_THEME = "is-dark-theme";
9 | public static final String SKILL_ITEM = "skill-item";
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/DatabaseUtil.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import com.github.mahadel.demo.model.SkillsItem;
4 | import com.github.mahadel.demo.model.SkillsItem_;
5 | import com.github.mahadel.demo.model.UserSkill;
6 | import com.github.mahadel.demo.model.UserSkill_;
7 |
8 | import java.util.List;
9 |
10 | import io.objectbox.Box;
11 | import io.objectbox.query.Query;
12 |
13 | public class DatabaseUtil {
14 |
15 | /**
16 | * Get userSkills with type of it
17 | *
18 | * @param userSkillBox {@link Box}
19 | * @param skillType Int
20 | * @return Instance of {@link Query}
21 | */
22 | public static Query getUserSkillWithType(Box userSkillBox, int skillType) {
23 | return userSkillBox.query()
24 | .equal(UserSkill_.skillType, skillType)
25 | .orderDesc(UserSkill_.id)
26 | .build();
27 | }
28 |
29 | /**
30 | * Get userSkill with skill uuid
31 | *
32 | * @param userSkillBox {@link Box}
33 | * @param uuid String uuid
34 | * @return Instance of {@link UserSkill}
35 | */
36 | public static UserSkill getUserSkillWithSkillUUID(Box userSkillBox, String uuid) {
37 | return userSkillBox.query()
38 | .equal(UserSkill_.skillUuid, uuid)
39 | .build().findFirst();
40 | }
41 |
42 | /**
43 | * Get userSkill with uuid
44 | *
45 | * @param userSkillBox {@link Box}
46 | * @param uuid String uuid
47 | * @return Instance of {@link UserSkill}
48 | */
49 | public static UserSkill getUserSkillWithUUID(Box userSkillBox, String uuid) {
50 | return userSkillBox.query()
51 | .equal(UserSkill_.uuid, uuid)
52 | .build().findFirst();
53 | }
54 |
55 | /**
56 | * Get SkillItem with uuid
57 | *
58 | * @param skillsItemBox {@link Box}
59 | * @param uuid String uuid
60 | * @return Instance of {@link Query}
61 | */
62 |
63 | public static Query getSkillItemQueryWithUUID(Box skillsItemBox, String uuid) {
64 | return skillsItemBox.query()
65 | .equal(SkillsItem_.uuid, uuid)
66 | .build();
67 | }
68 |
69 | /**
70 | * Get list of skills item with uuid of category
71 | *
72 | * @param skillsItemBox {@link Box}
73 | * @param categoryUUID String uuid
74 | * @return List of {@link SkillsItem}
75 | */
76 | public static List getSkillItemOfCategory(Box skillsItemBox, String categoryUUID) {
77 | return skillsItemBox.query()
78 | .equal(SkillsItem_.categoryUuid, categoryUUID)
79 | .build().find();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/FirebaseEventLog.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import android.os.Bundle;
4 |
5 | public class FirebaseEventLog {
6 |
7 | public static void log(String event, String tag, String function, String message) {
8 | Bundle bundle = new Bundle();
9 | bundle.putString("tag", tag);
10 | bundle.putString("function", function);
11 | bundle.putString("error_message", message);
12 | MyApplication.getFirebaseAnalytics().logEvent(event, bundle);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/GridSpacingItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import android.graphics.Rect;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.recyclerview.widget.RecyclerView;
8 |
9 | public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
10 | private int spanCount;
11 | private int spacing;
12 | private boolean includeEdge;
13 |
14 | public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
15 | this.spanCount = spanCount;
16 | this.spacing = spacing;
17 | this.includeEdge = includeEdge;
18 | }
19 |
20 | @Override
21 | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
22 | int position = parent.getChildAdapterPosition(view); // item position
23 | int column = position % spanCount; // item column
24 |
25 | if (includeEdge) {
26 | outRect.left = spacing - column * spacing / spanCount; // spacing - column * ((1f / spanCount) * spacing)
27 | outRect.right = (column + 1) * spacing / spanCount; // (column + 1) * ((1f / spanCount) * spacing)
28 |
29 | if (position < spanCount) { // top edge
30 | outRect.top = spacing;
31 | }
32 | outRect.bottom = spacing; // item bottom
33 | } else {
34 | outRect.left = column * spacing / spanCount; // column * ((1f / spanCount) * spacing)
35 | outRect.right = spacing - (column + 1) * spacing / spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing)
36 | if (position >= spanCount) {
37 | outRect.top = spacing; // item top
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/LocaleManager.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.content.res.Configuration;
7 | import android.content.res.Resources;
8 | import android.preference.PreferenceManager;
9 |
10 | import java.util.Locale;
11 |
12 | import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
13 | import static android.os.Build.VERSION_CODES.N;
14 |
15 | /**
16 | * Utils for handle locale language change
17 | */
18 | public class LocaleManager {
19 |
20 | public static final String LANGUAGE_ENGLISH = "en";
21 | public static final String LANGUAGE_PERSIAN = "fa";
22 | private final SharedPreferences prefs;
23 |
24 | LocaleManager(Context context) {
25 | prefs = PreferenceManager.getDefaultSharedPreferences(context);
26 | }
27 |
28 | public static Locale getLocale(Resources res) {
29 | Configuration config = res.getConfiguration();
30 | return AppUtil.isAtLeastVersion(N) ? config.getLocales().get(0) : config.locale;
31 | }
32 |
33 | public Context setLocale(Context c) {
34 | return updateResources(c, getLanguage());
35 | }
36 |
37 | public Context setNewLocale(Context c, String language) {
38 | persistLanguage(language);
39 | return updateResources(c, language);
40 | }
41 |
42 | public String getLanguage() {
43 | return prefs.getString(Constant.LANGUAGE, LANGUAGE_PERSIAN);
44 | }
45 |
46 | @SuppressLint("ApplySharedPref")
47 | private void persistLanguage(String language) {
48 | prefs.edit().putString(Constant.LANGUAGE, language).commit();
49 | }
50 |
51 | private Context updateResources(Context context, String language) {
52 | Locale locale = new Locale(language);
53 | Locale.setDefault(locale);
54 |
55 | Resources res = context.getResources();
56 | Configuration config = new Configuration(res.getConfiguration());
57 | if (AppUtil.isAtLeastVersion(JELLY_BEAN_MR1)) {
58 | config.setLocale(locale);
59 | context = context.createConfigurationContext(config);
60 | } else {
61 | config.locale = locale;
62 | res.updateConfiguration(config, res.getDisplayMetrics());
63 | }
64 | return context;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.res.Configuration;
6 |
7 | import com.github.mahadel.demo.BuildConfig;
8 | import com.github.mahadel.demo.R;
9 | import com.github.mahadel.demo.model.MyObjectBox;
10 | import com.google.firebase.analytics.FirebaseAnalytics;
11 |
12 | import io.github.inflationx.calligraphy3.CalligraphyConfig;
13 | import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
14 | import io.github.inflationx.viewpump.ViewPump;
15 | import io.objectbox.BoxStore;
16 | import io.objectbox.android.AndroidObjectBrowser;
17 |
18 | public class MyApplication extends Application {
19 | private static BoxStore boxStore;
20 | public static LocaleManager localeManager;
21 | private static FirebaseAnalytics firebaseAnalytics;
22 |
23 | public static FirebaseAnalytics getFirebaseAnalytics() {
24 | return firebaseAnalytics;
25 | }
26 |
27 | @Override
28 | public void onCreate() {
29 | super.onCreate();
30 | ViewPump.init(ViewPump.builder()
31 | .addInterceptor(new CalligraphyInterceptor(
32 | new CalligraphyConfig.Builder()
33 | .setDefaultFontPath("fonts/IRANSansMobile.ttf")
34 | .setFontAttrId(R.attr.fontPath)
35 | .build()))
36 | .build());
37 | firebaseAnalytics = FirebaseAnalytics.getInstance(this);
38 | createBoxStore();
39 |
40 | }
41 |
42 |
43 | /**
44 | * Return instance of box store
45 | *
46 | * @return Instance of {@link BoxStore}
47 | */
48 |
49 | public static BoxStore getBoxStore() {
50 | return boxStore;
51 | }
52 |
53 | /**
54 | * Create static {@link BoxStore} instance
55 | */
56 | private void createBoxStore() {
57 | boxStore = MyObjectBox.builder().androidContext(MyApplication.this).build();
58 | if (BuildConfig.DEBUG) {
59 | new AndroidObjectBrowser(boxStore).start(this);
60 | }
61 | }
62 |
63 | @Override
64 | protected void attachBaseContext(Context base) {
65 | localeManager = new LocaleManager(base);
66 | super.attachBaseContext(localeManager.setLocale(base));
67 | }
68 |
69 | @Override
70 | public void onConfigurationChanged(Configuration newConfig) {
71 | super.onConfigurationChanged(newConfig);
72 | localeManager.setLocale(this);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/mahadel/demo/util/RetrofitUtil.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo.util;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.io.IOException;
6 |
7 | import okhttp3.Interceptor;
8 | import okhttp3.OkHttpClient;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 | import okhttp3.logging.HttpLoggingInterceptor;
12 | import retrofit2.Retrofit;
13 | import retrofit2.converter.gson.GsonConverterFactory;
14 |
15 | /**
16 | * Retrofit Utils
17 | */
18 | public class RetrofitUtil {
19 |
20 | /**
21 | * Get retrofit instance
22 | *
23 | * @param token String token of user
24 | * @return Instance of {@link Retrofit}
25 | */
26 | public static Retrofit getRetrofit(String token) {
27 | return new Retrofit.Builder().baseUrl(Constant.BASE_URL)
28 | .client(getHeader(token))
29 | .addConverterFactory(GsonConverterFactory.create())
30 | .build();
31 | }
32 |
33 | /**
34 | * Get OkHttpClient with authorization header & logging interceptor
35 | *
36 | * @param authorizationValue String user token
37 | * @return Instance of {@link OkHttpClient}
38 | */
39 | private static OkHttpClient getHeader(final String authorizationValue) {
40 | //delete this interceptor in released app
41 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
42 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
43 | //end interceptor
44 | return new OkHttpClient.Builder()
45 | .addInterceptor(interceptor)
46 | .addNetworkInterceptor(
47 | new Interceptor() {
48 | @Override
49 | public Response intercept(@NonNull Chain chain) throws IOException {
50 | Request request = null;
51 | if (authorizationValue != null) {
52 | Request original = chain.request();
53 | // Request customization: add request headers
54 | Request.Builder requestBuilder = original.newBuilder()
55 | .addHeader("Authorization", authorizationValue);
56 |
57 | request = requestBuilder.build();
58 | }
59 | assert request != null;
60 | return chain.proceed(request);
61 | }
62 | })
63 | .build();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_downward_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_upward_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_book_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_create_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_done_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_drawer_menu_24px.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_english.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/drawable/ic_english.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_exit_to_app_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_google_plus_32px.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_language_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_list_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_mail_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_persian.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/drawable/ic_persian.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_search_24px.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_swap_vert_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sync_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
42 |
43 |
50 |
51 |
60 |
61 |
62 |
63 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_select_skill.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
34 |
35 |
41 |
42 |
48 |
49 |
52 |
53 |
58 |
59 |
62 |
63 |
70 |
71 |
72 |
73 |
74 |
75 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
16 |
17 |
28 |
29 |
34 |
35 |
42 |
43 |
44 |
45 |
46 |
47 |
55 |
56 |
62 |
63 |
74 |
75 |
81 |
82 |
87 |
88 |
93 |
94 |
95 |
96 |
104 |
105 |
112 |
113 |
119 |
120 |
131 |
132 |
138 |
139 |
144 |
145 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_confirm.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
21 |
22 |
30 |
31 |
37 |
38 |
42 |
43 |
51 |
52 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_edit_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
22 |
30 |
31 |
38 |
39 |
50 |
51 |
52 |
62 |
63 |
74 |
75 |
76 |
82 |
83 |
90 |
91 |
98 |
99 |
100 |
101 |
102 |
114 |
115 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_full_screen_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_skill_type.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
23 |
24 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/error_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
24 |
25 |
30 |
31 |
36 |
37 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_add_skill.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
22 |
23 |
30 |
31 |
37 |
38 |
39 |
46 |
47 |
54 |
55 |
65 |
66 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_skill_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
22 |
23 |
30 |
31 |
35 |
36 |
43 |
44 |
47 |
48 |
56 |
57 |
58 |
64 |
65 |
72 |
73 |
83 |
84 |
87 |
88 |
89 |
96 |
97 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
17 |
18 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_connection_received.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
24 |
25 |
31 |
32 |
35 |
36 |
41 |
42 |
43 |
44 |
45 |
52 |
53 |
58 |
59 |
65 |
66 |
69 |
70 |
75 |
76 |
77 |
82 |
83 |
89 |
90 |
93 |
94 |
99 |
100 |
101 |
102 |
103 |
104 |
112 |
113 |
121 |
122 |
127 |
128 |
136 |
137 |
138 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
25 |
26 |
31 |
32 |
38 |
39 |
46 |
47 |
48 |
51 |
52 |
58 |
59 |
65 |
66 |
69 |
70 |
76 |
77 |
78 |
81 |
82 |
83 |
84 |
85 |
89 |
90 |
97 |
98 |
104 |
105 |
112 |
113 |
120 |
121 |
129 |
130 |
136 |
137 |
144 |
145 |
152 |
153 |
154 |
155 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_skill.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
17 |
18 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_user_skill.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
17 |
18 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_appbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_primary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-fa/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | تبادل مهارت دمو
3 | ورود با حسابکاربری گوگل
4 | تایید
5 | نام
6 | نامخانوادگی
7 | مرد
8 | زن
9 | نام مهارت:
10 | توضیحات:
11 | قصد یادگیری دارم
12 | قصد یاددادن دارم
13 | میخوام یاد بگیرم
14 | میخوام یاد بدم
15 | انتخاب مهارت
16 | این مهارت قبلا اضافه شده است.
17 | پروفایل
18 | تنظیمات
19 | درباره
20 | ویرایش
21 | حذف
22 | از حذف مهارت مطمئن هستید؟
23 | لغو
24 | بله
25 | زبان
26 | تم
27 | روشن
28 | تاریک
29 | بهروز خضری
30 | توسعهدهنده
31 | وبسایت
32 | اسپانسر
33 | لایسنس
34 | تغییرات برنامه
35 | نسخهبرنامه
36 | لطفا ارتباط اینترنت را چک کنید
37 | باشه
38 | خطا در حین دریافت اطلاعات
39 | تلاش مجدد
40 | لطفا تمامی اطلاعات را وارد نمایید
41 | لطفا مهارت مورد نظر را انتخاب کنید
42 | درخواست
43 | درخواستها
44 | جستجو
45 | ارسال ایمیل
46 | حذف درخواست
47 | دریافت شده
48 | ارسال شده
49 | رد درخواست
50 | قبول درخواست
51 | درخواست با موفقیت ارسال شد.
52 | مهارتی وجود ندارد
53 | برای اضافه کردن مهارت دکمه + را فشار دهید
54 | حذف
55 | خروج
56 | برای خروج از برنامه مطمئن هستید؟
57 | از حذف کامل حسابکاربری خود مطمئن هستید؟
58 | بهروزرسانی
59 | دستهبندی
60 | جستجو نتیجهای نداشت
61 | لطفا بعدا جستجو نمایید
62 | جنسیت:
63 | کاربر یافتشده:
64 | یاد میگیرد:
65 | یاد میدهد:
66 | ارسال شده به:
67 | ایمیل:
68 | ارسال درخواست به:
69 | حسابکاربری شخص حذف شده است
70 | درخواست شما رد شده است
71 | هنوز پاسخ داده نشده است
72 | درخواستی یافت نشد
73 | در صورت ثبت درخواست، در اینجا نمایش داده میشود
74 | از حذف این درخواست مطمئن هستید؟
75 | درخواست تبادل مهارت
76 | برنامه ارسال ایمیل در دسترس نیست
77 | یاد میگیرم:
78 | یاد میدهم:
79 | دریافت شده از:
80 | برنامه مرورگر یافت نشد
81 | دسترسی غیرمجاز. لطفا دوباره وارد شوید
82 | خطایی روی داد. دوباره تلاش کنید
83 | ایمیل کاربر در دسترس نیست
84 | درخواست شما تکراری است. لطفا منتظر پاسخ باشید.
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/res/values-large/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 250dp
4 | 260dp
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #039be5
4 | #e6e6e6
5 | #999999
6 | #666666
7 | #37474F
8 | #263238
9 | #141d26
10 | #00ffffff
11 | #FFFFFF
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 150dp
4 | 160dp
5 |
6 | 1dp
7 | 3dp
8 | 5dp
9 | 10dp
10 | 15dp
11 | 20dp
12 | 25dp
13 | 35dp
14 | 40dp
15 | 50dp
16 | 130dp
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Skill Swap Demo
3 | Login with Google account
4 | Submit
5 | First Name
6 | Last Name
7 | Male
8 | Female
9 | Skill name:
10 | Description:
11 | Add skill want learn
12 | Add skill want teach
13 | I want to learn
14 | I want to teach
15 | Select skill
16 | This skill already exists.
17 | Profile
18 | Settings
19 | About
20 | Edit
21 | Remove
22 | Are you sure want remove skill?
23 | Cancel
24 | Yes
25 | Language
26 | Theme
27 | Light
28 | Dark
29 | \@bkhezry
30 | Behrouz Khezry
31 | Developer
32 | Access Website
33 | Sponsor
34 | License
35 | Changelog
36 | Version
37 | Please check internet connection
38 | OK
39 | Error during get data from server
40 | Retry
41 | Please fill all fields
42 | Please select a skill
43 | Request
44 | Connections
45 | Search
46 | Send Email
47 | Delete
48 | Received
49 | Sent
50 | Reject
51 | Accept
52 | request sent successfully.
53 | No skill
54 | For add skill press + button
55 | Delete
56 | Logout
57 | Are you sure want logout from app?
58 | Are you sure want delete your account permanently?
59 | Update
60 | Category
61 | No search result
62 | Please search later
63 | Gender:
64 | Account found:
65 | Learns:
66 | Teaches:
67 | Sent to:
68 | Email:
69 | Send request to:
70 | Account deleted
71 | Your request rejected
72 | No response yet
73 | No request found
74 | Submitted request will be showing here
75 | Are you sure want remove this request?
76 | Request skill swap
77 | Mail app not available
78 | I learn:
79 | I teach:
80 | Received from:
81 | https://twitter.com/bkhezry
82 | Browser not found
83 | Access is deny, Please login again
84 | fcm_default_channel
85 | Error occurred. Please try again
86 | Email of user not available
87 | Request is duplicate. Please wait for response.
88 |
89 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
19 |
20 |
31 |
32 |
41 |
42 |
51 |
52 |
55 |
56 |
59 |
60 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
29 |
--------------------------------------------------------------------------------
/app/src/release/res/values/google_api.xml:
--------------------------------------------------------------------------------
1 |
2 | 1071346960599-otiq3a2lc3rkfhttna29mb3d64rt4ala.apps.googleusercontent.com
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/test/java/com/github/mahadel/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mahadel.demo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/welcome-img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/assets/welcome-img.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | maven { url 'https://maven.fabric.io/public' }
6 | google()
7 | jcenter()
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.4.0-alpha08'
12 | classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.3'
13 | classpath "io.objectbox:objectbox-gradle-plugin:2.2.0"
14 | classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
15 | classpath 'com.google.gms:google-services:4.2.0'
16 | classpath 'io.fabric.tools:gradle:1.27.0'
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | maven { url 'https://maven.fabric.io/public' }
26 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
27 | jcenter()
28 | maven { url 'https://jitpack.io' }
29 | }
30 | }
31 |
32 | task clean(type: Delete) {
33 | delete rootProject.buildDir
34 | }
35 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | android.jetifier.blacklist=butterknife-compiler
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahadel/android/c55090900894df7fa927e6775e0f919f012e9082/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 13 13:57:16 IRST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------